diff --git a/inc/maiken/app.hpp b/inc/maiken/app.hpp index ef938502..a89f58a4 100644 --- a/inc/maiken/app.hpp +++ b/inc/maiken/app.hpp @@ -100,7 +100,7 @@ class KUL_PUBLISH Application : public Constants { void preSetupValidation() KTHROW(Exception); void postSetupValidation() KTHROW(Exception); - void resolveProperties() KTHROW(Exception); + This& resolveProperties() KTHROW(Exception); void resolveLang() KTHROW(Exception); static void parseDependencyString(std::string s, mkn::kul::hash::set::String& include); @@ -330,7 +330,7 @@ class Applications : public Constants { std::vector applicationsFor(Project const& project) const { std::vector ret; - for (auto const& profile : m_apps.at(project.dir().real())) ret.emplace_back(profile.second); + for (auto const& profile : m_apps.at(project.file())) ret.emplace_back(profile.second); return ret; } diff --git a/mkn.yaml b/mkn.yaml index 44ac316e..c49244be 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -3,7 +3,7 @@ name: mkn version: master property: - DATE: 20-AUG-2024 + DATE: 21-AUG-2024 parent: bin mode: none diff --git a/src/maiken.cpp b/src/maiken.cpp index c960c189..f6b8c9a8 100644 --- a/src/maiken.cpp +++ b/src/maiken.cpp @@ -192,23 +192,36 @@ void maiken::Application::setSuper() { if (sup) return; if (project().root()[STR_SUPER]) { mkn::kul::os::PushDir pushd(project().dir().real()); - mkn::kul::Dir d(project().root()[STR_SUPER].Scalar()); - if (!d) KEXIT(1, "Super does not exist in project: " + project().dir().real()); - std::string super(d.real()); - if (super == project().dir().real()) - KEXIT(1, "Super cannot reference itself: " + project().dir().real()); - d = mkn::kul::Dir(super); - try { - sup = Applications::INSTANCE().getOrCreate(*maiken::Projects::INSTANCE().getOrCreate(d), ""); - sup->resolveProperties(); - } catch (std::exception const& e) { - KLOG(ERR) << e.what(); - KEXIT(1, "Possible super cycle detected: " + project().dir().real()); + + auto const& super_string = project().root()[STR_SUPER].Scalar(); + auto const gOrC = [&](auto const& in) { + try { + return &Applications::INSTANCE() + .getOrCreate(*maiken::Projects::INSTANCE().getOrCreate(in), "") + ->resolveProperties(); + } catch (std::exception const& e) { + KLOG(ERR) << e.what(); + KEXIT(1, "Possible super cycle detected: " + project().dir().real()); + } + }; + + if (auto const file = mkn::kul::File{super_string}; file.is()) { + if (file.real() == project().file()) + KEXIT(1, "Super cannot reference itself: " + project().dir().real()); + sup = gOrC(file); + } else { + // + mkn::kul::Dir const dir{super_string}; + if (!dir) KEXIT(1, "Super does not exist in project: " + project().dir().real()); + if (dir.real() == project().dir().real()) + KEXIT(1, "Super cannot reference itself: " + project().dir().real()); + sup = gOrC(dir); } + auto cycle = sup; while (cycle) { - if (cycle->project().dir() == project().dir()) - KEXIT(1, "Super cycle detected: " + project().dir().real()); + if (cycle->project().file() == project().file()) + KEXIT(1, "Super cycle detected: " + project().file()); cycle = cycle->sup; } for (auto const& p : sup->properties()) diff --git a/src/maiken/app.cpp b/src/maiken/app.cpp index 2ee3c4e9..12671c32 100644 --- a/src/maiken/app.cpp +++ b/src/maiken/app.cpp @@ -34,27 +34,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. maiken::Application* maiken::Applications::getOrCreate(maiken::Project const& proj, std::string const& _profile, bool setup) KTHROW(mkn::kul::Exception) { - std::string pDir(proj.dir().real()); + std::string pFile(proj.file()); std::string profile = _profile.empty() ? "@" : _profile; - if (!m_apps.count(pDir) || !m_apps[pDir].count(profile)) { + if (!m_apps.count(pFile) || !m_apps[pFile].count(profile)) { auto app = std::make_unique(proj, _profile); auto pp = app.get(); m_appPs.push_back(std::move(app)); - m_apps[pDir][profile] = pp; + m_apps[pFile][profile] = pp; if (setup) { mkn::kul::os::PushDir pushd(proj.dir()); pp->setup(); } } - return m_apps[pDir][profile]; + return m_apps[pFile][profile]; } maiken::Application* maiken::Applications::getOrCreateRoot(maiken::Project const& proj, std::string const& _profile, bool setup) KTHROW(mkn::kul::Exception) { - std::string pDir(proj.dir().real()); + std::string pFile(proj.file()); std::string profile = _profile.empty() ? "@" : _profile; - if (!m_apps.count(pDir) || !m_apps[pDir].count(profile)) { + if (!m_apps.count(pFile) || !m_apps[pFile].count(profile)) { auto* pp = getOrCreate(proj, _profile, /*setup = */ false); pp->ro = 1; if (setup) { @@ -62,7 +62,7 @@ maiken::Application* maiken::Applications::getOrCreateRoot(maiken::Project const pp->setup(); } } - return m_apps[pDir][profile]; + return m_apps[pFile][profile]; } maiken::Application* maiken::Applications::getOrNullptr(std::string const& project) { diff --git a/src/maiken/build/bin.cpp b/src/maiken/build/bin.cpp index 7db00af1..bcb14a93 100644 --- a/src/maiken/build/bin.cpp +++ b/src/maiken/build/bin.cpp @@ -96,12 +96,13 @@ class Executioner : public Constants { KOUT(NON) << cpc.cmd(); else { if (AppVars::INSTANCE().dump()) { + 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(); + mkn::kul::io::Writer(mkn::kul::File(base + ".txt", cmdLogDir)) << cpc.cmd() << eol; if (cpc.outs().size()) - mkn::kul::io::Writer(mkn::kul::File(base + ".txt", outLogDir)) << cpc.outs(); + mkn::kul::io::Writer(mkn::kul::File(base + ".txt", outLogDir)) << cpc.outs() << eol; if (cpc.errs().size()) - mkn::kul::io::Writer(mkn::kul::File(base + ".txt", errLogDir)) << cpc.errs(); + mkn::kul::io::Writer(mkn::kul::File(base + ".txt", errLogDir)) << cpc.errs() << eol; } #if defined(_MKN_WITH_MKN_RAM_) && defined(_MKN_WITH_IO_CEREAL_) diff --git a/src/maiken/build/obj.cpp b/src/maiken/build/obj.cpp index 072c53ba..6111a77f 100644 --- a/src/maiken/build/obj.cpp +++ b/src/maiken/build/obj.cpp @@ -207,12 +207,13 @@ void maiken::Application::compile(std::queue lock(mute); diff --git a/src/maiken/properties.cpp b/src/maiken/properties.cpp index f8cd8185..89806baf 100644 --- a/src/maiken/properties.cpp +++ b/src/maiken/properties.cpp @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "maiken.hpp" -void maiken::Application::resolveProperties() KTHROW(maiken::Exception) { +maiken::Application& maiken::Application::resolveProperties() KTHROW(maiken::Exception) { ps.setDeletedKey("--DELETED--"); for (YAML::const_iterator it = project().root()[STR_PROPERTY].begin(); it != project().root()[STR_PROPERTY].end(); ++it) @@ -41,6 +41,7 @@ void maiken::Application::resolveProperties() KTHROW(maiken::Exception) { if (ps.count(it->first.as())) ps.erase(it->first.as()); ps[it->first.as()] = s; } + return *this; } std::shared_ptr> maiken::Properties::KEY( diff --git a/src/maiken/setup.cpp b/src/maiken/setup.cpp index 6b94c2b3..20f6af4d 100644 --- a/src/maiken/setup.cpp +++ b/src/maiken/setup.cpp @@ -40,7 +40,7 @@ void sub_initializer(Application const& app, std::vector const& node auto const process = [&](auto n) { if (n[STR_SUB] && n[STR_SUB].IsScalar()) { - for (auto const& line : mkn::kul::String::LINES(n[STR_SUB].Scalar())) { + for (auto const& line : mkn::kul::cli::asArgs(n[STR_SUB].Scalar())) { auto pInfo = ProjectInfo::PARSE_LINE(line); mkn::kul::Dir local{pInfo.local}; if (!local) diff --git a/src/project.cpp b/src/project.cpp index 60071538..9f138173 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -61,7 +61,7 @@ maiken::ProjectInfo maiken::ProjectInfo::PARSE_LINE(std::string const& line) { if (version.size() == 0 && scm.size() && !Github::GET_LATEST(scm, version)) version = ""; #endif - return {local, profiles, proj, version, scm}; + return {local, profiles, proj, version, scm.size() ? scm : proj}; } mkn::kul::yaml::Validator maiken::Project::validator() const {