Skip to content

Commit

Permalink
sub updates /etc
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Feb 28, 2024
1 parent d753b2c commit 9b9b51d
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 44 deletions.
24 changes: 16 additions & 8 deletions README.noformat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -403,7 +407,7 @@ If neither are set the following rules apply
Unix : gdb ./bin/<profile>/<binary> <args>

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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions inc/maiken/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class KUL_PUBLISH Application : public Constants {
std::vector<std::pair<maiken::Source, bool>> srcs;
std::vector<std::pair<std::string, bool>> incs;
mkn::kul::SCM const* scm = 0;
std::vector<ProjectInfo> subs;
};

class Applications : public Constants {
Expand Down
5 changes: 5 additions & 0 deletions inc/maiken/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";

Expand Down
12 changes: 9 additions & 3 deletions inc/maiken/project.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<Application const*> 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;
Expand Down
5 changes: 3 additions & 2 deletions inc/maiken/scm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion inc/maiken/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> const& remoteModules() const { return rms; }
std::vector<std::string> const& remoteRepos() const { return rrs; }
mkn::kul::hash::map::S2S const& properties() const { return ps; }
Expand Down
2 changes: 1 addition & 1 deletion mkn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/maiken/build/bin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions src/maiken/compiler/gcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "maiken.hpp"
#include <unordered_set>

#include <cstdint>

maiken::cpp::GccCompiler::GccCompiler(int const& v) : CCompiler(v) {
m_optimise_c.insert({{0, ""},
{1, "-O1"},
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/maiken/defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/maiken/depmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
29 changes: 10 additions & 19 deletions src/maiken/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,15 @@ void maiken::Application::mod(mkn::kul::hash::set::String& mods, std::vector<YAM
mkn::kul::String::TRIM(mod);
if (mod.empty()) continue;

mod_nodes.emplace_back();
auto& node = mod_nodes.back();
std::string local /*&*/, profiles, proj = mod, version /*#*/, scm, objs;
auto& node = mod_nodes.emplace_back();

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;
};
ProjectInfo pInfo = ProjectInfo::PARSE_LINE(mod);

if (!get_between(scm, "(", ")")) KEXIT(1, "Invalid -m - missing right ) bracket");
if (!node[STR_SCM]) node[STR_SCM] = scm;
auto& [local, profiles, proj, version, scm] = pInfo;
// KLOG(INF) << proj;
std::string objs;

if (!get_between(profiles, "[", "]")) KEXIT(1, "Invalid -m - missing right ] bracket");
mkn::kul::String::REPLACE_ALL(profiles, ",", " ");
if (!node[STR_SCM] && scm.size()) node[STR_SCM] = scm;
if (!node[STR_PROFILE] && profiles.size()) node[STR_PROFILE] = profiles;

{
Expand All @@ -94,14 +88,11 @@ void maiken::Application::mod(mkn::kul::hash::set::String& mods, std::vector<YAM
"location");
}

if (am != std::string::npos && ha != std::string::npos)
if (ha > 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())
Expand Down
9 changes: 9 additions & 0 deletions src/maiken/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
}
48 changes: 47 additions & 1 deletion src/maiken/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YAML::Node> 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])
Expand All @@ -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<YAML::Node> nodes;
if (profile.empty()) {
nodes.push_back(project().root());
Expand Down Expand Up @@ -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__)];
Expand Down
Loading

0 comments on commit 9b9b51d

Please sign in to comment.