From b08793c972d3cb808f05ff80f15d1d9642c287a8 Mon Sep 17 00:00:00 2001 From: Michael Wang <41721295+zwang20@users.noreply.github.com> Date: Sat, 19 Aug 2023 23:47:03 +1000 Subject: [PATCH] Quote application-provided build options for the shell used to invoke clspv (#601) * Update supported-applications.md * Quote options --- src/program.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/program.cpp b/src/program.cpp index 268075d2..b0390fab 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -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 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() {