Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl extension for the Node.js build of PHP.wasm #1273

Merged
merged 10 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/php-wasm/compile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ libzip/dist/1.9.2/root/lib/lib/libzip.a: base-image libz
libpng16: libpng16/dist/root/lib/lib/libpng16.a
libpng16/dist/root/lib/lib/libpng16.a: base-image libz
mkdir -p ./libpng16/dist/root/lib
docker build -f ./libpng16/Dockerfile -t playground-php-wasm:libpng .
docker build -f ./libpng16/Dockerfile -t playground-php-wasm:libpng .
docker cp $$(docker create playground-php-wasm:libpng):/root/install/lib ./libpng16/dist/root/lib
docker cp $$(docker create playground-php-wasm:libpng):/root/install/include ./libpng16/dist/root/lib

Expand Down Expand Up @@ -88,7 +88,21 @@ oniguruma/dist/root/lib/lib/libonig.a: base-image
docker cp $$(docker create playground-php-wasm:oniguruma):/root/lib/lib ./oniguruma/dist/root/lib/
docker cp $$(docker create playground-php-wasm:oniguruma):/root/lib/include ./oniguruma/dist/root/lib

all: libz libzip libpng16 libxml2 libopenssl libsqlite3 libiconv libncurses libedit bison2.7 oniguruma
libcurl: libcurl/dist/root/lib/lib/libcurl.a
libcurl/dist/root/lib/lib/libcurl.a: base-image libz libopenssl
mkdir -p ./libcurl/dist/root/lib
docker build -f ./libcurl/Dockerfile -t playground-php-wasm:libcurl . --progress=plain
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.69.1/lib/.libs ./libcurl/dist/root/lib/lib
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.69.1/include/ ./libcurl/dist/root/lib

libcurl7.15: libcurl7.15/dist/root/lib/lib/libcurl.a
libcurl7.15/dist/root/lib/lib/libcurl.a: base-image libz libopenssl
mkdir -p ./libcurl7.15/dist/root/lib
docker build -f ./libcurl7.15/Dockerfile -t playground-php-wasm:libcurl7.15 . --progress=plain
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.15.5/lib/.libs ./libcurl7.15/dist/root/lib/lib
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.15.5/include/ ./libcurl7.15/dist/root/lib

all: libz libzip libpng16 libxml2 libopenssl libsqlite3 libiconv libncurses libedit bison2.7 oniguruma libcurl libcurl7.15
clean:
rm -rf ./libz/dist
rm -rf ./libzip/dist
Expand Down
1 change: 1 addition & 0 deletions packages/php-wasm/compile/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const platformDefaults = {
WITH_OPENSSL: 'yes',
},
node: {
WITH_CURL: 'yes',
WITH_FILEINFO: 'yes',
WITH_ICONV: 'yes',
WITH_LIBXML: 'yes',
Expand Down
66 changes: 66 additions & 0 deletions packages/php-wasm/compile/libcurl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM playground-php-wasm:base

RUN mkdir -p /root/lib/include /root/lib/lib
COPY ./libz/dist/root/lib/include /root/lib/include
COPY ./libz/dist/root/lib/lib /root/lib/lib
COPY ./libopenssl/dist/root/lib/include /root/lib/include
COPY ./libopenssl/dist/root/lib/lib /root/lib/lib

ARG CURL_VERSION="curl-7.69.1"

RUN /root/copy-lib.sh lib-libz
RUN set -euxo pipefail && \
source /root/emsdk/emsdk_env.sh && \
wget https://curl.haxx.se/download/$CURL_VERSION.tar.gz && \
tar xf $CURL_VERSION.tar.gz

WORKDIR /root/$CURL_VERSION

RUN CPPFLAGS="-I/root/lib/include " \
LDFLAGS="-L/root/lib/lib " \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
source /root/emsdk/emsdk_env.sh && \
emconfigure ./configure \
--build i386-pc-linux-gnu \
--target wasm32-unknown-emscripten \
--prefix=/root/lib/ \
--disable-shared \
--enable-static \
--with-ssl \
--with-openssl=/root/lib \
--enable-https \
--enable-http \
--disable-pop3 \
--disable-imap \
--disable-smb \
--disable-smtp \
--disable-telnet \
--disable-gopher \
--disable-ftp \
--disable-ftps \
--disable-rtsp \
--disable-tftp \
--disable-pthreads \
--disable-threaded-resolver \
--with-zlib=/root/lib

RUN cp /root/emsdk/upstream/bin/wasm-ld /root/emsdk/upstream/bin/wasm-ld-original && \
echo $'#!/bin/bash\n\
if [[ " $@ " =~ " -o curl " ]]; then \n\
echo '' > /root/curl-7.69.1/src/curl; \n\
echo '' > /root/curl-7.69.1/curl; \n\
fi; \n\
/root/emsdk/upstream/bin/wasm-ld-original "$@" || true; \n\
exit 0; \n' > /root/emsdk/upstream/bin/wasm-ld && \
chmod a+x /root/emsdk/upstream/bin/wasm-ld


RUN source /root/emsdk/emsdk_env.sh && \
EMCC_SKIP="-lc -lz -lcurl -lssl " \
EMCC_FLAGS="-sSIDE_MODULE -Wl,--wrap=select " emmake make -i || true

RUN source /root/emsdk/emsdk_env.sh && \
EMCC_SKIP="-lc -lz -lcurl -lssl " \
EMCC_FLAGS="-sSIDE_MODULE -Wl,--wrap=select " emmake make install -i || true

RUN ls -R /root/lib
Loading
Loading