diff --git a/README.md b/README.md index ac9c981..f26369b 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,16 @@ git clone https://github.com/ading2210/libcurl.js --recursive cd libcurl.js/client ./build.sh ``` -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. +Make sure you have emscripten, git, and the various C build tools installed. The only OS supported for building libcurl.js is Linux. On Debian-based systems, you can run the following command to install all the dependencies: +``` +sudo apt install make cmake emscripten autoconf automake libtool pkg-config wget xxd +``` -You can supply the following arguments to the build script to control the build: +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: diff --git a/client/javascript/main.js b/client/javascript/main.js index 00fa80c..851fbdf 100644 --- a/client/javascript/main.js +++ b/client/javascript/main.js @@ -1,6 +1,10 @@ //everything is wrapped in a function to prevent emscripten from polluting the global scope window.libcurl = (function() { +if (typeof window === "undefined") { + throw new Error("NodeJS is not supported. This only works inside the browser."); +} + //emscripten compiled code is inserted here /* __emscripten_output__ */ diff --git a/client/tools/all_deps.sh b/client/tools/all_deps.sh index 13bd32e..d3b857c 100755 --- a/client/tools/all_deps.sh +++ b/client/tools/all_deps.sh @@ -2,6 +2,7 @@ #build all deps +set -e mkdir -p build OPENSSL_PREFIX=$(realpath build/openssl-wasm)