Skip to content

Commit d1e372a

Browse files
Adding -output_no_suffix flag
Change-Id: Ic444ea8b049f7582ff25700c2fb029c13a2eb9ef
1 parent 2e8e6bd commit d1e372a

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

offline_compiler/offline_compiler.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
511511
argIndex++;
512512
} else if (stringsAreEqual(argv[argIndex], "-q")) {
513513
quiet = true;
514+
} else if (stringsAreEqual(argv[argIndex], "-output_no_suffix")) {
515+
outputNoSuffix = true;
514516
} else if (stringsAreEqual(argv[argIndex], "--help")) {
515517
printUsage();
516518
retVal = PRINT_USAGE;
@@ -661,7 +663,7 @@ void OfflineCompiler::printUsage() {
661663
Additionally, outputs intermediate representation (e.g. spirV).
662664
Different input and intermediate file formats are available.
663665
664-
Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename>] [-out_dir <output_dir>] [-options <options>] [-32|-64] [-internal_options <options>] [-llvm_text|-llvm_input|-spirv_input] [-options_name] [-q] [-cpp_file] [--help]
666+
Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename>] [-out_dir <output_dir>] [-options <options>] [-32|-64] [-internal_options <options>] [-llvm_text|-llvm_input|-spirv_input] [-options_name] [-q] [-cpp_file] [-output_no_suffix] [--help]
665667
666668
-file <filename> The input file to be compiled
667669
(by default input source format is
@@ -732,6 +734,8 @@ Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename
732734
-cpp_file Will generate c++ file with C-array
733735
containing Intel OpenCL device binary.
734736
737+
-output_no_suffix Prevents ocloc from adding family name suffix.
738+
735739
--help Print this usage message.
736740
737741
Examples :
@@ -797,10 +801,18 @@ bool OfflineCompiler::generateElfBinary() {
797801
void OfflineCompiler::writeOutAllFiles() {
798802
std::string fileBase;
799803
std::string fileTrunk = getFileNameTrunk(inputFile);
800-
if (outputFile.empty()) {
801-
fileBase = fileTrunk + "_" + familyNameWithType;
804+
if (outputNoSuffix) {
805+
if (outputFile.empty()) {
806+
fileBase = fileTrunk;
807+
} else {
808+
fileBase = outputFile;
809+
}
802810
} else {
803-
fileBase = outputFile + "_" + familyNameWithType;
811+
if (outputFile.empty()) {
812+
fileBase = fileTrunk + "_" + familyNameWithType;
813+
} else {
814+
fileBase = outputFile + "_" + familyNameWithType;
815+
}
804816
}
805817

806818
if (outputDirectory != "") {
@@ -845,8 +857,12 @@ void OfflineCompiler::writeOutAllFiles() {
845857
}
846858

847859
if (!elfBinary.empty()) {
848-
std::string elfOutputFile = generateFilePath(outputDirectory, fileBase, ".bin") + generateOptsSuffix();
849-
860+
std::string elfOutputFile;
861+
if (outputNoSuffix) {
862+
elfOutputFile = generateFilePath(outputDirectory, fileBase, "");
863+
} else {
864+
elfOutputFile = generateFilePath(outputDirectory, fileBase, ".bin") + generateOptsSuffix();
865+
}
850866
writeDataToFile(
851867
elfOutputFile.c_str(),
852868
elfBinary.data(),

offline_compiler/offline_compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class OfflineCompiler {
9393
bool quiet = false;
9494
bool inputFileLlvm = false;
9595
bool inputFileSpirV = false;
96+
bool outputNoSuffix = false;
9697

9798
CLElfLib::ElfBinaryStorage elfBinary;
9899
size_t elfBinarySize = 0;

0 commit comments

Comments
 (0)