Quellcode durchsuchen

Merge branch 'feature/bootstrap-p3' into develop

default_compile_flags
vector-of-bool vor 5 Jahren
Ursprung
Commit
32236dfb93
3 geänderte Dateien mit 61 neuen und 8 gelöschten Zeilen
  1. +32
    -8
      src/dds/toolchain/from_dds.cpp
  2. +28
    -0
      src/dds/toolchain/from_dds.test.cpp
  3. +1
    -0
      tools/ci.py

+ 32
- 8
src/dds/toolchain/from_dds.cpp Datei anzeigen

@@ -306,11 +306,34 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
return cxx_ver_iter->second;
};

auto get_flags = [&](language lang) -> string_seq {
auto get_link_flags = [&]() -> string_seq {
string_seq ret;
if (flags) {
extend(ret, *flags);
if (is_msvc) {
strv rt_lib = "/MT";
if (do_optimize.value_or(false)) {
extend(ret, {"/O2"});
}
if (do_debug.value_or(false)) {
extend(ret, {"/Z7", "/DEBUG"});
rt_lib = "/MTd";
}
ret.emplace_back(rt_lib);
} else if (is_gnu_like) {
if (do_optimize.value_or(false)) {
extend(ret, {"-O2"});
}
if (do_debug.value_or(false)) {
extend(ret, {"-g"});
}
}
if (link_flags) {
extend(ret, *link_flags);
}
return ret;
};

auto get_flags = [&](language lang) -> string_seq {
string_seq ret;
if (lang == language::cxx && cxx_flags) {
extend(ret, *cxx_flags);
}
@@ -329,11 +352,11 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
extend(ret, {"/O2"});
}
if (do_debug.has_value() && *do_debug) {
extend(ret, {"/Z7", "/DEBUG", "/MTd"});
extend(ret, {"/Z7", "/DEBUG"});
rt_lib = "/MTd";
}
ret.emplace_back(rt_lib);
extend(ret, {"/nologo", "<FLAGS>", "/c", "<IN>", "/permissive-", "/Fo<OUT>"});
extend(ret, {"/nologo", "<FLAGS>", "/permissive-", "/c", "<IN>", "/Fo<OUT>"});
if (lang == language::cxx) {
extend(ret, {"/EHsc"});
}
@@ -353,6 +376,9 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
"<IN>",
"-o<OUT>"});
}
if (flags) {
extend(ret, *flags);
}
return ret;
};

@@ -485,9 +511,7 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
assert(false && "No link-exe command");
std::terminate();
}
if (link_flags) {
extend(ret, *link_flags);
}
extend(ret, get_link_flags());
return ret;
});


+ 28
- 0
src/dds/toolchain/from_dds.test.cpp Datei anzeigen

@@ -76,6 +76,34 @@ void run_tests() {
"ar rcs stuff.a foo.o bar.o",
"g++ -fPIC -fdiagnostics-color foo.o bar.a -pthread -lstdc++fs -omeow.exe");

check_tc_compile(
"Compiler-ID: GNU\nDebug: True",
"g++ -g -fPIC -fdiagnostics-color -pthread -c foo.cpp -ofoo.o",
"g++ -g -fPIC -fdiagnostics-color -pthread -Wall -Wextra -Wpedantic -Wconversion "
"-c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o",
"g++ -fPIC -fdiagnostics-color foo.o bar.a -pthread -lstdc++fs -omeow.exe -g");

check_tc_compile(
"Compiler-ID: GNU\nDebug: True\nOptimize: True",
"g++ -O2 -g -fPIC -fdiagnostics-color -pthread -c foo.cpp -ofoo.o",
"g++ -O2 -g -fPIC -fdiagnostics-color -pthread -Wall -Wextra -Wpedantic -Wconversion "
"-c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o",
"g++ -fPIC -fdiagnostics-color foo.o bar.a -pthread -lstdc++fs -omeow.exe -O2 -g");

check_tc_compile("Compiler-ID: MSVC",
"cl.exe /MT /nologo /permissive- /c foo.cpp /Fofoo.o /EHsc",
"cl.exe /MT /nologo /W4 /permissive- /c foo.cpp /Fofoo.o /EHsc",
"lib /nologo /OUT:stuff.a foo.o bar.o",
"cl.exe /nologo /EHsc foo.o bar.a /Femeow.exe /MT");

check_tc_compile("Compiler-ID: MSVC\nDebug: True",
"cl.exe /Z7 /DEBUG /MTd /nologo /permissive- /c foo.cpp /Fofoo.o /EHsc",
"cl.exe /Z7 /DEBUG /MTd /nologo /W4 /permissive- /c foo.cpp /Fofoo.o /EHsc",
"lib /nologo /OUT:stuff.a foo.o bar.o",
"cl.exe /nologo /EHsc foo.o bar.a /Femeow.exe /Z7 /DEBUG /MTd");

auto tc = dds::parse_toolchain_dds(R"(
Compiler-ID: GNU
)");

+ 1
- 0
tools/ci.py Datei anzeigen

@@ -124,6 +124,7 @@ def main(argv: Sequence[str]) -> int:
'--durations=10',
f'--basetemp={paths.BUILD_DIR / "_tmp"}',
'-n4',
'tests/',
])



Laden…
Abbrechen
Speichern