From e43ff9e5173a5313c3d1b426334717f6a1342fb5 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Mon, 30 Sep 2024 23:04:03 +0200 Subject: [PATCH 1/3] arm on osx --- .github/workflows/build_osx.yml | 2 +- .github/workflows/build_win.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index 00363d0..0ffdf72 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -18,6 +18,6 @@ jobs: MKN_LIB_LINK_LIB: 1 KUL_GIT_CO: --depth 1 run: | - curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_osx + curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_arm_osx chmod +x mkn KLOG=2 ./mkn clean build run -dtOa "-std=c++17 -fPIC" diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml index db2fe4d..fd179ac 100644 --- a/.github/workflows/build_win.yml +++ b/.github/workflows/build_win.yml @@ -24,4 +24,5 @@ jobs: run: | # /bin/link interferes with cl/link.exe bash -c "rm /bin/link" bash -c 'curl -Lo mkn.exe https://github.com/mkn/mkn/releases/download/latest/mkn.exe' - bash -c 'KLOG=2 ./mkn clean build run -dtOa "-EHsc -std:c++17"' + SET KLOG=2 + mkn clean build run -dtOa "-EHsc -std:c++17" From 6467814b88c4df5dbd972c9e7687de0229626b4f Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Sun, 9 Aug 2026 13:41:47 +0200 Subject: [PATCH 2/3] ++ --- .github/workflows/build.yml | 44 +++++++ .github/workflows/build_nix.yml | 23 ---- .github/workflows/build_osx.yml | 23 ---- .github/workflows/build_win.yml | 28 ----- mkn.yaml | 4 +- mod.cpp | 195 ++++++++++++++++---------------- 6 files changed, 145 insertions(+), 172 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/build_nix.yml delete mode 100644 .github/workflows/build_osx.yml delete mode 100644 .github/workflows/build_win.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0e4d90b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + MKN_LIB_LINK_LIB: 1 + MKN_KUL_GIT_CO: --depth 1 + +jobs: + ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - run: | + curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_nix + chmod +x mkn + KLOG=2 ./mkn clean build run -dtOa "-std=c++20 -fPIC" + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v6 + - run: | + curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_arm_osx + chmod +x mkn + KLOG=2 ./mkn clean build run -dtOa "-std=c++20 -fPIC" + + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v6 + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + - shell: cmd + run: | # /bin/link interferes with cl/link.exe + bash -c "rm /bin/link" + bash -c 'curl -Lo mkn.exe https://github.com/mkn/mkn/releases/download/latest/mkn.exe' + SET KLOG=2 + mkn clean build run -dtOa "-EHsc -std:c++20" diff --git a/.github/workflows/build_nix.yml b/.github/workflows/build_nix.yml deleted file mode 100644 index 17ea70c..0000000 --- a/.github/workflows/build_nix.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: ubuntu-latest - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - run: uname -a - - - env: - MKN_LIB_LINK_LIB: 1 - KUL_GIT_CO: --depth 1 - run: | - curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_nix - chmod +x mkn - KLOG=2 ./mkn clean build run -dtOa "-std=c++17 -fPIC" diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml deleted file mode 100644 index 0ffdf72..0000000 --- a/.github/workflows/build_osx.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: macos-latest - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - - run: uname -a - - - env: - MKN_LIB_LINK_LIB: 1 - KUL_GIT_CO: --depth 1 - run: | - curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_arm_osx - chmod +x mkn - KLOG=2 ./mkn clean build run -dtOa "-std=c++17 -fPIC" diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml deleted file mode 100644 index fd179ac..0000000 --- a/.github/workflows/build_win.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: windows-latest - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - # setup MSVC compiler - - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - - env: - KUL_GIT_CO: --depth 1 - MKN_CL_PREFERRED: 1 - shell: cmd - run: | # /bin/link interferes with cl/link.exe - bash -c "rm /bin/link" - bash -c 'curl -Lo mkn.exe https://github.com/mkn/mkn/releases/download/latest/mkn.exe' - SET KLOG=2 - mkn clean build run -dtOa "-EHsc -std:c++17" diff --git a/mkn.yaml b/mkn.yaml index f56fbb4..40dc6a6 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -10,7 +10,7 @@ parent: base src: mod.cpp mode: shared if_arg: - win_shared: -DYAML_CPP_DLL + win_static: -DYAML_CPP_STATIC_DEFINE shared: -DKUL_SHARED profile: @@ -21,7 +21,7 @@ profile: parent: base main: test.cpp if_arg: - win_shared: -DYAML_CPP_DLL + win_static: -DYAML_CPP_STATIC_DEFINE - name: format mod: | diff --git a/mod.cpp b/mod.cpp index 4033f58..3ce0313 100644 --- a/mod.cpp +++ b/mod.cpp @@ -28,117 +28,120 @@ 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 #include "maiken/module/init.hpp" +#include #include -namespace mkn { -namespace lang { +namespace mkn::lang { class SwigModule : public maiken::Module { - private: - bool pyconfig_found = 0; - std::string HOME, SWIG = "swig", - PATH = mkn::kul::env::GET("PATH"); - - protected: - - static void VALIDATE_NODE(const YAML::Node& node) { - using namespace mkn::kul::yaml; - Validator( - { - NodeValidator("src", 1), // TODO : add regex - NodeValidator("inc"), // TODO : add regex - NodeValidator("conf"), - NodeValidator("outdir"), - NodeValidator("objdir"), - NodeValidator("objfile"), - } - ).validate(node); - } - - public: - SwigModule(){ - if(mkn::kul::env::EXISTS("SWIG")) SWIG = mkn::kul::env::GET("SWIG"); - } - void compile(maiken::Application& a, const YAML::Node& node) - KTHROW(std::exception) override { - VALIDATE_NODE(node); - - std::string conf = "-python -c++"; - if(node["conf"]) conf = node["conf"].Scalar(); - std::stringstream incs; - if(node["inc"]) - for(const auto inc : mkn::kul::cli::asArgs(node["inc"].Scalar())) - incs << "-I" << inc << " "; - - for(const auto source : mkn::kul::cli::asArgs(node["src"].Scalar())){ - mkn::kul::File src(source); - if(!src) { - KERR << "WARNING: Source does not exist: " << src.full(); - continue; - } - - std::string outdir = src.dir().escm(), objdir = src.dir().escm(); - if(node["outdir"]) outdir = node["outdir"].Scalar(); - if(node["objdir"]) outdir = node["objdir"].Scalar(); - - mkn::kul::File objfile(src.name()+".cpp", objdir); - if(node["objfile"]) objfile = mkn::kul::File(node["objfile"].Scalar(), objdir); - - mkn::kul::Process p(SWIG); - p << conf << incs.str(); - p << "-outdir" << outdir; - p << "-o" << objfile.escm() << src.escm(); - KLOG(DBG) << p; - p.start(); + private: + bool pyconfig_found = 0; + std::string HOME, SWIG = "swig", PATH = mkn::kul::env::GET("PATH"); + + protected: + static void VALIDATE_NODE(const YAML::Node& node) { + using namespace mkn::kul::yaml; + Validator({ + NodeValidator("src", 1), // TODO : add regex + NodeValidator("inc"), // TODO : add regex + NodeValidator("conf"), + NodeValidator("outdir"), + NodeValidator("objdir"), + NodeValidator("objfile"), + }) + .validate(node); } - a.m_cInfo.lib_ext = mkn::kul::String::LINES(extension())[0]; // drop EOL - a.m_cInfo.lib_prefix = ""; - KLOG(TRC); - a.mode(maiken::compiler::Mode::SHAR); - KLOG(TRC); - } -protected: - std::string extension(){ - auto pyconfig = mkn::kul::env::GET("PY3_CONFIG", "python3-config"); + public: + SwigModule() { + if (mkn::kul::env::EXISTS("SWIG")) + SWIG = mkn::kul::env::GET("SWIG"); + } + void compile(maiken::Application& a, const YAML::Node& node) + KTHROW(std::exception) override { + + VALIDATE_NODE(node); + + std::string conf = "-python -c++"; + if (node["conf"]) + conf = node["conf"].Scalar(); + std::stringstream incs; + if (node["inc"]) + for (const auto inc : mkn::kul::cli::asArgs(node["inc"].Scalar())) + incs << "-I" << inc << " "; + + for (const auto source : mkn::kul::cli::asArgs(node["src"].Scalar())) { + mkn::kul::File src(source); + if (!src) { + KERR << "WARNING: Source does not exist: " << src.full(); + continue; + } + + std::string outdir = src.dir().escm(), objdir = src.dir().escm(); + if (node["outdir"]) + outdir = node["outdir"].Scalar(); + if (node["objdir"]) + outdir = node["objdir"].Scalar(); + + mkn::kul::File objfile(src.name() + ".cpp", objdir); + if (node["objfile"]) + objfile = mkn::kul::File(node["objfile"].Scalar(), objdir); + + mkn::kul::Process p(SWIG); + p << conf << incs.str(); + p << "-outdir" << outdir; + p << "-o" << objfile.escm() << src.escm(); + KLOG(DBG) << p; + p.start(); + } + + a.m_cInfo.lib_ext = mkn::kul::String::LINES(extension())[0]; // drop EOL + a.m_cInfo.lib_prefix = ""; + KLOG(TRC); + a.mode(maiken::compiler::Mode::SHAR); + KLOG(TRC); + } + + protected: + std::string extension() { + auto pyconfig = mkn::kul::env::GET("PY3_CONFIG", "python3-config"); #if defined(_WIN32) - auto pyconfig_found = false; // doesn't exist on windows (generally) + auto pyconfig_found = false; // doesn't exist on windows (generally) #else - auto pyconfig_found = mkn::kul::env::WHICH(pyconfig); + auto pyconfig_found = mkn::kul::env::WHICH(pyconfig); #endif - std::string extension; - if (pyconfig_found) { - // mkn::kul::os::PushDir pushd(a.project().dir()); - mkn::kul::Process p(pyconfig); - mkn::kul::ProcessCapture pc(p); - p << "--extension-suffix"; - p.start(); - extension = pc.outs(); - } else { - auto py = mkn::kul::env::GET("PYTHON", "python3"); - mkn::kul::Process p(py); - mkn::kul::ProcessCapture pc(p); - p << "-c" - << "\"import sysconfig; " - "print(sysconfig.get_config_var('EXT_SUFFIX'))\""; - p.start(); - extension = pc.outs(); - } - return extension; - } + std::string extension; + if (pyconfig_found) { + // mkn::kul::os::PushDir pushd(a.project().dir()); + mkn::kul::Process p(pyconfig); + mkn::kul::ProcessCapture pc(p); + p << "--extension-suffix"; + p.start(); + extension = pc.outs(); + } else { + auto py = mkn::kul::env::GET("PYTHON", "python3"); + mkn::kul::Process p(py); + mkn::kul::ProcessCapture pc(p); + p << "-c" + << "\"import sysconfig; " + "print(sysconfig.get_config_var('EXT_SUFFIX'))\""; + p.start(); + extension = pc.outs(); + } + return extension; + } }; -} // namespace lang -} // namespace mkn -extern "C" KUL_PUBLISH maiken::Module* maiken_module_construct() { - return new mkn::lang::SwigModule; +} // namespace mkn::lang + +extern "C" MKN_KUL_PUBLISH maiken::Module* maiken_module_construct() { + return new mkn::lang::SwigModule; } -extern "C" KUL_PUBLISH void maiken_module_destruct(maiken::Module* p) { - delete p; +extern "C" MKN_KUL_PUBLISH void maiken_module_destruct(maiken::Module* p) { + delete p; } From e88ef9f36de35d1e14ec2f5543814c3eb7863a1b Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Sun, 9 Aug 2026 14:04:52 +0200 Subject: [PATCH 3/3] ++ --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e4d90b..f09e841 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,9 @@ name: build +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + on: push: branches: [ master ] @@ -36,7 +40,10 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 with: arch: amd64 + - shell: cmd + env: + MKN_CL_PREFERRED: 1 run: | # /bin/link interferes with cl/link.exe bash -c "rm /bin/link" bash -c 'curl -Lo mkn.exe https://github.com/mkn/mkn/releases/download/latest/mkn.exe'