From acd78020b887dc172c069da33c6391f22a48c584 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Wed, 19 Aug 2026 20:49:53 +0200 Subject: [PATCH 1/9] ++ --- .github/workflows/build.yml | 10 ++++++++- mkn.yaml | 12 ++--------- mod.cpp | 41 ++++++++++++++++++------------------- test.cpp | 35 ------------------------------- 4 files changed, 31 insertions(+), 67 deletions(-) delete mode 100644 test.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c890014..67c188f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,4 @@ + name: build concurrency: @@ -27,6 +28,7 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + architecture: x64 - run: | set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_nix @@ -45,12 +47,14 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + architecture: x64 - run: | set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_arm_osx chmod +x mkn KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" - KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" -p test + KLOG=3 ./mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module + python3 -c "import test_module as tm; tm.lol()" windows: runs-on: windows-latest @@ -62,7 +66,10 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + architecture: x64 - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 - env: MKN_CL_PREFERRED: 1 shell: bash @@ -73,3 +80,4 @@ jobs: KLOG=3 ./mkn clean build run -dtOa "-EHsc -std:c++20" KLOG=3 ./mkn clean build run -dtOp test -a "-EHsc -std:c++20" KLOG=3 ./mkn clean build -dtOa "-std:c++20 -EHsc" -p test_module + python3 -c "import test_module as tm; tm.lol()" diff --git a/mkn.yaml b/mkn.yaml index 24c87b9..12783aa 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -1,9 +1,6 @@ name: python3.module version: master -property: - maiken_location: ${MKN_HOME}/app/mkn/${version} - maiken_scm: https://github.com/mkn/mkn parent: base src: mod.cpp @@ -11,16 +8,11 @@ mode: shared profile: - name: base - dep: mkn&${maiken_location}(${maiken_scm})[mod] + dep: mkn.mod if_arg: - win_shared: -DYAML_CPP_DLL + win_static: -DYAML_CPP_STATIC_DEFINE shared: -DMKN_KUL_SHARED -- name: test - parent: base - dep: mkn&${maiken_location}(${maiken_scm})[lib] - main: test.cpp - - name: test_module dep: lang.pybind11 src: test_module.cpp diff --git a/mod.cpp b/mod.cpp index 0184500..7b9f0ed 100644 --- a/mod.cpp +++ b/mod.cpp @@ -28,19 +28,16 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "maiken/module/init.hpp" // IWYU pragma: keep - -#include "maiken/app.hpp" // for Application -#include "maiken/compiler.hpp" // for CompilationInfo, Mode +#include "mkn/mod/init.hpp" // IWYU pragma: keep #include "mkn/kul/os.hpp" // for Dir, WHICH, PushDir -#include "mkn/kul/cli.hpp" // for EnvVar, EnvVarMode -#include "mkn/kul/env.hpp" // for GET, SET +#include "mkn/kul/env.hpp" // for Var, Var::Mode, GET, SET +#include "mkn/kul/dbg.hpp" // for TRACING #include "mkn/kul/defs.hpp" // for MKN_KUL_PUBLISH #include "mkn/kul/proc.hpp" // for Process, ProcessCapture, AProcess -#include "maiken/project.hpp" // for Project #include "mkn/kul/except.hpp" // for Exception, KEXCEPT, KTHROW #include "mkn/kul/string.hpp" // for String +#include "mkn/kul/log.hpp" // for KOUT, KLOG, KERR #include // for basic_string, string #include // for vector @@ -51,8 +48,7 @@ namespace YAML { class Node; } -namespace mkn { -namespace python3 { +namespace mkn::python3 { kul::File find_python3() KTHROW(std::exception) { std::string const HOME = kul::env::GET("PYTHON3_HOME"); @@ -83,8 +79,8 @@ kul::File find_python3() KTHROW(std::exception) { throw std::runtime_error("Could not find python!"); } -kul::cli::EnvVar python3_path_var(kul::File const& exe) { - return {"PATH", exe.dir().real(), kul::cli::EnvVarMode::PREP}; +kul::env::Var python3_path_var(kul::File const& exe) { + return {"PATH", exe.dir().real(), kul::env::Var::Mode::PREP}; } static inline kul::File const python_exe = find_python3(); @@ -110,23 +106,26 @@ std::string pyexec_for_string(std::string const& cmd) { return ret; } -class ModuleMaker : public maiken::Module { +class ModuleMaker : public mkn::mod::Module { public: - void init(maiken::Application& a, YAML::Node const& /*node*/) KTHROW(std::exception) override; + void init(mkn::mod::Context& ctx, YAML::Node const& /*node*/) KTHROW(std::exception) override; }; -void ModuleMaker::init(maiken::Application& a, YAML::Node const& /*node*/) KTHROW(std::exception) { +void ModuleMaker::init(mkn::mod::Context& ctx, YAML::Node const& /*node*/) KTHROW(std::exception) { + MKN_KUL_DBG_FUNC_ENTER; + auto const cmd = "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"; - a.m_cInfo.lib_ext = pyexec_for_string(cmd); - a.m_cInfo.lib_prefix = ""; - a.mode(maiken::compiler::Mode::SHAR); + auto info = ctx.state().compileEnv.compilationInfo; + info.lib_ext = pyexec_for_string(cmd); + info.lib_prefix = ""; + ctx.compilerState().add(mkn::mod::CompilationInfoInput{info}); + ctx.compilerState().add(mkn::mod::BuildModeInput{mkn::mod::Mode::SHAR}); } -} // namespace python3 -} // namespace mkn +} // namespace mkn::python3 -extern "C" MKN_KUL_PUBLISH maiken::Module* maiken_module_construct() { +extern "C" MKN_KUL_PUBLISH mkn::mod::Module* maiken_module_construct() { return new mkn::python3::ModuleMaker; } -extern "C" MKN_KUL_PUBLISH void maiken_module_destruct(maiken::Module* p) { delete p; } +extern "C" MKN_KUL_PUBLISH void maiken_module_destruct(mkn::mod::Module* p) { delete p; } diff --git a/test.cpp b/test.cpp deleted file mode 100644 index 603069d..0000000 --- a/test.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -#include - -#include "mkn/kul/signal.hpp" -#include "mkn/kul/yaml.hpp" - -std::string const yArgs = ""; - -int main(int argc, char* argv[]) { - KOUT(NON) << __FILE__; - mkn::kul::Signal sig; - try { - YAML::Node node = mkn::kul::yaml::String(yArgs).root(); - char* argv2[2] = {argv[0], (char*)"-O"}; - auto app = (maiken::Application::CREATE(2, argv2))[0]; - auto loader(maiken::ModuleLoader::LOAD(*app)); - loader->module()->init(*app, node); - loader->module()->compile(*app, node); - loader->module()->link(*app, node); - loader->module()->pack(*app, node); - loader->unload(); - for (auto const inc : app->includes()) KLOG(INF) << inc.first; - } catch (mkn::kul::Exception const& e) { - KLOG(ERR) << e.what(); - return 2; - } catch (std::exception const& e) { - KERR << e.what(); - return 3; - } catch (...) { - KERR << "UNKNOWN EXCEPTION TYPE CAUGHT"; - return 5; - } - return 0; -} From dd7ff27a4038b18929be8e94f31c357531e06fc6 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 00:37:44 +0200 Subject: [PATCH 2/9] ++ --- .github/workflows/build.yml | 5 +---- mkn.yaml | 7 +++++-- res/ci/linux.sh | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100755 res/ci/linux.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67c188f..41b8ce8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,12 +30,9 @@ jobs: python-version: ${{ matrix.python-version }} architecture: x64 - run: | - set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_nix chmod +x mkn - KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" - KLOG=3 ./mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module - python3 -c "import test_module as tm; tm.lol()" + PATH=$PWD:$PATH ./res/ci/linux.sh macos: runs-on: macos-latest diff --git a/mkn.yaml b/mkn.yaml index 12783aa..b70ddd3 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -9,9 +9,12 @@ mode: shared profile: - name: base dep: mkn.mod + if_dep: + bsd: parse.yaml[lib] + win: parse.yaml[lib] if_arg: - win_static: -DYAML_CPP_STATIC_DEFINE - shared: -DMKN_KUL_SHARED + shared: -DMKN_KUL_SHARED + win_static: -DYAML_CPP_STATIC_DEFINE - name: test_module dep: lang.pybind11 diff --git a/res/ci/linux.sh b/res/ci/linux.sh new file mode 100755 index 0000000..a963eba --- /dev/null +++ b/res/ci/linux.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +KLOG=3 mkn clean build run -dtOa "-std=c++20 -fPIC" +KLOG=3 mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module +python3 -c "import test_module as tm; tm.lol()" From fe7b9523d2179f9b88dbfbd9a5dcf4dac331ee18 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 00:52:05 +0200 Subject: [PATCH 3/9] ++ --- .github/workflows/build.yml | 11 +++++------ mkn.yaml | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41b8ce8..a33f74b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,13 +44,13 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - architecture: x64 + architecture: arm64 - run: | set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_arm_osx chmod +x mkn - KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" - KLOG=3 ./mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module + KLOG=3 ./mkn clean build run -dtKOa "-std=c++20 -fPIC" + KLOG=3 ./mkn clean build -tOa "-std=c++20 -fPIC" -p test_module python3 -c "import test_module as tm; tm.lol()" windows: @@ -74,7 +74,6 @@ jobs: set -ex rm /bin/link $CURL_GET -o mkn.exe ${PATH_GET}/mkn.exe - KLOG=3 ./mkn clean build run -dtOa "-EHsc -std:c++20" - KLOG=3 ./mkn clean build run -dtOp test -a "-EHsc -std:c++20" - KLOG=3 ./mkn clean build -dtOa "-std:c++20 -EHsc" -p test_module + KLOG=3 ./mkn clean build run -dtKOa "-EHsc -std:c++20" + KLOG=3 ./mkn clean build -tOa "-std:c++20 -EHsc" -p test_module python3 -c "import test_module as tm; tm.lol()" diff --git a/mkn.yaml b/mkn.yaml index b70ddd3..33f7a4d 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -22,6 +22,7 @@ profile: mod: python3.module lang.python3 out: test_module install: . + mode: shared - name: format mod: | From 5d4625efe103ad76b2acb08425a4cc6b513096fe Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 00:55:50 +0200 Subject: [PATCH 4/9] ++ --- mkn.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkn.yaml b/mkn.yaml index 33f7a4d..f5725c0 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -17,7 +17,7 @@ profile: win_static: -DYAML_CPP_STATIC_DEFINE - name: test_module - dep: lang.pybind11 + dep: lang.pybind11 parse.yaml[lib] src: test_module.cpp mod: python3.module lang.python3 out: test_module From 52915df8140a08bcf042c43f28d09cac74b5199b Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 01:00:04 +0200 Subject: [PATCH 5/9] ++ --- .github/workflows/build.yml | 1 - mkn.yaml | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a33f74b..e1d7aa1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,6 @@ on: branches: [ master ] env: - MKN_LIB_LINK_LIB: 1 MKN_KUL_GIT_CO: --depth 1 CURL_GET: curl -fL --retry 3 --retry-delay 2 PATH_GET: https://github.com/mkn/mkn/releases/download/latest diff --git a/mkn.yaml b/mkn.yaml index f5725c0..affc7ed 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -17,12 +17,14 @@ profile: win_static: -DYAML_CPP_STATIC_DEFINE - name: test_module - dep: lang.pybind11 parse.yaml[lib] + dep: lang.pybind11 src: test_module.cpp mod: python3.module lang.python3 out: test_module install: . mode: shared + if_arg: + win: -DYAML_CPP_STATIC_DEFINE - name: format mod: | From ec856cb1e0e6253c398d379a558e99ea8a5bc4bc Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 01:03:41 +0200 Subject: [PATCH 6/9] ++ --- .github/workflows/build.yml | 4 +++- mkn.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1d7aa1..5d62e1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,9 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: arm64 - - run: | + - env: + MKN_PYTHON_LIB_EMBED: 1 + run: | set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_arm_osx chmod +x mkn diff --git a/mkn.yaml b/mkn.yaml index affc7ed..131542f 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -14,7 +14,7 @@ profile: win: parse.yaml[lib] if_arg: shared: -DMKN_KUL_SHARED - win_static: -DYAML_CPP_STATIC_DEFINE + win: -DYAML_CPP_STATIC_DEFINE - name: test_module dep: lang.pybind11 From 7604af4b8c4f949e083b00d82782260f8caec89f Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 01:06:47 +0200 Subject: [PATCH 7/9] ++ --- .github/workflows/build.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d62e1c..f28ecc4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,14 +44,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: arm64 - - env: - MKN_PYTHON_LIB_EMBED: 1 - run: | + - run: | set -ex $CURL_GET -o mkn ${PATH_GET}/mkn_arm_osx chmod +x mkn - KLOG=3 ./mkn clean build run -dtKOa "-std=c++20 -fPIC" - KLOG=3 ./mkn clean build -tOa "-std=c++20 -fPIC" -p test_module + KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" + KLOG=3 ./mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module python3 -c "import test_module as tm; tm.lol()" windows: @@ -76,5 +74,5 @@ jobs: rm /bin/link $CURL_GET -o mkn.exe ${PATH_GET}/mkn.exe KLOG=3 ./mkn clean build run -dtKOa "-EHsc -std:c++20" - KLOG=3 ./mkn clean build -tOa "-std:c++20 -EHsc" -p test_module + KLOG=3 ./mkn clean build -dtKOa "-std:c++20 -EHsc" -p test_module python3 -c "import test_module as tm; tm.lol()" From 195e29265421f5ce518d04dda2743b9453a7df3e Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 01:10:56 +0200 Subject: [PATCH 8/9] ++ --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f28ecc4..1c3a0f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,6 @@ jobs: set -ex rm /bin/link $CURL_GET -o mkn.exe ${PATH_GET}/mkn.exe - KLOG=3 ./mkn clean build run -dtKOa "-EHsc -std:c++20" - KLOG=3 ./mkn clean build -dtKOa "-std:c++20 -EHsc" -p test_module + KLOG=3 ./mkn clean build run -dtKOa "-EHsc -std:c++20 -DYAML_CPP_STATIC_DEFINE" + KLOG=3 ./mkn clean build -dtKOa "-std:c++20 -EHsc -DYAML_CPP_STATIC_DEFINE" -p test_module python3 -c "import test_module as tm; tm.lol()" From 96a58abaa6bc798a758ac7773fc267cac790bd8b Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 20 Aug 2026 01:15:54 +0200 Subject: [PATCH 9/9] ++ --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c3a0f0..d85038f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,8 +49,6 @@ jobs: $CURL_GET -o mkn ${PATH_GET}/mkn_arm_osx chmod +x mkn KLOG=3 ./mkn clean build run -dtOa "-std=c++20 -fPIC" - KLOG=3 ./mkn clean build -dtOa "-std=c++20 -fPIC" -p test_module - python3 -c "import test_module as tm; tm.lol()" windows: runs-on: windows-latest