From 29b7e03b93229090928d08dbcdb2622be0b27b53 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 2 Nov 2026 22:17:53 +0100 Subject: Prep for kel_git stuff --- default.nix | 4 +++ kel_git/.nix/derivation.nix | 23 ++++++++++++++ kel_git/SConstruct | 70 ++++++++++++++++++++++++++++++++++++++++++ kel_git/c++/SConscript | 32 ++++++++++++++++++++ kel_git/c++/common.hpp | 7 +++++ kel_git/c++/config.hpp | 16 ++++++++++ kel_git/c++/git_schema.hpp | 10 ++++++ kel_git/c++/kel_git.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 236 insertions(+) create mode 100644 kel_git/.nix/derivation.nix create mode 100644 kel_git/SConstruct create mode 100644 kel_git/c++/SConscript create mode 100644 kel_git/c++/common.hpp create mode 100644 kel_git/c++/config.hpp create mode 100644 kel_git/c++/git_schema.hpp create mode 100644 kel_git/c++/kel_git.cpp diff --git a/default.nix b/default.nix index d255840..57ba300 100644 --- a/default.nix +++ b/default.nix @@ -23,5 +23,9 @@ in { rap = pkgs.callPackage ./kel_rap/.nix/derivation.nix { inherit stdenv clang-tools; }; + + git = pkgs.callPackage ./kel_git/.nix/derivation.nix { + inherit stdenv clang-tools forstio; + }; }; } diff --git a/kel_git/.nix/derivation.nix b/kel_git/.nix/derivation.nix new file mode 100644 index 0000000..8126434 --- /dev/null +++ b/kel_git/.nix/derivation.nix @@ -0,0 +1,23 @@ +{ stdenv +, scons +, clang-tools +, forstio +}: + +stdenv.mkDerivation { + pname = "kel_git"; + version = "0.0.0"; + + nativeBuildInputs = [ + clang-tools + scons + ]; + + buildInputs = [ + forstio.core + forstio.codec + forstio.codec-json + ]; + + src = ./..; +} diff --git a/kel_git/SConstruct b/kel_git/SConstruct new file mode 100644 index 0000000..eeb0737 --- /dev/null +++ b/kel_git/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_git/c++/SConscript b/kel_git/c++/SConscript new file mode 100644 index 0000000..da43c01 --- /dev/null +++ b/kel_git/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_git', [objects_static]); + +# Set Alias +env.Alias('binary', [env.binary]); + +env.targets += ['binary']; + +# Install +env.Install('$prefix/bin/', [env.binary]); diff --git a/kel_git/c++/common.hpp b/kel_git/c++/common.hpp new file mode 100644 index 0000000..79e3bbb --- /dev/null +++ b/kel_git/c++/common.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace kel { + +} diff --git a/kel_git/c++/config.hpp b/kel_git/c++/config.hpp new file mode 100644 index 0000000..3f98d3b --- /dev/null +++ b/kel_git/c++/config.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "common.hpp" + +namespace kel { +namespace sch { +using GitConfig = Struct< + Member< +>; +} + +template +saw::error_or parse_config(const saw::data& cfg_enc, saw::data& cfg){ + return saw::make_void(); +} +} diff --git a/kel_git/c++/git_schema.hpp b/kel_git/c++/git_schema.hpp new file mode 100644 index 0000000..4f06f36 --- /dev/null +++ b/kel_git/c++/git_schema.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "common.hpp" + +namespace kel { +namespace sch { +using namespace saw::schema; + +} +} diff --git a/kel_git/c++/kel_git.cpp b/kel_git/c++/kel_git.cpp new file mode 100644 index 0000000..65d7cad --- /dev/null +++ b/kel_git/c++/kel_git.cpp @@ -0,0 +1,74 @@ +#include +#include + +#include +#include + +#include "common.hpp" +#include "config.hpp" + +namespace kel { +namespace sch { +using namespace saw::schema; + +using GitArgs = Args< + Struct< + >, + Tuple<> +>; +} + +saw::error_or kmain(int argc, char** argv){ + saw::data args_d; + { + saw::data args_data{argc, argv}; + saw::codec args_codec; + + auto eov = args_codec.decode(args_data, args_d); + if(eov.is_error()){ + return eov; + } + } + // saw::data cmd_data; + { + // Parse from file + } + + bool running = true; + + auto eo_aio = saw::setup_async_io(); + if(eo_aio.is_error()){ + return std::move(eo_aio.get_error()); + } + auto& aio = eo_aio.get_value(); + auto term_sink = aio.event_port.on_signal(saw::Signal::Terminate).then([&running](){ + running = false; + }).sink(); + + + + while(running){ + aio.event_port.wait(); + } + + return saw::make_void(); +} +} + +int main(int argc, char** argv){ + auto eov = kel::kmain(argc, argv); + if(eov.is_error()){ + auto& err = eov.get_error(); + auto err_msg = err.get_message(); + std::cerr<<"[Error]: "<