fix: Support multiple option settings in ocloc
If ocloc is given -options several times, the variable is overwritten. This change allows the user to add additional options multiple times. Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
parent
2aacc04ffd
commit
4d359b5eef
|
@ -2888,6 +2888,28 @@ TEST(OfflineCompilerTest, givenInternalOptionsWhenCmdLineParsedThenOptionsAreApp
|
|||
EXPECT_TRUE(hasSubstr(internalOptions, std::string("myInternalOptions")));
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenOptionsWhenCmdLineParsedThenOptionsAreAppendedToOptionsString) {
|
||||
std::vector<std::string> argv = {
|
||||
"ocloc",
|
||||
"-options",
|
||||
"options1",
|
||||
"-options",
|
||||
"options2"};
|
||||
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
mockOfflineCompiler->parseCommandLine(argv.size(), argv);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
EXPECT_NE(0u, output.size());
|
||||
|
||||
std::string options = mockOfflineCompiler->options;
|
||||
EXPECT_TRUE(hasSubstr(options, std::string("options1")));
|
||||
EXPECT_TRUE(hasSubstr(options, std::string("options2")));
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenInputOptionsAndInternalOptionsFilesWhenOfflineCompilerIsInitializedThenCorrectOptionsAreSetAndRemainAfterBuild) {
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
|
|
|
@ -698,7 +698,7 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
|
|||
} else if ("-gen_file" == currArg) {
|
||||
useGenFile = true;
|
||||
} else if (("-options" == currArg) && hasMoreArgs) {
|
||||
options = argv[argIndex + 1];
|
||||
CompilerOptions::concatenateAppend(options, argv[argIndex + 1]);
|
||||
argIndex++;
|
||||
} else if (("-internal_options" == currArg) && hasMoreArgs) {
|
||||
CompilerOptions::concatenateAppend(internalOptions, argv[argIndex + 1]);
|
||||
|
|
Loading…
Reference in New Issue