command-line option support + switch compiler profile on command line
This commit is contained in:
parent
dfcf57aae1
commit
816dcbe118
|
@ -48,3 +48,7 @@ up
|
||||||
up
|
up
|
||||||
up
|
up
|
||||||
q
|
q
|
||||||
|
q
|
||||||
|
q
|
||||||
|
r gen -compiler_profile release
|
||||||
|
q
|
||||||
|
|
|
@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.28)
|
||||||
|
|
||||||
project(grbc)
|
project(grbc)
|
||||||
|
|
||||||
|
message(${CMAKE_CXX_FLAGS_RELEASE})
|
||||||
|
|
||||||
add_subdirectory("vendor/sol2")
|
add_subdirectory("vendor/sol2")
|
||||||
|
|
||||||
include_directories("include")
|
include_directories("include")
|
||||||
|
|
5
HConfig
5
HConfig
|
@ -2,8 +2,6 @@ grbc_want_version("1.0")
|
||||||
grbc_ext("GRBC_EXT_pkg_config")
|
grbc_ext("GRBC_EXT_pkg_config")
|
||||||
grbc_ext("GRBC_EXT_profiles")
|
grbc_ext("GRBC_EXT_profiles")
|
||||||
|
|
||||||
grbc_set_profile("release")
|
|
||||||
|
|
||||||
local grbc_extensions = grbc_library(LibraryConfig.new({
|
local grbc_extensions = grbc_library(LibraryConfig.new({
|
||||||
name = "libgrbc_extensions",
|
name = "libgrbc_extensions",
|
||||||
language_type = LanguageType.Cpp,
|
language_type = LanguageType.Cpp,
|
||||||
|
@ -47,7 +45,8 @@ local grbc_lib = grbc_library(LibraryConfig.new({
|
||||||
grbc_file("src/target_lib.cc"),
|
grbc_file("src/target_lib.cc"),
|
||||||
grbc_file("src/package.cc"),
|
grbc_file("src/package.cc"),
|
||||||
grbc_file("src/ext.cc"),
|
grbc_file("src/ext.cc"),
|
||||||
grbc_file("src/task.cc")
|
grbc_file("src/task.cc"),
|
||||||
|
grbc_file("src/options.cc")
|
||||||
},
|
},
|
||||||
lib_type = LibraryType.Static,
|
lib_type = LibraryType.Static,
|
||||||
|
|
||||||
|
|
39
build.ninja
39
build.ninja
|
@ -1,5 +1,5 @@
|
||||||
### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ###
|
### GENERATED BY THE GRBC BUILT-IN NINJA GENERATOR ###
|
||||||
### GENERATED ON: 1727637831 ###
|
### GENERATED ON: 1727642123 ###
|
||||||
|
|
||||||
## Default variables ##
|
## Default variables ##
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ rule archive
|
||||||
## Compile: src/ext_pkg_config.cc ##
|
## Compile: src/ext_pkg_config.cc ##
|
||||||
|
|
||||||
build $builddir/src/ext_pkg_config.o: cxx src/ext_pkg_config.cc
|
build $builddir/src/ext_pkg_config.o: cxx src/ext_pkg_config.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/ext_profiles.cc ##
|
## Compile: src/ext_profiles.cc ##
|
||||||
|
|
||||||
build $builddir/src/ext_profiles.o: cxx src/ext_profiles.cc
|
build $builddir/src/ext_profiles.o: cxx src/ext_profiles.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Link: libgrbc_extensions.a ##
|
## Link: libgrbc_extensions.a ##
|
||||||
|
|
||||||
|
@ -58,67 +58,72 @@ build $builddir/libgrbc_extensions.a: archive $builddir/src/ext_pkg_config.o $bu
|
||||||
## Compile: src/file.cc ##
|
## Compile: src/file.cc ##
|
||||||
|
|
||||||
build $builddir/src/file.o: cxx src/file.cc
|
build $builddir/src/file.o: cxx src/file.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/ninja.cc ##
|
## Compile: src/ninja.cc ##
|
||||||
|
|
||||||
build $builddir/src/ninja.o: cxx src/ninja.cc
|
build $builddir/src/ninja.o: cxx src/ninja.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/platform.cc ##
|
## Compile: src/platform.cc ##
|
||||||
|
|
||||||
build $builddir/src/platform.o: cxx src/platform.cc
|
build $builddir/src/platform.o: cxx src/platform.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/target_exe.cc ##
|
## Compile: src/target_exe.cc ##
|
||||||
|
|
||||||
build $builddir/src/target_exe.o: cxx src/target_exe.cc
|
build $builddir/src/target_exe.o: cxx src/target_exe.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/utils.cc ##
|
## Compile: src/utils.cc ##
|
||||||
|
|
||||||
build $builddir/src/utils.o: cxx src/utils.cc
|
build $builddir/src/utils.o: cxx src/utils.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/generator.cc ##
|
## Compile: src/generator.cc ##
|
||||||
|
|
||||||
build $builddir/src/generator.o: cxx src/generator.cc
|
build $builddir/src/generator.o: cxx src/generator.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/target_lib.cc ##
|
## Compile: src/target_lib.cc ##
|
||||||
|
|
||||||
build $builddir/src/target_lib.o: cxx src/target_lib.cc
|
build $builddir/src/target_lib.o: cxx src/target_lib.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/package.cc ##
|
## Compile: src/package.cc ##
|
||||||
|
|
||||||
build $builddir/src/package.o: cxx src/package.cc
|
build $builddir/src/package.o: cxx src/package.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/ext.cc ##
|
## Compile: src/ext.cc ##
|
||||||
|
|
||||||
build $builddir/src/ext.o: cxx src/ext.cc
|
build $builddir/src/ext.o: cxx src/ext.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Compile: src/task.cc ##
|
## Compile: src/task.cc ##
|
||||||
|
|
||||||
build $builddir/src/task.o: cxx src/task.cc
|
build $builddir/src/task.o: cxx src/task.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
|
## Compile: src/options.cc ##
|
||||||
|
|
||||||
|
build $builddir/src/options.o: cxx src/options.cc
|
||||||
|
p_cflags = -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Link: libgrbc.a ##
|
## Link: libgrbc.a ##
|
||||||
|
|
||||||
build $builddir/libgrbc.a: archive $builddir/src/file.o $builddir/src/ninja.o $builddir/src/platform.o $builddir/src/target_exe.o $builddir/src/utils.o $builddir/src/generator.o $builddir/src/target_lib.o $builddir/src/package.o $builddir/src/ext.o $builddir/src/task.o
|
build $builddir/libgrbc.a: archive $builddir/src/file.o $builddir/src/ninja.o $builddir/src/platform.o $builddir/src/target_exe.o $builddir/src/utils.o $builddir/src/generator.o $builddir/src/target_lib.o $builddir/src/package.o $builddir/src/ext.o $builddir/src/task.o $builddir/src/options.o
|
||||||
|
|
||||||
## Compile: src/main.cc ##
|
## Compile: src/main.cc ##
|
||||||
|
|
||||||
build $builddir/src/main.o: cxx src/main.cc
|
build $builddir/src/main.o: cxx src/main.cc
|
||||||
p_cflags = -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/sol2/include
|
p_cflags = -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/sol2/include -g -O1
|
||||||
|
|
||||||
## Link: grbc ##
|
## Link: grbc ##
|
||||||
|
|
||||||
build $builddir/grbc: link_cxx $builddir/src/main.o | $builddir/libgrbc.a $builddir/libgrbc_extensions.a
|
build $builddir/grbc: link_cxx $builddir/src/main.o | $builddir/libgrbc.a $builddir/libgrbc_extensions.a
|
||||||
p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a -O3 -Lbuild -Wl,-rpath,build:.
|
p_linker_flags = -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a -Lbuild -Wl,-rpath,build:.
|
||||||
p_cflags =
|
p_cflags = -g -O1
|
||||||
|
|
||||||
## clean ##
|
## clean ##
|
||||||
rule clean_task
|
rule clean_task
|
||||||
|
|
110
compile_commands.json
Normal file
110
compile_commands.json
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_pkg_config.o -MF build/src/ext_pkg_config.o.d -Iinclude -Ivendor/sol2/include -c src/ext_pkg_config.cc -o build/src/ext_pkg_config.o",
|
||||||
|
"file": "src/ext_pkg_config.cc",
|
||||||
|
"output": "build/src/ext_pkg_config.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext_profiles.o -MF build/src/ext_profiles.o.d -Iinclude -Ivendor/sol2/include -c src/ext_profiles.cc -o build/src/ext_profiles.o",
|
||||||
|
"file": "src/ext_profiles.cc",
|
||||||
|
"output": "build/src/ext_profiles.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "rm -f build/libgrbc_extensions.a; ar crs build/libgrbc_extensions.a build/src/ext_pkg_config.o build/src/ext_profiles.o",
|
||||||
|
"file": "build/src/ext_pkg_config.o",
|
||||||
|
"output": "build/libgrbc_extensions.a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/file.o -MF build/src/file.o.d -Iinclude -Ivendor/sol2/include -c src/file.cc -o build/src/file.o",
|
||||||
|
"file": "src/file.cc",
|
||||||
|
"output": "build/src/file.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ninja.o -MF build/src/ninja.o.d -Iinclude -Ivendor/sol2/include -c src/ninja.cc -o build/src/ninja.o",
|
||||||
|
"file": "src/ninja.cc",
|
||||||
|
"output": "build/src/ninja.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/platform.o -MF build/src/platform.o.d -Iinclude -Ivendor/sol2/include -c src/platform.cc -o build/src/platform.o",
|
||||||
|
"file": "src/platform.cc",
|
||||||
|
"output": "build/src/platform.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_exe.o -MF build/src/target_exe.o.d -Iinclude -Ivendor/sol2/include -c src/target_exe.cc -o build/src/target_exe.o",
|
||||||
|
"file": "src/target_exe.cc",
|
||||||
|
"output": "build/src/target_exe.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/utils.o -MF build/src/utils.o.d -Iinclude -Ivendor/sol2/include -c src/utils.cc -o build/src/utils.o",
|
||||||
|
"file": "src/utils.cc",
|
||||||
|
"output": "build/src/utils.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/generator.o -MF build/src/generator.o.d -Iinclude -Ivendor/sol2/include -c src/generator.cc -o build/src/generator.o",
|
||||||
|
"file": "src/generator.cc",
|
||||||
|
"output": "build/src/generator.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/target_lib.o -MF build/src/target_lib.o.d -Iinclude -Ivendor/sol2/include -c src/target_lib.cc -o build/src/target_lib.o",
|
||||||
|
"file": "src/target_lib.cc",
|
||||||
|
"output": "build/src/target_lib.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/package.o -MF build/src/package.o.d -Iinclude -Ivendor/sol2/include -c src/package.cc -o build/src/package.o",
|
||||||
|
"file": "src/package.cc",
|
||||||
|
"output": "build/src/package.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/ext.o -MF build/src/ext.o.d -Iinclude -Ivendor/sol2/include -c src/ext.cc -o build/src/ext.o",
|
||||||
|
"file": "src/ext.cc",
|
||||||
|
"output": "build/src/ext.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/task.o -MF build/src/task.o.d -Iinclude -Ivendor/sol2/include -c src/task.cc -o build/src/task.o",
|
||||||
|
"file": "src/task.cc",
|
||||||
|
"output": "build/src/task.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/options.o -MF build/src/options.o.d -Iinclude -Ivendor/sol2/include -c src/options.cc -o build/src/options.o",
|
||||||
|
"file": "src/options.cc",
|
||||||
|
"output": "build/src/options.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "rm -f build/libgrbc.a; ar crs build/libgrbc.a build/src/file.o build/src/ninja.o build/src/platform.o build/src/target_exe.o build/src/utils.o build/src/generator.o build/src/target_lib.o build/src/package.o build/src/ext.o build/src/task.o build/src/options.o",
|
||||||
|
"file": "build/src/file.o",
|
||||||
|
"output": "build/libgrbc.a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -MMD -MT build/src/main.o -MF build/src/main.o.d -Iinclude -Ivendor/sol2/include -Iinclude -Ivendor/sol2/include -c src/main.cc -o build/src/main.o",
|
||||||
|
"file": "src/main.cc",
|
||||||
|
"output": "build/src/main.o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "/usr/lib64/ccache/g++ -o build/grbc build/src/main.o -llua -lm -ldl build/libgrbc.a build/libgrbc_extensions.a -O3 -DNDEBUG -Lbuild -Wl,-rpath,build:. ",
|
||||||
|
"file": "build/src/main.o",
|
||||||
|
"output": "build/grbc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/home/interfiber/dev/grbc",
|
||||||
|
"command": "",
|
||||||
|
"file": "build/libgrbc_extensions.a",
|
||||||
|
"output": "all"
|
||||||
|
}
|
||||||
|
]
|
|
@ -273,3 +273,7 @@ std::string grbc_platform_file(PlatformType platform_type,
|
||||||
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);
|
void grbc_task(const TaskConfig &config);
|
||||||
|
|
||||||
|
bool grbc_has_option(const std::string &option_name);
|
||||||
|
|
||||||
|
std::string grbc_get_option(const std::string &option_name);
|
|
@ -2,6 +2,7 @@
|
||||||
#include "grbc/ext.h"
|
#include "grbc/ext.h"
|
||||||
#include "grbc/generator.h"
|
#include "grbc/generator.h"
|
||||||
#include "grbc/spec.h"
|
#include "grbc/spec.h"
|
||||||
|
#include <map>
|
||||||
#include <sol/sol.hpp>
|
#include <sol/sol.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -15,6 +16,8 @@ struct GState {
|
||||||
std::vector<GeneratorTarget> targets;
|
std::vector<GeneratorTarget> targets;
|
||||||
std::vector<Generator> generators;
|
std::vector<Generator> generators;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> options;
|
||||||
|
|
||||||
std::unordered_map<std::string, Package> packages;
|
std::unordered_map<std::string, Package> packages;
|
||||||
|
|
||||||
std::vector<Extension> extensions;
|
std::vector<Extension> extensions;
|
||||||
|
|
|
@ -84,3 +84,9 @@ Convert a PackageConfig into a Package
|
||||||
|
|
||||||
## [X] grbc_task(config: TaskConfig) -> Void
|
## [X] grbc_task(config: TaskConfig) -> Void
|
||||||
Create a task and add it to the build script
|
Create a task and add it to the build script
|
||||||
|
|
||||||
|
## [X] grbc_has_option(option_name: String) -> Boolean
|
||||||
|
Check if the given option was set on the command line
|
||||||
|
|
||||||
|
## [X] grbc_get_option(option_name: String) -> String
|
||||||
|
Get the value of an option
|
|
@ -51,17 +51,21 @@ void grbc_profiles_init(sol::state &lua) {
|
||||||
|
|
||||||
Profile release_with_debug_symbols_profile{};
|
Profile release_with_debug_symbols_profile{};
|
||||||
release_with_debug_symbols_profile.name = "release_with_debug_symbols";
|
release_with_debug_symbols_profile.name = "release_with_debug_symbols";
|
||||||
release_with_debug_symbols_profile.compiler_flags = {"-g", "-O3"};
|
release_with_debug_symbols_profile.compiler_flags = {"-g", "-O3", "-DNDEBUG"};
|
||||||
|
|
||||||
Profile release_profile{};
|
Profile release_profile{};
|
||||||
release_profile.name = "release";
|
release_profile.name = "release";
|
||||||
release_profile.linker_flags = {"-O3"};
|
release_profile.linker_flags = {"-O3", "-DNDEBUG"};
|
||||||
|
|
||||||
EXT_profiles_get_profiles().push_back(debug_profile);
|
EXT_profiles_get_profiles().push_back(debug_profile);
|
||||||
EXT_profiles_get_profiles().push_back(release_with_debug_symbols_profile);
|
EXT_profiles_get_profiles().push_back(release_with_debug_symbols_profile);
|
||||||
EXT_profiles_get_profiles().push_back(release_profile);
|
EXT_profiles_get_profiles().push_back(release_profile);
|
||||||
|
|
||||||
|
if (!grbc_has_option("compiler_profile")) {
|
||||||
EXT_profiles_set("debug"); // Always use debug as the default profile
|
EXT_profiles_set("debug"); // Always use debug as the default profile
|
||||||
|
} else {
|
||||||
|
EXT_profiles_set(grbc_get_option("compiler_profile"));
|
||||||
|
}
|
||||||
|
|
||||||
lua.set("grbc_set_profile", EXT_profiles_set);
|
lua.set("grbc_set_profile", EXT_profiles_set);
|
||||||
|
|
||||||
|
|
67
src/main.cc
67
src/main.cc
|
@ -1,15 +1,49 @@
|
||||||
#include "grbc/ext_pkg_config.h"
|
#include "grbc/ext_pkg_config.h"
|
||||||
#include "grbc/ext_profiles.h"
|
#include "grbc/ext_profiles.h"
|
||||||
#include "grbc/state.h"
|
|
||||||
#include <sol/raii.hpp>
|
|
||||||
#include <sol/table.hpp>
|
|
||||||
#define SOL_ALL_SAFETIES_ON 1
|
|
||||||
|
|
||||||
#include "grbc/helpers.h"
|
#include "grbc/helpers.h"
|
||||||
#include "grbc/spec.h"
|
#include "grbc/spec.h"
|
||||||
|
#include "grbc/state.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <map>
|
||||||
|
#include <sol/raii.hpp>
|
||||||
#include <sol/sol.hpp>
|
#include <sol/sol.hpp>
|
||||||
|
#include <sol/table.hpp>
|
||||||
|
|
||||||
|
void print_help() {
|
||||||
|
printf("GRBC - Graphite Build Configurator\n");
|
||||||
|
printf("Author: Interfiber <webmaster@interfiber.dev>\n");
|
||||||
|
printf("Commands:\n");
|
||||||
|
printf(" gen - Generate build configuration from HConfig\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc == 1) {
|
||||||
|
print_help();
|
||||||
|
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::string> options;
|
||||||
|
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
std::string arg = argv[i];
|
||||||
|
|
||||||
|
if (arg[0] == '-' && i + 1 < argc) {
|
||||||
|
if (std::string(argv[i + 1]).empty()) continue;
|
||||||
|
|
||||||
|
arg.erase(arg.begin());
|
||||||
|
|
||||||
|
options.insert({ arg, std::string(argv[i + 1]) });
|
||||||
|
|
||||||
|
log_msg(("found option: " + arg + " = " + std::string(argv[i + 1])).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GState::get().options = options;
|
||||||
|
|
||||||
|
if (std::string(argv[1]) == "gen") {
|
||||||
|
log_msg("running grbc generator...");
|
||||||
|
|
||||||
int main() {
|
|
||||||
log_msg("opening lua libraries...");
|
log_msg("opening lua libraries...");
|
||||||
|
|
||||||
auto &lua = GState::get().lua;
|
auto &lua = GState::get().lua;
|
||||||
|
@ -31,9 +65,9 @@ int main() {
|
||||||
&PackageConfig::linker_flags);
|
&PackageConfig::linker_flags);
|
||||||
|
|
||||||
// GlobalConfig
|
// GlobalConfig
|
||||||
lua.new_usertype<GlobalConfig>("GlobalConfig", "engine_version",
|
lua.new_usertype<GlobalConfig>(
|
||||||
&GlobalConfig::engine_version, "architecture",
|
"GlobalConfig", "engine_version", &GlobalConfig::engine_version,
|
||||||
&GlobalConfig::architecture, "target_config",
|
"architecture", &GlobalConfig::architecture, "target_config",
|
||||||
&GlobalConfig::platform_config);
|
&GlobalConfig::platform_config);
|
||||||
|
|
||||||
// Platform
|
// Platform
|
||||||
|
@ -77,10 +111,10 @@ int main() {
|
||||||
"package_config", &LibraryConfig::package_config);
|
"package_config", &LibraryConfig::package_config);
|
||||||
|
|
||||||
// Package
|
// Package
|
||||||
lua.new_usertype<Package>("Package", sol::constructors<Package(sol::table)>(),
|
lua.new_usertype<Package>(
|
||||||
"name", &Package::name, "compiler_flags",
|
"Package", sol::constructors<Package(sol::table)>(), "name",
|
||||||
&Package::compiler_flags, "linker_flags",
|
&Package::name, "compiler_flags", &Package::compiler_flags,
|
||||||
&Package::linker_flags);
|
"linker_flags", &Package::linker_flags);
|
||||||
|
|
||||||
// TaskConfig
|
// TaskConfig
|
||||||
lua.new_usertype<TaskConfig>(
|
lua.new_usertype<TaskConfig>(
|
||||||
|
@ -116,6 +150,8 @@ int main() {
|
||||||
lua.set("grbc_platform_file", grbc_platform_file);
|
lua.set("grbc_platform_file", grbc_platform_file);
|
||||||
lua.set("grbc_is_ext_loaded", grbc_is_ext_loaded);
|
lua.set("grbc_is_ext_loaded", grbc_is_ext_loaded);
|
||||||
lua.set("grbc_task", grbc_task);
|
lua.set("grbc_task", grbc_task);
|
||||||
|
lua.set("grbc_has_option", grbc_has_option);
|
||||||
|
lua.set("grbc_get_option", grbc_get_option);
|
||||||
|
|
||||||
// Load generators
|
// Load generators
|
||||||
|
|
||||||
|
@ -152,4 +188,9 @@ int main() {
|
||||||
log_msg("loading HConfig...");
|
log_msg("loading HConfig...");
|
||||||
|
|
||||||
lua.script_file("HConfig");
|
lua.script_file("HConfig");
|
||||||
|
} else {
|
||||||
|
printf("unknown command\n");
|
||||||
|
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
22
src/options.cc
Normal file
22
src/options.cc
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include "grbc/spec.h"
|
||||||
|
#include "grbc/state.h"
|
||||||
|
|
||||||
|
bool grbc_has_option(const std::string &option_name) {
|
||||||
|
for (auto &k : GState::get().options) {
|
||||||
|
if (k.first == option_name)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string grbc_get_option(const std::string &option_name) {
|
||||||
|
for (auto &k : GState::get().options) {
|
||||||
|
if (k.first == option_name)
|
||||||
|
return k.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
grbc_exception("Failed to find option with name '" + option_name + "'");
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
|
@ -5,6 +5,10 @@
|
||||||
TargetInfo grbc_library(const LibraryConfig &library_config) {
|
TargetInfo grbc_library(const LibraryConfig &library_config) {
|
||||||
TargetInfo target_config{};
|
TargetInfo target_config{};
|
||||||
|
|
||||||
|
if (library_config.name[0] != 'l' && library_config.name[1] != 'i' && library_config.name[2] != 'b') {
|
||||||
|
grbc_exception("library names are mandated to start with 'lib'");
|
||||||
|
}
|
||||||
|
|
||||||
std::string lib_name = library_config.name;
|
std::string lib_name = library_config.name;
|
||||||
lib_name += grbc_get_lib_extension(library_config.lib_type);
|
lib_name += grbc_get_lib_extension(library_config.lib_type);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue