Skip to content

Commit

Permalink
Quote application-provided build options for the shell used to invoke…
Browse files Browse the repository at this point in the history
… clspv (#601)

* Update supported-applications.md

* Quote options
  • Loading branch information
zwang20 authored Aug 19, 2023
1 parent f181479 commit b08793c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,29 @@ std::string cvk_program::prepare_build_options(const cvk_device* device) const {
#if COMPILER_AVAILABLE
options += " " + config.clspv_options() + " ";
#endif
// split options into a vector
std::istringstream iss(options);
std::vector<std::string> vector_options;
std::string token;
while (std::getline(iss, token, ' ')) {
vector_options.push_back(token);
}

// loop through the options and quote the ones that need it
std::string quoted_options;
for (size_t i = 0; i < vector_options.size(); i++) {
if (vector_options[i].empty()) {
continue;
}
if (vector_options[i].find("-") == 0) {
quoted_options += vector_options[i];
} else {
quoted_options += "\"" + vector_options[i] + "\"";
}
quoted_options += " ";
}

return options;
return quoted_options;
}

cl_int cvk_program::parse_user_spec_constants() {
Expand Down

0 comments on commit b08793c

Please sign in to comment.