From a3338b55da55f467d984ac36e7c3f158b88245b9 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 27 Oct 2025 16:31:40 +0100 Subject: Dangling changes --- run_and_record/c++/file.hpp | 78 +++++++++++++++++++++++++++++++++++++ run_and_record/c++/main.cpp | 74 ++++++++++++++++++++++------------- task_cell_graph/.nix/derivation.nix | 21 ++++++++++ task_cell_graph/SConstruct | 71 +++++++++++++++++++++++++++++++++ task_cell_graph/c++/SConscript | 32 +++++++++++++++ task_cell_graph/c++/dependency.hpp | 14 +++++++ task_cell_graph/c++/main.cpp | 28 +++++++++++++ 7 files changed, 290 insertions(+), 28 deletions(-) create mode 100644 run_and_record/c++/file.hpp create mode 100644 task_cell_graph/.nix/derivation.nix create mode 100644 task_cell_graph/SConstruct create mode 100644 task_cell_graph/c++/SConscript create mode 100644 task_cell_graph/c++/dependency.hpp create mode 100644 task_cell_graph/c++/main.cpp diff --git a/run_and_record/c++/file.hpp b/run_and_record/c++/file.hpp new file mode 100644 index 0000000..cb3077f --- /dev/null +++ b/run_and_record/c++/file.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include + +namespace kel { +namespace sch { +using namespace saw::schema; +} + +template +saw::error_or simple_write_file(const data& data_, const std::filesystem::path& p){ + saw::data dat; + { + saw::codec cdc; + auto eov = cdc.encode(data_,dat); + if(eov.is_error()){ + return eov; + } + } + + saw::remote file_remote; + auto eo_addr = file_remote.parse_address(p); + if(eo_addr.is_error()){ + return std::move(eo_addr.get_error()); + } + auto& addr = eo_addr.get_value(); + + auto eo_srv = file_remote.template data_listen({*addr}); + if(eo_srv.is_error()){ + return std::move(eo_srv.get_error()); + } + auto& srv = eo_srv.get_value(); + saw::id fid{0u}; + + auto eo_write = srv->send({fid}, dat); + if(eo_write.is_error()){ + return eo_write; + } + + return saw::make_void(); +} + +template +saw::error_or> simple_read_file(const std::filesystem::path& p){ + saw::data dat; + + saw::remote file_remote; + auto eo_addr = file_remote.parse_address(p); + if(eo_addr.is_error()){ + return std::move(eo_addr.get_error()); + } + auto& addr = eo_addr.get_value(); + + auto eo_srv = file_remote.template data_listen({*addr}); + if(eo_srv.is_error()){ + return std::move(eo_srv.get_error()); + } + auto& srv = eo_srv.get_value(); + saw::id fid{0u}; + + auto eo_read = srv->receive({fid}); + if(eo_read.is_error()){ + return eo_read; + } + auto& read = eo_read.get_value(); + + { + saw::codec cdc; + auto eov = cdc.decode(read,dat); + if(eov.is_error()){ + return std::move(eov.get_error()); + } + } + + return dat; +} +} diff --git a/run_and_record/c++/main.cpp b/run_and_record/c++/main.cpp index 9a33f59..7df7cb5 100644 --- a/run_and_record/c++/main.cpp +++ b/run_and_record/c++/main.cpp @@ -1,3 +1,5 @@ +#include "file.hpp" + #include #include @@ -22,6 +24,22 @@ using RarArgs = Args< RarArgsTuple >; +using RarDataFile = Struct< + Member,"command">, + Member< + Array< + Struct< + Member, + Member + > + >, "env">, + Member< + Struct< + Member, + Member + >, + "git"> +>; } /** @@ -58,6 +76,11 @@ saw::error_or run_program(int argc, char** argv){ waitpid(pid,&status,0); } + + /// @todo check status recoverd and write based on that. + /// + /// @todo record ENV used in run. + return saw::make_void(); } @@ -93,40 +116,26 @@ saw::error_or kel_main(int argc, char** argv){ // Grab home variable Check the default config location and try to decode the file saw::data args; + auto eo_home = get_home_env(); + if(eo_home.is_error()){ + return std::move(eov.get_error()); + } + auto& home = eov.get_value(); + + /// @todo Generate unique entry YYYY-MM-DD-HH-SS-MSMS-BIN_NAME-DUMB_HASH ? + auto data_dir = home / ".local" / "kel" / "run_and_record"; + // + { - auto eo_home = get_home_env(); - if(eo_home.is_error()){ - return std::move(eov.get_error()); - } - auto& home = eov.get_value(); auto conf_file = home / ".config" / "kel" / "run_and_record.json"; - saw::remote file_remote; - auto eo_addr = file_remote.parse_address(conf_file); - if(eo_addr.is_error()){ - return std::move(eo_addr.get_error()); - } - auto& addr = eo_addr.get_value(); - auto eo_srv = file_remote.template data_listen({*addr}); - if(eo_srv.is_error()){ - return std::move(eo_srv.get_error()); - } - auto& srv = eo_srv.get_value(); - saw::id fid{0u}; - - auto eo_data = srv->receive({fid}); - if(eo_data.is_error()){ - return std::move(eo_data.get_error()); - } - auto& data = eo_data.get_value(); + auto eo_file = simple_read_file(conf_file); - saw::codec json_cdc; - auto& args_str = args.template get<"arguments">(); - auto eo_dec = json_cdc.decode(data,args_str); - if(eo_dec.is_error()){ - return eo_dec; + if(eo_file.is_error()){ + return std::move(eo_file.get_error()); } + args.template get<"args">() = eo_file.get_value(); } // 0 til i/sep_pos-1 with count of sep_pos @@ -139,6 +148,10 @@ saw::error_or kel_main(int argc, char** argv){ return eov; } } + saw::data data_for_file; + { + auto& env = data_for_file.template get<"env">(); + } // sep_pos+1 til end int argc_prog = argc - (sep_pos+1); { @@ -147,6 +160,11 @@ saw::error_or kel_main(int argc, char** argv){ return eov; } } + { + + } + + return saw::make_void(); } diff --git a/task_cell_graph/.nix/derivation.nix b/task_cell_graph/.nix/derivation.nix new file mode 100644 index 0000000..8837a86 --- /dev/null +++ b/task_cell_graph/.nix/derivation.nix @@ -0,0 +1,21 @@ +{ stdenv +, scons +, forstio +}: + +stdenv.mkDerivation { + pname = "kel_task_cell_graph"; + version = "0.0.0"; + + nativeBuildInputs = [ + scons + ]; + + buildInputs = [ + forstio.core + forstio.codec + forstio.codec-json + ]; + + src = ./..; +} diff --git a/task_cell_graph/SConstruct b/task_cell_graph/SConstruct new file mode 100644 index 0000000..d85358b --- /dev/null +++ b/task_cell_graph/SConstruct @@ -0,0 +1,71 @@ +#!/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/task_cell_graph/c++/SConscript b/task_cell_graph/c++/SConscript new file mode 100644 index 0000000..a1ac803 --- /dev/null +++ b/task_cell_graph/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_tcg', [objects_static]); + +# Set Alias +env.Alias('binary', [env.binary]); + +env.targets += ['binary']; + +# Install +env.Install('$prefix/bin/', [env.binary]); diff --git a/task_cell_graph/c++/dependency.hpp b/task_cell_graph/c++/dependency.hpp new file mode 100644 index 0000000..5e78cb3 --- /dev/null +++ b/task_cell_graph/c++/dependency.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include + +namespace kel { +namespace ops { +struct Write {}; +struct Read {}; +} + +template +struct operation { +}; +} diff --git a/task_cell_graph/c++/main.cpp b/task_cell_graph/c++/main.cpp new file mode 100644 index 0000000..9fa6aab --- /dev/null +++ b/task_cell_graph/c++/main.cpp @@ -0,0 +1,28 @@ +#include + +#include "dependency.hpp" + +namespace kel { +saw::error_or real_main(int argc, char** argv){ + + return saw::make_void(); +} +} + +int main(int argc, char** argv){ + auto eov = kel::real_main(argc, argv); + if(eov.is_error()){ + auto& err = eov.get_error(); + auto err_msg = err.get_message(); + std::cerr<<"[Error]: "<