Skip to content

Instantly share code, notes, and snippets.

@okovalov
Created January 20, 2022 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okovalov/d3731970b7bab7fdcda6601ecd43b3e7 to your computer and use it in GitHub Desktop.
Save okovalov/d3731970b7bab7fdcda6601ecd43b3e7 to your computer and use it in GitHub Desktop.
Build three types of wasm from the wasm component of the platform and sync it to the sdk
function wasm_sync -d "Compile wasm from platform, and cody to findora-wallet-wasm "
set original_directory $PWD
set -l findoraDir "$OLEKS_ROOT/prj/Findora"
set -l wasmComponentDir "$findoraDir/platform/src/components/wasm"
set -l sourceDir "$wasmComponentDir/pkg"
set -l wasmTargetRootDir "$findoraDir/findora-wallet-wasm"
echo
echo "================================================================="
echo " * * WASM Compile and Sync (platform -> findora-wallet-wasm) * *"
echo "================================================================="
echo
echo "Current directory is - " $PWD " (after process is completed, it would be changed back here)"
echo
set -l iterations 3
for x in (seq $iterations)
echo "=========================================== "
echo " -= Running step $x out of $iterations =-"
echo "=========================================== "
# Set initial time (for random directory name)
set -l start_time (date '+%s')
# Define which target to use for the build
if [ "$x" = 1 ]
set build_target web
else if [ "$x" = 2 ]
set build_target nodejs
else
set build_target bundler
end
echo
echo "Current build target $build_target"
# final directory name with a random suffix, which is current date time stamp
set -l rename_value $build_target.$start_time
echo
echo "Directory name to rename $rename_value"
# set values for renaming directories in findora-wallet-wasm
set -l targetDir "$wasmTargetRootDir/$build_target"
set -l renameDir "$wasmTargetRootDir/$rename_value"
echo
echo "1. Changing directory to $wasmComponentDir "
cd "$wasmComponentDir"
echo
echo "2. Current directory is $PWD "
echo
echo "3. Removing $sourceDir (current wasm build)"
rm -rf $sourceDir
echo
echo "4. Compiling wasm for target $build_target "
echo
wasm-pack build -t $build_target
echo
echo "5. Rename destination directory $targetDir -> $renameDir"
echo
mv -v $targetDir $renameDir
echo
echo "6. Copy compiled wasm to target dir $sourceDir -> $targetDir "
echo
yes | cp -rfv $sourceDir $targetDir
# Change the directory to the original one, which was changed during the process
if not set -q $original_directory
echo
echo "7. Changing current directory back to -" $original_directory
echo
cd $original_directory
echo
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment