Add quotes to options in cmdline printed by ocloc

When ocloc prints the command it was called with, enclose the -options
and -internal_options with quotes.
This allows easier copy-paste of the cmdline.

Related-To: NEO-6002

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2021-12-16 17:43:11 +00:00
committed by Compute-Runtime-Automation
parent f4c151cce5
commit b6ec17843d
4 changed files with 69 additions and 2 deletions

View File

@@ -64,8 +64,17 @@ Examples:
extern "C" {
void printOclocCmdLine(unsigned int numArgs, const char *argv[], std::unique_ptr<OclocArgHelper> &helper) {
printf("Command was:");
for (auto i = 0u; i < numArgs; ++i)
printf(" %s", argv[i]);
bool useQuotes = false;
for (auto i = 0u; i < numArgs; ++i) {
const char *currArg = argv[i];
if (useQuotes) {
printf(" \"%s\"", currArg);
useQuotes = false;
} else {
printf(" %s", currArg);
useQuotes = helper->areQuotesRequired(currArg);
}
}
printf("\n");
}

View File

@@ -346,6 +346,10 @@ unsigned int OclocArgHelper::returnIGFXforGen(const std::string &device) {
return it->second;
}
bool OclocArgHelper::areQuotesRequired(const std::string_view &argName) {
return argName == "-options" || argName == "-internal_options";
}
PRODUCT_CONFIG OclocArgHelper::findConfigMatch(const std::string &device, bool firstAppearance) {
auto numeration = getMajorMinorRevision(device);
if (numeration.empty()) {

View File

@@ -147,4 +147,5 @@ class OclocArgHelper {
std::string returnProductNameForDevice(unsigned short deviceId);
bool isGen(const std::string &device);
unsigned int returnIGFXforGen(const std::string &device);
bool areQuotesRequired(const std::string_view &argName);
};