Skip to content

Commit 83d8574

Browse files
authored
toolchain: normalize toolchain args before parsing (#17)
1 parent 1765156 commit 83d8574

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/toolchain.cxx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ void ToolChainInvocation::ParseCommandArgs(char const* const* cli) {
5656
// Collect include args as we need to ensure Spack
5757
// Includes come first
5858
for (char const* const* co = cli; *co; co++) {
59-
std::string const arg = std::string(*co);
60-
if (startswith(arg, "/I") || startswith(arg, "-I")) {
59+
std::string norm_arg = std::string(*co);
60+
const std::string arg = std::string(*co);
61+
lower(norm_arg);
62+
if (isCommandArg(norm_arg, "i")) {
6163
// We have an include arg
6264
// can have an optional space
6365
// check if there are characters after
@@ -69,19 +71,20 @@ void ToolChainInvocation::ParseCommandArgs(char const* const* cli) {
6971
this->include_args.push_back(arg);
7072
this->include_args.emplace_back(*(++co));
7173
}
72-
} else if (endswith(arg, ".lib") &&
73-
(arg.find("implib:") == std::string::npos))
74+
} else if (endswith(norm_arg, ".lib") &&
75+
(norm_arg.find("implib:") == std::string::npos))
7476
// Lib args are just libraries
7577
// provided like system32.lib on the
7678
// command line.
7779
// lib specification order does not matter
7880
// on MSVC but this is useful for filtering system libs
7981
// and adding all libs
8082
this->lib_args.push_back(arg);
81-
else if (endswith(arg, ".obj"))
83+
else if (endswith(norm_arg, ".obj"))
8284
this->obj_args.push_back(arg);
83-
else
85+
else {
8486
this->command_args.push_back(arg);
87+
}
8588
}
8689
}
8790

0 commit comments

Comments
 (0)