-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2293 from alixander/trim-wasm-size
d2js: trim wasm size
- Loading branch information
Showing
27 changed files
with
106,712 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
OUTPUT_FILE="main.wasm" | ||
SOURCE_PACKAGE="./d2js" | ||
|
||
echo "Building WASM file..." | ||
GOOS=js GOARCH=wasm go build -ldflags='-s -w' -trimpath -o "$OUTPUT_FILE" "$SOURCE_PACKAGE" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Build successful." | ||
|
||
if [ -f "$OUTPUT_FILE" ]; then | ||
FILE_SIZE_BYTES=$(stat -f%z "$OUTPUT_FILE") | ||
FILE_SIZE_MB=$(echo "scale=2; $FILE_SIZE_BYTES / 1024 / 1024" | bc) | ||
|
||
echo "File size of $OUTPUT_FILE: $FILE_SIZE_MB MB" | ||
else | ||
echo "File $OUTPUT_FILE not found!" | ||
exit 1 | ||
fi | ||
|
||
echo "Deleting $OUTPUT_FILE..." | ||
rm "$OUTPUT_FILE" | ||
echo "File deleted." | ||
else | ||
echo "Build failed." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.