From ca7acb3b0df1fc2674cbdfe454dadcf617643b73 Mon Sep 17 00:00:00 2001 From: dekken Date: Wed, 28 Feb 2024 18:01:24 +0100 Subject: [PATCH] better --- README.noformat | 2 +- src/maiken/setup.cpp | 41 ++++++++++++++++------------------------- src/project.cpp | 5 +++++ 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/README.noformat b/README.noformat index 66581a51..c08696ce 100644 --- a/README.noformat +++ b/README.noformat @@ -146,7 +146,7 @@ profiles: - name: test self: ${OS} ${aaa} # dependencies on current project profiles, cycles detected - sub: project # subprojects, follows with rules for resolution, requires URL + sub: project # subprojects, follows "with" rules (4.9) for resolution, requires URL main: test.cpp out: ${aaa} # override default binary/library name install: ${aaa} # install binary or library to directory specified diff --git a/src/maiken/setup.cpp b/src/maiken/setup.cpp index 34e4779a..3e9f4861 100644 --- a/src/maiken/setup.cpp +++ b/src/maiken/setup.cpp @@ -34,40 +34,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace maiken { void sub_initializer(Application& app) { - KLOG(INF); - auto const& STR_NAME = Constants::STR_NAME; auto const& STR_PROFILE = Constants::STR_PROFILE; auto const& STR_SUB = Constants::STR_SUB; - std::string profile(app.profile()); - std::vector nodes; - if (profile.empty()) { - nodes.push_back(app.project().root()); - profile = app.project().root()[STR_NAME].Scalar(); - } - if (app.project().root()[STR_PROFILE]) - for (std::size_t i = 0; i < app.project().root()[STR_PROFILE].size(); i++) - nodes.push_back(app.project().root()[STR_PROFILE][i]); - - for (auto const& n : nodes) { - KLOG(INF) << profile; - if (n[STR_NAME].Scalar() != profile) continue; - KLOG(INF); + + auto const process = [&](auto n) { if (n[STR_SUB] && n[STR_SUB].IsScalar()) { - KLOG(INF) << n[STR_SUB].Scalar(); for (auto const& line : mkn::kul::String::LINES(n[STR_SUB].Scalar())) { - KLOG(INF) << line; auto pInfo = ProjectInfo::PARSE_LINE(line); mkn::kul::Dir local{pInfo.local}; - KLOG(INF) << local; - KLOG(INF) << local.is(); - if (!local) { - KLOG(INF) << pInfo.scm; - KLOG(INF) << pInfo.version; - + if (!local) SCMGetter::GET(local, pInfo.scm) ->co(local.path(), SCMGetter::REPO(local, pInfo.scm), pInfo.version); - } + } + } + }; + + std::string const& profile(app.profile()); + if (profile.empty()) { + process(app.project().root()); + } else if (app.project().root()[STR_PROFILE]) { + for (std::size_t i = 0; i < app.project().root()[STR_PROFILE].size(); i++) { + auto const& n = app.project().root()[STR_PROFILE][i]; + if (n[STR_NAME].Scalar() == profile) { + process(n); + break; } } } diff --git a/src/project.cpp b/src/project.cpp index 271dfdcb..60071538 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -32,6 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "maiken/defs.hpp" #include "maiken/string.hpp" +#include "maiken/github.hpp" #include "maiken/project.hpp" maiken::ProjectInfo maiken::ProjectInfo::PARSE_LINE(std::string const& line) { @@ -56,6 +57,10 @@ maiken::ProjectInfo maiken::ProjectInfo::PARSE_LINE(std::string const& line) { if_set(am, local); if_set(ha, version); +#if defined(_MKN_WITH_MKN_RAM_) + if (version.size() == 0 && scm.size() && !Github::GET_LATEST(scm, version)) version = ""; +#endif + return {local, profiles, proj, version, scm}; }