Skip to content

Commit

Permalink
ocl: fixed script turning code into embedded resource
Browse files Browse the repository at this point in the history
* Check if include-guard is actually present.
  • Loading branch information
hfp committed Mar 22, 2024
1 parent c853f4e commit 3c7daf2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/acc/opencl/acc_opencl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ trap_exit() {

process_pre() {
if [ "$1" ]; then
GUARD=$(${BASENAME} "$1" | ${TR} '[:lower:]' '[:upper:]' | ${TR} '.' '_')
if [ "${CPP}" ] && \
[ "$(eval "${CPP} ${CPPBASEFLAGS} $1" 2>/dev/null >/dev/null && echo "YES")" ];
then
Expand All @@ -51,8 +50,13 @@ process_pre() {
else # fallback to sed
${SED} -r ':a;s%(.*)/\*.*\*/%\1%;ta;/\/\*/!b;N;ba' "$1"
fi | \
if [ "${GUARD}" ] && [[ (! "$2" || "0" = "$2") ]]; then # strip include guards
${SED} "/${GUARD}/d;\${/\s*\#\s*endif/d}"
if [ ! "$2" ] || [ "0" = "$2" ]; then # strip include guards
GUARD=$(${BASENAME} "$1" | ${TR} '[:lower:]' '[:upper:]' | ${TR} '.' '_')
if [ "${GUARD}" ] && [ "$(${SED} -n "/${GUARD}/p" "$1")" ]; then
${SED} "/${GUARD}/d;\${/\s*\#\s*endif/d}"
else
${CAT}
fi
else
${CAT}
fi
Expand Down

0 comments on commit 3c7daf2

Please sign in to comment.