Skip to content

Commit ebfd486

Browse files
authored
[ php-wasm ] add intl extension (#2187)
1 parent d96ba60 commit ebfd486

File tree

539 files changed

+399467
-125189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

539 files changed

+399467
-125189
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,35 @@ jobs:
2626
test-unit-asyncify:
2727
runs-on: ubuntu-latest
2828
needs: [lint-and-typecheck]
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
include:
33+
- name: test-unit-asyncify (1/8)
34+
target: test-node
35+
- name: test-unit-asyncify (2/8)
36+
target: test-php
37+
- name: test-unit-asyncify (3/8)
38+
target: test-php-request-handler-files
39+
- name: test-unit-asyncify (4/8)
40+
target: test-php-request-handler-requests
41+
- name: test-unit-asyncify (5/8)
42+
target: test-php-asyncify-file-get-contents
43+
- name: test-unit-asyncify (6/8)
44+
target: test-php-asyncify-fopen
45+
- name: test-unit-asyncify (7/8)
46+
target: test-php-asyncify-fsockopen
47+
- name: test-unit-asyncify (8/8)
48+
target: test-php-asyncify-gethostbyname
49+
name: ${{ matrix.name }}
2950
steps:
3051
- uses: actions/checkout@v4
3152
with:
3253
submodules: true
3354
- uses: ./.github/actions/prepare-playground
3455
with:
3556
node-version: 22
36-
- run: node --expose-gc node_modules/nx/bin/nx affected --target=test --configuration=ci
57+
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }} --configuration=ci
3758
# Most of these tests pass locally but the process is crashing
3859
# on the CI runner.
3960
#
@@ -126,7 +147,7 @@ jobs:
126147
path: packages/playground/website/playwright/e2e/deployment.spec.ts-snapshots/
127148
if-no-files-found: ignore
128149
- name: Delete playwright-dist artifact
129-
uses: geekyeggo/delete-artifact@v2
150+
uses: geekyeggo/delete-artifact@v5
130151
with:
131152
name: playwright-dist
132153

packages/php-wasm/compile/Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,26 @@ libcurl/jspi/dist/root/lib/lib/libcurl.a: base-image libz libopenssl
235235
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.69.1/lib/.libs ./libcurl/jspi/dist/root/lib/lib
236236
docker cp $$(docker create playground-php-wasm:libcurl):/root/curl-7.69.1/include/ ./libcurl/jspi/dist/root/lib
237237

238+
libintl_asyncify: libintl/asyncify/dist/root/lib/lib/libintl.a
239+
libintl/asyncify/dist/root/lib/lib/libintl.a: base-image
240+
mkdir -p ./libintl/asyncify/dist/root/lib
241+
docker build -f ./libintl/Dockerfile -t playground-php-wasm:libintl . --progress=plain
242+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/lib ./libintl/asyncify/dist/root/lib
243+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/include ./libintl/asyncify/dist/root/lib
244+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/data/. ./libintl/
245+
246+
247+
libintl_jspi: libintl/jspi/dist/root/lib/lib/libintl.a
248+
libintl/jspi/dist/root/lib/lib/libintl.a: base-image
249+
mkdir -p ./libintl/jspi/dist/root/lib
250+
docker build -f ./libintl/Dockerfile -t playground-php-wasm:libintl . --progress=plain --build-arg JSPI=1
251+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/lib ./libintl/jspi/dist/root/lib
252+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/include ./libintl/jspi/dist/root/lib
253+
docker cp $$(docker create playground-php-wasm:libintl):/root/lib/data/. ./libintl/
254+
238255
all: all_jspi all_asyncify
239-
all_jspi: libz_jspi libzip_jspi libpng16_jspi libjpeg_jspi libwebp_jspi libxml2_jspi libopenssl_jspi libsqlite3_jspi libiconv_jspi bison2.7 oniguruma_jspi libcurl_jspi
240-
all_asyncify: libz_asyncify libzip_asyncify libpng16_asyncify libjpeg_asyncify libwebp_asyncify libxml2_asyncify libopenssl_asyncify libsqlite3_asyncify libiconv_asyncify bison2.7 oniguruma_asyncify libcurl_asyncify
256+
all_jspi: libz_jspi libzip_jspi libpng16_jspi libjpeg_jspi libwebp_jspi libxml2_jspi libopenssl_jspi libsqlite3_jspi libiconv_jspi bison2.7 oniguruma_jspi libcurl_jspi libintl_jspi
257+
all_asyncify: libz_asyncify libzip_asyncify libpng16_asyncify libjpeg_asyncify libwebp_asyncify libxml2_asyncify libopenssl_asyncify libsqlite3_asyncify libiconv_asyncify bison2.7 oniguruma_asyncify libcurl_asyncify libintl_asyncify
241258

