Skip to content

Commit a05401b

Browse files
svenvhvmaksimo
authored andcommitted
Generate all .h files in one invocation
This makes running the script after changing spirv.hpp more convenient.
1 parent f4d2751 commit a05401b

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

llvm-spirv/tools/spirv-tool/gen_spirv.bash

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,13 @@ else
108108
fi
109109
}
110110

111-
####################
112-
#
113-
# main
114-
#
115-
####################
116-
117-
if [[ $# -ne 2 ]]; then
118-
echo "usage: gen_spirv path_to_spirv.hpp [NameMap|isValid]"
119-
exit
120-
fi
121-
122-
spirvHeader=$1
123-
type=$2
124-
if [[ "$type" == NameMap ]]; then
125-
outputFile="lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h"
126-
elif [[ "$type" == isValid ]]; then
127-
outputFile="lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h"
128-
else
129-
echo "Unknown type $type"
130-
exit 1
131-
fi
132-
outputBasename="$(basename ${outputFile})"
133-
includeGuard="SPIRV_LIBSPIRV_`echo ${outputBasename} | tr '[:lower:]' '[:upper:]' | sed -e 's/[\.\/]/_/g'`"
111+
genFile() {
112+
outputFile=$1
113+
genType=$2
114+
outputBasename="$(basename ${outputFile})"
115+
includeGuard="SPIRV_LIBSPIRV_`echo ${outputBasename} | tr '[:lower:]' '[:upper:]' | sed -e 's/[\.\/]/_/g'`"
134116

135-
echo "//===- ${outputBasename} - SPIR-V ${type} enums ----------------*- C++ -*-===//
117+
echo "//===- ${outputBasename} - SPIR-V ${genType} enums ----------------*- C++ -*-===//
136118
//
137119
// The LLVM/SPIRV Translator
138120
//
@@ -167,7 +149,7 @@ echo "//===- ${outputBasename} - SPIR-V ${type} enums ----------------*- C++ -*-
167149
//===----------------------------------------------------------------------===//
168150
/// \\file
169151
///
170-
/// This file defines SPIR-V ${type} enums.
152+
/// This file defines SPIR-V ${genType} enums.
171153
///
172154
//===----------------------------------------------------------------------===//
173155
// WARNING:
@@ -188,8 +170,24 @@ using namespace spv;
188170
namespace SPIRV {
189171
" > ${outputFile}
190172

191-
gen $type >> ${outputFile}
173+
gen $genType >> ${outputFile}
192174

193-
echo "} /* namespace SPIRV */
175+
echo "} /* namespace SPIRV */
194176
195177
#endif // ${includeGuard}" >> ${outputFile}
178+
}
179+
180+
####################
181+
#
182+
# main
183+
#
184+
####################
185+
186+
if [[ $# -ne 1 ]]; then
187+
echo "usage: gen_spirv path_to_spirv.hpp"
188+
exit
189+
fi
190+
191+
spirvHeader=$1
192+
genFile "lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h" NameMap
193+
genFile "lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h" isValid

0 commit comments

Comments
 (0)