summaryrefslogtreecommitdiff
path: root/modules/codec-obj
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-24 18:10:41 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-24 18:10:41 +0200
commit49fbd753bee3e6cec68f4e23cc766934c8449eb3 (patch)
treed33420ab311156cb557db213222b3b7fc9e03f13 /modules/codec-obj
parent53738bc556fc13c80dacdb56633ef8b7441e6566 (diff)
Preparing for wavefront
Diffstat (limited to 'modules/codec-obj')
-rw-r--r--modules/codec-obj/.nix/derivation.nix36
-rw-r--r--modules/codec-obj/SConstruct72
-rw-r--r--modules/codec-obj/c++/SConscript38
-rw-r--r--modules/codec-obj/c++/obj.hpp31
-rw-r--r--modules/codec-obj/tests/SConscript31
5 files changed, 208 insertions, 0 deletions
diff --git a/modules/codec-obj/.nix/derivation.nix b/modules/codec-obj/.nix/derivation.nix
new file mode 100644
index 0000000..1152cee
--- /dev/null
+++ b/modules/codec-obj/.nix/derivation.nix
@@ -0,0 +1,36 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, version
+, forstio
+}:
+
+let
+
+in stdenv.mkDerivation {
+ pname = "forstio-codec-obj";
+ 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-obj/SConstruct b/modules/codec-obj/SConstruct
new file mode 100644
index 0000000..ff2b31d
--- /dev/null
+++ b/modules/codec-obj/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-obj/c++/SConscript b/modules/codec-obj/c++/SConscript
new file mode 100644
index 0000000..1b93e07
--- /dev/null
+++ b/modules/codec-obj/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_json_env = env.Clone();
+
+codec_json_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+codec_json_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+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);
+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);
+env.library_static = codec_json_env.StaticLibrary('#build/forstio-codec-json', [objects_static]);
+
+# Set Alias
+env.Alias('library_codec_json', [env.library_shared, env.library_static]);
+
+env.targets += ['library_codec_json'];
+
+# Install
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
+env.Install('$prefix/include/forstio/codec/json/', [codec_json_env.headers]);
diff --git a/modules/codec-obj/c++/obj.hpp b/modules/codec-obj/c++/obj.hpp
new file mode 100644
index 0000000..d8d0dde
--- /dev/null
+++ b/modules/codec-obj/c++/obj.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <forstio/codec/data.hpp>
+
+namespace saw {
+namespace encode {
+struct WavefrontObj {};
+}
+}
+
+namespace saw{
+template<typename Schema>
+class data<Schema, encode::WavefrontObj> {
+private:
+public:
+};
+
+template<typename Schema>
+class codec<Schema, encode::WavefrontObj> {
+private:
+ template<typename ToEncode>
+ error_or<void> decode(data<Schema,encode::WavefrontObj>& from, data<Schema, ToEncode>& to){
+ return make_error<err::not_implemented>("Wavefront decode not available");
+ }
+
+ template<typename FromEncode>
+ error_or<void> encode(data<Schema,FromEncode>& from, data<Schema, encode::WavefrontObj>& to){
+ return make_error<err::not_implemented>("Wavefront encode not available");
+ }
+};
+}
diff --git a/modules/codec-obj/tests/SConscript b/modules/codec-obj/tests/SConscript
new file mode 100644
index 0000000..f8ffc92
--- /dev/null
+++ b/modules/codec-obj/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'];