mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 14:00:01 -04:00
improve build script arguments
This commit is contained in:
parent
5ecb30d5ed
commit
8ad11cd515
3 changed files with 17 additions and 2 deletions
|
@ -19,6 +19,10 @@ cd libcurl.js/client
|
|||
```
|
||||
Make sure you have emscripten, git, and the various C build tools installed. The build script will generate `client/out/libcurl.js` as well as `client/out/libcurl_module.mjs`, which is an ES6 module.
|
||||
|
||||
You can supply the following arguments to the build script to control the build:
|
||||
- `release` - Use all optimizations.
|
||||
- `single_file` - Include the WASM binary in the outputted JS using base64.
|
||||
|
||||
## Javascript API:
|
||||
|
||||
### Importing the Library:
|
||||
|
|
|
@ -20,13 +20,18 @@ RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
|||
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR"
|
||||
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASSERTIONS=1 -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
||||
|
||||
if [ "$1" = "release" ]; then
|
||||
if [[ "$*" == *"release"* ]]; then
|
||||
COMPILER_OPTIONS="-Oz -flto $COMPILER_OPTIONS"
|
||||
#EMSCRIPTEN_OPTIONS="-sSINGLE_FILE $EMSCRIPTEN_OPTIONS"
|
||||
echo "note: building with release optimizations"
|
||||
else
|
||||
COMPILER_OPTIONS="$COMPILER_OPTIONS --profiling"
|
||||
fi
|
||||
|
||||
if [[ "$*" == *"single_file"* ]]; then
|
||||
EMSCRIPTEN_OPTIONS="-sSINGLE_FILE $EMSCRIPTEN_OPTIONS"
|
||||
echo "note: building as a single js file"
|
||||
fi
|
||||
|
||||
#ensure deps are compiled
|
||||
tools/all_deps.sh
|
||||
tools/generate_cert.sh
|
||||
|
@ -39,6 +44,7 @@ mkdir -p out
|
|||
COMPILE_CMD="emcc main.c $COMPILER_OPTIONS $EMSCRIPTEN_OPTIONS"
|
||||
echo $COMPILE_CMD
|
||||
$COMPILE_CMD
|
||||
mv $COMPILED_FILE $WASM_FILE || true
|
||||
|
||||
#merge compiled emscripten module and wrapper code
|
||||
cp $WRAPPER_SOURCE $OUT_FILE
|
||||
|
|
|
@ -3,6 +3,11 @@ var asm ?= ?createWasm\(\);
|
|||
*/
|
||||
var asm = null;
|
||||
|
||||
/* REPLACE
|
||||
var wasmExports ?= ?createWasm\(\);
|
||||
*/
|
||||
var wasmExports = null;
|
||||
|
||||
/* DELETE
|
||||
run\(\);\n\n
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue