Skip to content

Commit

Permalink
Fix issue with sed in wasm target
Browse files Browse the repository at this point in the history
  • Loading branch information
michelerenzullo committed Dec 26, 2024
1 parent 08b50f2 commit 8253ddf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions bootstrap/bootstrap.gaussianblur.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,15 @@ compile_gaussian_blur() {
cp ../examples/wasm/multi-thread/gaussianblur.html ${FINAL_PREFIX_DIR}/bin/
######## Find the closure compiled Module var name to set up in worker.js in order to load the wasm module
GREP_CMD="grep"
SED_CMD="sed -i"
if command -v ggrep; then
GREP_CMD="ggrep"
SED_CMD="sed -i ''"
fi
MODULE_NAME=$($GREP_CMD -oP '\b[a-zA-Z]\b(?=[^a-zA-Z]*typeof Module(?![\s\S]*typeof Module))' "${FINAL_PREFIX_DIR}/bin/GaussianBlur.js")
if [ -z "$MODULE_NAME" ]; then
printf "${RED}Error: Unable to find the Module value in GaussianBlur.js${RESET}\n"
exit 1
fi
cp ../examples/wasm/multi-thread/gaussianblur_worker.js ${FINAL_PREFIX_DIR}/bin/
$SED_CMD "s|const Module = h|const Module = "${MODULE_NAME}";|" "${FINAL_PREFIX_DIR}/bin/gaussianblur_worker.js"
sed "s|const Module = h|const Module = "${MODULE_NAME}"|" ../examples/wasm/multi-thread/gaussianblur_worker.js > "${FINAL_PREFIX_DIR}/bin/gaussianblur_worker.js"
printf "${GREEN}Module var name closure compiled is '${MODULE_NAME}', succesfully set in ${FINAL_PREFIX_DIR}/bin/gaussianblur_worker.js${RESET}\n"
####################
elif [ "$PLATFORM" = "ios" ] ; then
Expand Down
2 changes: 1 addition & 1 deletion examples/wasm/multi-thread/gaussianblur_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ onmessage = async e => {
const arguments = e.data[1]

const startTime = performance.now()
const Module = z //needed because of closure
const Module = h //needed because of closure

//js string to C like const char array with null terminator
const utf8 = new Uint8Array(arguments.length + 1);
Expand Down

0 comments on commit 8253ddf

Please sign in to comment.