Skip to content

Commit

Permalink
Merge branch 'feature/bootstrap-p3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vector-of-bool committed Nov 13, 2019
2 parents ac0da1f + 10d8613 commit 32236df
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/dds/toolchain/from_dds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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"});
}
Expand All @@ -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;
};

Expand Down Expand Up @@ -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;
});

Expand Down
28 changes: 28 additions & 0 deletions src/dds/toolchain/from_dds.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
)");
Expand Down
1 change: 1 addition & 0 deletions tools/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def main(argv: Sequence[str]) -> int:
'--durations=10',
f'--basetemp={paths.BUILD_DIR / "_tmp"}',
'-n4',
'tests/',
])


Expand Down

0 comments on commit 32236df

Please sign in to comment.