105 lines
4.0 KiB
C++
105 lines
4.0 KiB
C++
#include "regexis024_build_system.h"
|
|
|
|
struct TestWebsiteBuildScript {
|
|
/* Building runlevel */
|
|
BuildUnitsArray runlevel_1;
|
|
/* Installation runlevel */
|
|
BuildUnitsArray runlevel_2;
|
|
|
|
std::string build_type;
|
|
bool make_tests = false;
|
|
|
|
std::vector<std::string> warning_flags = {"-Wall", "-Wno-unused-variable", "-Werror=return-type","-pedantic",
|
|
"-Wno-unused-but-set-variable", "-Wno-reorder"};
|
|
std::vector<std::string> version_flags = {"--std", "c++14", "-D", "_POSIX_C_SOURCE=200809L"};
|
|
|
|
std::vector<std::string> debug_defines_release = {"_GLIBCXX_DEBUG"};
|
|
std::vector<std::string> debug_defines_debug = {"_GLIBCXX_DEBUG", "DEBUG_JSON_ALLOW_LOUD"};
|
|
std::vector<std::string> opt_flags_release = {"-g", "-O2"};
|
|
std::vector<std::string> opt_flags_debug = {"-g", "-ggdb", "-O0"};
|
|
|
|
|
|
std::vector<std::string> getSomeRadFlags() {
|
|
std::vector<std::string> my_flag_collection;
|
|
gxx_add_cli_options(my_flag_collection, warning_flags);
|
|
gxx_add_cli_options(my_flag_collection, version_flags);
|
|
if (build_type == "release") {
|
|
gxx_add_cli_defines(my_flag_collection, debug_defines_release);
|
|
gxx_add_cli_options(my_flag_collection, opt_flags_release);
|
|
} else if (build_type == "debug") {
|
|
gxx_add_cli_defines(my_flag_collection, debug_defines_debug);
|
|
gxx_add_cli_options(my_flag_collection, opt_flags_debug);
|
|
}
|
|
return my_flag_collection;
|
|
}
|
|
|
|
explicit TestWebsiteBuildScript(const NormalCBuildSystemCommandMeaning& cmd){
|
|
const char* BSCRIPT_TYPE = getenv("BSCRIPT_TYPE");
|
|
const char* BSCRIPT_TESTS = getenv("BSCRIPT_TESTS");
|
|
build_type = BSCRIPT_TYPE ? BSCRIPT_TYPE : "release";
|
|
make_tests = (bool)BSCRIPT_TESTS;
|
|
ASSERT(build_type == "release" || build_type == "debug", "Unknown build type");
|
|
|
|
std::vector<ExternalLibraryTarget> ext_targets;
|
|
|
|
std::vector<CTarget> my_targets;
|
|
{ CTarget T{"libjsonincpp", "shared_library"};
|
|
T.additional_compilation_flags = getSomeRadFlags();
|
|
T.units = {
|
|
"utf8.cpp",
|
|
"jsonobj.cpp",
|
|
"quality_of_life.cpp",
|
|
"integer.cpp",
|
|
"inner_storage.cpp",
|
|
"generator.cpp",
|
|
"parser.cpp",
|
|
"parser_context.cpp",
|
|
"container_parsing.cpp",
|
|
};
|
|
for (std::string& u: T.units)
|
|
u = "library/jsonincpp/" + u;
|
|
T.include_pr = "library";
|
|
T.include_ir = "";
|
|
T.exported_headers = {
|
|
"jsonobj.h",
|
|
"string_representation.h",
|
|
"utf8.h",
|
|
"integer.h",
|
|
};
|
|
for (std::string& u: T.exported_headers)
|
|
u = "jsonincpp/" + u;
|
|
T.installation_dir = "json";
|
|
my_targets.push_back(T);
|
|
}
|
|
if (make_tests) { CTarget T{"libjsonincpp_test0", "executable"};
|
|
T.additional_compilation_flags = getSomeRadFlags();
|
|
T.proj_deps = {CTargetDependenceOnProjectsLibrary{"libjsonincpp"}};
|
|
T.units = {"tests/test0.cpp"};
|
|
T.include_pr = "tests";
|
|
my_targets.push_back(T);
|
|
}
|
|
regular_ctargets_to_2bus_conversion(ext_targets, my_targets, runlevel_1, runlevel_2,
|
|
cmd.project_root, cmd.installation_root);
|
|
}
|
|
};
|
|
|
|
int main(int argc, char** argv) {
|
|
try {
|
|
ASSERT_pl(argc > 0);
|
|
std::vector<std::string> args(argc - 1);
|
|
for (int i = 0; i + 1 < argc; i++) {
|
|
args[i] = argv[i + 1];
|
|
}
|
|
NormalCBuildSystemCommandMeaning cmd;
|
|
regular_bs_cli_cmd_interpret(args, cmd);
|
|
TestWebsiteBuildScript bs(cmd);
|
|
if (cmd.need_to_build)
|
|
complete_tasks_of_build_units(bs.runlevel_1);
|
|
umask(~0755);
|
|
if (cmd.need_to_install)
|
|
complete_tasks_of_build_units(bs.runlevel_2);
|
|
} catch (const buildSystemFailure& e) {
|
|
printf("Build system failure\n""%s\n", e.toString().c_str());
|
|
}
|
|
}
|