Skip to content

Feat/add curl #78

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ WITH_LIBXML := no
WITH_LIBPNG := no
WITH_MBSTRING := yes
WITH_CLI_SAPI := no
WITH_OPENSSL := no
WITH_OPENSSL := yes
WITH_NODEFS := no
WITH_CURL := no
WITH_CURL := yes
WITH_SQLITE := no
WITH_MYSQL := no
WITH_WS_NETWORKING_PROXY := no
Expand All @@ -22,7 +22,7 @@ DIST_DIR := $(PWD)/dist
.PHONY: build-image build-wasm build build-all build-5.6 build-7.0 build-7.1 build-7.2 build-7.3 build-7.4 build-8.0 build-8.1 build-8.2
build-image:
cd src/wasm && \
docker build . --tag=$(PHP_IMAGE) \
DOCKER_BUILDKIT=0 docker build . --tag=$(PHP_IMAGE) \
--build-arg PHP_VERSION=$(PHP_VERSION) \
--build-arg WITH_VRZNO=$(WITH_VRZNO) \
--build-arg WITH_LIBXML=$(WITH_LIBXML) \
Expand All @@ -35,6 +35,7 @@ build-image:
--build-arg WITH_SQLITE=$(WITH_SQLITE) \
--build-arg WITH_MYSQL=$(WITH_MYSQL) \
--build-arg WITH_WS_NETWORKING_PROXY=$(WITH_WS_NETWORKING_PROXY) \
--build-arg WITH_CURL=$(WITH_CURL) \
--build-arg EMSCRIPTEN_ENVIRONMENT=$(PLATFORM) && \
cd -

Expand Down
30 changes: 30 additions & 0 deletions src/wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,29 @@ RUN source /root/emsdk/emsdk_env.sh && \
RUN source /root/emsdk/emsdk_env.sh && EMCC_SKIP="-lc -lz" EMCC_FLAGS="-sSIDE_MODULE" emmake make
RUN source /root/emsdk/emsdk_env.sh && emmake make install

FROM emscripten-openssl AS emscripten-curl
COPY --from=emscripten-libz /root/lib /root/lib-libz
RUN /root/copy-lib.sh lib-libz
RUN export CURL_VERSION="8_3_0" && \
wget https://github.com/curl/curl/archive/refs/tags/curl-${CURL_VERSION}.tar.gz && \
tar -xf curl-${CURL_VERSION}.tar.gz;
WORKDIR /root/curl-curl-8_3_0
# copy for include curl's headers
RUN cp -r include/curl /root/lib/include
RUN source /root/emsdk/emsdk_env.sh && \
autoreconf -fi && \
CPPFLAGS="-I/root/lib/include " \
LDFLAGS="-L/root/lib/lib " \
emconfigure ./configure \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
--build i386-pc-linux-gnu \
--target wasm32-unknown-emscripten \
--with-openssl \
--without-zlib \
--prefix=/root/lib/
RUN source /root/emsdk/emsdk_env.sh && EMCC_FLAGS="-sSIDE_MODULE" emmake make
RUN source /root/emsdk/emsdk_env.sh && emmake make install

# Clone PHP
FROM emscripten AS emscripten-php-src
ARG PHP_VERSION
Expand Down Expand Up @@ -292,6 +315,7 @@ ARG WITH_SQLITE
ARG WITH_MYSQL
ARG WITH_OPENSSL
ARG WITH_WS_NETWORKING_PROXY
ARG WITH_CURL

# The platform to build for: web or node
ARG EMSCRIPTEN_ENVIRONMENT=web
Expand Down Expand Up @@ -443,11 +467,17 @@ RUN if [ "$WITH_VRZNO" = "yes" ]; \
RUN if [ "$WITH_MYSQL" = "yes" ]; then \
echo -n ' --enable-mysql --enable-pdo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd ' >> /root/.php-configure-flags; \
fi
COPY --from=emscripten-curl /root/lib /root/lib-curl
RUN if [ "$WITH_CURL" = "yes" ]; then \
bash /root/copy-lib.sh lib-curl && \
echo -n ' --with-curl ' >> /root/.php-configure-flags; \
fi

# Build the patched PHP
WORKDIR /root/php-src
RUN source /root/emsdk/emsdk_env.sh && \
emconfigure ./configure \
CPPFLAGS="-I/root/lib/include " \
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed here.

checking curl_easy_perform, probably build option is missing? 🤔

PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
# Fibers are a PHP 8.1+ feature. They are compiled as
# a custom assembly implementation by default. However,
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/build-assets/php_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const char WASM_HARDCODED_INI[] =
"always_populate_raw_post_data = -1\n"
"upload_max_filesize = 2000M\n"
"post_max_size = 2000M\n"
"disable_functions = proc_open,popen,curl_exec,curl_multi_exec\n"
"disable_functions = proc_open,popen\n"
"allow_url_fopen = Off\n"
"allow_url_include = Off\n"
"session.save_path = /home/web_user\n"
Expand Down