diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-07-30 16:26:33 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-07-30 16:26:33 +0200 |
commit | c241f520fefbf02542694466f34ce816b65fc8b6 (patch) | |
tree | 928ff634370dab9a41185bd524e4c29b49cf03cf | |
parent | 2b42c5fcfd2148b1fdc2e3dd562c591ce289a7fc (diff) |
c++,io-fs: Setting up io-fs folder
-rw-r--r-- | c++/io-fs/.nix/derivation.nix | 33 | ||||
-rw-r--r-- | c++/io-fs/SConscript | 38 | ||||
-rw-r--r-- | c++/io-fs/SConstruct | 66 |
3 files changed, 137 insertions, 0 deletions
diff --git a/c++/io-fs/.nix/derivation.nix b/c++/io-fs/.nix/derivation.nix new file mode 100644 index 0000000..c8a4962 --- /dev/null +++ b/c++/io-fs/.nix/derivation.nix @@ -0,0 +1,33 @@ +{ lib +, stdenvNoCC +, scons +, clang +, clang-tools +, version +, forstio +}: + +let + +in stdenvNoCC.mkDerivation { + pname = "forstio-io-fs"; + inherit version; + src = ./..; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + scons + clang + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + forstio.io + ]; + + outputs = ["out" "dev"]; +} diff --git a/c++/io-fs/SConscript b/c++/io-fs/SConscript new file mode 100644 index 0000000..0d85f62 --- /dev/null +++ b/c++/io-fs/SConscript @@ -0,0 +1,38 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +io_env = env.Clone(); + +io_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +io_env.headers = sorted(glob.glob(dir_path + "/*.h")) + +env.sources += io_env.sources; +env.headers += io_env.headers; + +## Shared lib +objects_shared = [] +io_env.add_source_files(objects_shared, io_env.sources, shared=True); +io_env.library_shared = io_env.SharedLibrary('#build/forstio-io-fs', [objects_shared]); + +## Static lib +objects_static = [] +io_env.add_source_files(objects_static, io_env.sources, shared=False); +io_env.library_static = io_env.StaticLibrary('#build/forstio-io-fs', [objects_static]); + +# Set Alias +env.Alias('library_io', [io_env.library_shared, io_env.library_static]); + +env.targets += ['library_io']; + +# Install +env.Install('$prefix/lib/', [io_env.library_shared, io_env.library_static]); +env.Install('$prefix/include/forstio/io/fs/', [io_env.headers]); diff --git a/c++/io-fs/SConstruct b/c++/io-fs/SConstruct new file mode 100644 index 0000000..4cccf82 --- /dev/null +++ b/c++/io-fs/SConstruct @@ -0,0 +1,66 @@ +#!/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=[], + CPPDEFINES=['SAW_UNIX'], + CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], + LIBS=['forstio-async']) +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') |