diff --git a/README.noformat b/README.noformat index ab04df90..66581a51 100644 --- a/README.noformat +++ b/README.noformat @@ -30,6 +30,11 @@ Languages supported Compilers supported - C# (partially) +1.4 Distributions + +Binaries available @ https://github.com/mkn/mkn/releases/tag/latest + + 2.1 Basic project mkn.yaml files 2.1.1 Binary @@ -141,6 +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 main: test.cpp out: ${aaa} # override default binary/library name install: ${aaa} # install binary or library to directory specified @@ -165,7 +171,7 @@ If no mode tag is found, the -K and -S args will be used if found. Linking cannot be guaranteed if no mode is used, but shared is generally default. Unless a project requires a mode, it's advised to avoid using one. So it can be overridden with -K or -S. -If a application includes both static and shared dependencies, using the mode "none" is advised. +If an application includes both static and shared dependencies, using the mode "none" is advised. 2.2.1.3 Entry points @@ -248,8 +254,6 @@ Testing: Example Windows settings can be found at: https://github.com/mkn/maiken/wiki -Binary available @ https://github.com/mkn/maiken/tree/binaries - 3.2 Unix @@ -403,7 +407,7 @@ If neither are set the following rules apply Unix : gdb ./bin// Launch app with gdb, autorun and print backtrace - MKN_DBG='gdb -batch -ex "run" -ex "bt" --args' mkn dbg -r "arg0 arg1" + MKN_DBG='gdb -batch -ex run -ex bt --args' mkn dbg -r "arg0 arg1" 4.7 Initialising scripts @@ -600,14 +604,18 @@ Description See section 4 Key MKN_COMPILE_THREADS Type uint Default none -Description Global override, if set forces all compile calls to use value - Example, low RAM systems +Description Global override, if set forces all compile calls to use value. Example, low RAM systems + +Key MKN_DEFAULT_BRANCH +Type String +Default "master" +Description Default branch for SCM if not given or set + Key MKN_DBG Type String Default "" -Description Sets the preceding command line string when using "dbg" - See seciont 4.6 +Description Sets the preceding command line string when using "dbg". See seciont 4.6 Key MKN_OBJ Type String diff --git a/inc/maiken/app.hpp b/inc/maiken/app.hpp index fb7d3d74..ef938502 100644 --- a/inc/maiken/app.hpp +++ b/inc/maiken/app.hpp @@ -309,6 +309,7 @@ class KUL_PUBLISH Application : public Constants { std::vector> srcs; std::vector> incs; mkn::kul::SCM const* scm = 0; + std::vector subs; }; class Applications : public Constants { diff --git a/inc/maiken/defs.hpp b/inc/maiken/defs.hpp index b5bb20cd..bdaa1cb7 100644 --- a/inc/maiken/defs.hpp +++ b/inc/maiken/defs.hpp @@ -31,6 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MAIKEN_DEFS_HPP_ #define _MAIKEN_DEFS_HPP_ +#include "mkn/kul/env.hpp" #include "mkn/kul/defs.hpp" #ifndef MKN_LANG @@ -78,6 +79,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif /* _KUL_PROC_LOOP_NSLEEP_ */ namespace maiken { + +auto inline defaultSCMBranchName() { return mkn::kul::env::GET("MKN_DEFAULT_BRANCH", "master"); } + class Constants { public: static constexpr auto STR_MAIKEN = "maiken"; @@ -124,6 +128,7 @@ class Constants { static constexpr auto STR_REMOTE = "remote"; static constexpr auto STR_SCM = "scm"; static constexpr auto STR_SELF = "self"; + static constexpr auto STR_SUB = "sub"; static constexpr auto STR_PROFILE = "profile"; static constexpr auto STR_PROFILES = "profiles"; diff --git a/inc/maiken/project.hpp b/inc/maiken/project.hpp index c035666c..d74d0987 100644 --- a/inc/maiken/project.hpp +++ b/inc/maiken/project.hpp @@ -31,14 +31,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MAIKEN_PROJECT_HPP_ #define _MAIKEN_PROJECT_HPP_ -#include "mkn/kul/log.hpp" #include "mkn/kul/os.hpp" +#include "mkn/kul/log.hpp" #include "mkn/kul/yaml.hpp" #include "maiken/defs.hpp" namespace maiken { +struct ProjectInfo { + std::string local /*&*/, profiles, name, version /*#*/, scm; + + ProjectInfo static PARSE_LINE(std::string const& line); +}; + class Application; class ProjectException : public mkn::kul::Exception { @@ -53,13 +59,13 @@ class KUL_PUBLISH Project : public mkn::kul::yaml::File, public Constants { Project(mkn::kul::File const& f) : mkn::kul::yaml::File(f), m_dir(f.dir().real()) {} Project(Project const& p) : mkn::kul::yaml::File(p), m_dir(p.m_dir.real()) {} mkn::kul::Dir const& dir() const { return m_dir; } - const mkn::kul::yaml::Validator validator() const; + mkn::kul::yaml::Validator validator() const; static mkn::kul::hash::map::S2S populate_tests(YAML::Node const& node); std::vector getBinaryTargets() const; private: - const mkn::kul::Dir m_dir; + mkn::kul::Dir const m_dir; friend class Projects; friend class Application; friend class mkn::kul::yaml::File; diff --git a/inc/maiken/scm.hpp b/inc/maiken/scm.hpp index bbe1ccc0..8cbe38e1 100644 --- a/inc/maiken/scm.hpp +++ b/inc/maiken/scm.hpp @@ -43,8 +43,9 @@ class SCMGetter { return s; } static bool HAS(mkn::kul::Dir const& d); - static std::string REPO(mkn::kul::Dir const& d, std::string const& r, bool module); - static mkn::kul::SCM const* GET(mkn::kul::Dir const& d, std::string const& r, bool module); + static std::string REPO(mkn::kul::Dir const& d, std::string const& r, bool module = false); + static mkn::kul::SCM const* GET(mkn::kul::Dir const& d, std::string const& r, + bool module = false); private: static bool IS_SOLID(std::string const& r); diff --git a/inc/maiken/settings.hpp b/inc/maiken/settings.hpp index 8e863f0f..e8fba94d 100644 --- a/inc/maiken/settings.hpp +++ b/inc/maiken/settings.hpp @@ -60,7 +60,7 @@ class Settings : public mkn::kul::yaml::File, public Constants { Settings const* super() const { return sup.get(); } - const mkn::kul::yaml::Validator validator() const; + mkn::kul::yaml::Validator validator() const; std::vector const& remoteModules() const { return rms; } std::vector const& remoteRepos() const { return rrs; } mkn::kul::hash::map::S2S const& properties() const { return ps; } diff --git a/mkn.yaml b/mkn.yaml index e76f8367..0e5dcb01 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -65,7 +65,7 @@ profile: - name: server parent: lib with: io.cereal mkn.ram[https] - main: src/server.cpp + main: server.cpp mode: none - name: format diff --git a/src/maiken/build/bin.cpp b/src/maiken/build/bin.cpp index e25e9d3f..7db00af1 100644 --- a/src/maiken/build/bin.cpp +++ b/src/maiken/build/bin.cpp @@ -95,10 +95,6 @@ class Executioner : public Constants { if (dryRun) KOUT(NON) << cpc.cmd(); else { - app.checkErrors(cpc); - KOUT(INF) << cpc.cmd(); - KOUT(NON) << "Creating bin: " << mkn::kul::File(cpc.file()).real(); - if (AppVars::INSTANCE().dump()) { std::string base = mkn::kul::File(cpc.file()).name(); mkn::kul::io::Writer(mkn::kul::File(base + ".txt", cmdLogDir)) << cpc.cmd(); @@ -140,6 +136,10 @@ void maiken::Application::buildExecutable(mkn::kul::hash::set::String const& obj auto cpc = Executioner::build_exe(objects, starDirs, file, name, install, *this); Executioner::print(cpc, *this); + + checkErrors(cpc); + KOUT(INF) << cpc.cmd(); + KOUT(NON) << "Creating bin: " << mkn::kul::File(cpc.file()).real(); } void maiken::Application::buildTest(mkn::kul::hash::set::String const& objects) @@ -207,6 +207,7 @@ maiken::CompilerProcessCapture maiken::Application::buildLibrary( if (dryRun) KOUT(NON) << cpc.cmd(); else { + Executioner::print(cpc, *this); checkErrors(cpc); KOUT(INF) << cpc.cmd(); KOUT(NON) << "Creating lib: " << mkn::kul::File(cpc.file()).real(); diff --git a/src/maiken/compiler/gcc.cpp b/src/maiken/compiler/gcc.cpp index e5b5820a..49272b32 100644 --- a/src/maiken/compiler/gcc.cpp +++ b/src/maiken/compiler/gcc.cpp @@ -31,6 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "maiken.hpp" #include +#include + maiken::cpp::GccCompiler::GccCompiler(int const& v) : CCompiler(v) { m_optimise_c.insert({{0, ""}, {1, "-O1"}, @@ -196,9 +198,9 @@ maiken::CompilerProcessCapture maiken::cpp::GccCompiler::buildLibrary(LinkDAO& d for (std::string const& o : objects) p << mkn::kul::File(o).escm(); { - auto ll(mkn::kul::env::GET("MKN_LIB_LINK_LIB")); + auto ll(mkn::kul::env::GET("MKN_LIB_LINK_LIB", "0")); if (ll.size() && mode == compiler::Mode::SHAR) { - uint16_t llv = mkn::kul::String::UINT16(ll); + std::uint16_t llv = mkn::kul::String::UINT16(ll); for (std::string const& path : libPaths) p.arg("-L" + path); if (llv == 1) { for (std::string const& lib : libs) p.arg("-l" + lib); diff --git a/src/maiken/defs.cpp b/src/maiken/defs.cpp index 3cfd2c83..b4b7f0f4 100644 --- a/src/maiken/defs.cpp +++ b/src/maiken/defs.cpp @@ -58,6 +58,7 @@ constexpr char const* maiken::Constants::STR_FILE; constexpr char const* maiken::Constants::STR_ARG; constexpr char const* maiken::Constants::STR_INSTALL; constexpr char const* maiken::Constants::STR_SELF; +constexpr char const* maiken::Constants::STR_SUB; constexpr char const* maiken::Constants::STR_VALUE; constexpr char const* maiken::Constants::STR_MAIN; diff --git a/src/maiken/depmod.cpp b/src/maiken/depmod.cpp index 15a6a49e..5524516b 100644 --- a/src/maiken/depmod.cpp +++ b/src/maiken/depmod.cpp @@ -102,7 +102,7 @@ mkn::kul::Dir maiken::Application::resolveDepOrModDirectory(YAML::Node const& n, if (Github::GET_LATEST(depName, version)) return version; #endif //_MKN_WITH_MKN_RAM_ - return "master"; + return defaultSCMBranchName(); }; std::string version(resolveSCMBranch()); if (version.empty()) { diff --git a/src/maiken/mods.cpp b/src/maiken/mods.cpp index 751b1944..e761ba09 100644 --- a/src/maiken/mods.cpp +++ b/src/maiken/mods.cpp @@ -61,21 +61,15 @@ void maiken::Application::mod(mkn::kul::hash::set::String& mods, std::vector am) KEXIT(1, "-m invalid, version must before location"); - - auto if_set = [&](auto s, auto& v, auto n) { - if (s != std::string::npos) v = proj.substr(s + 1), proj = proj.substr(0, s), n = v; + auto if_set = [&](auto& v, auto n) { + if (v.size()) n = v; }; - if_set(am, local, node[STR_LOCAL]); - if_set(ha, version, node[STR_VERSION]); + if_set(local, node[STR_LOCAL]); + if_set(version, node[STR_VERSION]); } if (proj.empty() && local.empty() && scm.empty()) diff --git a/src/maiken/process.cpp b/src/maiken/process.cpp index 4dc79073..bc0f9293 100644 --- a/src/maiken/process.cpp +++ b/src/maiken/process.cpp @@ -31,6 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "maiken.hpp" void maiken::Application::process() KTHROW(mkn::kul::Exception) { + mkn::kul::hash::map::S2S oldEvs; + for (auto const& ev : evs) { + std::string const& v = mkn::kul::env::GET(ev.name()); + if (v.size()) oldEvs.insert(ev.name(), v); + mkn::kul::env::SET(ev.name(), ev.value()); + } + auto const& cmds = CommandStateMachine::INSTANCE().commands(); mkn::kul::os::PushDir pushd(this->project().dir()); @@ -134,4 +141,6 @@ void maiken::Application::process() KTHROW(mkn::kul::Exception) { run(cmds.count(STR_DBG)); CommandStateMachine::INSTANCE().reset(); AppVars::INSTANCE().show(0); + + for (auto const& oldEv : oldEvs) mkn::kul::env::SET(oldEv.first.c_str(), oldEv.second.c_str()); } diff --git a/src/maiken/setup.cpp b/src/maiken/setup.cpp index b7f5e5d5..34e4779a 100644 --- a/src/maiken/setup.cpp +++ b/src/maiken/setup.cpp @@ -30,6 +30,49 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "maiken/github.hpp" #include "maiken/regex.hpp" +#include "maiken/scm.hpp" + +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); + 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; + + SCMGetter::GET(local, pInfo.scm) + ->co(local.path(), SCMGetter::REPO(local, pInfo.scm), pInfo.version); + } + } + } + } +} +} // namespace maiken void maiken::Application::setup() KTHROW(mkn::kul::Exception) { if (scr.empty() && project().root()[STR_SCM]) @@ -47,6 +90,9 @@ void maiken::Application::setup() KTHROW(mkn::kul::Exception) { if (p.empty()) buildD = mkn::kul::Dir::JOIN(STR_BIN, STR_BUILD); this->bd = mkn::kul::Dir(project().dir().join(buildD)); std::string profile(p); + + sub_initializer(*this); + std::vector nodes; if (profile.empty()) { nodes.push_back(project().root()); @@ -140,8 +186,8 @@ void maiken::Application::setup() KTHROW(mkn::kul::Exception) { else KEXCEPTION(STR_DEP) << " is invalid type"; } - populateMaps(n); popDepOrMod(n, deps, STR_DEP, 0); + populateMaps(n); if (n[STR_IF_DEP] && n[STR_IF_DEP][KTOSTRING(__MKN_KUL_OS__)]) { auto node = n[STR_IF_DEP][KTOSTRING(__MKN_KUL_OS__)]; diff --git a/src/project.cpp b/src/project.cpp index b40c5416..271dfdcb 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -31,9 +31,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "mkn/kul/io.hpp" #include "maiken/defs.hpp" +#include "maiken/string.hpp" #include "maiken/project.hpp" -const mkn::kul::yaml::Validator maiken::Project::validator() const { +maiken::ProjectInfo maiken::ProjectInfo::PARSE_LINE(std::string const& line) { + std::string local /*&*/, profiles, proj = line, version /*#*/, scm; + + auto get_between = [&](auto& var, auto lbrak, auto rbrak) { + auto between = maiken::string::between_rm_str(proj, lbrak, rbrak); + if (between.found) proj = between.remaining, var = *between.found; + return !between.error; + }; + + if (!get_between(scm, "(", ")")) KEXIT(1, "Invalid -m - missing right ) bracket"); + if (!get_between(profiles, "[", "]")) KEXIT(1, "Invalid -m - missing right ] bracket"); + mkn::kul::String::REPLACE_ALL(profiles, ",", " "); + + auto am = proj.find("&"), ha = proj.find("#"); + if (am != std::string::npos && ha != std::string::npos) + if (ha > am) KEXIT(1, "invalid input, version & must before location #"); + auto if_set = [&](auto s, auto& v) { + if (s != std::string::npos) v = proj.substr(s + 1), proj = proj.substr(0, s); + }; + if_set(am, local); + if_set(ha, version); + + return {local, profiles, proj, version, scm}; +} + +mkn::kul::yaml::Validator maiken::Project::validator() const { using namespace mkn::kul::yaml; std::vector depVals{NodeValidator("name"), NodeValidator("version"), @@ -90,6 +116,7 @@ const mkn::kul::yaml::Validator maiken::Project::validator() const { NodeValidator("out"), NodeValidator("ext"), NodeValidator("self"), + NodeValidator("sub"), NodeValidator("with"), env, dep, @@ -118,6 +145,7 @@ const mkn::kul::yaml::Validator maiken::Project::validator() const { NodeValidator("install"), NodeValidator("out"), NodeValidator("self"), + NodeValidator("sub"), NodeValidator("with"), env, dep, diff --git a/src/settings.cpp b/src/settings.cpp index c44b16f0..244a8005 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -142,7 +142,7 @@ bool maiken::Settings::SET(std::string const& s) { return 0; } -const mkn::kul::yaml::Validator maiken::Settings::validator() const { +mkn::kul::yaml::Validator maiken::Settings::validator() const { using namespace mkn::kul::yaml; std::vector masks;