242259
clean:
243260
rm -rf ./libz/jspi/dist
@@ -261,3 +278,5 @@ clean:
261278
rm -rf ./bison2.7/dist
262279
rm -rf ./oniguruma/jspi/dist
263280
rm -rf ./oniguruma/asyncify/dist
281+
rm -rf ./libintl/jspi/dist
282+
rm -rf ./libintl/asyncify/dist

packages/php-wasm/compile/build.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ const argParser = yargs(process.argv.slice(2))
6161
choices: ['yes', 'no'],
6262
description: 'Build with mbregex support',
6363
},
64+
WITH_INTL: {
65+
type: 'string',
66+
choices: ['yes', 'no'],
67+
description: 'Build with intl support',
68+
},
6469
WITH_CLI_SAPI: {
6570
type: 'string',
6671
choices: ['yes', 'no'],
@@ -139,6 +144,7 @@ const platformDefaults = {
139144
WITH_GD: 'yes',
140145
WITH_MBSTRING: 'yes',
141146
WITH_MBREGEX: 'yes',
147+
WITH_INTL: 'yes',
142148
WITH_OPENSSL: 'yes',
143149
WITH_WS_NETWORKING_PROXY: 'yes',
144150
},
@@ -205,6 +211,8 @@ await asyncSpawn(
205211
'--build-arg',
206212
getArg('WITH_MBREGEX'),
207213
'--build-arg',
214+
getArg('WITH_INTL'),
215+
'--build-arg',
208216
getArg('WITH_CLI_SAPI'),
209217
'--build-arg',
210218
getArg('WITH_OPENSSL'),
@@ -256,6 +264,20 @@ await asyncSpawn(
256264
{ cwd: sourceDir, stdio: 'inherit' }
257265
);
258266

267+
// Copy data files
268+
const libDir = path.resolve(process.cwd(), 'packages/php-wasm/compile');
269+
const publicDir =
270+
platform === 'node'
271+
? `${path.dirname(outputDir)}/src/lib/data`
272+
: `${path.dirname(path.dirname(outputDir))}`;
273+
if (getArg('WITH_INTL').endsWith('yes')) {
274+
await asyncSpawn(
275+
'cp',
276+
[`${libDir}/libintl/icudt74l.dat`, `${publicDir}/shared/icudt74l.dat`],
277+
{ cwd: sourceDir, stdio: 'inherit' }
278+
);
279+
}
280+
259281
const _args = args;
260282

261283
function asyncSpawn(...args) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM playground-php-wasm:base
2+
3+
4+
ARG JSPI
5+
6+
7+
RUN set -euxo pipefail && \
8+
wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-src.tgz && \
9+
tar -xvf icu4c-74_2-src.tgz && \
10+
rm -rf /root/icu/source/data/ && \
11+
rm icu4c-74_2-src.tgz
12+
13+
14+
RUN set -euxo pipefail && \
15+
wget https://github.com/unicode-org/icu/releases/download/release-74-2/icu4c-74_2-data.zip && \
16+
unzip icu4c-74_2-data.zip -d /root/icu/source && \
17+
rm icu4c-74_2-data.zip
18+
19+
20+
RUN set -euxo pipefail && \
21+
mkdir -p /root/native && \
22+
cd /root/native && \
23+
/root/icu/source/runConfigureICU Linux \
24+
--disable-shared \
25+
--enable-static && \
26+
make -j"$(nproc)" && \
27+
make install
28+
29+
30+
RUN set -euxo pipefail && \
31+
cd /root/icu/source && \
32+
mkdir -p /root/lib && \
33+
source /root/emsdk/emsdk_env.sh && \
34+
emconfigure ./configure \
35+
--build=i386-pc-linux-gnu \
36+
--target=wasm32-unknown-emscripten \
37+
--prefix=/root/lib \
38+
--with-cross-build=/root/native \
39+
--with-data-packaging=archive \
40+
--disable-extras \
41+
--disable-shared \
42+
--enable-static && \
43+
export JSPI_FLAGS=$(if [ "$JSPI" = "1" ]; then echo "-sSUPPORT_LONGJMP=wasm -fwasm-exceptions"; else echo ""; fi) && \
44+
EMCC_FLAGS=" -sSIDE_MODULE $JSPI_FLAGS " emmake make -j"$(nproc)" && \
45+
EMCC_FLAGS=" -sSIDE_MODULE $JSPI_FLAGS " emmake make install -i;
46+
47+
48+
RUN set -euxo pipefail && \
49+
mkdir -p /root/lib/data && \
50+
mv /root/lib/share/icu/74.2/icudt74l.dat /root/lib/data

0 commit comments

Comments
 (0)