diff options
Diffstat (limited to 'src/codec-json')
-rw-r--r-- | src/codec-json/.nix/derivation.nix | 34 | ||||
-rw-r--r-- | src/codec-json/SConscript | 38 | ||||
-rw-r--r-- | src/codec-json/SConstruct | 66 | ||||
-rw-r--r-- | src/codec-json/json.h | 12 |
4 files changed, 150 insertions, 0 deletions
diff --git a/src/codec-json/.nix/derivation.nix b/src/codec-json/.nix/derivation.nix new file mode 100644 index 0000000..fcc276d --- /dev/null +++ b/src/codec-json/.nix/derivation.nix @@ -0,0 +1,34 @@ +{ lib +, stdenvNoCC +, scons +, clang +, clang-tools +, version +, forstio +, gnutls +}: + +let + +in stdenvNoCC.mkDerivation { + pname = "forstio-codec-json"; + inherit version; + + src = ./..; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + scons + clang + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + ]; + + outputs = ["out" "dev"]; +} diff --git a/src/codec-json/SConscript b/src/codec-json/SConscript new file mode 100644 index 0000000..772ac0b --- /dev/null +++ b/src/codec-json/SConscript @@ -0,0 +1,38 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +codec_json_env = env.Clone(); + +codec_json_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +codec_json_env.headers = sorted(glob.glob(dir_path + "/*.h")) + +env.sources += codec_json_env.sources; +env.headers += codec_json_env.headers; + +## Shared lib +objects_shared = [] +codec_json_env.add_source_files(objects_shared, codec_json_env.sources, shared=True); +codec_json_env.library_shared = codec_json_env.SharedLibrary('#build/forstio-codec-json', [objects_shared]); + +## Static lib +objects_static = [] +codec_json_env.add_source_files(objects_static, codec_json_env.sources, shared=False); +codec_json_env.library_static = codec_json_env.StaticLibrary('#build/forstio-codec-json', [objects_static]); + +# Set Alias +env.Alias('library_codec_json', [codec_json_env.library_shared, codec_json_env.library_static]); + +env.targets += ['library_codec_json']; + +# Install +env.Install('$prefix/lib/', [codec_json_env.library_shared, codec_json_env.library_static]); +env.Install('$prefix/include/forstio/codec/json/', [codec_json_env.headers]); diff --git a/src/codec-json/SConstruct b/src/codec-json/SConstruct new file mode 100644 index 0000000..edd5f57 --- /dev/null +++ b/src/codec-json/SConstruct @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +import sys +import os +import os.path +import glob +import re + + +if sys.version_info < (3,): + def isbasestring(s): + return isinstance(s,basestring) +else: + def isbasestring(s): + return isinstance(s, (str,bytes)) + +def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""): + + if isbasestring(filetype): + dir_path = self.Dir('.').abspath + filetype = sorted(glob.glob(dir_path+"/"+filetype)) + + for path in filetype: + target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path ) + if shared: + target_name+='.os' + sources.append( self.SharedObject( target=target_name, source=path ) ) + else: + target_name+='.o' + sources.append( self.StaticObject( target=target_name, source=path ) ) + pass + +def isAbsolutePath(key, dirname, env): + assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,) + +env_vars = Variables( + args=ARGUMENTS +) + +env_vars.Add('prefix', + help='Installation target location of build results and headers', + default='/usr/local/', + validator=isAbsolutePath +) + +env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], + CPPDEFINES=['SAW_UNIX'], + CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], + LIBS=['forstio-codec']) +env.__class__.add_source_files = add_kel_source_files +env.Tool('compilation_db'); +env.cdb = env.CompilationDatabase('compile_commands.json'); + +env.objects = []; +env.sources = []; +env.headers = []; +env.targets = []; + +Export('env') +SConscript('SConscript') + +env.Alias('cdb', env.cdb); +env.Alias('all', [env.targets]); +env.Default('all'); + +env.Alias('install', '$prefix') diff --git a/src/codec-json/json.h b/src/codec-json/json.h new file mode 100644 index 0000000..2c5b83e --- /dev/null +++ b/src/codec-json/json.h @@ -0,0 +1,12 @@ +#pragma once + +namespace saw { +namespace encoded { +struct Json {}; +} + +template<typename Schema> +class codec<Schema, Json> { + +}; +} |