summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct11
-rw-r--r--c++/distance/meter.hpp2
-rw-r--r--c++/time/second.hpp2
-rw-r--r--c++/unit.hpp4
-rw-r--r--c++/unit_print.hpp14
-rw-r--r--default.nix2
-rw-r--r--examples/SConscript31
7 files changed, 53 insertions, 13 deletions
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 <string_view>
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<typename UnitType, int64_t Exponent>
@@ -46,4 +46,4 @@ template<typename S>
using scalar = unit<S>;
}
-#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 <iostream>
namespace std {
template<typename UnitT, int64_t UnitE>
-inline ostream& operator<<(ostream& o, const kel::unit_base<UnitT,UnitE>& ele){
+inline ostream& operator<<(ostream& o, const kel::unit_component<UnitT,UnitE>&){
o<<UnitT::short_name;
if constexpr ( UnitE != 1 ){
o<<'^'<<'('<<UnitE<<')';
@@ -21,16 +21,16 @@ struct unit_print_impl {
};
template<typename UnitT, int64_t UnitE, typename... UnitTL, int64_t... UnitEL>
-struct unit_print_impl<unit_base<UnitT,UnitE>,unit_base<UnitTL,UnitEL>...> {
+struct unit_print_impl<unit_component<UnitT,UnitE>,unit_component<UnitTL,UnitEL>...> {
static std::ostream& print(std::ostream& o){
- unit_base<UnitT,UnitE> element;
+ unit_component<UnitT,UnitE> element;
std::ostream& o_ret = o << element;
if constexpr (sizeof...(UnitTL) > 0){
std::ostream& o_ret_next = o_ret << ' ' << '*' << ' ';
- return unit_print_impl<unit_base<UnitTL,UnitEL>...>::print(o_ret_next);
+ return unit_print_impl<unit_component<UnitTL,UnitEL>...>::print(o_ret_next);
}
return o_ret<<']';
@@ -44,11 +44,11 @@ template<typename StorageT, typename... T>
inline ostream& operator<<(ostream& o, const kel::unit<StorageT,T...>& unit);
template<typename StorageT, typename... UnitT, int64_t... UnitE>
-inline ostream& operator<<(ostream& o, const kel::unit<StorageT,kel::unit_base<UnitT,UnitE>...>& unit){
+inline ostream& operator<<(ostream& o, const kel::unit<StorageT,kel::unit_component<UnitT,UnitE>...>& unit){
o << unit.data();
if constexpr (sizeof...(UnitT) > 0) {
auto& o_ret = o << ' '<<'[';
- return kel::unit_print_impl<kel::unit_base<UnitT,UnitE>...>::print(o_ret);
+ return kel::unit_print_impl<kel::unit_component<UnitT,UnitE>...>::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