summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-09-09 11:02:12 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-09-09 11:02:12 +0200
commit7ff6ea3bde6eb1d3b55c558303c48e065c38199b (patch)
tree6da790a967d7fe73f696dd3de25e18690a5e1d55
parent3fa7dcb5684504dc99d14d2dc003876151636834 (diff)
Trying to isolate nix builds a bit
-rw-r--r--examples/SConscript5
-rw-r--r--examples/cavity_2d/.nix/derivation.nix36
-rw-r--r--examples/cavity_2d/SConscript41
-rw-r--r--examples/cavity_2d/SConstruct80
-rw-r--r--examples/cavity_2d/cavity_2d.cpp (renamed from examples/cavity_2d.cpp)0
5 files changed, 157 insertions, 5 deletions
diff --git a/examples/SConscript b/examples/SConscript
index 13335c8..cf94fb3 100644
--- a/examples/SConscript
+++ b/examples/SConscript
@@ -23,11 +23,6 @@ examples_objects = [];
examples_env.add_source_files(examples_objects, ['meta_2d.cpp'], shared=False);
examples_env.meta_2d = examples_env.Program('#bin/meta_2d', [env.library_static, examples_objects]);
-# Cavity2D
-examples_objects = [];
-examples_env.add_source_files(examples_objects, ['cavity_2d.cpp'], shared=False);
-examples_env.cavity_2d = examples_env.Program('#bin/cavity_2d', [env.library_static, examples_objects]);
-
# Cavity3D
examples_objects = [];
examples_env.add_source_files(examples_objects, ['cavity_3d.cpp'], shared=False);
diff --git a/examples/cavity_2d/.nix/derivation.nix b/examples/cavity_2d/.nix/derivation.nix
new file mode 100644
index 0000000..a98795b
--- /dev/null
+++ b/examples/cavity_2d/.nix/derivation.nix
@@ -0,0 +1,36 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, forstio
+, pname
+, version
+}:
+
+stdenv.mkDerivation {
+ inherit pname version;
+ src = ./..;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.async
+ forstio.codec
+ forstio.codec-unit
+ forstio.codec-json
+ ];
+
+ doCheck = true;
+ checkPhase = ''
+ scons test
+ ./bin/tests
+ '';
+
+ preferLocalBuild = true;
+
+ outputs = [ "out" "dev" ];
+}
diff --git a/examples/cavity_2d/SConscript b/examples/cavity_2d/SConscript
new file mode 100644
index 0000000..077fb99
--- /dev/null
+++ b/examples/cavity_2d/SConscript
@@ -0,0 +1,41 @@
+#!/bin/false
+
+import os
+import os.path
+import glob
+
+
+Import('env')
+
+dir_path = Dir('.').abspath
+
+# Environment for base library
+cavity2d_env = examples_env.Clone();
+
+examples_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+examples_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += examples_env.sources;
+env.headers += examples_env.headers;
+
+# Cavity2D
+examples_objects = [];
+examples_env.add_source_files(examples_objects, ['cavity_2d.cpp'], shared=False);
+examples_env.cavity_2d = examples_env.Program('#bin/cavity_2d', [env.library_static, examples_objects]);
+
+# Set Alias
+env.examples = [
+ examples_env.meta_2d,
+# examples_env.cavity_2d,
+# examples_env.cavity_3d,
+# examples_env.particle_ibm_2d
+ examples_env.poiseulle_2d,
+ examples_env.poiseulle_channel_2d,
+ examples_env.poiseulle_particles_channel_2d
+];
+env.Alias('examples', env.examples);
+
+if env["build_examples"]:
+ env.targets += ['examples'];
+ env.Install('$prefix/bin/', env.examples);
+#endif
diff --git a/examples/cavity_2d/SConstruct b/examples/cavity_2d/SConstruct
new file mode 100644
index 0000000..fc60882
--- /dev/null
+++ b/examples/cavity_2d/SConstruct
@@ -0,0 +1,80 @@
+#!/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_vars.Add('build_examples',
+ help='If examples should be built',
+ default="true"
+)
+
+env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[],
+ 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('SConscript')
+
+env.Alias('cdb', env.cdb);
+env.Alias('all', [env.targets]);
+env.Default('all');
+
+env.Alias('install', '$prefix')
diff --git a/examples/cavity_2d.cpp b/examples/cavity_2d/cavity_2d.cpp
index e228a06..e228a06 100644
--- a/examples/cavity_2d.cpp
+++ b/examples/cavity_2d/cavity_2d.cpp