From d9a1368e23fae9e696bc061b3688fc226eaf1d7e Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 29 Jul 2024 20:57:51 +0200 Subject: Fixed lib for basic example --- SConstruct | 11 ++++++++++- c++/distance/meter.hpp | 2 +- c++/time/second.hpp | 2 +- c++/unit.hpp | 4 ++-- c++/unit_print.hpp | 14 +++++++------- default.nix | 2 +- examples/SConscript | 31 +++++++++++++++++++++++++++++++ 7 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 examples/SConscript diff --git a/SConstruct b/SConstruct index def568e..a22a508 100644 --- a/SConstruct +++ b/SConstruct @@ -43,10 +43,18 @@ env_vars.Add('prefix', validator=isAbsolutePath ) +env_vars.Add( + BoolVariable('build_examples', + help='Build examples', + default=True + ) +); + 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'] +); env.__class__.add_source_files = add_kel_source_files env.Tool('compilation_db'); env.cdb = env.CompilationDatabase('compile_commands.json'); @@ -58,6 +66,7 @@ env.targets = []; Export('env') SConscript('c++/SConscript') +SConscript('examples/SConscript') env.Alias('cdb', env.cdb); env.Alias('all', [env.targets]); diff --git a/c++/distance/meter.hpp b/c++/distance/meter.hpp index 0d9fb3b..9ab3762 100644 --- a/c++/distance/meter.hpp +++ b/c++/distance/meter.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../unit.h" +#include "../unit.hpp" #include diff --git a/c++/time/second.hpp b/c++/time/second.hpp index 6dca456..d127f86 100644 --- a/c++/time/second.hpp +++ b/c++/time/second.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../unit.h" +#include "../unit.hpp" namespace kel { namespace unit_type { diff --git a/c++/unit.hpp b/c++/unit.hpp index a8e8320..171fcb6 100644 --- a/c++/unit.hpp +++ b/c++/unit.hpp @@ -1,6 +1,6 @@ #pragma once -#include "unit_reduction.h" +#include "unit_reduction.hpp" namespace kel { template @@ -46,4 +46,4 @@ template using scalar = unit; } -#include "unit.tmpl.h" +#include "unit.tmpl.hpp" diff --git a/c++/unit_print.hpp b/c++/unit_print.hpp index 4d9187b..248a48d 100644 --- a/c++/unit_print.hpp +++ b/c++/unit_print.hpp @@ -1,11 +1,11 @@ -#include "./unit.h" +#include "unit.hpp" #include namespace std { template -inline ostream& operator<<(ostream& o, const kel::unit_base& ele){ +inline ostream& operator<<(ostream& o, const kel::unit_component&){ o< -struct unit_print_impl,unit_base...> { +struct unit_print_impl,unit_component...> { static std::ostream& print(std::ostream& o){ - unit_base element; + unit_component element; std::ostream& o_ret = o << element; if constexpr (sizeof...(UnitTL) > 0){ std::ostream& o_ret_next = o_ret << ' ' << '*' << ' '; - return unit_print_impl...>::print(o_ret_next); + return unit_print_impl...>::print(o_ret_next); } return o_ret<<']'; @@ -44,11 +44,11 @@ template inline ostream& operator<<(ostream& o, const kel::unit& unit); template -inline ostream& operator<<(ostream& o, const kel::unit...>& unit){ +inline ostream& operator<<(ostream& o, const kel::unit...>& unit){ o << unit.data(); if constexpr (sizeof...(UnitT) > 0) { auto& o_ret = o << ' '<<'['; - return kel::unit_print_impl...>::print(o_ret); + return kel::unit_print_impl...>::print(o_ret); } return o; } diff --git a/default.nix b/default.nix index ec96333..a775c9e 100644 --- a/default.nix +++ b/default.nix @@ -16,5 +16,5 @@ let in pkgs.callPackage ./.nix/derivation.nix { inherit forstio; inherit stdenv; - inherit clang-tools; + inherit clang-tools; } diff --git a/examples/SConscript b/examples/SConscript new file mode 100644 index 0000000..f69fc64 --- /dev/null +++ b/examples/SConscript @@ -0,0 +1,31 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +examples_env = 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; + +objects_static = [] +examples_env.echo_server = examples_env.Program('#bin/kel_unit_example_basic', ['basic.cpp']); + +# Set Alias +env.examples = [examples_env.echo_server]; +env.Alias('examples', env.examples); + +if env["build_examples"]: + env.targets += ['examples']; + env.Install('$prefix/bin/', env.examples); +#endif -- cgit v1.2.3