diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-10-27 16:31:40 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-10-27 16:31:40 +0100 |
| commit | a3338b55da55f467d984ac36e7c3f158b88245b9 (patch) | |
| tree | deb64e36a86d2455d215c9a379a1924b23bdf75e | |
| parent | 2c850f934d7087061e6f8540ee3a273b9817fbc7 (diff) | |
| download | apps-science_tools-a3338b55da55f467d984ac36e7c3f158b88245b9.tar.gz | |
Dangling changes
| -rw-r--r-- | run_and_record/c++/file.hpp | 78 | ||||
| -rw-r--r-- | run_and_record/c++/main.cpp | 74 | ||||
| -rw-r--r-- | task_cell_graph/.nix/derivation.nix | 21 | ||||
| -rw-r--r-- | task_cell_graph/SConstruct | 71 | ||||
| -rw-r--r-- | task_cell_graph/c++/SConscript | 32 | ||||
| -rw-r--r-- | task_cell_graph/c++/dependency.hpp | 14 | ||||
| -rw-r--r-- | task_cell_graph/c++/main.cpp | 28 |
7 files changed, 290 insertions, 28 deletions
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 <filesystem> +#include <forstio/remote/remote.hpp> + +namespace kel { +namespace sch { +using namespace saw::schema; +} + +template<typename Sch, typename FileEnc, typename Enc = saw::encode::Native> +saw::error_or<void> simple_write_file(const data<Sch,Enc>& data_, const std::filesystem::path& p){ + saw::data<Sch, FileEnc> dat; + { + saw::codec<Sch, FileEnc> cdc; + auto eov = cdc.encode(data_,dat); + if(eov.is_error()){ + return eov; + } + } + + saw::remote<saw::rmt::File> 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<Sch,FileEnc>({*addr}); + if(eo_srv.is_error()){ + return std::move(eo_srv.get_error()); + } + auto& srv = eo_srv.get_value(); + saw::id<Sch> fid{0u}; + + auto eo_write = srv->send({fid}, dat); + if(eo_write.is_error()){ + return eo_write; + } + + return saw::make_void(); +} + +template<typename Sch, typename FileEnc, typename Enc = saw::encode::Native> +saw::error_or<saw::data<Sch,Enc>> simple_read_file(const std::filesystem::path& p){ + saw::data<Sch, Enc> dat; + + saw::remote<saw::rmt::File> 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<Sch,FileEnc>({*addr}); + if(eo_srv.is_error()){ + return std::move(eo_srv.get_error()); + } + auto& srv = eo_srv.get_value(); + saw::id<Sch> fid{0u}; + + auto eo_read = srv->receive({fid}); + if(eo_read.is_error()){ + return eo_read; + } + auto& read = eo_read.get_value(); + + { + saw::codec<Sch, FileEnc> 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 <forstio/codec/args.hpp> #include <forstio/codec/json/json.hpp> @@ -22,6 +24,22 @@ using RarArgs = Args< RarArgsTuple >; +using RarDataFile = Struct< + Member<Array<String>,"command">, + Member< + Array< + Struct< + Member<String, "key">, + Member<String, "value"> + > + >, "env">, + Member< + Struct< + Member<String, "commit">, + Member<String, "origin"> + >, + "git"> +>; } /** @@ -58,6 +76,11 @@ saw::error_or<void> 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<void> kel_main(int argc, char** argv){ // Grab home variable Check the default config location and try to decode the file saw::data<sch::RarArgs> 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<saw::rmt::File> 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<sch::RarConfig,saw::encode::Json>({*addr}); - if(eo_srv.is_error()){ - return std::move(eo_srv.get_error()); - } - auto& srv = eo_srv.get_value(); - saw::id<sch::RarConfig> 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<sch::RarConfig,saw::encode::Json>(conf_file); - saw::codec<sch::RarConfig, saw::encode::Json> 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<void> kel_main(int argc, char** argv){ return eov; } } + saw::data<sch::RarDataFile> 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<void> 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 <forstio/codec/schema.hpp> + +namespace kel { +namespace ops { +struct Write {}; +struct Read {}; +} + +template<bool Write, bool Read> +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 <forstio/error.hpp> + +#include "dependency.hpp" + +namespace kel { +saw::error_or<void> 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]: "<<err.get_category(); + + if(not err_msg.empty()){ + std::cerr<<" - "<<err_msg; + } + std::cerr<<std::endl; + + return err.get_id(); + } + + return 0; +} |
