Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- uses: actions/checkout@v4

- env:
KUL_GIT_CO: --depth 1
MKN_KUL_GIT_CO: --depth 1
run: |
curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_nix
curl -fL --retry 3 --retry-delay 2 -o 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"
KLOG=2 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
4 changes: 2 additions & 2 deletions .github/workflows/build_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:

- env:
MKN_LIB_LINK_LIB: 1
KUL_GIT_CO: --depth 1
MKN_KUL_GIT_CO: --depth 1
run: |
curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_arm_osx
curl -fL --retry 3 --retry-delay 2 -o 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"
KLOG=2 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
2 changes: 1 addition & 1 deletion .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
arch: amd64

- env:
KUL_GIT_CO: --depth 1
MKN_KUL_GIT_CO: --depth 1
MKN_CL_PREFERRED: 1
shell: cmd
run: | # /bin/link interferes with cl/link.exe
Expand Down
2 changes: 1 addition & 1 deletion mkn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ profile:
dep: mkn&${maiken_location}(${maiken_scm})[mod]
if_arg:
win_shared: -DYAML_CPP_DLL
shared: -DKUL_SHARED
shared: -DMKN_KUL_SHARED

- name: test
parent: base
Expand Down
37 changes: 12 additions & 25 deletions mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class Python3Module : public maiken::Module {
for (auto const& idx : {0, 1}) {
kul::Process p(PY);
kul::ProcessCapture pc(p);
std::string print{"\"import sys; print(sys.version_info[" +
std::to_string(idx) + "])\""};
std::string print{"\"import sys; print(sys.version_info[" + std::to_string(idx) + "])\""};
p << "-c" << print;
p.start();

Expand All @@ -83,8 +82,7 @@ class Python3Module : public maiken::Module {
}

public:
void init(maiken::Application& a, YAML::Node const& node)
KTHROW(std::exception) override {
void init(maiken::Application& a, YAML::Node const& node) KTHROW(std::exception) override {
bool finally = 0;
if (!kul::env::WHICH(PY.c_str())) PY = "python";
PYTHON = kul::env::GET("PYTHON");
Expand All @@ -103,8 +101,7 @@ class Python3Module : public maiken::Module {
bin = kul::Dir("bin", HOME);
if (!bin) KEXCEPT(kul::Exception, "$PYTHON3_HOME/bin does not exist");
#endif
path_var = std::make_shared<kul::cli::EnvVar>("PATH", bin.real(),
kul::cli::EnvVarMode::PREP);
path_var = std::make_shared<kul::cli::EnvVar>("PATH", bin.real(), kul::cli::EnvVarMode::PREP);
kul::env::SET(path_var->name(), path_var->toString().c_str());
p.var(path_var->name(), path_var->toString());
};
Expand All @@ -131,8 +128,7 @@ class Python3Module : public maiken::Module {
if (finally) exit(2);
}

void compile(maiken::Application& a, YAML::Node const& node)
KTHROW(std::exception) override {
void compile(maiken::Application& a, YAML::Node const& node) KTHROW(std::exception) override {
VALIDATE_NODE(node);
kul::os::PushDir pushd(a.project().dir());
std::vector<std::string> incs;
Expand All @@ -153,12 +149,9 @@ class Python3Module : public maiken::Module {
kul::Dir dInc;
if (path_var) {
dInc = kul::Dir("include", bin.parent());
if (!dInc)
dInc = kul::Dir("include",
kul::File(kul::env::WHERE(PY.c_str())).dir());
if (!dInc) dInc = kul::Dir("include", kul::File(kul::env::WHERE(PY.c_str())).dir());
} else {
dInc =
kul::Dir("include", kul::File(kul::env::WHERE(PY.c_str())).dir());
dInc = kul::Dir("include", kul::File(kul::env::WHERE(PY.c_str())).dir());
}
if (!dInc)
KEXCEPT(kul::Exception, "$PYTHON3_HOME/include does not exist")
Expand All @@ -177,8 +170,7 @@ class Python3Module : public maiken::Module {
if (node["with"]) {
for (auto const with : kul::cli::asArgs(node["with"].Scalar())) {
std::stringstream import;
import << "\"import " << with << "; print(" << with
<< ".get_include())\"";
import << "\"import " << with << "; print(" << with << ".get_include())\"";
kul::Process p(PY);
kul::ProcessCapture pc(p);
p << "-c" << import.str();
Expand All @@ -196,8 +188,7 @@ class Python3Module : public maiken::Module {
kul::Dir req_include(inc);
if (req_include) {
a.addInclude(req_include.real());
for (auto* rep : a.revendencies())
rep->addInclude(req_include.real());
for (auto* rep : a.revendencies()) rep->addInclude(req_include.real());
}
}
} catch (kul::Exception const& e) {
Expand All @@ -219,8 +210,7 @@ class Python3Module : public maiken::Module {
return ret;
};

void link(maiken::Application& a, YAML::Node const& node)
KTHROW(std::exception) override {
void link(maiken::Application& a, YAML::Node const& node) KTHROW(std::exception) override {
VALIDATE_NODE(node);
if (pyconfig_found) {
auto version = MajMin(PY);
Expand All @@ -232,8 +222,7 @@ class Python3Module : public maiken::Module {

if (path_var) p.var(path_var->name(), path_var->toString());

auto const embed =
kul::String::BOOL(kul::env::GET("MKN_PYTHON_LIB_EMBED", "0"));
auto const embed = kul::String::BOOL(kul::env::GET("MKN_PYTHON_LIB_EMBED", "0"));
if (embed) p << "--embed";

p.start();
Expand Down Expand Up @@ -284,10 +273,8 @@ class Python3Module : public maiken::Module {
} // namespace lang
} // namespace mkn

extern "C" KUL_PUBLISH maiken::Module* maiken_module_construct() {
extern "C" MKN_KUL_PUBLISH maiken::Module* maiken_module_construct() {
return new mkn::lang::Python3Module;
}

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; }