Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Feb 28, 2024
1 parent 9b9b51d commit ca7acb3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.noformat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 16 additions & 25 deletions src/maiken/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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);

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;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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};
}

Expand Down

0 comments on commit ca7acb3

Please sign in to comment.