mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
support latest emscripten and detect emcc version changes
This commit is contained in:
parent
627fd15e4d
commit
b2df01fd18
7 changed files with 30 additions and 11 deletions
|
@ -52,10 +52,11 @@ git clone https://github.com/ading2210/libcurl.js --recursive
|
||||||
cd libcurl.js/client
|
cd libcurl.js/client
|
||||||
./build.sh
|
./build.sh
|
||||||
```
|
```
|
||||||
Make sure you have emscripten v3.1.6, 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:
|
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 jq
|
sudo apt install make cmake emscripten autoconf automake libtool pkg-config wget xxd jq
|
||||||
```
|
```
|
||||||
|
Emscripten versions 3.1.6 and 3.1.72 have been tested and known to work.
|
||||||
|
|
||||||
The build script will generate `client/out/libcurl.js` as well as `client/out/libcurl.mjs`, which is an ES6 module. 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.mjs`, which is an ES6 module. You can supply the following arguments to the build script to control the build:
|
||||||
- `release` - Use all optimizations.
|
- `release` - Use all optimizations.
|
||||||
|
|
|
@ -18,6 +18,16 @@ MODULE_FILE="$OUT_DIR/emscripten_compiled.js"
|
||||||
COMPILED_FILE="$OUT_DIR/emscripten_compiled.wasm"
|
COMPILED_FILE="$OUT_DIR/emscripten_compiled.wasm"
|
||||||
WASM_FILE="$OUT_DIR/libcurl.wasm"
|
WASM_FILE="$OUT_DIR/libcurl.wasm"
|
||||||
|
|
||||||
|
#check last used emscripten version
|
||||||
|
CURRENT_EMCC_VER="$(emcc --version)"
|
||||||
|
LAST_EMCC_VER="$(cat "$BUILD_DIR/emcc_version.txt" || emcc --version)"
|
||||||
|
if [ ! "$CURRENT_EMCC_VER" = "$LAST_EMCC_VER" ]; then
|
||||||
|
echo "triggering a full rebuild since we're on a different emcc version"
|
||||||
|
rm -rf "$BUILD_DIR"
|
||||||
|
mkdir -p "$BUILD_DIR"
|
||||||
|
fi
|
||||||
|
emcc --version > "$BUILD_DIR/emcc_version.txt"
|
||||||
|
|
||||||
#read exported functions
|
#read exported functions
|
||||||
EXPORTED_FUNCS=""
|
EXPORTED_FUNCS=""
|
||||||
for func in $(cat exported_funcs.txt); do
|
for func in $(cat exported_funcs.txt); do
|
||||||
|
|
|
@ -3,4 +3,12 @@ var ?opts ?= ?undefined;
|
||||||
*/
|
*/
|
||||||
var parts = addr.split("/");
|
var parts = addr.split("/");
|
||||||
if (!url.endsWith("/")) url += "/";
|
if (!url.endsWith("/")) url += "/";
|
||||||
url += parts[0] + ":" + port;
|
url += parts[0] + ":" + port;
|
||||||
|
|
||||||
|
/* REPLACE
|
||||||
|
url ?= ?SOCKFS\.websocketArgs\[['"]url['"]\];
|
||||||
|
*/
|
||||||
|
var parts = addr.split("/");
|
||||||
|
url = Module.websocket.url;
|
||||||
|
if (!url.endsWith("/")) url += "/";
|
||||||
|
url += parts[0] + ":" + port;
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/* REPLACE
|
/* REPLACE
|
||||||
var asm ?= ?createWasm\(\);
|
var asm ?= ?createWasm\(\);
|
||||||
*/
|
*/
|
||||||
if (isDataURI(wasmBinaryFile)) var asm = createWasm();
|
if (wasmBinaryFile && isDataURI(wasmBinaryFile)) var asm = createWasm();
|
||||||
else var asm = null;
|
else var asm = null;
|
||||||
|
|
||||||
/* REPLACE
|
/* REPLACE
|
||||||
var wasmExports ?= ?createWasm\(\);
|
var wasmExports ?= ?createWasm\(\);
|
||||||
*/
|
*/
|
||||||
if (isDataURI(wasmBinaryFile)) var wasmExports = createWasm();
|
if (wasmBinaryFile && isDataURI(wasmBinaryFile)) var wasmExports = createWasm();
|
||||||
else var wasmExports = null;
|
else var wasmExports = null;
|
||||||
|
|
||||||
/* REPLACE
|
/* REPLACE
|
||||||
run\(\);\n\n
|
run\(\);\n\n
|
||||||
*/
|
*/
|
||||||
if (isDataURI(wasmBinaryFile)) run();
|
if (wasmBinaryFile && isDataURI(wasmBinaryFile)) run();
|
|
@ -2,8 +2,3 @@
|
||||||
err\("__syscall_getsockname " ?\+ ?fd\);
|
err\("__syscall_getsockname " ?\+ ?fd\);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* INSERT
|
|
||||||
function _emscripten_console_error\(str\) ?{
|
|
||||||
*/
|
|
||||||
if (UTF8ToString(str).endsWith("__syscall_setsockopt\\n")) return;
|
|
|
@ -45,6 +45,8 @@ function set_websocket_url(url) {
|
||||||
websocket_url = url;
|
websocket_url = url;
|
||||||
if (typeof Module.websocket === "undefined")
|
if (typeof Module.websocket === "undefined")
|
||||||
Module.websocket = {};
|
Module.websocket = {};
|
||||||
|
if (typeof SOCKFS.websocketArgs !== "undefined")
|
||||||
|
SOCKFS.websocketArgs.url = url;
|
||||||
Module.websocket.url = url;
|
Module.websocket.url = url;
|
||||||
if (!main_session && wasm_ready) {
|
if (!main_session && wasm_ready) {
|
||||||
setup_main_session();
|
setup_main_session();
|
||||||
|
@ -101,7 +103,7 @@ function load_wasm(url) {
|
||||||
if (wasm_ready) return;
|
if (wasm_ready) return;
|
||||||
|
|
||||||
//skip this if we are running in single file mode
|
//skip this if we are running in single file mode
|
||||||
if (!isDataURI(wasmBinaryFile)) {
|
if (!wasmBinaryFile || !isDataURI(wasmBinaryFile)) {
|
||||||
wasmBinaryFile = url;
|
wasmBinaryFile = url;
|
||||||
createWasm();
|
createWasm();
|
||||||
run();
|
run();
|
||||||
|
|
|
@ -46,6 +46,9 @@ CURL* create_request(const char* url, int request_id, DataCallback data_callback
|
||||||
curl_easy_setopt(http_handle, CURLOPT_CAINFO_BLOB, cacert_blob);
|
curl_easy_setopt(http_handle, CURLOPT_CAINFO_BLOB, cacert_blob);
|
||||||
curl_easy_setopt(http_handle, CURLOPT_BUFFERSIZE, 512*1024);
|
curl_easy_setopt(http_handle, CURLOPT_BUFFERSIZE, 512*1024);
|
||||||
|
|
||||||
|
//emscripten doesn't support tcp nodelay anyways
|
||||||
|
curl_easy_setopt(http_handle, CURLOPT_TCP_NODELAY, 0L);
|
||||||
|
|
||||||
//callbacks to pass the response data back to js
|
//callbacks to pass the response data back to js
|
||||||
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, &write_function);
|
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, &write_function);
|
||||||
curl_easy_setopt(http_handle, CURLOPT_WRITEDATA, request_info);
|
curl_easy_setopt(http_handle, CURLOPT_WRITEDATA, request_info);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue