diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-19 20:29:35 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-19 20:31:06 +0200 |
commit | 955905b06c5a45adac73631056c9caa758e6d249 (patch) | |
tree | 30944e1cd879873a4780ade60337d749b79fa620 | |
parent | caa36e5cb2be6c0f37ff8cc0c500cc41beec1d42 (diff) |
c++,nix: basic setup
-rw-r--r-- | .nix/derivation.nix | 2 | ||||
-rw-r--r-- | SConstruct | 4 | ||||
-rw-r--r-- | c++/SConscript | 37 | ||||
-rw-r--r-- | c++/examples/cavity_2d.cpp | 9 | ||||
-rw-r--r-- | c++/lattice.h | 19 | ||||
-rw-r--r-- | default.nix | 14 |
6 files changed, 81 insertions, 4 deletions
diff --git a/.nix/derivation.nix b/.nix/derivation.nix index 33a4207..6ba3b2f 100644 --- a/.nix/derivation.nix +++ b/.nix/derivation.nix @@ -2,6 +2,7 @@ , stdenvNoCC , scons , clang +, clang-tools , forstio , kel-unit }: @@ -14,6 +15,7 @@ stdenvNoCC.mkDerivation { nativeBuildInputs = [ scons clang + clang-tools ]; buildInputs = [ @@ -46,7 +46,7 @@ env_vars.Add('prefix', env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], CPPDEFINES=['SAW_UNIX'], CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], - LIBS=['forstio-core']) + 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'); @@ -57,7 +57,7 @@ env.headers = []; env.targets = []; Export('env') -SConscript('src/SConscript') +SConscript('c++/SConscript') env.Alias('cdb', env.cdb); env.Alias('all', [env.targets]); diff --git a/c++/SConscript b/c++/SConscript new file mode 100644 index 0000000..d696204 --- /dev/null +++ b/c++/SConscript @@ -0,0 +1,37 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +core_env = env.Clone(); + +core_env.sources = sorted(glob.glob(dir_path + "/*.cpp")); +core_env.headers = sorted(glob.glob(dir_path + "/*.h")); + +env.sources += core_env.sources; +env.headers += core_env.headers; + + +## Shared lib +objects = [] +core_env.add_source_files(objects, core_env.sources, shared=False); + +# Cavity2D +core_env.cavity_2d_source = sorted(glob.glob(dir_path + "/examples/cavity_2d.cpp")); +env.sources += core_env.cavity_2d_source; +core_env.cavity_2d = core_env.Program('#bin/cavity_2d', [core_env.cavity_2d_source, core_env.objects]); + +# Set Alias +env.Alias('examples', [core_env.cavity_2d]); + +env.targets += ['examples']; + +# Install +env.Install('$prefix/bin', ['examples']); diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp new file mode 100644 index 0000000..bb21e96 --- /dev/null +++ b/c++/examples/cavity_2d.cpp @@ -0,0 +1,9 @@ +#include "../lattice.h" + +#include <forstio/codec/data.h> + +int main(){ + saw::data<schema::Lattice2D<saw::schema::Float32>, saw::encode::Native> lattice{512, 512}; + + return 0; +} diff --git a/c++/lattice.h b/c++/lattice.h new file mode 100644 index 0000000..62752e8 --- /dev/null +++ b/c++/lattice.h @@ -0,0 +1,19 @@ +#pragma once + +#include <forstio/codec/schema.h> + +namespace kel { +namespace lbm { +namespace schema { +template<typename T, size_t D> +using Lattice = Array<T,D>; + +template<typename T> +using Lattice2D = Lattice<T,2>; + +template<typename T> +using Lattice3D = Lattice<T,3>; +} +} +} +} diff --git a/default.nix b/default.nix index f93b364..0ea5cdf 100644 --- a/default.nix +++ b/default.nix @@ -1,18 +1,28 @@ { pkgs ? import <nixpkgs> {} +, clang ? pkgs.clang_15 +, clang-tools ? pkgs.clang-tools_15 }: let forstio = (import ((builtins.fetchGit { url = "git@git.keldu.de:forstio/forstio"; ref = "dev"; - }).outPath + "/default.nix"){}).forstio; + }).outPath + "/default.nix"){ + inherit clang; + inherit clang-tools; + }).forstio; kel-unit = (import ((builtins.fetchGit { url = "git@git.keldu.de:libs/unit"; ref = "dev"; - }).outPath + "/default.nix"){}); + }).outPath + "/default.nix"){ + inherit clang; + inherit clang-tools; + }); in pkgs.callPackage ./.nix/derivation.nix { inherit forstio; inherit kel-unit; + inherit clang; + inherit clang-tools; } |