#include "regexis024_build_system.h" struct TestWebsiteBuildScript { /* Building runlevel */ BuildUnitsArray runlevel_1; /* Installation runlevel */ BuildUnitsArray runlevel_2; /* "debug" or "release" */ std::string build_type; bool make_tests = false; std::vector warning_flags = {"-Wall", "-Wno-unused-variable", "-Werror=return-type","-pedantic", "-Wno-unused-but-set-variable", "-Wno-reorder"}; std::vector version_flags = {"--std", "c++14", "-D", "_POSIX_C_SOURCE=200809L"}; std::vector debug_defines_release = {"_GLIBCXX_DEBUG"}; std::vector debug_defines_debug = {"_GLIBCXX_DEBUG", "DEBUG_ALLOW_LOUD"}; std::vector opt_flags_release = {"-g", "-O2"}; std::vector opt_flags_debug = {"-g", "-ggdb", "-O0"}; std::vector getSomeRadFlags() { std::vector 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; } TestWebsiteBuildScript(const std::string& _build_type, bool make_tests, const NormalCBuildSystemCommandMeaning& cmd) : build_type(_build_type), make_tests(make_tests) { ASSERT(build_type == "release" || build_type == "debug", "Unknown build type"); std::vector ext_targets; std::vector my_targets; { CTarget T("libjsonincpp", "shared_library"); T.additional_compilation_flags = getSomeRadFlags(); T.units_dir = "library"; T.units = { "libjsonincpp/utf8.cpp", "libjsonincpp/jsonobj.cpp", "libjsonincpp/quality_of_life.cpp", "libjsonincpp/quality_of_life_2.cpp", "libjsonincpp/integer.cpp", "libjsonincpp/inner_storage.cpp", "libjsonincpp/generator.cpp", "libjsonincpp/parser.cpp", "libjsonincpp/parser_context.cpp", "libjsonincpp/container_parsing.cpp", }; T.include_pr = "library"; T.include_ir = ""; T.exported_headers = { "libjsonincpp/jsonobj.h", "libjsonincpp/string_representation.h", "libjsonincpp/utf8.h" }; T.installation_dir = ""; T.description = "C++ JSON object structure + parser and generator"; my_targets.push_back(T); } if (make_tests) { CTarget T("test0", "executable"); T.additional_compilation_flags = getSomeRadFlags(); T.proj_deps = {CTargetDependenceOnProjectsLibrary("libjsonincpp")}; T.units_dir = "tests"; T.units = {"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(argc > 0); std::vector 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("debug", true, cmd); if (cmd.need_to_build) complete_tasks_of_build_units(bs.runlevel_1); 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()); } }