diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-12 16:05:22 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-12 16:05:22 +0100 |
| commit | 6eb839f219d80c018a58865a79f0623e839cef09 (patch) | |
| tree | b9668086665748487cb9be6e8de5eaeda838405c | |
| parent | af4bb05489eae478420a1792419fe43ee4b732d3 (diff) | |
| download | apps-dev_tools-6eb839f219d80c018a58865a79f0623e839cef09.tar.gz | |
Adding commands
| -rw-r--r-- | default.nix | 14 | ||||
| -rw-r--r-- | kel_cmds/.nix/derivation.nix | 23 | ||||
| -rw-r--r-- | kel_cmds/SConstruct | 70 | ||||
| -rw-r--r-- | kel_cmds/c++/SConscript | 32 | ||||
| -rw-r--r-- | kel_cmds/c++/kel_cmds.cpp | 1 |
5 files changed, 136 insertions, 4 deletions
diff --git a/default.nix b/default.nix index 52cd500..890fccd 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,7 @@ { pkgs ? import <nixpkgs> {} -, stdenv ? pkgs.llvmPackages_19.stdenv -, clang-tools ? pkgs.clang-tools_19 +, llvmPackages ? pkgs.llvmPackages_21 +, stdenv ? llvmPackages.stdenv +, clang-tools ? llvmPackages.clang-tools }: let @@ -11,7 +12,12 @@ let inherit stdenv; }).forstio; in { - kel_cpp_boilerplate = pkgs.callPackage ./kel_cpp_boilerplate/.nix/derivation.nix { - inherit stdenv clang-tools forstio; + kel = { + cpp_boilerplate = pkgs.callPackage ./kel_cpp_boilerplate/.nix/derivation.nix { + inherit stdenv clang-tools forstio; + }; + cmds = pkgs.callPackage ./kel_cmds/.nix/derivation.nix { + inherit stdenv clang-tools forstio; + }; }; } diff --git a/kel_cmds/.nix/derivation.nix b/kel_cmds/.nix/derivation.nix new file mode 100644 index 0000000..ac8f771 --- /dev/null +++ b/kel_cmds/.nix/derivation.nix @@ -0,0 +1,23 @@ +{ stdenv +, scons +, clang-tools +, forstio +}: + +stdenv.mkDerivation { + pname = "kel_cmds"; + version = "0.0.0"; + + nativeBuildInputs = [ + clang-tools + scons + ]; + + buildInputs = [ + forstio.core + forstio.codec + forstio.codec-json + ]; + + src = ./..; +} diff --git a/kel_cmds/SConstruct b/kel_cmds/SConstruct new file mode 100644 index 0000000..eeb0737 --- /dev/null +++ b/kel_cmds/SConstruct @@ -0,0 +1,70 @@ +#!/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=[], + CXX=['c++'], + CPPDEFINES=['SAW_UNIX'], + CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], + LIBS=[ + 'forstio-core' + ] +) +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('c++/SConscript') +#SConscript('tests/SConscript') + +env.Alias('cdb', env.cdb); +env.Alias('all', [env.targets]); +env.Default('all'); + +env.Alias('install', '$prefix') diff --git a/kel_cmds/c++/SConscript b/kel_cmds/c++/SConscript new file mode 100644 index 0000000..6024167 --- /dev/null +++ b/kel_cmds/c++/SConscript @@ -0,0 +1,32 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +program_env = env.Clone(); + +program_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +program_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += program_env.sources; +env.headers += program_env.headers; + +## Static lib +objects_static = [] +program_env.add_source_files(objects_static, program_env.sources, shared=False); +env.binary = program_env.Program('#build/kel_cmds', [objects_static]); + +# Set Alias +env.Alias('binary', [env.binary]); + +env.targets += ['binary']; + +# Install +env.Install('$prefix/bin/', [env.binary]); diff --git a/kel_cmds/c++/kel_cmds.cpp b/kel_cmds/c++/kel_cmds.cpp new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/kel_cmds/c++/kel_cmds.cpp @@ -0,0 +1 @@ + |
