Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better guards for compile command logging #112

Merged
merged 1 commit into from
Feb 20, 2025
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
2 changes: 1 addition & 1 deletion mkn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: mkn
version: master
property:
DATE: 19-FEB-2025
DATE: 20-FEB-2025
maiken_location: ${MKN_HOME}/app/mkn/${version}
maiken_scm: https://github.com/mkn/mkn
self.deps: mkn.kul
Expand Down
14 changes: 8 additions & 6 deletions src/maiken/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ void maiken::Application::link(mkn::kul::hash::set::String const& objects)
if (CommandStateMachine::INSTANCE().commands().count(STR_TEST) && !tests.empty())
buildTest(objects);

auto delEmpty = [](auto dir) {
if (dir && dir.files().empty()) dir.rm();
};
if (AppVars::INSTANCE().dump()) {
auto const delEmpty = [](auto dir) {
if (dir && dir.files().empty()) dir.rm();
};

delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/cmd"));
delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/out"));
delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/err"));
delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/cmd"));
delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/out"));
delEmpty(mkn::kul::Dir(".mkn/log/" + buildDir().name() + "/bin/err"));
}
}

void maiken::Application::checkErrors(CompilerProcessCapture const& cpc)
Expand Down
8 changes: 4 additions & 4 deletions src/maiken/build/bin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ class Executioner : public Constants {
static void print(CompilerProcessCapture const& cpc, Application& app) {
auto dryRun = AppVars::INSTANCE().dryRun();

mkn::kul::Dir cmdLogDir(".mkn/log/" + app.buildDir().name() + "/bin/cmd", 1);
mkn::kul::Dir outLogDir(".mkn/log/" + app.buildDir().name() + "/bin/out", 1);
mkn::kul::Dir errLogDir(".mkn/log/" + app.buildDir().name() + "/bin/err", 1);

if (dryRun)
KOUT(NON) << cpc.cmd();
else {
if (AppVars::INSTANCE().dump()) {
mkn::kul::Dir cmdLogDir(".mkn/log/" + app.buildDir().name() + "/bin/cmd", 1);
mkn::kul::Dir outLogDir(".mkn/log/" + app.buildDir().name() + "/bin/out", 1);
mkn::kul::Dir errLogDir(".mkn/log/" + app.buildDir().name() + "/bin/err", 1);

auto const eol = mkn::kul::os::EOL();
std::string base = mkn::kul::File(cpc.file()).name();
mkn::kul::io::Writer(mkn::kul::File(base + ".txt", cmdLogDir)) << cpc.cmd() << eol;
Expand Down
26 changes: 17 additions & 9 deletions src/maiken/build/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,15 @@ void maiken::Application::compile(std::queue<std::pair<maiken::Source, std::stri
ctp.interrupt();
};

mkn::kul::Dir cmdLogDir(".mkn/log/" + buildDir().name() + "/obj/cmd", 1);
mkn::kul::Dir outLogDir(".mkn/log/" + buildDir().name() + "/obj/out", 1);
mkn::kul::Dir errLogDir(".mkn/log/" + buildDir().name() + "/obj/err", 1);
mkn::kul::Dir cmdLogDir(".mkn/log/" + buildDir().name() + "/obj/cmd");
mkn::kul::Dir outLogDir(".mkn/log/" + buildDir().name() + "/obj/out");
mkn::kul::Dir errLogDir(".mkn/log/" + buildDir().name() + "/obj/err");

if (AppVars::INSTANCE().dump()) {
cmdLogDir.mk();
outLogDir.mk();
errLogDir.mk();
}

auto lambda = [&, o, e](maiken::CompilationUnit const& c_unit) {
CompilerProcessCapture const cpc = c_unit.compile();
Expand Down Expand Up @@ -237,13 +243,15 @@ void maiken::Application::compile(std::queue<std::pair<maiken::Source, std::stri

ctp.finish(1000000 * 1000);

auto delEmpty = [](auto& dir) {
if (dir.files().empty()) dir.rm();
};
if (AppVars::INSTANCE().dump()) {
auto delEmpty = [](auto& dir) {
if (dir.files().empty()) dir.rm();
};

delEmpty(cmdLogDir);
delEmpty(outLogDir);
delEmpty(errLogDir);
delEmpty(cmdLogDir);
delEmpty(outLogDir);
delEmpty(errLogDir);
}

if (!AppVars::INSTANCE().force())
if (ctp.exception()) KEXIT(1, "Compile error detected");
Expand Down
Loading