Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ build --@boost.dll//:use_std_fs
query --@boost.dll//:use_std_fs
build --@boost.process//:use_std_fs
query --@boost.process//:use_std_fs
build --//:use_sdk_version
query --//:use_sdk_version

build:windows --workspace_status_command=bazel/tools/wsc.cmd
build:linux --workspace_status_command=bazel/tools/wsc.sh
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "ecsact_runtime", version = "0.6.7")
bazel_dep(name = "ecsact_runtime", version = "0.6.8")
bazel_dep(name = "ecsact_interpret", version = "0.6.4")
bazel_dep(name = "ecsact_codegen", version = "0.4.1")
bazel_dep(name = "boost.dll", version = "1.83.0.bzl.2")
Expand Down
12 changes: 6 additions & 6 deletions ecsact/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ package(default_visibility = ["//:__subpackages__"])

cc_library(
name = "report_message",
copts = copts,
hdrs = ["report_message.hh"],
copts = copts,
)

cc_library(
name = "report",
copts = copts,
hdrs = ["report.hh"],
srcs = ["report.cc"],
hdrs = ["report.hh"],
copts = copts,
deps = [
":report_message",
],
Expand All @@ -27,17 +27,17 @@ cc_stamp_header(

cc_binary(
name = "ecsact",
visibility = ["//visibility:public"],
srcs = [
"ecsact_cli.cc",
"bazel_stamp_header.hh",
"ecsact_cli.cc",
],
copts = copts,
defines = select({
"//:use_sdk_version_enabled": ["ECSACT_CLI_USE_SDK_VERSION"],
"//:use_sdk_version_disabled": [],
}),
copts = copts,
stamp = 1,
visibility = ["//visibility:public"],
deps = [
# "//ecsact/cli/commands:benchmark",
"//ecsact/cli/commands:codegen",
Expand Down
23 changes: 12 additions & 11 deletions ecsact/cli/commands/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ cc_library(
hdrs = ["common.hh"],
copts = copts,
deps = [
"@docopt.cpp//:docopt",
"//ecsact/cli:report",
"//ecsact/cli:report_message",
"//ecsact/cli/detail:json_report",
"//ecsact/cli/detail:text_report",
"@docopt.cpp//:docopt",
],
)


cc_library(
name = "codegen",
srcs = ["codegen.cc"],
Expand All @@ -51,15 +50,15 @@ cc_library(
deps = [
":command",
":common",
"//ecsact/cli/commands/codegen:codegen",
"@magic_enum",
"@docopt.cpp//:docopt",
"//ecsact/cli/commands/codegen",
"@boost.dll",
"@ecsact_interpret",
"@docopt.cpp//:docopt",
"@ecsact_codegen//:plugin",
"@ecsact_codegen//:plugin_validate",
"@ecsact_interpret",
"@ecsact_runtime//:dylib",
"@ecsact_runtime//:meta",
"@magic_enum",
],
)

Expand All @@ -86,13 +85,14 @@ cc_library(
":common",
"//ecsact/cli:report",
"//ecsact/cli:report_message",
"//ecsact/cli/commands/build/recipe:taste",
"//ecsact/cli/commands/build/recipe:cook",
"//ecsact/cli/commands/build:cc_compiler",
"//ecsact/cli/commands/build:build_recipe",
"//ecsact/cli/commands/build:cc_compiler",
"//ecsact/cli/commands/build/recipe:cook",
"//ecsact/cli/commands/build/recipe:taste",
"//ecsact/cli/commands/recipe-bundle:build_recipe_bundle",
"@ecsact_interpret",
"@docopt.cpp//:docopt",
"@ecsact_codegen//:plugin_validate",
"@ecsact_interpret",
"@magic_enum",
],
)
Expand All @@ -110,8 +110,9 @@ cc_library(
"//ecsact/cli/commands/build:build_recipe",
"//ecsact/cli/commands/recipe-bundle:build_recipe_bundle",
"//ecsact/cli/detail:argv0",
"@ecsact_interpret",
"@docopt.cpp//:docopt",
"@ecsact_codegen//:plugin_validate",
"@ecsact_interpret",
"@magic_enum",
],
)
98 changes: 73 additions & 25 deletions ecsact/cli/commands/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
#include "ecsact/cli/commands/build/recipe/cook.hh"
#include "ecsact/cli/commands/build/recipe/taste.hh"
#include "ecsact/cli/commands/recipe-bundle/build_recipe_bundle.hh"
#include "ecsact/codegen/plugin_validate.hh"
#include "codegen/codegen_util.hh"

namespace fs = std::filesystem;

using namespace std::string_view_literals;
using namespace std::string_literals;

constexpr auto USAGE = R"docopt(Ecsact Build Command

Expand Down Expand Up @@ -107,28 +110,15 @@ auto ecsact::cli::detail::build_command( //

auto recipe_composite = std::optional<build_recipe>{};
auto recipe_paths = args.at("--recipe").asStringList();

for(auto& recipe_path_str : recipe_paths) {
auto builtin_path = resolve_builtin_recipe(recipe_path_str, argv);

fs::path recipe_path;
if(builtin_path) {
recipe_path = *builtin_path;
} else {
recipe_path = fs::path{recipe_path_str};
recipe_path_str = builtin_path->string();
}

if(std::ranges::find(allowed_recipe_extensions, recipe_path.extension()) ==
allowed_recipe_extensions.end()) {
ecsact::cli::report_error(
"Invalid recipe file extension {}",
recipe_path.extension().string()
);
return 1;
}

if(!recipe_path.has_extension()) {
recipe_path.replace_extension("ecsact-recipe-bundle");
}
auto recipe_path = fs::path(recipe_path_str);

if(recipe_path.extension() == ".ecsact-recipe-bundle") {
auto bundle_result = ecsact::build_recipe_bundle::from_file(recipe_path);
Expand All @@ -152,14 +142,36 @@ auto ecsact::cli::detail::build_command( //
return 1;
}

recipe_path = extract_result.recipe_path();
recipe_path_str = recipe_path.generic_string();
recipe_path_str = extract_result.recipe_path().generic_string();

ecsact::cli::report_info(
"Extracted build recipe bundle to {}",
recipe_path.parent_path().generic_string()
);
}
}

auto additional_plugin_dirs = std::vector<fs::path>{};
for(fs::path recipe_path : recipe_paths) {
if(recipe_path.has_parent_path()) {
additional_plugin_dirs.emplace_back(recipe_path.parent_path());
}
}

for(const auto& recipe_path_str : recipe_paths) {
auto recipe_path = fs::path(recipe_path_str);
if(std::ranges::find(allowed_recipe_extensions, recipe_path.extension()) ==
allowed_recipe_extensions.end()) {
ecsact::cli::report_error(
"Invalid recipe file extension {}",
recipe_path.extension().string()
);
return 1;
}

if(!recipe_path.has_extension()) {
recipe_path.replace_extension("ecsact-recipe-bundle");
}

auto recipe_result = build_recipe::from_yaml_file(recipe_path);

Expand All @@ -173,6 +185,49 @@ auto ecsact::cli::detail::build_command( //
}

auto recipe = std::move(std::get<build_recipe>(recipe_result));

for(auto& source : recipe.sources()) {
auto result = std::get_if<build_recipe::source_codegen>(&source);
if(result) {
if(result->plugins.empty()) {
ecsact::cli::report_error(
"Recipe source build has no plugins {}",
recipe_path_str
);
return 1;
}

for(auto plugin : result->plugins) {
auto checked_plugin_paths = std::vector<fs::path>{};
auto plugin_path = resolve_plugin_path(
{.plugin_arg = plugin,
.default_plugins_dir = get_default_plugins_dir(),
.additional_plugin_dirs = additional_plugin_dirs},
checked_plugin_paths
);
if(plugin_path) {
auto validate_result =
ecsact::codegen::plugin_validate(*plugin_path);
if(!validate_result.ok()) {
auto err_msg = "Plugin validation failed for '" + plugin + "'\n";
for(auto err : validate_result.errors) {
err_msg += " - "s + to_string(err) + "\n";
}
ecsact::cli::report_error("{}", err_msg);
return 1;
}
} else {
auto err_msg = "Unable to find codegen plugin '" + plugin +
"'. Paths checked:\n";
for(auto& checked_path : checked_plugin_paths) {
err_msg += " - " + fs::relative(checked_path).string() + "\n";
}
ecsact::cli::report_error("{}", err_msg);
}
}
}
}

if(!recipe_composite) {
recipe_composite.emplace(std::move(recipe));
} else {
Expand Down Expand Up @@ -290,13 +345,6 @@ auto ecsact::cli::detail::build_command( //
compiler->compiler_version
);

auto additional_plugin_dirs = std::vector<fs::path>{};
for(fs::path recipe_path : recipe_paths) {
if(recipe_path.has_parent_path()) {
additional_plugin_dirs.emplace_back(recipe_path.parent_path());
}
}

auto cook_options = cook_recipe_options{
.files = file_paths,
.work_dir = work_dir,
Expand Down
10 changes: 10 additions & 0 deletions ecsact/cli/commands/build/build_recipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ static auto parse_sources( //

for(auto src : sources) {
if(src.IsMap()) {
ecsact::cli::report_error("UHHH IT'S A MAP??");

auto codegen = src["codegen"];
auto fetch = src["fetch"];
auto path = src["path"];
Expand All @@ -192,12 +194,20 @@ static auto parse_sources( //
}

if(codegen) {
ecsact::cli::report_error("CODEGEN??");

auto entry = source_codegen{};
if(src["outdir"]) {
entry.outdir = src["outdir"].as<std::string>();
}
if(codegen.IsSequence()) {
ecsact::cli::report_error("CODEGEN??!!");

entry.plugins = codegen.as<std::vector<std::string>>();
for(auto plugin : entry.plugins) {
ecsact::cli::report_error("CODEGEN PLUGINS: {}", plugin);
}

} else {
entry.plugins.push_back(codegen.as<std::string>());
}
Expand Down
Loading