task support

This commit is contained in:
Hunter 2024-09-29 15:24:13 -04:00
parent d9e4642472
commit dfcf57aae1
12 changed files with 134 additions and 12 deletions

View file

@ -38,6 +38,12 @@ struct GeneratorTarget {
std::vector<GeneratorLinkTargetCommand> link_target_commands;
};
struct GeneratorTask {
std::string description, id;
std::string shell_script;
};
typedef GeneratorResult (*Generator_Run)();
struct Generator {

View file

@ -49,3 +49,8 @@ ninja_build_rule_link_exe_target(const GeneratorLinkTargetCommand &link_cmd);
*/
std::string
ninja_build_rule_link_lib_target(const GeneratorLinkTargetCommand &link_cmd);
/**
* Generate a line which describes the given task
*/
std::string ninja_build_rule_task(const GeneratorTask &task);

View file

@ -128,6 +128,23 @@ struct ExecutableConfig {
std::vector<std::string> include_dirs{};
};
struct TaskConfig {
TaskConfig(const sol::table &table) {
name = table.get<std::string>("name");
task_id = table.get<std::string>("task_id");
shell_script = table.get<std::string>("shell_script");
}
/// Name of the task
std::string name;
/// ID of the task
std::string task_id;
/// Shell script content for this task
std::string shell_script;
};
struct LibraryConfig {
LibraryConfig(const sol::table &table) {
name = table.get<std::string>("name");
@ -253,4 +270,6 @@ bool grbc_has_ext(const std::string &extension_id);
std::string grbc_platform_file(PlatformType platform_type,
const std::string &file_name);
bool grbc_is_ext_loaded(const std::string &extension_name);
bool grbc_is_ext_loaded(const std::string &extension_name);
void grbc_task(const TaskConfig &config);

View file

@ -11,6 +11,7 @@ struct GState {
Platform current_platform{};
sol::state lua;
std::vector<GeneratorTask> tasks;
std::vector<GeneratorTarget> targets;
std::vector<Generator> generators;
@ -19,7 +20,7 @@ struct GState {
std::vector<Extension> extensions;
std::string global_compiler_flags = "";
std::string global_linker_flags = "";
std::string global_linker_flags = " ";
std::string ninja_output;