Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Conan recipe for VTD simulator #3

Merged
merged 11 commits into from
Feb 3, 2021
Prev Previous commit
Next Next commit
engine: Add interpolation for ${THIS_STACKFILE_DIR} and -FILE
  • Loading branch information
cassava committed Feb 2, 2021
commit 4a9799a8686f273a595a04d52e8af1b1c93c3727
28 changes: 19 additions & 9 deletions engine/src/main_stack.cpp
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@

#include <cloe/utility/std_extensions.hpp> // for split_string
#include <cloe/utility/xdg.hpp> // for merge_config
#include <fable/environment.hpp> // for Environment
#include <fable/utility.hpp> // for pretty_print, read_conf_from_file

#include "plugins/nop_controller.hpp" // for NopFactory
@@ -41,14 +42,24 @@

namespace cloe {

Conf read_conf(const StackOptions& opt, const std::string& filepath) {
if (!opt.interpolate_vars) {
return fable::read_conf(filepath);
}

// Prepare environment with extra variables:
fable::Environment env(*opt.environment);
if (!filepath.empty() && filepath != "-") {
std::string dirpath = boost::filesystem::canonical(filepath).parent_path().native();
env.set("THIS_STACKFILE_FILE", filepath);
env.set("THIS_STACKFILE_DIR", dirpath);
}
return fable::read_conf_with_interpolation(filepath, &env);
}

void merge_stack(const StackOptions& opt, Stack& s, const std::string& filepath) {
auto merge = [&]() {
Conf c;
if (opt.interpolate_vars) {
c = fable::read_conf_with_interpolation(filepath, opt.environment.get());
} else {
c = fable::read_conf(filepath);
}
Conf c = read_conf(opt, filepath);

if (opt.no_hooks) {
// Removing hooks from the config allows the stack to validate even if
@@ -95,9 +106,8 @@ Stack new_stack(const StackOptions& opt) {
};
interpolate_path(s.engine.registry_path);
interpolate_path(s.engine.output_path);
s.set_conf_reader([&opt](const std::string& filepath) -> cloe::Conf {
return fable::read_conf_with_interpolation(filepath, opt.environment.get());
});
s.set_conf_reader(
[&opt](const std::string& filepath) -> cloe::Conf { return read_conf(opt, filepath); });
}

// Insert ignored sections
1 change: 0 additions & 1 deletion engine/src/stack.cpp
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@
namespace fs = boost::filesystem;

#include <cloe/utility/std_extensions.hpp> // for join_vector
#include <fable/utility.hpp> // for read_conf_with_interpolation

namespace cloe {