summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-08-29 22:17:14 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-08-29 22:17:27 +0200
commit6379fe9ca2cad3d0c9d886e7808b1d579ce349c2 (patch)
treef0b86c5c64476ace6a02bca6586047df0dae4196 /modules
parent153f808a0eb648a28a2203a96a5d68f9245e361b (diff)
Not even sure why I have this
Diffstat (limited to 'modules')
-rw-r--r--modules/codec-obj/c++/SConscript24
-rw-r--r--modules/codec-sql/.nix/derivation.nix36
-rw-r--r--modules/codec-sql/SConstruct72
-rw-r--r--modules/codec-sql/c++/SConscript38
-rw-r--r--modules/codec-sql/c++/sql.hpp35
-rw-r--r--modules/codec-sql/tests/SConscript31
6 files changed, 224 insertions, 12 deletions
diff --git a/modules/codec-obj/c++/SConscript b/modules/codec-obj/c++/SConscript
index 1b93e07..544dd65 100644
--- a/modules/codec-obj/c++/SConscript
+++ b/modules/codec-obj/c++/SConscript
@@ -10,29 +10,29 @@ Import('env')
dir_path = Dir('.').abspath
# Environment for base library
-codec_json_env = env.Clone();
+codec_obj_env = env.Clone();
-codec_json_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
-codec_json_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+codec_obj_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+codec_obj_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
-env.sources += codec_json_env.sources;
-env.headers += codec_json_env.headers;
+env.sources += codec_obj_env.sources;
+env.headers += codec_obj_env.headers;
## Shared lib
objects_shared = []
-codec_json_env.add_source_files(objects_shared, codec_json_env.sources, shared=True);
-env.library_shared = codec_json_env.SharedLibrary('#build/forstio-codec-json', [objects_shared]);
+codec_obj_env.add_source_files(objects_shared, codec_obj_env.sources, shared=True);
+env.library_shared = codec_obj_env.SharedLibrary('#build/forstio-codec-obj', [objects_shared]);
## Static lib
objects_static = []
-codec_json_env.add_source_files(objects_static, codec_json_env.sources, shared=False);
-env.library_static = codec_json_env.StaticLibrary('#build/forstio-codec-json', [objects_static]);
+codec_obj_env.add_source_files(objects_static, codec_obj_env.sources, shared=False);
+env.library_static = codec_obj_env.StaticLibrary('#build/forstio-codec-obj', [objects_static]);
# Set Alias
-env.Alias('library_codec_json', [env.library_shared, env.library_static]);
+env.Alias('library_codec_obj', [env.library_shared, env.library_static]);
-env.targets += ['library_codec_json'];
+env.targets += ['library_codec_obj'];
# Install
env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
-env.Install('$prefix/include/forstio/codec/json/', [codec_json_env.headers]);
+env.Install('$prefix/include/forstio/codec/obj/', [codec_obj_env.headers]);
diff --git a/modules/codec-sql/.nix/derivation.nix b/modules/codec-sql/.nix/derivation.nix
new file mode 100644
index 0000000..6bd3fdb
--- /dev/null
+++ b/modules/codec-sql/.nix/derivation.nix
@@ -0,0 +1,36 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, version
+, forstio
+}:
+
+let
+
+in stdenv.mkDerivation {
+ pname = "forstio-codec-sql";
+ inherit version;
+ src = ./..;
+
+ enableParallelBuilding = true;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.async
+ forstio.codec
+ ];
+
+ doCheck = true;
+ checkPhase = ''
+ scons test
+ ./bin/tests
+ '';
+
+ outputs = ["out" "dev"];
+}
diff --git a/modules/codec-sql/SConstruct b/modules/codec-sql/SConstruct
new file mode 100644
index 0000000..ff2b31d
--- /dev/null
+++ b/modules/codec-sql/SConstruct
@@ -0,0 +1,72 @@
+#!/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=[],
+ CXX=['c++'],
+ CPPDEFINES=['SAW_UNIX'],
+ CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
+ LIBS=[
+ 'forstio-core',
+ '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('c++/SConscript')
+SConscript('tests/SConscript')
+
+env.Alias('cdb', env.cdb);
+env.Alias('all', [env.targets]);
+env.Default('all');
+
+env.Alias('install', '$prefix')
diff --git a/modules/codec-sql/c++/SConscript b/modules/codec-sql/c++/SConscript
new file mode 100644
index 0000000..b31529d
--- /dev/null
+++ b/modules/codec-sql/c++/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_sql_env = env.Clone();
+
+codec_sql_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+codec_sql_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += codec_sql_env.sources;
+env.headers += codec_sql_env.headers;
+
+## Shared lib
+objects_shared = []
+codec_sql_env.add_source_files(objects_shared, codec_sql_env.sources, shared=True);
+env.library_shared = codec_sql_env.SharedLibrary('#build/forstio-codec-sql', [objects_shared]);
+
+## Static lib
+objects_static = []
+codec_sql_env.add_source_files(objects_static, codec_sql_env.sources, shared=False);
+env.library_static = codec_sql_env.StaticLibrary('#build/forstio-codec-sql', [objects_static]);
+
+# Set Alias
+env.Alias('library_codec_sql', [env.library_shared, env.library_static]);
+
+env.targets += ['library_codec_sql'];
+
+# Install
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
+env.Install('$prefix/include/forstio/codec/sql/', [codec_sql_env.headers]);
diff --git a/modules/codec-sql/c++/sql.hpp b/modules/codec-sql/c++/sql.hpp
new file mode 100644
index 0000000..5f4f3d3
--- /dev/null
+++ b/modules/codec-sql/c++/sql.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <forstio/codec/data.hpp>
+#include <sqlite3.h>
+
+namespace saw {
+namespace encode {
+struct Sql {};
+}
+}
+
+namespace saw{
+template<typename Schema>
+class data<Schema, encode::Sql> {
+private:
+ data<Schema> int_;
+public:
+ data(const data<Schema>& int__):int_{int__}{}
+ data(data<Schema>&& int__):int_{std::move(int__)}{}
+};
+
+template<typename Schema>
+class codec<Schema, encode::Sql> {
+private:
+ template<typename ToEncode>
+ error_or<void> decode(data<Schema,encode::Sql>& from, data<Schema, ToEncode>& to){
+ return make_error<err::not_implemented>("SQL decode not available");
+ }
+
+ template<typename FromEncode>
+ error_or<void> encode(data<Schema,FromEncode>& from, data<Schema, encode::Sql>& to){
+ return make_error<err::not_implemented>("SQL encode not available");
+ }
+};
+}
diff --git a/modules/codec-sql/tests/SConscript b/modules/codec-sql/tests/SConscript
new file mode 100644
index 0000000..f8ffc92
--- /dev/null
+++ b/modules/codec-sql/tests/SConscript
@@ -0,0 +1,31 @@
+#!/bin/false
+
+import os
+import os.path
+import glob
+
+
+Import('env')
+
+dir_path = Dir('.').abspath
+
+# Environment for base library
+test_cases_env = env.Clone();
+
+test_cases_env.Append(LIBS=['forstio-test']);
+
+test_cases_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+test_cases_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += test_cases_env.sources;
+env.headers += test_cases_env.headers;
+
+objects_static = []
+test_cases_env.add_source_files(objects_static, test_cases_env.sources, shared=False);
+test_cases_env.program = test_cases_env.Program('#bin/tests', [objects_static, env.library_static]);
+
+# Set Alias
+env.Alias('test', test_cases_env.program);
+env.Alias('check', test_cases_env.program);
+
+env.targets += ['test','check'];