Skip to content

Commit

Permalink
fix env parsing = (#82)
Browse files Browse the repository at this point in the history
* fix env parsing =

* better test finding regex / sample -x files
  • Loading branch information
PhilipDeegan authored Aug 6, 2023
1 parent 9d82c95 commit 0320492
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 78 deletions.
9 changes: 0 additions & 9 deletions .lgtm.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"ClangFormat" :
{
"binary" : "clang-format-8",
"binary" : "clang-format",
"format_on_save" : true,
"style" : "file"
}
Expand Down
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

6 changes: 2 additions & 4 deletions inc/maiken/env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ namespace maiken {

template <typename HasProperties>
mkn::kul::cli::EnvVar PARSE_ENV_NODE(YAML::Node const& n, HasProperties const& hasProperties,
std::string hasProperties_id) {
std::string /*hasProperties_id*/) {
using namespace mkn::kul::cli;
if (n.IsScalar()) {
auto bits = mkn::kul::String::ESC_SPLIT(n.Scalar(), '=');

if (bits.size() != 2)
KEXIT(1, "env string is invalid, expects one '=' only, string ")
<< n.Scalar() << "\n in: " << hasProperties_id;
for (std::size_t i = 2; i < bits.size(); ++i) bits[1] += "=" + bits[i];

auto replace = [](std::string const& n, std::string& in, std::string f) {
auto pos = in.find(f);
Expand Down
2 changes: 1 addition & 1 deletion mkn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: mkn
# scm: https://github.com/mkn/mkn
version: master
property:
DATE: 12-DEC-2022
DATE: 06-AUG-2023

parent: bin
mode: none
Expand Down
18 changes: 18 additions & 0 deletions res/mkn/clang_asan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
property:
cxx_flags: -std=c++17 -fsanitize=address -fno-omit-frame-pointer
local:
repo: /mkn/r
mod-repo: /mkn/m
remote:
repo: [email protected]:mkn/
mod-repo: [email protected]:mkn-mod/
path: |
/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux
env: | # replace with $(clang++ -print-file-name=libclang_rt.asan-x86_64.so)
LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so
ASAN_OPTIONS=detect_leaks=0
file:
- type: cpp:cxx:cc:c:S
archiver: ar -cr
compiler: ccache clang++ ${cxx_flags}
linker: clang++ -Bmold -lclang_rt.asan-x86_64
13 changes: 13 additions & 0 deletions res/mkn/clang_mold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
property:
cxx_flags: -std=c++17
local:
repo: /mkn/r
mod-repo: /mkn/m
remote:
repo: [email protected]:mkn/
mod-repo: [email protected]:mkn-mod/
file:
- type: cpp:cxx:cc:c:S
archiver: ar -cr
compiler: ccache clang++ ${cxx_flags}
linker: clang++ -Bmold
13 changes: 13 additions & 0 deletions res/mkn/gcc_asan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
property:
cxx_flags: -std=c++17 -fsanitize=address -fno-omit-frame-pointer
local:
repo: /mkn/r
mod-repo: /mkn/m
remote:
repo: [email protected]:mkn/
mod-repo: [email protected]:mkn-mod/
file:
- type: cpp:cxx:cc:c:S
archiver: ar -cr
compiler: ccache g++ ${cxx_flags}
linker: g++ ${cxx_flags}
2 changes: 1 addition & 1 deletion src/maiken/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ std::vector<maiken::Application*> maiken::Application::CREATE(int16_t argc, char
Args args(cli.cmds(), cli.args());
try {
args.process(argc, argv);
} catch (const mkn::kul::cli::Exception& e) {
} catch (mkn::kul::cli::Exception const& e) {
KEXIT(1, e.what());
}
return CREATE(args);
Expand Down
13 changes: 9 additions & 4 deletions src/regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ std::vector<std::string> maiken::Regexer::RESOLVE(std::string str) KTHROW(mkn::k
if (str.size() > 1 && str.substr(0, 2) == "./") str = str.substr(2);

auto bits = mkn::kul::String::SPLIT(str, "/");
str = bits[bits.size() - 1];
mkn::kul::Dir d(mkn::kul::env::CWD());

mkn::kul::Dir d(mkn::kul::env::CWD());
if (bits.size() > 1) d = mkn::kul::Dir(bits[0]);
for (size_t i = 1; i < bits.size() - 1; i++) d = d.join(bits[i]);

str = bits[bits.size() - 1];

for (size_t i = 1; i < bits.size() - 1; i++) {
if (bits[i].find("(") != std::string::npos && bits[i].find(")") != std::string::npos) break;
d = d.join(bits[i]);
}

auto regexer = [&](auto items) {
for (auto const& item : items) {
Expand All @@ -59,7 +64,7 @@ std::vector<std::string> maiken::Regexer::RESOLVE(std::string str) KTHROW(mkn::k
}
}
};
regexer(d.files(1));
regexer(d.files(/*recursive=*/true));
return v;
}

Expand Down

0 comments on commit 0320492

Please sign in to comment.