From a67492c0796462d3a8228f37a757347fbfe5f444 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Tue, 4 Jul 2023 09:00:17 +0300 Subject: [PATCH 01/12] chore: Improved scripts logging --- scripts/wlr-build.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/wlr-build.sh b/scripts/wlr-build.sh index 493b1d6d..7cd4b5bb 100755 --- a/scripts/wlr-build.sh +++ b/scripts/wlr-build.sh @@ -46,10 +46,6 @@ function logStatus { export -f logStatus -for line in $(env | grep -E "WLR_\w+="); do - logStatus $line -done - logStatus WASI_SDK_PATH=${WASI_SDK_PATH} logStatus WASI_SDK_ASSET_NAME=${WASI_SDK_ASSET_NAME} logStatus BINARYEN_PATH=${BINARYEN_PATH} @@ -86,5 +82,10 @@ fi source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_package.sh +logStatus "Building with environment:" +for line in $(env | grep -E "WLR_\w+=" | sort); do + logStatus $line +done + logStatus "Building..." source ${WLR_ENV}/wlr-build.sh From b729f5bb2e1e99491ba034084f3af8ca290a1315 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Tue, 4 Jul 2023 08:57:19 +0300 Subject: [PATCH 02/12] chore: php 8.2.0 build scripts more readable --- php/php-8.2.0-slim/wlr-build.sh | 24 +++++++++++++++++++++--- php/php-8.2.0/wlr-build.sh | 16 +++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/php/php-8.2.0-slim/wlr-build.sh b/php/php-8.2.0-slim/wlr-build.sh index e6ee0a38..ab72d93d 100644 --- a/php/php-8.2.0-slim/wlr-build.sh +++ b/php/php-8.2.0-slim/wlr-build.sh @@ -32,7 +32,25 @@ if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then logStatus "Generating configure script..." ./buildconf --force || exit 1 - export PHP_CONFIGURE='--disable-all --without-libxml --disable-dom --without-iconv --without-openssl --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --disable-phar --disable-opcache --disable-zend-signals --without-pcre-jit --without-sqlite3 --disable-pdo --without-pdo-sqlite --disable-fiber-asm' + export PHP_CONFIGURE='' + PHP_CONFIGURE+=' --disable-all' + PHP_CONFIGURE+=' --without-libxml' + PHP_CONFIGURE+=' --disable-dom' + PHP_CONFIGURE+=' --without-iconv' + PHP_CONFIGURE+=' --without-openssl' + PHP_CONFIGURE+=' --disable-simplexml' + PHP_CONFIGURE+=' --disable-xml' + PHP_CONFIGURE+=' --disable-xmlreader' + PHP_CONFIGURE+=' --disable-xmlwriter' + PHP_CONFIGURE+=' --without-pear' + PHP_CONFIGURE+=' --disable-phar' + PHP_CONFIGURE+=' --disable-opcache' + PHP_CONFIGURE+=' --disable-zend-signals' + PHP_CONFIGURE+=' --without-pcre-jit' + PHP_CONFIGURE+=' --without-sqlite3' + PHP_CONFIGURE+=' --disable-pdo' + PHP_CONFIGURE+=' --without-pdo-sqlite' + PHP_CONFIGURE+=' --disable-fiber-asm' if [[ -v WLR_RUNTIME ]] then @@ -67,12 +85,12 @@ logStatus "Preparing artifacts..." mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 logStatus "Running wasm-opt with the asyncify pass on php-cgi..." -wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php-cgi${WLR_RUNTIME:+-$WLR_RUNTIME}.wasm sapi/cgi/php-cgi || exit 1 +wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php-cgi${WLR_RUNTIME:+-$WLR_RUNTIME}-slim.wasm sapi/cgi/php-cgi || exit 1 if [[ "${WLR_RUNTIME}" == "wasmedge" ]] then logStatus "Running wasm-opt with the asyncify pass on php..." - wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php${WLR_RUNTIME:+-$WLR_RUNTIME}.wasm sapi/cli/php || exit 1 + wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php${WLR_RUNTIME:+-$WLR_RUNTIME}-slim.wasm sapi/cli/php || exit 1 fi logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/php/php-8.2.0/wlr-build.sh b/php/php-8.2.0/wlr-build.sh index 2e3c9933..f690b0d4 100644 --- a/php/php-8.2.0/wlr-build.sh +++ b/php/php-8.2.0/wlr-build.sh @@ -35,7 +35,21 @@ if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then ./buildconf --force || exit 1 fi - export PHP_CONFIGURE='--without-iconv --without-openssl --without-pear --disable-phar --disable-opcache --disable-zend-signals --without-pcre-jit --with-sqlite3 --enable-pdo --with-pdo-sqlite --enable-mbstring --enable-gd --disable-fiber-asm --with-jpeg' + export PHP_CONFIGURE='' + PHP_CONFIGURE+=' --without-iconv' + PHP_CONFIGURE+=' --without-openssl' + PHP_CONFIGURE+=' --without-pear' + PHP_CONFIGURE+=' --disable-phar' + PHP_CONFIGURE+=' --disable-opcache' + PHP_CONFIGURE+=' --disable-zend-signals' + PHP_CONFIGURE+=' --without-pcre-jit' + PHP_CONFIGURE+=' --with-sqlite3' + PHP_CONFIGURE+=' --enable-pdo' + PHP_CONFIGURE+=' --with-pdo-sqlite' + PHP_CONFIGURE+=' --enable-mbstring' + PHP_CONFIGURE+=' --enable-gd' + PHP_CONFIGURE+=' --disable-fiber-asm' + PHP_CONFIGURE+=' --with-jpeg' if [[ "${WLR_BUILD_FLAVOR}" == *"wasmedge"* ]] then From 111bdc6f150727e6cf7f1344f642a8d7b106ce96 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Fri, 30 Jun 2023 15:56:58 +0300 Subject: [PATCH 03/12] feat: slim flavors and php 8.2.6 --- .github/workflows/release-php.yaml | 20 +++------ Makefile | 5 +++ php/php-8.2.6/wlr-build.sh | 53 ++++++++++++++++++++--- php/php-8.2.6/wlr-info.json | 7 ++- scripts/build-helpers/wlr_dependencies.sh | 17 +++++--- scripts/wlr-build.sh | 2 +- 6 files changed, 79 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release-php.yaml b/.github/workflows/release-php.yaml index 2e994652..23856e0e 100644 --- a/.github/workflows/release-php.yaml +++ b/.github/workflows/release-php.yaml @@ -20,33 +20,27 @@ jobs: # on all versions. include: - name: php- - suffix: "" flavor: "" build-php-cli: false version: 8.1.11 - name: php- - suffix: "" flavor: "" build-php-cli: false version: 8.2.0 - name: wasmedge-php- - suffix: "-wasmedge" - flavor: "" + flavor: "-wasmedge" build-php-cli: true version: 8.2.0 - name: php- - suffix: "" flavor: -slim build-php-cli: false version: 8.2.0 - name: php- - suffix: "" flavor: "" build-php-cli: false version: 8.2.6 - name: wasmedge-php- - suffix: "-wasmedge" - flavor: "" + flavor: "-wasmedge" build-php-cli: true version: 8.2.6 runs-on: ubuntu-latest @@ -73,7 +67,7 @@ jobs: if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) shell: bash run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}}.wasm + sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - name: Rename CLI release artifacts # Only run for the PHP version specified in the git tag. # @@ -82,7 +76,7 @@ jobs: if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) && matrix.build-php-cli }} shell: bash run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}}.wasm + sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - name: Create release # Only run for the PHP version specified in the git tag. # @@ -103,7 +97,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release upload ${{ github.ref_name }} \ - build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/*.wasm + build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.wasm - name: Generate release assets digests # Only run for the PHP version specified in the git tag. # @@ -113,7 +107,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - for asset in build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/*.wasm; do + for asset in build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.wasm; do sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null done - name: Append release assets digests @@ -126,4 +120,4 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release upload ${{ github.ref_name }} \ - build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/*.sha256sum + build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.sha256sum diff --git a/Makefile b/Makefile index 8420a0de..018ca356 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,11 @@ include Makefile.helpers php/php-*: make -C php $(subst php/php-,php-,$@) +.PHONY: php/php-8.2.6-slim +php/php-8.2.6-slim: + WLR_BUILD_FLAVOR=slim \ + make -C php php-8.2.6 + .PHONY: php/wasmedge-php-8.2.0 php/wasmedge-php-8.2.0: WLR_BUILD_FLAVOR=wasmedge \ diff --git a/php/php-8.2.6/wlr-build.sh b/php/php-8.2.6/wlr-build.sh index f39bac07..9509c0b4 100644 --- a/php/php-8.2.6/wlr-build.sh +++ b/php/php-8.2.6/wlr-build.sh @@ -15,7 +15,12 @@ export CFLAGS_WASI="--sysroot=${WASI_SYSROOT} -D_WASI_EMULATED_GETPID -D_WASI_EM export LDFLAGS_WASI="--sysroot=${WASI_SYSROOT} -lwasi-emulated-getpid -lwasi-emulated-signal -lwasi-emulated-process-clocks" ########## Setup the flags for php ############# -export CFLAGS_PHP='-D_POSIX_SOURCE=1 -D_GNU_SOURCE=1 -DHAVE_FORK=0 -DPNG_USER_CONFIG -DWASM_WASI' +export CFLAGS_PHP='-D_POSIX_SOURCE=1 -D_GNU_SOURCE=1 -DHAVE_FORK=0 -DWASM_WASI' + +if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]] +then + CFLAGS_PHP+=' -DPNG_USER_CONFIG' +fi export LDFLAGS_WARNINGS='-Wno-unused-command-line-argument -Werror=implicit-function-declaration -Wno-incompatible-function-pointer-types' @@ -33,16 +38,54 @@ if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then logStatus "Generating configure script..." ./buildconf --force || exit 1 - export PHP_CONFIGURE='--without-iconv --without-openssl --without-pear --disable-phar --disable-opcache --disable-zend-signals --without-pcre-jit --with-sqlite3 --enable-pdo --with-pdo-sqlite --enable-mbstring --enable-gd --disable-fiber-asm --with-jpeg' + export PHP_CONFIGURE='' + PHP_CONFIGURE+=' --without-iconv' + PHP_CONFIGURE+=' --without-openssl' + PHP_CONFIGURE+=' --without-pear' + PHP_CONFIGURE+=' --disable-phar' + PHP_CONFIGURE+=' --disable-opcache' + PHP_CONFIGURE+=' --disable-zend-signals' + PHP_CONFIGURE+=' --without-pcre-jit' + PHP_CONFIGURE+=' --disable-fiber-asm' + + if [[ "${WLR_BUILD_FLAVOR}" == *"slim"* ]] + then + PHP_CONFIGURE+=' --disable-all' + PHP_CONFIGURE+=' --without-libxml' + PHP_CONFIGURE+=' --disable-dom' + PHP_CONFIGURE+=' --disable-simplexml' + PHP_CONFIGURE+=' --disable-xml' + PHP_CONFIGURE+=' --disable-xmlreader' + PHP_CONFIGURE+=' --disable-xmlwriter' + PHP_CONFIGURE+=' --without-sqlite3' + PHP_CONFIGURE+=' --disable-pdo' + PHP_CONFIGURE+=' --without-pdo-sqlite' + else + PHP_CONFIGURE+=' --with-sqlite3' + PHP_CONFIGURE+=' --enable-pdo' + PHP_CONFIGURE+=' --with-pdo-sqlite' + PHP_CONFIGURE+=' --enable-mbstring' + PHP_CONFIGURE+=' --enable-gd' + PHP_CONFIGURE+=' --with-jpeg' + fi if [[ "${WLR_BUILD_FLAVOR}" == *"wasmedge"* ]] then - export PHP_CONFIGURE="${PHP_CONFIGURE} --enable-mysqlnd --with-pdo-mysql --with-mysqli" - export PHP_CONFIGURE="--with-wasm-runtime=wasmedge ${PHP_CONFIGURE}" + PHP_CONFIGURE+=' --enable-mysqlnd' + PHP_CONFIGURE+=' --with-pdo-mysql' + PHP_CONFIGURE+=' --with-mysqli' + + PHP_CONFIGURE="--with-wasm-runtime=wasmedge ${PHP_CONFIGURE}" fi logStatus "Configuring build with '${PHP_CONFIGURE}'... " - ./configure --config-cache --host=wasm32-wasi host_alias=wasm32-musl-wasi --target=wasm32-wasi target_alias=wasm32-musl-wasi ${PHP_CONFIGURE} || exit 1 + ./configure \ + --config-cache \ + --host=wasm32-wasi \ + host_alias=wasm32-musl-wasi \ + --target=wasm32-wasi \ + target_alias=wasm32-musl-wasi \ + ${PHP_CONFIGURE} || exit 1 else logStatus "Skipping configure..." fi diff --git a/php/php-8.2.6/wlr-info.json b/php/php-8.2.6/wlr-info.json index a49780b7..af13ee16 100644 --- a/php/php-8.2.6/wlr-info.json +++ b/php/php-8.2.6/wlr-info.json @@ -30,7 +30,7 @@ "required_file": "lib/wasm32-wasi/libonig.a", "url": "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/libs%2Foniguruma%2F6.9.8%2B20230623-2993864/libonig-6.9.8-wasi-sdk-20.0.tar.gz" }, - "SQLite": { + "SQLite": { "build_target": "libs/sqlite/v3.42.0", "required_file": "lib/wasm32-wasi/libsqlite3.a", "url": "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/libs%2Fsqlite%2F3.42.0%2B20230623-2993864/libsqlite-3.42.0-wasi-sdk-20.0.tar.gz" @@ -40,5 +40,10 @@ "required_file": "lib/wasm32-wasi/libbz2.a", "url": "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/libs%2Fbzip2%2F1.0.8%2B20230623-2993864/libbzip2-1.0.8-wasi-sdk-20.0.tar.gz" } + }, + "flavors": { + "slim": { + "deps": {} + } } } \ No newline at end of file diff --git a/scripts/build-helpers/wlr_dependencies.sh b/scripts/build-helpers/wlr_dependencies.sh index b218d769..2f5c130d 100644 --- a/scripts/build-helpers/wlr_dependencies.sh +++ b/scripts/build-helpers/wlr_dependencies.sh @@ -58,19 +58,26 @@ function wlr_dependencies_add { fi } -function wlr_dependencies_import { +function wlr_dependencies_load { local _DEPS_FILE=$1 + if [[ ! -z "$2" ]]; then + local _BLD_FLAVOR=$2 + fi if [ ! -f "${_DEPS_FILE}" ]; then echo "Missing dependencies file '${_DEPS_FILE}'" exit 1 fi - for dependency in $(jq '.deps | keys | join(" ")' -r $_DEPS_FILE); do + if [[ -v _BLD_FLAVOR ]] && jq -e ".flavors | has(\"${_BLD_FLAVOR}\")" ${_DEPS_FILE}; then + local _JSON_ROOT_PATH=".flavors.\"${_BLD_FLAVOR}\"" + fi + + for dependency in $(jq "${_JSON_ROOT_PATH}.deps | keys | join(\" \")" -r ${_DEPS_FILE} 2>/dev/null); do local _NAME=$dependency - local _BUILD_TARGET=$(jq ".deps.${_NAME}.build_target" -r $_DEPS_FILE) - local _REQUIRED_FILE=$(jq ".deps.${_NAME}.required_file" -r $_DEPS_FILE) - local _URL=$(jq ".deps.${_NAME}.url" -r $_DEPS_FILE) + local _BUILD_TARGET=$(jq "${_JSON_ROOT_PATH}.deps.\"${_NAME}\".build_target" -r ${_DEPS_FILE}) + local _REQUIRED_FILE=$(jq "${_JSON_ROOT_PATH}.deps.\"${_NAME}\".required_file" -r $_DEPS_FILE) + local _URL=$(jq "${_JSON_ROOT_PATH}.deps.\"${_NAME}\".url" -r ${_DEPS_FILE}) if [ "${_URL}" = "null" ]; then unset _URL diff --git a/scripts/wlr-build.sh b/scripts/wlr-build.sh index 7cd4b5bb..71a8c8be 100755 --- a/scripts/wlr-build.sh +++ b/scripts/wlr-build.sh @@ -77,7 +77,7 @@ logStatus "Checking dependencies..." if [[ -f ${WLR_ENV}/wlr-info.json ]] then source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_dependencies.sh - wlr_dependencies_import ${WLR_ENV}/wlr-info.json + wlr_dependencies_load ${WLR_ENV}/wlr-info.json "${WLR_BUILD_FLAVOR}" fi source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_package.sh From 6e7abb0007784b6b5bbf9a0da36eb3ad41e6f546 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Tue, 4 Jul 2023 14:56:34 +0300 Subject: [PATCH 04/12] chore: Simplify PHP GH actions --- .github/workflows/build-php.yaml | 46 +++++++++++------------------- .github/workflows/release-php.yaml | 23 +++++++-------- Makefile | 6 ++-- 3 files changed, 30 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-php.yaml b/.github/workflows/build-php.yaml index 628a5680..fdc53477 100644 --- a/.github/workflows/build-php.yaml +++ b/.github/workflows/build-php.yaml @@ -18,61 +18,49 @@ jobs: # make the PHP CLI conditionally compile local server code out # on all versions. include: - - name: php- - suffix: "" - flavor: "" + - flavor: "" build-php-cli: false version: 8.1.11 - - name: php- - suffix: "" - flavor: "" + - flavor: "" build-php-cli: false version: 8.2.0 - - name: wasmedge-php- - suffix: "-wasmedge" - flavor: "" - build-php-cli: false + - flavor: "-wasmedge" + build-php-cli: true version: 8.2.0 - - name: php- - suffix: "" - flavor: -slim + - flavor: -slim build-php-cli: false version: 8.2.0 - - name: php- - suffix: "" - flavor: "" + - flavor: "" build-php-cli: false version: 8.2.6 - - name: wasmedge-php- - suffix: "-wasmedge" - flavor: "" - build-php-cli: false + - flavor: "-wasmedge" + build-php-cli: true version: 8.2.6 runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Build PHP - run: make php/${{ matrix.name }}${{ matrix.version }}${{ matrix.flavor }} + run: make php/php-${{ matrix.version }}${{ matrix.flavor }} - name: Rename `php-cgi.wasm` binary (adding version and flavor) shell: bash run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}}.wasm + sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - name: Rename `php.wasm` binary (CLI) (adding version and flavor) shell: bash if: ${{ matrix.build-php-cli }} run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}}.wasm - - name: Upload php-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm artifact + sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm + - name: Upload php-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact uses: actions/upload-artifact@v3 if: ${{ matrix.build-php-cli }} with: - name: php-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm - path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm + name: php-${{ matrix.version }}${{ matrix.flavor }}.wasm + path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-${{ matrix.version }}${{ matrix.flavor }}.wasm if-no-files-found: error - - name: Upload php-cgi-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm artifact + - name: Upload php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact uses: actions/upload-artifact@v3 with: - name: php-cgi-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm artifact - path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}${{ matrix.suffix }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}${{ matrix.flavor }}.wasm + name: php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact + path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm if-no-files-found: error diff --git a/.github/workflows/release-php.yaml b/.github/workflows/release-php.yaml index 23856e0e..1dab4422 100644 --- a/.github/workflows/release-php.yaml +++ b/.github/workflows/release-php.yaml @@ -19,30 +19,27 @@ jobs: # make the PHP CLI conditionally compile local server code out # on all versions. include: - - name: php- - flavor: "" + - flavor: "" build-php-cli: false version: 8.1.11 - - name: php- - flavor: "" + - flavor: "" build-php-cli: false version: 8.2.0 - - name: wasmedge-php- - flavor: "-wasmedge" + - flavor: "-wasmedge" build-php-cli: true version: 8.2.0 - - name: php- - flavor: -slim + - flavor: -slim build-php-cli: false version: 8.2.0 - - name: php- - flavor: "" + - flavor: "" build-php-cli: false version: 8.2.6 - - name: wasmedge-php- - flavor: "-wasmedge" + - flavor: "-wasmedge" build-php-cli: true version: 8.2.6 + - flavor: "-slim" + build-php-cli: false + version: 8.2.6 runs-on: ubuntu-latest steps: - name: Checkout repository @@ -58,7 +55,7 @@ jobs: # This if could be moved to the parent `job` section when it's # supported by GitHub (https://github.com/community/community/discussions/37883) if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) - run: make php/${{ matrix.name }}${{ matrix.version }}${{ matrix.flavor }} + run: make php/php-${{ matrix.version }}${{ matrix.flavor }} - name: Rename CGI release artifacts # Only run for the PHP version specified in the git tag. # diff --git a/Makefile b/Makefile index 018ca356..e5f7d846 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,12 @@ php/php-8.2.6-slim: make -C php php-8.2.6 .PHONY: php/wasmedge-php-8.2.0 -php/wasmedge-php-8.2.0: +php/php-8.2.0-wasmedge: WLR_BUILD_FLAVOR=wasmedge \ make -C php php-8.2.0 -.PHONY: php/wasmedge-php-8.2.6 -php/wasmedge-php-8.2.6: +.PHONY: php/php-8.2.6-wasmedge +php/php-8.2.6-wasmedge: WLR_BUILD_FLAVOR=wasmedge \ make -C php php-8.2.6 From 6bac6407a4764e320c28b01cad14e42d472a2fea Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Fri, 7 Jul 2023 17:11:01 +0300 Subject: [PATCH 05/12] feat: Simplified flavor targets. Implemented for Ruby --- Makefile | 3 ++ Makefile.helpers | 36 +++++++++++++ ruby/v3_2_0-slim/wlr-build.sh | 45 ---------------- ruby/v3_2_0-slim/wlr-env-repo.sh | 18 ------- ruby/v3_2_0-slim/wlr-tag.sh | 1 - ruby/v3_2_0/wlr-build.sh | 78 +++++++++++++++++++++------ ruby/v3_2_2/wlr-build.sh | 73 +++++++++++++++++++------ scripts/build-helpers/wlr_wasi_vfs.sh | 4 ++ 8 files changed, 160 insertions(+), 98 deletions(-) delete mode 100644 ruby/v3_2_0-slim/wlr-build.sh delete mode 100644 ruby/v3_2_0-slim/wlr-env-repo.sh delete mode 100644 ruby/v3_2_0-slim/wlr-tag.sh diff --git a/Makefile b/Makefile index e5f7d846..46e27ce4 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,9 @@ php/master: ruby/v*: make -C ruby $(subst ruby/,,$@) +$(eval $(call create_flavor_targets,ruby,v3_2_0,slim)) +$(eval $(call create_flavor_targets,ruby,v3_2_2,slim)) + .PHONY: python/v* python/v*: make -C python $(subst python/,,$@) diff --git a/Makefile.helpers b/Makefile.helpers index 2d6f4281..f9dc2264 100644 --- a/Makefile.helpers +++ b/Makefile.helpers @@ -150,3 +150,39 @@ clean: rm -rf $(1)/build-output/$(2) $(1)/build-staging/$(2) endef + + + +########## +# Creates a flavor target for given runtime+version that is built from this repo. +# +# USAGE: +# - At Makefile root level (not as part of a target) +# - $(eval $(call create_flavor_target,php,php-1.2.3,slim)) +# +define create_flavor_target +# $1 - TARGET_NAME +# $2 - TARGET_VERSION +# $3 - TARGET_FLAVOR + +.PHONY: $(1)/$(2)-$(3) +$(1)/$(2)-$(3): + WLR_BUILD_FLAVOR=$(3) make -C $(1) $(2) +endef + + + +########## +# Creates target for all given flavors or given runtime+version that is built from this repo. +# +# USAGE: +# - At Makefile root level (not as part of a target) +# - $(call create_flavor_targets,php,php-1.2.3,slim wasmedge slim-wasmedge) +# +define create_flavor_targets +# $1 - TARGET_NAME +# $2 - TARGET_VERSION +# $3 - TARGET_FLAVORS - separated by space + +$(foreach _,${3},$(eval $(call create_flavor_target,${1},${2},$_))) +endef diff --git a/ruby/v3_2_0-slim/wlr-build.sh b/ruby/v3_2_0-slim/wlr-build.sh deleted file mode 100644 index f92a361a..00000000 --- a/ruby/v3_2_0-slim/wlr-build.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -v WLR_ENV ]] -then - echo "WLR build environment is not set" - exit 1 -fi - -cd "${WLR_SOURCE_PATH}" - -export PREFIX=/wlr-rubies - -if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then - logStatus "Downloading autotools data... " - ruby tool/downloader.rb -d tool -e gnu config.guess config.sub - - logStatus "Generating configure script... " - ./autogen.sh - - logStatus "Configuring ruby..." - ./configure \ - --host wasm32-unknown-wasi \ - --prefix=$PREFIX \ - --with-ext="" \ - --with-static-linked-ext \ - --disable-install-doc \ - LDFLAGS=" \ - -Xlinker --stack-first \ - -Xlinker -z -Xlinker stack-size=16777216 \ - " \ - optflags="-O2" \ - debugflags="" \ - wasmoptflags="-O2" -else - logStatus "Skipping configure..." -fi - -logStatus "Building ruby..." -make install - -logStatus "Preparing artifacts... " -mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 -mv $PREFIX/bin/ruby ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 - -logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/ruby/v3_2_0-slim/wlr-env-repo.sh b/ruby/v3_2_0-slim/wlr-env-repo.sh deleted file mode 100644 index 9d82d163..00000000 --- a/ruby/v3_2_0-slim/wlr-env-repo.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -if [[ $1 == "--unset" ]] -then - unset WLR_REPO - unset WLR_REPO_BRANCH - unset WLR_ENV_NAME - unset WLR_PACKAGE_VERSION - unset WLR_PACKAGE_NAME - return -fi - -export WLR_REPO=https://github.com/ruby/ruby.git -export WLR_REPO_BRANCH=v3_2_0 -export WLR_ENV_NAME=ruby/v3_2_0 -export WLR_PACKAGE_VERSION=3.2.0 -export WLR_PACKAGE_NAME=ruby -export WLR_BUILD_FLAVOR=${WLR_BUILD_FLAVOR:+-}slim diff --git a/ruby/v3_2_0-slim/wlr-tag.sh b/ruby/v3_2_0-slim/wlr-tag.sh deleted file mode 100644 index 10e3b4a6..00000000 --- a/ruby/v3_2_0-slim/wlr-tag.sh +++ /dev/null @@ -1 +0,0 @@ -export WLR_TAG="ruby/3.2.0" diff --git a/ruby/v3_2_0/wlr-build.sh b/ruby/v3_2_0/wlr-build.sh index 51475fbe..71d6bbc9 100644 --- a/ruby/v3_2_0/wlr-build.sh +++ b/ruby/v3_2_0/wlr-build.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -if [[ ! -v WLR_ENV ]] -then +if [[ ! -v WLR_ENV ]]; then echo "WLR build environment is not set" exit 1 fi @@ -9,40 +8,85 @@ fi cd "${WLR_SOURCE_PATH}" export PREFIX=/wlr-rubies -export XLDFLAGS="/wasi-vfs/lib/libwasi_vfs.a $XLDFLAGS" -if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then +if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then + source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_wasi_vfs.sh + export XLDFLAGS="$(wlr_wasi_vfs_get_link_flags) ${XLDFLAGS}" + echo "Added wasi-vfs to XDFLAGS. XLDFLAGS='${XLDFLAGS}'" +fi + +if [[ -z "${WLR_SKIP_CONFIGURE}" ]]; then logStatus "Downloading autotools data... " - ruby tool/downloader.rb -d tool -e gnu config.guess config.sub + ruby tool/downloader.rb -d tool -e gnu config.guess config.sub || exit 1 logStatus "Generating configure script... " - ./autogen.sh + ./autogen.sh || exit 1 + + CFG_WITH_EXT='' + if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then + CFG_WITH_EXT+='bigdecimal,' + CFG_WITH_EXT+='cgi/escape,' + CFG_WITH_EXT+='continuation,' + CFG_WITH_EXT+='coverage,' + CFG_WITH_EXT+='date,' + CFG_WITH_EXT+='dbm,' + CFG_WITH_EXT+='digest/bubblebabble,' + CFG_WITH_EXT+='digest,' + CFG_WITH_EXT+='digest/md5,' + CFG_WITH_EXT+='digest/rmd160,' + CFG_WITH_EXT+='digest/sha1,' + CFG_WITH_EXT+='digest/sha2,' + CFG_WITH_EXT+='etc,' + CFG_WITH_EXT+='fcntl,' + CFG_WITH_EXT+='fiber,' + CFG_WITH_EXT+='gdbm,' + CFG_WITH_EXT+='json,' + CFG_WITH_EXT+='json/generator,' + CFG_WITH_EXT+='json/parser,' + CFG_WITH_EXT+='nkf,' + CFG_WITH_EXT+='objspace,' + CFG_WITH_EXT+='pathname,' + CFG_WITH_EXT+='racc/cparse,' + CFG_WITH_EXT+='rbconfig/sizeof,' + CFG_WITH_EXT+='ripper,' + CFG_WITH_EXT+='stringio,' + CFG_WITH_EXT+='strscan,' + CFG_WITH_EXT+='monitor' + fi + + CFG_LDFLAGS=" -Xlinker --stack-first" + CFG_LDFLAGS+=" -Xlinker -z" + CFG_LDFLAGS+=" -Xlinker stack-size=16777216" logStatus "Configuring ruby..." ./configure \ --host wasm32-unknown-wasi \ - --prefix=$PREFIX \ - --with-ext=bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor \ + --prefix=${PREFIX} \ + --with-ext="${CFG_WITH_EXT}" \ --with-static-linked-ext \ --disable-install-doc \ - LDFLAGS=" \ - -Xlinker --stack-first \ - -Xlinker -z -Xlinker stack-size=16777216 \ - " \ + LDFLAGS="${CFG_LDFLAGS}" \ optflags="-O2" \ debugflags="" \ - wasmoptflags="-O2" + wasmoptflags="-O2" || exit 1 else logStatus "Skipping configure..." fi logStatus "Building ruby..." -make install +make install || exit 1 logStatus "Preparing artifacts... " mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 -mv $PREFIX/bin/ruby ruby -rm -rf $PREFIX/bin -wasi-vfs pack ruby --mapdir $PREFIX::$PREFIX -o ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 + +if [[ "${WLR_BUILD_FLAVOR}" == *"slim"* ]]; then + mv ${PREFIX}/bin/ruby ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 +else + logStatus "Packing with wasi-vfs" + mv ${PREFIX}/bin/ruby ruby + wlr_wasi_vfs_cli pack ruby --mapdir ${PREFIX}::${PREFIX} -o ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 +fi + +rm -rf ${PREFIX}/bin logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/ruby/v3_2_2/wlr-build.sh b/ruby/v3_2_2/wlr-build.sh index 51475fbe..7fea2ec0 100644 --- a/ruby/v3_2_2/wlr-build.sh +++ b/ruby/v3_2_2/wlr-build.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -if [[ ! -v WLR_ENV ]] -then +if [[ ! -v WLR_ENV ]]; then echo "WLR build environment is not set" exit 1 fi @@ -9,40 +8,80 @@ fi cd "${WLR_SOURCE_PATH}" export PREFIX=/wlr-rubies -export XLDFLAGS="/wasi-vfs/lib/libwasi_vfs.a $XLDFLAGS" -if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then +if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then + source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_wasi_vfs.sh + export XLDFLAGS="$(wlr_wasi_vfs_get_link_flags) ${XLDFLAGS}" + echo "Added wasi-vfs to XDFLAGS. XLDFLAGS='${XLDFLAGS}'" +fi + +if [[ -z "${WLR_SKIP_CONFIGURE}" ]]; then logStatus "Downloading autotools data... " - ruby tool/downloader.rb -d tool -e gnu config.guess config.sub + ruby tool/downloader.rb -d tool -e gnu config.guess config.sub || exit 1 logStatus "Generating configure script... " - ./autogen.sh + ./autogen.sh || exit 1 + + CFG_WITH_EXT='' + CFG_WITH_EXT+='bigdecimal,' + CFG_WITH_EXT+='cgi/escape,' + CFG_WITH_EXT+='continuation,' + CFG_WITH_EXT+='coverage,' + CFG_WITH_EXT+='date,' + CFG_WITH_EXT+='dbm,' + CFG_WITH_EXT+='digest/bubblebabble,' + CFG_WITH_EXT+='digest,' + CFG_WITH_EXT+='digest/md5,' + CFG_WITH_EXT+='digest/rmd160,' + CFG_WITH_EXT+='digest/sha1,' + CFG_WITH_EXT+='digest/sha2,' + CFG_WITH_EXT+='etc,' + CFG_WITH_EXT+='fcntl,' + CFG_WITH_EXT+='fiber,' + CFG_WITH_EXT+='gdbm,' + CFG_WITH_EXT+='json,' + CFG_WITH_EXT+='json/generator,' + CFG_WITH_EXT+='json/parser,' + CFG_WITH_EXT+='nkf,' + CFG_WITH_EXT+='objspace,' + CFG_WITH_EXT+='pathname,' + CFG_WITH_EXT+='racc/cparse,' + CFG_WITH_EXT+='rbconfig/sizeof,' + CFG_WITH_EXT+='ripper,' + CFG_WITH_EXT+='stringio,' + CFG_WITH_EXT+='strscan,' + CFG_WITH_EXT+='monitor' + + CFG_LDFLAGS=" -Xlinker --stack-first" + CFG_LDFLAGS+=" -Xlinker -z" + CFG_LDFLAGS+=" -Xlinker stack-size=16777216" logStatus "Configuring ruby..." ./configure \ --host wasm32-unknown-wasi \ - --prefix=$PREFIX \ - --with-ext=bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor \ + --prefix=${PREFIX} \ + --with-ext="${CFG_WITH_EXT}" \ --with-static-linked-ext \ --disable-install-doc \ - LDFLAGS=" \ - -Xlinker --stack-first \ - -Xlinker -z -Xlinker stack-size=16777216 \ - " \ + LDFLAGS="${CFG_LDFLAGS}" \ optflags="-O2" \ debugflags="" \ - wasmoptflags="-O2" + wasmoptflags="-O2" || exit 1 else logStatus "Skipping configure..." fi logStatus "Building ruby..." -make install +make install || exit 1 logStatus "Preparing artifacts... " mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 -mv $PREFIX/bin/ruby ruby -rm -rf $PREFIX/bin -wasi-vfs pack ruby --mapdir $PREFIX::$PREFIX -o ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 +mv ${PREFIX}/bin/ruby ruby +rm -rf ${PREFIX}/bin + +if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then + logStatus "Packing with wasi-vfs" + wlr_wasi_vfs_cli pack ruby --mapdir ${PREFIX}::${PREFIX} -o ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 +fi logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/scripts/build-helpers/wlr_wasi_vfs.sh b/scripts/build-helpers/wlr_wasi_vfs.sh index 0fe5af39..4e2d56c8 100644 --- a/scripts/build-helpers/wlr_wasi_vfs.sh +++ b/scripts/build-helpers/wlr_wasi_vfs.sh @@ -14,6 +14,10 @@ then exit 1 fi +function wlr_wasi_vfs_get_link_flags { + echo "-L${WASI_VFS_ROOT}/lib -lwasi_vfs" +} + function wlr_wasi_vfs_setup_dependencies { export LDFLAGS_DEPENDENCIES="${LDFLAGS_DEPENDENCIES} -L${WASI_VFS_ROOT}/lib -lwasi_vfs " } From 700a0b2c07252c0e4ebfc5cce5041f504fdb631d Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Fri, 7 Jul 2023 17:12:04 +0300 Subject: [PATCH 06/12] feat: Simplified flavors for latest PHP --- Makefile | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 46e27ce4..70de0f51 100644 --- a/Makefile +++ b/Makefile @@ -6,20 +6,8 @@ include Makefile.helpers php/php-*: make -C php $(subst php/php-,php-,$@) -.PHONY: php/php-8.2.6-slim -php/php-8.2.6-slim: - WLR_BUILD_FLAVOR=slim \ - make -C php php-8.2.6 - -.PHONY: php/wasmedge-php-8.2.0 -php/php-8.2.0-wasmedge: - WLR_BUILD_FLAVOR=wasmedge \ - make -C php php-8.2.0 - -.PHONY: php/php-8.2.6-wasmedge -php/php-8.2.6-wasmedge: - WLR_BUILD_FLAVOR=wasmedge \ - make -C php php-8.2.6 +$(eval $(call create_flavor_targets,php,php-8.2.0,wasmedge)) +$(eval $(call create_flavor_targets,php,php-8.2.6,slim wasmedge)) .PHONY: php/master php/master: From 474b7d89d95d0ea1959014adaecfbcca20a3e24b Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Tue, 11 Jul 2023 11:27:30 +0300 Subject: [PATCH 07/12] chore: Unify python flavors build with the rest --- .github/workflows/release-python.yaml | 6 ++--- Makefile | 35 +++------------------------ python/v3.11.3/wlr-build.sh | 2 +- python/v3.11.4/wlr-build.sh | 20 +++++++++++---- scripts/build-helpers/wlr_package.sh | 11 ++++++++- 5 files changed, 33 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release-python.yaml b/.github/workflows/release-python.yaml index 14e609b3..00b35573 100644 --- a/.github/workflows/release-python.yaml +++ b/.github/workflows/release-python.yaml @@ -25,11 +25,11 @@ jobs: - name: Build Python run: make python/v${{ steps.determineVersion.outputs.value }} - name: Build Python Wasmedge - run: make python/wasmedge-v${{ steps.determineVersion.outputs.value }} + run: make python/v${{ steps.determineVersion.outputs.value }}-wasmedge - name: Build Python AIO - run: make python/aio-v${{ steps.determineVersion.outputs.value }} + run: make python/v${{ steps.determineVersion.outputs.value }}-aio - name: Build Python AIO Wasmedge - run: make python/aio-wasmedge-v${{ steps.determineVersion.outputs.value }} + run: make python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge - name: Rename release artifacts shell: bash run: | diff --git a/Makefile b/Makefile index 70de0f51..6377674b 100644 --- a/Makefile +++ b/Makefile @@ -24,20 +24,8 @@ $(eval $(call create_flavor_targets,ruby,v3_2_2,slim)) python/v*: make -C python $(subst python/,,$@) -.PHONY: python/wasmedge-v3.11.1 -python/wasmedge-v3.11.1: - WLR_BUILD_FLAVOR=wasmedge \ - make -C python $(subst python/wasmedge-,,$@) - -.PHONY: python/aio-v3.11.1 -python/aio-v3.11.1: - WLR_BUILD_FLAVOR=aio \ - make -C python $(subst python/aio-,,$@) - -.PHONY: python/aio-wasmedge-v3.11.1 -python/aio-wasmedge-v3.11.1: - WLR_BUILD_FLAVOR=aio-wasmedge \ - make -C python $(subst python/aio-wasmedge-,,$@) +$(eval $(call create_flavor_targets,python,v3.11.1,aio wasmedge aio-wasmedge)) +$(eval $(call create_flavor_targets,python,v3.11.4,aio wasmedge aio-wasmedge)) .PHONY: oci-python-3.11.1 oci-python-3.11.1: python/v3.11.1 @@ -52,7 +40,7 @@ oci-python-3.11.1: python/v3.11.1 build-output .PHONY: oci-python-3.11.1-wasmedge -oci-python-3.11.1-wasmedge: python/wasmedge-v3.11.1 +oci-python-3.11.1-wasmedge: python/v3.11.1-wasmedge docker build \ --platform wasm32/wasi \ --build-arg NAME=python-wasm \ @@ -63,21 +51,6 @@ oci-python-3.11.1-wasmedge: python/wasmedge-v3.11.1 -f images/python/Dockerfile \ build-output -.PHONY: python/wasmedge-v3.11.4 -python/wasmedge-v3.11.4: - WLR_BUILD_FLAVOR=wasmedge \ - make -C python $(subst python/wasmedge-,,$@) - -.PHONY: python/aio-v3.11.4 -python/aio-v3.11.4: - WLR_BUILD_FLAVOR=aio \ - make -C python $(subst python/aio-,,$@) - -.PHONY: python/aio-wasmedge-v3.11.4 -python/aio-wasmedge-v3.11.4: - WLR_BUILD_FLAVOR=aio-wasmedge \ - make -C python $(subst python/aio-wasmedge-,,$@) - .PHONY: oci-python-3.11.4 oci-python-3.11.4: python/v3.11.4 docker build \ @@ -91,7 +64,7 @@ oci-python-3.11.4: python/v3.11.4 build-output .PHONY: oci-python-3.11.4-wasmedge -oci-python-3.11.3-wasmedge: python/wasmedge-v3.11.4 +oci-python-3.11.4-wasmedge: python/v3.11.4-wasmedge docker build \ --platform wasi/wasm32 \ --build-arg NAME=python-wasm \ diff --git a/python/v3.11.3/wlr-build.sh b/python/v3.11.3/wlr-build.sh index 5ddb46aa..cfa2e236 100644 --- a/python/v3.11.3/wlr-build.sh +++ b/python/v3.11.3/wlr-build.sh @@ -126,7 +126,7 @@ EOF PC_INCLUDE_SUBDIR=python3.11 wlr_pkg_config_create_pc_file "libpython3.11" "${WLR_PACKAGE_VERSION}" "${DESCRIPTION}" "${EXTRA_LINK_FLAGS}" || exit 1 - WLR_PACKAGE_LIB_EXTRA_DIRS=usr wlr_package_lib || exit 1 + WLR_PACKAGE_EXTRA_DIRS=usr wlr_package_lib || exit 1 fi logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/python/v3.11.4/wlr-build.sh b/python/v3.11.4/wlr-build.sh index 5ddb46aa..430403b3 100644 --- a/python/v3.11.4/wlr-build.sh +++ b/python/v3.11.4/wlr-build.sh @@ -11,7 +11,7 @@ cd "${WLR_SOURCE_PATH}" if [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]] then source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_wasi_vfs.sh - wlr_wasi_vfs_setup_dependencies || exit 1 + export LDFLAGS="$(wlr_wasi_vfs_get_link_flags) ${LDFLAGS}" fi source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_pkg_config.sh @@ -80,16 +80,16 @@ then fi logStatus "Preparing artifacts... " -TARGET_PYTHON_BINARY=${WLR_OUTPUT}/bin/python.wasm +TARGET_PYTHON_BINARY=bin/python-${WLR_PACKAGE_VERSION}.wasm mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 if [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]] then - cp -v python-optimized.wasm ${TARGET_PYTHON_BINARY} || exit 1 + cp -v python-optimized.wasm ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} || exit 1 else mkdir -p ${WLR_OUTPUT}/usr 2>/dev/null || exit 1 - cp -v python-optimized.wasm ${TARGET_PYTHON_BINARY} || exit 1 + cp -v python-optimized.wasm ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} || exit 1 cp -TRv usr ${WLR_OUTPUT}/usr || exit 1 fi @@ -126,7 +126,17 @@ EOF PC_INCLUDE_SUBDIR=python3.11 wlr_pkg_config_create_pc_file "libpython3.11" "${WLR_PACKAGE_VERSION}" "${DESCRIPTION}" "${EXTRA_LINK_FLAGS}" || exit 1 - WLR_PACKAGE_LIB_EXTRA_DIRS=usr wlr_package_lib || exit 1 + WLR_PACKAGE_EXTRA_DIRS=usr wlr_package_lib || exit 1 + WLR_PACKAGE_LIST="${TARGET_PYTHON_BINARY} usr" wlr_package || exit 1 + +elif [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]]; then + # skip 'aio' in the name + FLAVOR_SUFFIX=$(echo ${WLR_BUILD_FLAVOR} | sed 's/-\?aio//g') + PUBLISHED_PYTHON_BINARY=python-${WLR_PACKAGE_VERSION}${FLAVOR_SUFFIX}.wasm + cp -v ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} ${WLR_OUTPUT_BASE}/${PUBLISHED_PYTHON_BINARY} || exit 1 + +else + WLR_PACKAGE_LIST="${TARGET_PYTHON_BINARY} usr" wlr_package || exit 1 fi logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/scripts/build-helpers/wlr_package.sh b/scripts/build-helpers/wlr_package.sh index 5ef4bdd0..83d5df3a 100644 --- a/scripts/build-helpers/wlr_package.sh +++ b/scripts/build-helpers/wlr_package.sh @@ -18,7 +18,7 @@ function wlr_package_lib { --exclude=*.la \ --exclude=lib/wasm32-wasi/cmake \ include \ - lib ${WLR_PACKAGE_LIB_EXTRA_DIRS} + lib ${WLR_PACKAGE_EXTRA_DIRS} gzip -f ${_PACKAGE} } @@ -30,3 +30,12 @@ function wlr_package_bin { bin gzip -f ${_PACKAGE} } + +function wlr_package { + local _PACKAGE=${WLR_OUTPUT_BASE}/${WLR_PACKAGE_NAME}-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}-${WASI_SDK_ASSET_NAME}.tar + logStatus "Packaging... ${_PACKAGE}" + tar -cvf ${_PACKAGE} \ + -C ${WLR_OUTPUT}/ \ + ${WLR_PACKAGE_LIST} + gzip -f ${_PACKAGE} +} From ad04739e2fe6e72052f37ec0525b5f59807ff2d2 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Tue, 11 Jul 2023 11:27:47 +0300 Subject: [PATCH 08/12] chore: Simplify Python GH actions --- .github/workflows/build-python.yaml | 28 ++--- .github/workflows/release-python.yaml | 102 ++++++------------ .../reusable-build-runtime-flavor.yaml | 43 ++++++++ .../workflows/reusable-publish-assets.yaml | 50 +++++++++ Makefile | 1 + 5 files changed, 131 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/reusable-build-runtime-flavor.yaml create mode 100644 .github/workflows/reusable-publish-assets.yaml diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index e49ec02d..db823f02 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -12,34 +12,20 @@ jobs: strategy: fail-fast: false matrix: - include: - - prefix: "" - suffix: "" - version: "3.11.4" - - prefix: "wasmedge-" - suffix: "-wasmedge" - version: "3.11.4" - - prefix: "aio-" - suffix: "-aio" - version: "3.11.4" - - prefix: "aio-wasmedge-" - suffix: "-aio-wasmedge" - version: "3.11.4" + flavor: ["", "-wasmedge", "-aio", "-aio-wasmedge"] + version: ["3.11.3", "3.11.4"] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Build Python - run: make python/${{ matrix.prefix }}v${{ matrix.version }} - - name: Rename artifacts - shell: bash - run: | - sudo mv build-output/python/v${{ matrix.version }}${{ matrix.suffix }}/bin/python{,-${{ matrix.version }}${{ matrix.suffix }}}.wasm - - name: Upload python-${{ matrix.version }}.zip artifact + run: make python/v${{ matrix.version }}${{ matrix.flavor }} + - name: Upload python-${{ matrix.version }} assets uses: actions/upload-artifact@v3 with: name: python-${{ matrix.version }}.zip path: | - build-output/python/v${{ matrix.version }}${{ matrix.suffix }}/bin/python-${{ matrix.version }}${{ matrix.suffix }}.wasm - build-output/python/v${{ matrix.version }}${{ matrix.suffix }}/usr + build-output/*.gz + build-output/*.wasm + build-output/*.txt if-no-files-found: error diff --git a/.github/workflows/release-python.yaml b/.github/workflows/release-python.yaml index 00b35573..1a1189bf 100644 --- a/.github/workflows/release-python.yaml +++ b/.github/workflows/release-python.yaml @@ -10,75 +10,33 @@ on: tags: - python/* jobs: - release-python: - strategy: - fail-fast: false - runs-on: ubuntu-latest - steps: - - name: Determine version - id: determineVersion - run: | - VERSION=$(echo ${{ github.event.ref }} | sed 's,refs/tags/python/,,g' | cut -f 1 -d \+) - echo "value=${VERSION}" >> $GITHUB_OUTPUT - - name: Checkout repository - uses: actions/checkout@v3 - - name: Build Python - run: make python/v${{ steps.determineVersion.outputs.value }} - - name: Build Python Wasmedge - run: make python/v${{ steps.determineVersion.outputs.value }}-wasmedge - - name: Build Python AIO - run: make python/v${{ steps.determineVersion.outputs.value }}-aio - - name: Build Python AIO Wasmedge - run: make python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge - - name: Rename release artifacts - shell: bash - run: | - sudo mv build-output/python/v${{ steps.determineVersion.outputs.value }}/bin/python{,-${{ steps.determineVersion.outputs.value }}}.wasm - sudo mv build-output/python/v${{ steps.determineVersion.outputs.value }}-wasmedge/bin/python{,-${{ steps.determineVersion.outputs.value }}-wasmedge}.wasm - sudo mv build-output/python/v${{ steps.determineVersion.outputs.value }}-aio/bin/python{,-${{ steps.determineVersion.outputs.value }}}.wasm - sudo mv build-output/python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge/bin/python{,-${{ steps.determineVersion.outputs.value }}-wasmedge}.wasm - - name: Bundle Python with standard libraries - run: | - tar -cvf python-${{ steps.determineVersion.outputs.value }}.tar \ - -C build-output/python/v${{ steps.determineVersion.outputs.value }}/ \ - bin/python-${{ steps.determineVersion.outputs.value }}.wasm \ - usr - tar -rvf python-${{ steps.determineVersion.outputs.value }}.tar \ - -C build-output/python/v${{ steps.determineVersion.outputs.value }}-wasmedge/ \ - bin/python-${{ steps.determineVersion.outputs.value }}-wasmedge.wasm - gzip python-${{ steps.determineVersion.outputs.value }}.tar - - name: Create release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create --generate-notes ${{ github.ref_name }} || true - - name: Append Python release assets - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - python-${{ steps.determineVersion.outputs.value }}.tar.gz \ - build-output/libpython-${{ steps.determineVersion.outputs.value }}*.tar.gz \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio/bin/python-${{ steps.determineVersion.outputs.value }}.wasm \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge/bin/python-${{ steps.determineVersion.outputs.value }}-wasmedge.wasm - - name: Generate release assets digests - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - for asset in \ - python-${{ steps.determineVersion.outputs.value }}.tar.gz \ - build-output/libpython-${{ steps.determineVersion.outputs.value }}*.tar.gz \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio/bin/python-${{ steps.determineVersion.outputs.value }}.wasm \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge/bin/python-${{ steps.determineVersion.outputs.value }}-wasmedge.wasm; \ - do - sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null - done - - name: Append release assets digests - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - python-${{ steps.determineVersion.outputs.value }}.tar.gz.sha256sum \ - build-output/libpython-${{ steps.determineVersion.outputs.value }}*.tar.gz.sha256sum \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio/bin/python-${{ steps.determineVersion.outputs.value }}.wasm.sha256sum \ - build-output/python/v${{ steps.determineVersion.outputs.value }}-aio-wasmedge/bin/python-${{ steps.determineVersion.outputs.value }}-wasmedge.wasm.sha256sum + build-default: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "python" + trigger: ${{ github.event.ref }} + flavor: "" + build-wasmedge: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "python" + trigger: ${{ github.event.ref }} + flavor: "-wasmedge" + build-aio: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "python" + trigger: ${{ github.event.ref }} + flavor: "-aio" + build-aio-wasmedge: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "python" + trigger: ${{ github.event.ref }} + flavor: "-aio-wasmedge" + publish: + uses: ./.github/workflows/reusable-publish-assets.yaml + needs: [build-default, build-wasmedge, build-aio, build-aio-wasmedge] + with: + target-name: "python" + diff --git a/.github/workflows/reusable-build-runtime-flavor.yaml b/.github/workflows/reusable-build-runtime-flavor.yaml new file mode 100644 index 00000000..69c9998c --- /dev/null +++ b/.github/workflows/reusable-build-runtime-flavor.yaml @@ -0,0 +1,43 @@ +# Note: This workflow should be refactored into a custom GH action. +# This will allow us to call it in job steps and have more flexibility. +# Currently we can only call it as a separate job/ Thus we cannot populate +# its inputs from a matrix, but need to do explicit calls. +name: Build a runtime target +on: + workflow_call: + inputs: + target-name: + required: true + type: string + trigger: + required: true + type: string + flavor: + required: false + type: string + default: "" +jobs: + release-lib: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Determine version + id: determineVersion + run: | + VERSION=$(echo ${{ inputs.trigger }} | sed 's,refs/tags/${{ inputs.target-name }}/,,g' | cut -f 1 -d \+) + echo "value=${VERSION}" >> $GITHUB_OUTPUT + - name: Checkout repository + uses: actions/checkout@v3 + - name: Build ${{ inputs.target-name }} + run: | + make ${{ inputs.target-name }}/v${{ steps.determineVersion.outputs.value }}${{ inputs.flavor }} + - name: Upload ${{ inputs.target-name }}-${{ steps.determineVersion.outputs.value }} artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.target-name }}.zip + path: | + build-output/*.gz + build-output/*.wasm + build-output/*.txt + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/reusable-publish-assets.yaml b/.github/workflows/reusable-publish-assets.yaml new file mode 100644 index 00000000..140ae900 --- /dev/null +++ b/.github/workflows/reusable-publish-assets.yaml @@ -0,0 +1,50 @@ +# Note: This workflow should be refactored into a custom GH action. +# This will allow us to call it in job steps and have more flexibility. +on: + workflow_call: + inputs: + target-name: + required: true + type: string +jobs: + publish-release-assets: + strategy: + fail-fast: true + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Create release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create --verify-tag ${{ github.ref_name }} || true + - name: Download ${{ inputs.target-name }} artifact + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.target-name }}.zip + path: build-output + - name: List downloaded assets + run: | + ls -lrt -R build-output + - name: Append ${{ inputs.target-name }} release assets + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + shopt -s nullglob + gh release upload ${{ github.ref_name }} build-output/*.{gz,wasm,txt} + - name: Generate release assets digests + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + shopt -s nullglob + for asset in build-output/*.{gz,wasm}; do + sha256sum "${asset}" | sudo tee "${asset}.sha256sum" > /dev/null + done + - name: Append release assets digests + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.ref_name }} build-output/*.sha256sum + + diff --git a/Makefile b/Makefile index 6377674b..5966144b 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ python/v*: make -C python $(subst python/,,$@) $(eval $(call create_flavor_targets,python,v3.11.1,aio wasmedge aio-wasmedge)) +$(eval $(call create_flavor_targets,python,v3.11.3,aio wasmedge aio-wasmedge)) $(eval $(call create_flavor_targets,python,v3.11.4,aio wasmedge aio-wasmedge)) .PHONY: oci-python-3.11.1 From 7e3cc567d61c460a9ab23fda4c8171449bf02d5c Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Wed, 12 Jul 2023 13:16:35 +0300 Subject: [PATCH 09/12] chore: Simplify Ruby build scripts --- .github/workflows/build-ruby.yaml | 24 ++---- .github/workflows/release-ruby.yaml | 98 +++++-------------------- Makefile | 4 +- README.md | 2 +- ruby/README.md | 2 +- ruby/{v3_2_0 => v3.2.0}/wlr-build.sh | 3 + ruby/{v3_2_0 => v3.2.0}/wlr-env-repo.sh | 0 ruby/{v3_2_0 => v3.2.0}/wlr-tag.sh | 0 ruby/{v3_2_2 => v3.2.2}/wlr-build.sh | 72 ++++++++++-------- ruby/{v3_2_2 => v3.2.2}/wlr-env-repo.sh | 0 ruby/{v3_2_2 => v3.2.2}/wlr-tag.sh | 0 11 files changed, 72 insertions(+), 133 deletions(-) rename ruby/{v3_2_0 => v3.2.0}/wlr-build.sh (93%) rename ruby/{v3_2_0 => v3.2.0}/wlr-env-repo.sh (100%) rename ruby/{v3_2_0 => v3.2.0}/wlr-tag.sh (100%) rename ruby/{v3_2_2 => v3.2.2}/wlr-build.sh (52%) rename ruby/{v3_2_2 => v3.2.2}/wlr-env-repo.sh (100%) rename ruby/{v3_2_2 => v3.2.2}/wlr-tag.sh (100%) diff --git a/.github/workflows/build-ruby.yaml b/.github/workflows/build-ruby.yaml index d43a431d..cae3d6d0 100644 --- a/.github/workflows/build-ruby.yaml +++ b/.github/workflows/build-ruby.yaml @@ -13,27 +13,19 @@ jobs: fail-fast: false matrix: flavor: ["", "-slim"] - include: - - version: 3.2.0 - target_version: 3_2_0 - - version: 3.2.2 - target_version: 3_2_2 - exclude: - - flavor: "-slim" - version: 3.2.2 + version: ["3.2.0", "3.2.2"] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Build Ruby - run: make ruby/v${{ matrix.target_version }}${{ matrix.flavor }} - - name: Rename artifacts - shell: bash - run: | - sudo mv build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby{,-${{ matrix.version }}${{ matrix.flavor }}}.wasm - - name: Upload ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact + run: make ruby/v${{ matrix.version }}${{ matrix.flavor }} + - name: Upload ruby-${{ matrix.version }} assets uses: actions/upload-artifact@v3 with: - name: ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm - path: build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm + name: ruby-${{ matrix.version }}.zip + path: | + build-output/*.gz + build-output/*.wasm + build-output/*.txt if-no-files-found: error diff --git a/.github/workflows/release-ruby.yaml b/.github/workflows/release-ruby.yaml index b4d17ba1..94bf42dc 100644 --- a/.github/workflows/release-ruby.yaml +++ b/.github/workflows/release-ruby.yaml @@ -10,84 +10,20 @@ on: tags: - ruby/* jobs: - release-ruby: - strategy: - matrix: - flavor: ["", "-slim"] - include: - - version: 3.2.0 - target_version: 3_2_0 - - version: 3.2.2 - target_version: 3_2_2 - exclude: - - flavor: "-slim" - version: 3.2.2 - runs-on: ubuntu-latest - steps: - - name: Checkout repository - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version)) - uses: actions/checkout@v3 - - name: Build Ruby - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version)) - run: make ruby/v${{ matrix.target_version }}${{ matrix.flavor }} - - name: Rename release artifacts - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version)) - shell: bash - run: | - sudo mv build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby{,-${{ matrix.version }}${{ matrix.flavor }}}.wasm - - name: Create release - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version)) - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create --generate-notes ${{ github.ref_name }} || true - - name: Append Ruby release assets - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.wasm - - name: Generate release assets digests - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - for asset in build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.wasm; do - sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null - done - - name: Append release assets digests - # Only run for the Ruby version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.sha256sum + build-default: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "ruby" + trigger: ${{ github.event.ref }} + flavor: "" + build-slim: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "ruby" + trigger: ${{ github.event.ref }} + flavor: "-slim" + publish: + uses: ./.github/workflows/reusable-publish-assets.yaml + needs: [build-default, build-slim] + with: + target-name: "ruby" diff --git a/Makefile b/Makefile index 5966144b..f0c24b13 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ php/master: ruby/v*: make -C ruby $(subst ruby/,,$@) -$(eval $(call create_flavor_targets,ruby,v3_2_0,slim)) -$(eval $(call create_flavor_targets,ruby,v3_2_2,slim)) +$(eval $(call create_flavor_targets,ruby,v3.2.0,slim)) +$(eval $(call create_flavor_targets,ruby,v3.2.2,slim)) .PHONY: python/v* python/v*: diff --git a/README.md b/README.md index 5a1dcb7e..7a1bdc96 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ All you need in order to run these builds is to have `docker` or `podman` availa - `python/v3.11.3` - Resulting binaries are placed in `build-output/python`. -- `ruby/v3_2_0` +- `ruby/v3.2.0` - Resulting binaries are placed in `build-output/ruby`. ### Build strategy diff --git a/ruby/README.md b/ruby/README.md index fb9e433e..e3bc793a 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -4,7 +4,7 @@ You can build Ruby by running the following Makefile targets: -- `make v3_2_0` +- `make v3.2.0` ## Running a script with ruby diff --git a/ruby/v3_2_0/wlr-build.sh b/ruby/v3.2.0/wlr-build.sh similarity index 93% rename from ruby/v3_2_0/wlr-build.sh rename to ruby/v3.2.0/wlr-build.sh index 71d6bbc9..45e02265 100644 --- a/ruby/v3_2_0/wlr-build.sh +++ b/ruby/v3.2.0/wlr-build.sh @@ -89,4 +89,7 @@ fi rm -rf ${PREFIX}/bin +PUBLISHED_RUBY_BINARY=ruby-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm +cp -v ${WLR_OUTPUT}/bin/ruby.wasm ${WLR_OUTPUT_BASE}/${PUBLISHED_RUBY_BINARY} + logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/ruby/v3_2_0/wlr-env-repo.sh b/ruby/v3.2.0/wlr-env-repo.sh similarity index 100% rename from ruby/v3_2_0/wlr-env-repo.sh rename to ruby/v3.2.0/wlr-env-repo.sh diff --git a/ruby/v3_2_0/wlr-tag.sh b/ruby/v3.2.0/wlr-tag.sh similarity index 100% rename from ruby/v3_2_0/wlr-tag.sh rename to ruby/v3.2.0/wlr-tag.sh diff --git a/ruby/v3_2_2/wlr-build.sh b/ruby/v3.2.2/wlr-build.sh similarity index 52% rename from ruby/v3_2_2/wlr-build.sh rename to ruby/v3.2.2/wlr-build.sh index 7fea2ec0..45e02265 100644 --- a/ruby/v3_2_2/wlr-build.sh +++ b/ruby/v3.2.2/wlr-build.sh @@ -20,37 +20,39 @@ if [[ -z "${WLR_SKIP_CONFIGURE}" ]]; then ruby tool/downloader.rb -d tool -e gnu config.guess config.sub || exit 1 logStatus "Generating configure script... " - ./autogen.sh || exit 1 + ./autogen.sh || exit 1 CFG_WITH_EXT='' - CFG_WITH_EXT+='bigdecimal,' - CFG_WITH_EXT+='cgi/escape,' - CFG_WITH_EXT+='continuation,' - CFG_WITH_EXT+='coverage,' - CFG_WITH_EXT+='date,' - CFG_WITH_EXT+='dbm,' - CFG_WITH_EXT+='digest/bubblebabble,' - CFG_WITH_EXT+='digest,' - CFG_WITH_EXT+='digest/md5,' - CFG_WITH_EXT+='digest/rmd160,' - CFG_WITH_EXT+='digest/sha1,' - CFG_WITH_EXT+='digest/sha2,' - CFG_WITH_EXT+='etc,' - CFG_WITH_EXT+='fcntl,' - CFG_WITH_EXT+='fiber,' - CFG_WITH_EXT+='gdbm,' - CFG_WITH_EXT+='json,' - CFG_WITH_EXT+='json/generator,' - CFG_WITH_EXT+='json/parser,' - CFG_WITH_EXT+='nkf,' - CFG_WITH_EXT+='objspace,' - CFG_WITH_EXT+='pathname,' - CFG_WITH_EXT+='racc/cparse,' - CFG_WITH_EXT+='rbconfig/sizeof,' - CFG_WITH_EXT+='ripper,' - CFG_WITH_EXT+='stringio,' - CFG_WITH_EXT+='strscan,' - CFG_WITH_EXT+='monitor' + if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then + CFG_WITH_EXT+='bigdecimal,' + CFG_WITH_EXT+='cgi/escape,' + CFG_WITH_EXT+='continuation,' + CFG_WITH_EXT+='coverage,' + CFG_WITH_EXT+='date,' + CFG_WITH_EXT+='dbm,' + CFG_WITH_EXT+='digest/bubblebabble,' + CFG_WITH_EXT+='digest,' + CFG_WITH_EXT+='digest/md5,' + CFG_WITH_EXT+='digest/rmd160,' + CFG_WITH_EXT+='digest/sha1,' + CFG_WITH_EXT+='digest/sha2,' + CFG_WITH_EXT+='etc,' + CFG_WITH_EXT+='fcntl,' + CFG_WITH_EXT+='fiber,' + CFG_WITH_EXT+='gdbm,' + CFG_WITH_EXT+='json,' + CFG_WITH_EXT+='json/generator,' + CFG_WITH_EXT+='json/parser,' + CFG_WITH_EXT+='nkf,' + CFG_WITH_EXT+='objspace,' + CFG_WITH_EXT+='pathname,' + CFG_WITH_EXT+='racc/cparse,' + CFG_WITH_EXT+='rbconfig/sizeof,' + CFG_WITH_EXT+='ripper,' + CFG_WITH_EXT+='stringio,' + CFG_WITH_EXT+='strscan,' + CFG_WITH_EXT+='monitor' + fi CFG_LDFLAGS=" -Xlinker --stack-first" CFG_LDFLAGS+=" -Xlinker -z" @@ -76,12 +78,18 @@ make install || exit 1 logStatus "Preparing artifacts... " mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 -mv ${PREFIX}/bin/ruby ruby -rm -rf ${PREFIX}/bin -if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]]; then +if [[ "${WLR_BUILD_FLAVOR}" == *"slim"* ]]; then + mv ${PREFIX}/bin/ruby ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 +else logStatus "Packing with wasi-vfs" + mv ${PREFIX}/bin/ruby ruby wlr_wasi_vfs_cli pack ruby --mapdir ${PREFIX}::${PREFIX} -o ${WLR_OUTPUT}/bin/ruby.wasm || exit 1 fi +rm -rf ${PREFIX}/bin + +PUBLISHED_RUBY_BINARY=ruby-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm +cp -v ${WLR_OUTPUT}/bin/ruby.wasm ${WLR_OUTPUT_BASE}/${PUBLISHED_RUBY_BINARY} + logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/ruby/v3_2_2/wlr-env-repo.sh b/ruby/v3.2.2/wlr-env-repo.sh similarity index 100% rename from ruby/v3_2_2/wlr-env-repo.sh rename to ruby/v3.2.2/wlr-env-repo.sh diff --git a/ruby/v3_2_2/wlr-tag.sh b/ruby/v3.2.2/wlr-tag.sh similarity index 100% rename from ruby/v3_2_2/wlr-tag.sh rename to ruby/v3.2.2/wlr-tag.sh From af6ffcc93d76de351b2e53be702f6f66e57364e5 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Wed, 12 Jul 2023 14:42:26 +0300 Subject: [PATCH 10/12] chore: Simplify php build scripts --- .github/workflows/build-php.yaml | 56 ++------ .github/workflows/release-php.yaml | 131 +++--------------- .../reusable-build-runtime-flavor.yaml | 2 +- Makefile | 10 +- Makefile.helpers | 4 +- README.md | 48 ++++--- php/Makefile | 4 +- php/README.md | 10 +- php/examples/mysql/run_me.sh | 4 +- php/php-8.2.0-slim/patches | 1 - php/php-8.2.0-slim/wlr-build.sh | 96 ------------- php/php-8.2.0-slim/wlr-env-repo.sh | 18 --- php/php-8.2.0-slim/wlr-test.sh | 34 ----- php/php-8.2.0/wlr-tag.sh | 1 - php/{php-7.3.33 => v7.3.33}/README.md | 0 php/{php-7.4.32 => v7.4.32}/README.md | 0 php/{php-8.1.11 => v8.1.11}/README.md | 0 ...-the-php-7.4.32-patch-for-php-8.1.11.patch | 0 ...itate-fibers-when-compiling-for-WASI.patch | 0 php/{php-8.1.11 => v8.1.11}/wlr-build.sh | 4 +- php/{php-8.1.11 => v8.1.11}/wlr-env-repo.sh | 0 php/{php-8.1.11 => v8.1.11}/wlr-info.json | 0 php/{php-8.1.11 => v8.1.11}/wlr-tag.sh | 0 php/{php-8.1.11 => v8.1.11}/wlr-test.sh | 0 ...-the-php-7.4.32-patch-for-php-8.2.11.patch | 0 ...itate-fibers-when-compiling-for-WASI.patch | 0 ...03-fix-Add-more-ifdefs-for-php-8.2.0.patch | 0 ...y-issues-and-introduce-WASM_WASMEDGE.patch | 0 ...ckets-via-with-wasm-runtime-wasmedge.patch | 0 ...e-syslog.h-since-it-is-not-part-of-w.patch | 0 ...-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch | 0 .../0008-fix-Avoid-tmpfile-in-gd_bmp.patch | 0 .../0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch | 0 ...ore-Add-more-logs-in-wasi_socket_ext.patch | 0 ...stcgi-server-in-php-cgi-for-wasmedge.patch | 0 ...2-chore-Add-debug-logging-in-fastcgi.patch | 0 ...es-logs-getnameinfo-in-wasi-sock-sdk.patch | 0 ...licit-function-declaration-in-syslog.patch | 0 ...lnd-and-more-network-functions-with-.patch | 0 ...ction-declaration-for-bind-when-not-.patch | 0 ...017-fix-is_writable-with-stat-bypass.patch | 0 ...-fix-random_bytes-failing-on-Windows.patch | 0 php/{php-8.2.0 => v8.2.0}/wlr-build.sh | 61 +++++--- php/{php-8.2.0 => v8.2.0}/wlr-env-repo.sh | 0 php/{php-8.2.0 => v8.2.0}/wlr-info.json | 5 + php/{php-8.2.0-slim => v8.2.0}/wlr-tag.sh | 0 php/{php-8.2.0 => v8.2.0}/wlr-test.sh | 0 ...f-the-php-7.4.32-patch-for-php-8.2.6.patch | 0 ...itate-fibers-when-compiling-for-WASI.patch | 0 ...03-fix-Add-more-ifdefs-for-php-8.2.0.patch | 0 ...y-issues-and-introduce-WASM_WASMEDGE.patch | 0 ...ckets-via-with-wasm-runtime-wasmedge.patch | 0 ...e-syslog.h-since-it-is-not-part-of-w.patch | 0 ...-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch | 0 .../0008-fix-Avoid-tmpfile-in-gd_bmp.patch | 0 .../0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch | 0 ...ore-Add-more-logs-in-wasi_socket_ext.patch | 0 ...stcgi-server-in-php-cgi-for-wasmedge.patch | 0 ...2-chore-Add-debug-logging-in-fastcgi.patch | 0 ...es-logs-getnameinfo-in-wasi-sock-sdk.patch | 0 ...licit-function-declaration-in-syslog.patch | 0 ...lnd-and-more-network-functions-with-.patch | 0 ...ction-declaration-for-bind-when-not-.patch | 0 ..._readable-and-is_writable-to-bypass-.patch | 0 ...-fix-random_bytes-failing-on-Windows.patch | 0 php/{php-8.2.6 => v8.2.6}/wlr-build.sh | 6 +- php/{php-8.2.6 => v8.2.6}/wlr-env-repo.sh | 0 php/{php-8.2.6 => v8.2.6}/wlr-info.json | 0 php/{php-8.2.6 => v8.2.6}/wlr-tag.sh | 0 php/{php-8.2.6 => v8.2.6}/wlr-test.sh | 0 70 files changed, 139 insertions(+), 356 deletions(-) delete mode 120000 php/php-8.2.0-slim/patches delete mode 100644 php/php-8.2.0-slim/wlr-build.sh delete mode 100644 php/php-8.2.0-slim/wlr-env-repo.sh delete mode 100644 php/php-8.2.0-slim/wlr-test.sh delete mode 100644 php/php-8.2.0/wlr-tag.sh rename php/{php-7.3.33 => v7.3.33}/README.md (100%) rename php/{php-7.4.32 => v7.4.32}/README.md (100%) rename php/{php-8.1.11 => v8.1.11}/README.md (100%) rename php/{php-8.1.11 => v8.1.11}/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.1.11.patch (100%) rename php/{php-8.1.11 => v8.1.11}/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch (100%) rename php/{php-8.1.11 => v8.1.11}/wlr-build.sh (94%) rename php/{php-8.1.11 => v8.1.11}/wlr-env-repo.sh (100%) rename php/{php-8.1.11 => v8.1.11}/wlr-info.json (100%) rename php/{php-8.1.11 => v8.1.11}/wlr-tag.sh (100%) rename php/{php-8.1.11 => v8.1.11}/wlr-test.sh (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.11.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0012-chore-Add-debug-logging-in-fastcgi.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0014-fix-implicit-function-declaration-in-syslog.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0017-fix-is_writable-with-stat-bypass.patch (100%) rename php/{php-8.2.0 => v8.2.0}/patches/0018-fix-random_bytes-failing-on-Windows.patch (100%) rename php/{php-8.2.0 => v8.2.0}/wlr-build.sh (64%) rename php/{php-8.2.0 => v8.2.0}/wlr-env-repo.sh (100%) rename php/{php-8.2.0 => v8.2.0}/wlr-info.json (96%) rename php/{php-8.2.0-slim => v8.2.0}/wlr-tag.sh (100%) rename php/{php-8.2.0 => v8.2.0}/wlr-test.sh (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.6.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0012-chore-Add-debug-logging-in-fastcgi.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0014-fix-implicit-function-declaration-in-syslog.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0017-fix-Patch-for-is_readable-and-is_writable-to-bypass-.patch (100%) rename php/{php-8.2.6 => v8.2.6}/patches/0018-fix-random_bytes-failing-on-Windows.patch (100%) rename php/{php-8.2.6 => v8.2.6}/wlr-build.sh (94%) rename php/{php-8.2.6 => v8.2.6}/wlr-env-repo.sh (100%) rename php/{php-8.2.6 => v8.2.6}/wlr-info.json (100%) rename php/{php-8.2.6 => v8.2.6}/wlr-tag.sh (100%) rename php/{php-8.2.6 => v8.2.6}/wlr-test.sh (100%) diff --git a/.github/workflows/build-php.yaml b/.github/workflows/build-php.yaml index fdc53477..a255937b 100644 --- a/.github/workflows/build-php.yaml +++ b/.github/workflows/build-php.yaml @@ -12,55 +12,25 @@ jobs: strategy: fail-fast: false matrix: - # TODO (ereslibre): the PHP cli is conditionally compiled - # because it has the ability to open a listening socket-- only - # supported on wasmedge --. Remove build-php-cli from here and - # make the PHP CLI conditionally compile local server code out - # on all versions. - include: - - flavor: "" - build-php-cli: false - version: 8.1.11 - - flavor: "" - build-php-cli: false - version: 8.2.0 - - flavor: "-wasmedge" - build-php-cli: true - version: 8.2.0 - - flavor: -slim - build-php-cli: false - version: 8.2.0 - - flavor: "" - build-php-cli: false - version: 8.2.6 + flavor: ["", "-wasmedge", "-slim"] + version: [8.1.11, 8.2.0, 8.2.6] + exclude: - flavor: "-wasmedge" - build-php-cli: true - version: 8.2.6 + version: 8.1.11 + - flavor: "-slim" + version: 8.1.11 runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Build PHP - run: make php/php-${{ matrix.version }}${{ matrix.flavor }} - - name: Rename `php-cgi.wasm` binary (adding version and flavor) - shell: bash - run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - - name: Rename `php.wasm` binary (CLI) (adding version and flavor) - shell: bash - if: ${{ matrix.build-php-cli }} - run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - - name: Upload php-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact - uses: actions/upload-artifact@v3 - if: ${{ matrix.build-php-cli }} - with: - name: php-${{ matrix.version }}${{ matrix.flavor }}.wasm - path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-${{ matrix.version }}${{ matrix.flavor }}.wasm - if-no-files-found: error - - name: Upload php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact + run: make php/v${{ matrix.version }}${{ matrix.flavor }} + - name: Upload php-${{ matrix.version }} assets uses: actions/upload-artifact@v3 with: - name: php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact - path: build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi-${{ matrix.version }}${{ matrix.flavor }}.wasm + name: php-${{ matrix.version }}.zip + path: | + build-output/*.gz + build-output/*.wasm + build-output/*.txt if-no-files-found: error diff --git a/.github/workflows/release-php.yaml b/.github/workflows/release-php.yaml index 1dab4422..d1a490fe 100644 --- a/.github/workflows/release-php.yaml +++ b/.github/workflows/release-php.yaml @@ -10,111 +10,26 @@ on: tags: - php/* jobs: - release-php: - strategy: - matrix: - # TODO (ereslibre): the PHP cli is conditionally compiled - # because it has the ability to open a listening socket-- only - # supported on wasmedge --. Remove build-php-cli from here and - # make the PHP CLI conditionally compile local server code out - # on all versions. - include: - - flavor: "" - build-php-cli: false - version: 8.1.11 - - flavor: "" - build-php-cli: false - version: 8.2.0 - - flavor: "-wasmedge" - build-php-cli: true - version: 8.2.0 - - flavor: -slim - build-php-cli: false - version: 8.2.0 - - flavor: "" - build-php-cli: false - version: 8.2.6 - - flavor: "-wasmedge" - build-php-cli: true - version: 8.2.6 - - flavor: "-slim" - build-php-cli: false - version: 8.2.6 - runs-on: ubuntu-latest - steps: - - name: Checkout repository - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) - uses: actions/checkout@v3 - - name: Build PHP - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) - run: make php/php-${{ matrix.version }}${{ matrix.flavor }} - - name: Rename CGI release artifacts - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) - shell: bash - run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php-cgi{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - - name: Rename CLI release artifacts - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) && matrix.build-php-cli }} - shell: bash - run: | - sudo mv build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/php{,-${{ matrix.version }}}${{ matrix.flavor }}.wasm - - name: Create release - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create --generate-notes ${{ github.ref_name }} || true - - name: Append PHP release assets - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.wasm - - name: Generate release assets digests - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - for asset in build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.wasm; do - sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null - done - - name: Append release assets digests - # Only run for the PHP version specified in the git tag. - # - # This if could be moved to the parent `job` section when it's - # supported by GitHub (https://github.com/community/community/discussions/37883) - if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))}} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload ${{ github.ref_name }} \ - build-output/php/php-${{ matrix.version }}${{ matrix.flavor }}/bin/*.sha256sum + build-default: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "php" + trigger: ${{ github.event.ref }} + flavor: "" + build-wasmedge: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "php" + trigger: ${{ github.event.ref }} + flavor: "-wasmedge" + build-slim: + uses: ./.github/workflows/reusable-build-runtime-flavor.yaml + with: + target-name: "php" + trigger: ${{ github.event.ref }} + flavor: "-slim" + publish: + uses: ./.github/workflows/reusable-publish-assets.yaml + needs: [build-default, build-wasmedge, build-slim] + with: + target-name: "php" diff --git a/.github/workflows/reusable-build-runtime-flavor.yaml b/.github/workflows/reusable-build-runtime-flavor.yaml index 69c9998c..873fe61d 100644 --- a/.github/workflows/reusable-build-runtime-flavor.yaml +++ b/.github/workflows/reusable-build-runtime-flavor.yaml @@ -17,7 +17,7 @@ on: type: string default: "" jobs: - release-lib: + build-runtime: strategy: fail-fast: false runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index f0c24b13..c566abc0 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,12 @@ include Makefile.helpers -.PHONY: php/php-* -php/php-*: - make -C php $(subst php/php-,php-,$@) +.PHONY: php/v* +php/v*: + make -C php $(subst php/,,$@) -$(eval $(call create_flavor_targets,php,php-8.2.0,wasmedge)) -$(eval $(call create_flavor_targets,php,php-8.2.6,slim wasmedge)) +$(eval $(call create_flavor_targets,php,v8.2.0,slim wasmedge)) +$(eval $(call create_flavor_targets,php,v8.2.6,slim wasmedge)) .PHONY: php/master php/master: diff --git a/Makefile.helpers b/Makefile.helpers index f9dc2264..fb14bbd9 100644 --- a/Makefile.helpers +++ b/Makefile.helpers @@ -158,7 +158,7 @@ endef # # USAGE: # - At Makefile root level (not as part of a target) -# - $(eval $(call create_flavor_target,php,php-1.2.3,slim)) +# - $(eval $(call create_flavor_target,php,v1.2.3,slim)) # define create_flavor_target # $1 - TARGET_NAME @@ -177,7 +177,7 @@ endef # # USAGE: # - At Makefile root level (not as part of a target) -# - $(call create_flavor_targets,php,php-1.2.3,slim wasmedge slim-wasmedge) +# - $(call create_flavor_targets,php,v1.2.3,slim wasmedge slim-wasmedge) # define create_flavor_targets # $1 - TARGET_NAME diff --git a/README.md b/README.md index 7a1bdc96..6cd20bfa 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,8 @@ The rest of this document will help you if you want to build some of the assets All you need in order to run these builds is to have `docker` or `podman` available in your system. You can execute the following `Makefile` targets: -- `php/php-7.3.33`, `php/php-7.4.32`, `php/wasmedge-php-7.4.32`, - `php/php-8.1.11`, `php/php-8.2.0` +- `php/v7.3.33`, `php/v7.4.32`, + `php/v8.1.11`, `php/v8.2.0`, `php/v8.2.0-wasmedge` - Resulting binaries are placed in `build-output/php`. - `python/v3.11.3` @@ -81,7 +81,7 @@ For language runtimes we have something like this. ``` ${LANGUAGE_RUNTIME_NAME} (e.g. 'php') ├── README.md (generic notes about what was patched to build this language) -├── ${VERSION_TAG_IN_REPO} (e.g. 'php-7.4.32' from the php repo) +├── v${VERSION_FROM_TAG_IN_REPO} (e.g. 'v7.4.32' for the 'php-7.4.32 tag from the php repo) │   ├── README.md (generic notes about what was patched to build this version) │   ├── patches (consecutive patches on top of the tagged version, applied before building) │   │   ├── (e.g. '0001-Initial-port-of-7.3.33-patch-to-7.4.32.patch') @@ -92,7 +92,7 @@ ${LANGUAGE_RUNTIME_NAME} (e.g. 'php') └── wlr-env-repo.sh (script that sets up the source code repository for given langauge and tag) ``` -For common shared libraries we have something limilar. +For common shared libraries we have something similar. ``` libs (common libraries, needed by different modules) └── ${LIBRARY_NAME} (e.g. 'sqlite') @@ -122,44 +122,54 @@ libs (common libraries, needed by different modules) To add a build setup for a new version of something that is already configured: -1. Add a subfolder with the respective tag, like this: +1. Add a subfolder for the respective tag version, like this: ``` -mkdir php/php-7.3.33 +mkdir php/v8.1.11 ``` 2. Create a `wlr-build.sh` script in the target folder, like this: ```console -touch php/php-7.3.33/wlr-build.sh +touch php/v8.1.11/wlr-build.sh ``` 3. Setup your build environment via `scripts/wlr-env.sh` with the target path then query the respective environment variables, like this: ```console -source scripts/wlr-env.sh php/php-7.3.33 +source scripts/wlr-env.sh php/v8.1.11 export | grep WLR_ ``` -4. Create a local clone of the respective tag in build-staging, like this: +4. Create a `wlr-env-repo.sh` script in the target folder and define repository, tag, version, etc., like this: + +```console +export WLR_REPO=https://github.com/php/php-src.git +export WLR_REPO_BRANCH=php-8.1.11 +export WLR_ENV_NAME=php/php-8.1.11 +export WLR_PACKAGE_VERSION=8.1.11 +export WLR_PACKAGE_NAME=php +``` + +5. Create a local clone of the respective tag in build-staging, like this: ```console scripts/wlr-setup-repo.sh ``` -5. Open your favorite IDE in the said clone to iterate building from the tag until it works, like this: +6. Open your favorite IDE in the said clone to iterate building from the tag until it works, like this: ```console -code build-staging/php/php-7.3.33/checkout +code build-staging/php/v8.1.11/checkout ``` -6. Patch the checked out code where necessary. Add flags and build commands to the `wlr-build.sh` script in the target folder and each time rebuild like this: +7. Patch the checked out code where necessary. Add flags and build commands to the `wlr-build.sh` script in the target folder and each time rebuild like this: ```console scripts/wlr-build.sh ``` -7. After you manage to get a working build, add proper lines at the end of your `wlr-build.sh` script to copy from the `build-staging` folder to the respective `build-output` location, like this: +8. After you manage to get a working build, add proper lines at the end of your `wlr-build.sh` script to copy from the `build-staging` folder to the respective `build-output` location, like this: ```bash ... @@ -172,7 +182,7 @@ logStatus "DONE. Artifacts in ${WLR_OUTPUT}" ``` -8. Commit the patch changes from 6. into the local shallow clone. If necessary, split them into commits. Then export them to the target folder (e.g. `php/php-7.3.33/patches`) like this: +8. Commit the patch changes from 7. into the local shallow clone. If necessary, split them into commits. Then export them to the target folder (e.g. `php/v8.1.11/patches`) like this: ```console scripts/wlr-update-patches.sh @@ -181,18 +191,18 @@ scripts/wlr-update-patches.sh 9. Now add and commit the new target description folder containing the build script and respective patches to the current repository, like this: ```console -git add php/php-7.3.33 -git commit -m "Add support to build php version 7.3.33" +git add php/v8.1.11 +git commit -m "Add support to build php version 8.1.11" ``` ### Releasing In order to release a new version, you first have to tag the project you want to release. You can create a tag by using the `scripts/wlr-tag.sh` script. -This script accepts the path to be released, and will create a local tag of the form `/+YYYYMMDD-`. All parameters will be automatically filled by the script, so in order to create a valid tag for PHP 7.3.33, for example, you only have to execute: +This script accepts the path to be released, and will create a local tag of the form `/+YYYYMMDD-`. All parameters will be automatically filled by the script, so in order to create a valid tag for PHP 8.1.11, for example, you only have to execute: -- `scripts/wlr-tag.sh php/php-7.3.33` +- `scripts/wlr-tag.sh php/v8.1.11` -This will create a tag like the following in your local repository: `php/7.3.33+20221123-d3d8901`. +This will create a tag like the following in your local repository: `php/8.1.11+20221123-d3d8901`. When you push the tag to the remote repository, a GitHub release will be created automatically, and relevant artifacts will be automatically published to the release. diff --git a/php/Makefile b/php/Makefile index 59c162d9..6890e35d 100644 --- a/php/Makefile +++ b/php/Makefile @@ -12,8 +12,8 @@ php-builder: update-php-builder: php-builder @$(call push_container_image,$(PHP_BUILDER_NAME)) -.PHONY: php-* -php-*: +.PHONY: v* +v*: @$(call build_in_container,$(PHP_BUILDER_NAME),$(REPO_ROOT),php/$@) .PHONY: master diff --git a/php/README.md b/php/README.md index 33acd3c2..db22d712 100644 --- a/php/README.md +++ b/php/README.md @@ -4,11 +4,11 @@ You can build PHP by running the following Makefile targets: -- `make php-7.3.33` -- `make php-7.4.32` -- `make php-8.1.11` -- `make php-8.2.0` -- `make php-8.2.0-slim` +- `make v8.1.11` +- `make v8.2.0` +- `make v8.2.0-slim` +- `make v8.2.6` +- `make v8.2.6-slim` ## Running a script with php-cgi diff --git a/php/examples/mysql/run_me.sh b/php/examples/mysql/run_me.sh index 64bcdaad..d53b7514 100755 --- a/php/examples/mysql/run_me.sh +++ b/php/examples/mysql/run_me.sh @@ -76,9 +76,9 @@ docker exec ${MYSQL_CONTAINER_NAME} mysql -h 127.0.0.1 -P 3306 -u${TEST_USER} -p demo_step Build PHP if not available # TODO - download from github after release -if [ ! -f ../../../build-output/php/php-8.2.0-wasmedge/bin/php-wasmedge.wasm ]; +if [ ! -f ../../../build-output/php/v8.2.6-wasmedge/bin/php-wasmedge.wasm ]; then - (cd ../../..; WLR_BUILD_FLAVOR=wasmedge ./wlr-make.sh php/php-8.2.0) || exit 1 + (cd ../../..; WLR_BUILD_FLAVOR=wasmedge ./wlr-make.sh php/v8.2.6) || exit 1 fi demo_step Test mySQL with PHP. diff --git a/php/php-8.2.0-slim/patches b/php/php-8.2.0-slim/patches deleted file mode 120000 index 4650df72..00000000 --- a/php/php-8.2.0-slim/patches +++ /dev/null @@ -1 +0,0 @@ -../php-8.2.0/patches \ No newline at end of file diff --git a/php/php-8.2.0-slim/wlr-build.sh b/php/php-8.2.0-slim/wlr-build.sh deleted file mode 100644 index ab72d93d..00000000 --- a/php/php-8.2.0-slim/wlr-build.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -logStatus "Building libs 'php/php-8.2.0-slim'" - -if [[ ! -v WLR_ENV ]] -then - echo "WLR build environment is not set" - exit 1 -fi - -export CFLAGS_CONFIG="-O2" - -########## Setup the wasi related flags ############# -export CFLAGS_WASI="--sysroot=${WASI_SYSROOT} -D_WASI_EMULATED_GETPID -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS" -export LDFLAGS_WASI="--sysroot=${WASI_SYSROOT} -lwasi-emulated-getpid -lwasi-emulated-signal -lwasi-emulated-process-clocks" - -########## Setup the flags for php ############# -export CFLAGS_PHP='-D_POSIX_SOURCE=1 -D_GNU_SOURCE=1 -DHAVE_FORK=0 -DWASM_WASI' - -export LDFLAGS_WARNINGS='-Wno-unused-command-line-argument -Werror=implicit-function-declaration -Wno-incompatible-function-pointer-types' - -# We need to add LDFLAGS ot CFLAGS because autoconf compiles(+links) to binary when checking stuff -export LDFLAGS="${LDFLAGS_WASI} ${LDFLAGS_DEPENDENCIES} ${LDFLAGS_SQLITE} ${LDFLAGS_WARNINGS}" -export CFLAGS="${CFLAGS_CONFIG} ${CFLAGS_WASI} ${CFLAGS_DEPENDENCIES} ${CFLAGS_PHP} ${LDFLAGS}" - -logStatus "CFLAGS="${CFLAGS} -logStatus "LDFLAGS="${LDFLAGS} - - -cd "${WLR_SOURCE_PATH}" - -if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then - logStatus "Generating configure script..." - ./buildconf --force || exit 1 - - export PHP_CONFIGURE='' - PHP_CONFIGURE+=' --disable-all' - PHP_CONFIGURE+=' --without-libxml' - PHP_CONFIGURE+=' --disable-dom' - PHP_CONFIGURE+=' --without-iconv' - PHP_CONFIGURE+=' --without-openssl' - PHP_CONFIGURE+=' --disable-simplexml' - PHP_CONFIGURE+=' --disable-xml' - PHP_CONFIGURE+=' --disable-xmlreader' - PHP_CONFIGURE+=' --disable-xmlwriter' - PHP_CONFIGURE+=' --without-pear' - PHP_CONFIGURE+=' --disable-phar' - PHP_CONFIGURE+=' --disable-opcache' - PHP_CONFIGURE+=' --disable-zend-signals' - PHP_CONFIGURE+=' --without-pcre-jit' - PHP_CONFIGURE+=' --without-sqlite3' - PHP_CONFIGURE+=' --disable-pdo' - PHP_CONFIGURE+=' --without-pdo-sqlite' - PHP_CONFIGURE+=' --disable-fiber-asm' - - if [[ -v WLR_RUNTIME ]] - then - export PHP_CONFIGURE="--with-wasm-runtime=${WLR_RUNTIME} ${PHP_CONFIGURE}" - fi - - logStatus "Configuring build with '${PHP_CONFIGURE}'..." - ./configure --host=wasm32-wasi host_alias=wasm32-musl-wasi --target=wasm32-wasi target_alias=wasm32-musl-wasi ${PHP_CONFIGURE} || exit 1 -else - logStatus "Skipping configure..." -fi - -export MAKE_TARGETS='cgi' -if [[ "${WLR_RUNTIME}" == "wasmedge" ]] -then - export MAKE_TARGETS="${MAKE_TARGETS} cli" -fi - -logStatus "Building '${MAKE_TARGETS}'..." -# By exporting WLR_SKIP_WASM_OPT envvar during the build, the -# wasm-opt wrapper in the wasm-base image will be a dummy wrapper that -# is effectively a NOP. -# -# This is due to https://github.com/llvm/llvm-project/issues/55781, so -# that we get to choose which optimization passes are executed after -# the artifacts have been built. -export WLR_SKIP_WASM_OPT=1 -make -j ${MAKE_TARGETS} || exit 1 -unset WLR_SKIP_WASM_OPT - -logStatus "Preparing artifacts..." -mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 - -logStatus "Running wasm-opt with the asyncify pass on php-cgi..." -wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php-cgi${WLR_RUNTIME:+-$WLR_RUNTIME}-slim.wasm sapi/cgi/php-cgi || exit 1 - -if [[ "${WLR_RUNTIME}" == "wasmedge" ]] -then - logStatus "Running wasm-opt with the asyncify pass on php..." - wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php${WLR_RUNTIME:+-$WLR_RUNTIME}-slim.wasm sapi/cli/php || exit 1 -fi - -logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/php/php-8.2.0-slim/wlr-env-repo.sh b/php/php-8.2.0-slim/wlr-env-repo.sh deleted file mode 100644 index 693459b7..00000000 --- a/php/php-8.2.0-slim/wlr-env-repo.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -if [[ $1 == "--unset" ]] -then - unset WLR_REPO - unset WLR_REPO_BRANCH - unset WLR_ENV_NAME - unset WLR_PACKAGE_VERSION - unset WLR_PACKAGE_NAME - return -fi - -export WLR_REPO=https://github.com/php/php-src.git -export WLR_REPO_BRANCH=php-8.2.0 -export WLR_ENV_NAME=php/php-8.2.0 -export WLR_PACKAGE_VERSION=8.2.0 -export WLR_PACKAGE_NAME=php -export WLR_BUILD_FLAVOR=${WLR_BUILD_FLAVOR:+-}slim diff --git a/php/php-8.2.0-slim/wlr-test.sh b/php/php-8.2.0-slim/wlr-test.sh deleted file mode 100644 index cb20de8e..00000000 --- a/php/php-8.2.0-slim/wlr-test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -v WLR_ENV ]] -then - echo "WLR build environment is not set" - exit 1 -fi - -if ! [ -x "$(command -v php)" ] -then - echo "Native php is required in PATH on the host to act as orchestrator for php.wasm tests!" - exit 1 -fi - -if [ -f "${WLR_OUTPUT}/bin/php${WLR_RUNTIME:+-$WLR_RUNTIME}" ] -then - export WLR_TESTED_MODULE="${WLR_OUTPUT}/bin/php${WLR_RUNTIME:+-$WLR_RUNTIME}" -else - export WLR_TESTED_MODULE="${WLR_OUTPUT}/bin/php-cgi${WLR_RUNTIME:+-$WLR_RUNTIME}" -fi - -if ! [ -x "${WLR_TESTED_MODULE}" ] -then - echo "WASM module not found at '${WLR_TESTED_MODULE}'" - exit 1 -fi - -cd "${WLR_SOURCE_PATH}" -echo "Calling 'WLR_TESTED_MODULE=${WLR_TESTED_MODULE} php -f run-tests.php -- -p ${WLR_TEST_RUNTIME_WRAPPER} -j6' to run tests..." -php -f run-tests.php -- -p ${WLR_TEST_RUNTIME_WRAPPER} -j6 \ - tests/lang \ - tests/output \ - tests/strings \ - Zend/tests/fibers diff --git a/php/php-8.2.0/wlr-tag.sh b/php/php-8.2.0/wlr-tag.sh deleted file mode 100644 index 5aaebfa5..00000000 --- a/php/php-8.2.0/wlr-tag.sh +++ /dev/null @@ -1 +0,0 @@ -export WLR_TAG="php/8.2.0" diff --git a/php/php-7.3.33/README.md b/php/v7.3.33/README.md similarity index 100% rename from php/php-7.3.33/README.md rename to php/v7.3.33/README.md diff --git a/php/php-7.4.32/README.md b/php/v7.4.32/README.md similarity index 100% rename from php/php-7.4.32/README.md rename to php/v7.4.32/README.md diff --git a/php/php-8.1.11/README.md b/php/v8.1.11/README.md similarity index 100% rename from php/php-8.1.11/README.md rename to php/v8.1.11/README.md diff --git a/php/php-8.1.11/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.1.11.patch b/php/v8.1.11/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.1.11.patch similarity index 100% rename from php/php-8.1.11/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.1.11.patch rename to php/v8.1.11/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.1.11.patch diff --git a/php/php-8.1.11/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch b/php/v8.1.11/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch similarity index 100% rename from php/php-8.1.11/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch rename to php/v8.1.11/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch diff --git a/php/php-8.1.11/wlr-build.sh b/php/v8.1.11/wlr-build.sh similarity index 94% rename from php/php-8.1.11/wlr-build.sh rename to php/v8.1.11/wlr-build.sh index 307d21fe..dbbcfdaf 100644 --- a/php/php-8.1.11/wlr-build.sh +++ b/php/v8.1.11/wlr-build.sh @@ -51,6 +51,8 @@ logStatus "Preparing artifacts... " mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 logStatus "Running wasm-opt with the asyncify pass on php-cgi.." -wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php-cgi.wasm sapi/cgi/php-cgi || exit 1 +wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WLR_OUTPUT}/bin/php-cgi-${WLR_PACKAGE_VERSION}.wasm sapi/cgi/php-cgi || exit 1 + +cp -v ${WLR_OUTPUT}/bin/php-* ${WLR_OUTPUT_BASE} logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/php/php-8.1.11/wlr-env-repo.sh b/php/v8.1.11/wlr-env-repo.sh similarity index 100% rename from php/php-8.1.11/wlr-env-repo.sh rename to php/v8.1.11/wlr-env-repo.sh diff --git a/php/php-8.1.11/wlr-info.json b/php/v8.1.11/wlr-info.json similarity index 100% rename from php/php-8.1.11/wlr-info.json rename to php/v8.1.11/wlr-info.json diff --git a/php/php-8.1.11/wlr-tag.sh b/php/v8.1.11/wlr-tag.sh similarity index 100% rename from php/php-8.1.11/wlr-tag.sh rename to php/v8.1.11/wlr-tag.sh diff --git a/php/php-8.1.11/wlr-test.sh b/php/v8.1.11/wlr-test.sh similarity index 100% rename from php/php-8.1.11/wlr-test.sh rename to php/v8.1.11/wlr-test.sh diff --git a/php/php-8.2.0/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.11.patch b/php/v8.2.0/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.11.patch similarity index 100% rename from php/php-8.2.0/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.11.patch rename to php/v8.2.0/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.11.patch diff --git a/php/php-8.2.0/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch b/php/v8.2.0/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch similarity index 100% rename from php/php-8.2.0/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch rename to php/v8.2.0/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch diff --git a/php/php-8.2.0/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch b/php/v8.2.0/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch similarity index 100% rename from php/php-8.2.0/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch rename to php/v8.2.0/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch diff --git a/php/php-8.2.0/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch b/php/v8.2.0/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch similarity index 100% rename from php/php-8.2.0/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch rename to php/v8.2.0/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch diff --git a/php/php-8.2.0/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch b/php/v8.2.0/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch similarity index 100% rename from php/php-8.2.0/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch rename to php/v8.2.0/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch diff --git a/php/php-8.2.0/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch b/php/v8.2.0/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch similarity index 100% rename from php/php-8.2.0/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch rename to php/v8.2.0/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch diff --git a/php/php-8.2.0/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch b/php/v8.2.0/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch similarity index 100% rename from php/php-8.2.0/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch rename to php/v8.2.0/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch diff --git a/php/php-8.2.0/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch b/php/v8.2.0/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch similarity index 100% rename from php/php-8.2.0/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch rename to php/v8.2.0/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch diff --git a/php/php-8.2.0/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch b/php/v8.2.0/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch similarity index 100% rename from php/php-8.2.0/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch rename to php/v8.2.0/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch diff --git a/php/php-8.2.0/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch b/php/v8.2.0/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch similarity index 100% rename from php/php-8.2.0/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch rename to php/v8.2.0/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch diff --git a/php/php-8.2.0/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch b/php/v8.2.0/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch similarity index 100% rename from php/php-8.2.0/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch rename to php/v8.2.0/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch diff --git a/php/php-8.2.0/patches/0012-chore-Add-debug-logging-in-fastcgi.patch b/php/v8.2.0/patches/0012-chore-Add-debug-logging-in-fastcgi.patch similarity index 100% rename from php/php-8.2.0/patches/0012-chore-Add-debug-logging-in-fastcgi.patch rename to php/v8.2.0/patches/0012-chore-Add-debug-logging-in-fastcgi.patch diff --git a/php/php-8.2.0/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch b/php/v8.2.0/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch similarity index 100% rename from php/php-8.2.0/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch rename to php/v8.2.0/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch diff --git a/php/php-8.2.0/patches/0014-fix-implicit-function-declaration-in-syslog.patch b/php/v8.2.0/patches/0014-fix-implicit-function-declaration-in-syslog.patch similarity index 100% rename from php/php-8.2.0/patches/0014-fix-implicit-function-declaration-in-syslog.patch rename to php/v8.2.0/patches/0014-fix-implicit-function-declaration-in-syslog.patch diff --git a/php/php-8.2.0/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch b/php/v8.2.0/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch similarity index 100% rename from php/php-8.2.0/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch rename to php/v8.2.0/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch diff --git a/php/php-8.2.0/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch b/php/v8.2.0/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch similarity index 100% rename from php/php-8.2.0/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch rename to php/v8.2.0/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch diff --git a/php/php-8.2.0/patches/0017-fix-is_writable-with-stat-bypass.patch b/php/v8.2.0/patches/0017-fix-is_writable-with-stat-bypass.patch similarity index 100% rename from php/php-8.2.0/patches/0017-fix-is_writable-with-stat-bypass.patch rename to php/v8.2.0/patches/0017-fix-is_writable-with-stat-bypass.patch diff --git a/php/php-8.2.0/patches/0018-fix-random_bytes-failing-on-Windows.patch b/php/v8.2.0/patches/0018-fix-random_bytes-failing-on-Windows.patch similarity index 100% rename from php/php-8.2.0/patches/0018-fix-random_bytes-failing-on-Windows.patch rename to php/v8.2.0/patches/0018-fix-random_bytes-failing-on-Windows.patch diff --git a/php/php-8.2.0/wlr-build.sh b/php/v8.2.0/wlr-build.sh similarity index 64% rename from php/php-8.2.0/wlr-build.sh rename to php/v8.2.0/wlr-build.sh index f690b0d4..8e04f64f 100644 --- a/php/php-8.2.0/wlr-build.sh +++ b/php/v8.2.0/wlr-build.sh @@ -15,7 +15,12 @@ export CFLAGS_WASI="--sysroot=${WASI_SYSROOT} -D_WASI_EMULATED_GETPID -D_WASI_EM export LDFLAGS_WASI="--sysroot=${WASI_SYSROOT} -lwasi-emulated-getpid -lwasi-emulated-signal -lwasi-emulated-process-clocks" ########## Setup the flags for php ############# -export CFLAGS_PHP='-D_POSIX_SOURCE=1 -D_GNU_SOURCE=1 -DHAVE_FORK=0 -DPNG_USER_CONFIG -DWASM_WASI' +export CFLAGS_PHP='-D_POSIX_SOURCE=1 -D_GNU_SOURCE=1 -DHAVE_FORK=0 -DWASM_WASI' + +if [[ "${WLR_BUILD_FLAVOR}" != *"slim"* ]] +then + CFLAGS_PHP+=' -DPNG_USER_CONFIG' +fi export LDFLAGS_WARNINGS='-Wno-unused-command-line-argument -Werror=implicit-function-declaration -Wno-incompatible-function-pointer-types' @@ -30,10 +35,8 @@ logStatus "LDFLAGS="${LDFLAGS} cd "${WLR_SOURCE_PATH}" if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then - if [[ ! -e ./configure ]]; then - logStatus "Generating configure script..." - ./buildconf --force || exit 1 - fi + logStatus "Generating configure script..." + ./buildconf --force || exit 1 export PHP_CONFIGURE='' PHP_CONFIGURE+=' --without-iconv' @@ -43,22 +46,46 @@ if [[ -z "$WLR_SKIP_CONFIGURE" ]]; then PHP_CONFIGURE+=' --disable-opcache' PHP_CONFIGURE+=' --disable-zend-signals' PHP_CONFIGURE+=' --without-pcre-jit' - PHP_CONFIGURE+=' --with-sqlite3' - PHP_CONFIGURE+=' --enable-pdo' - PHP_CONFIGURE+=' --with-pdo-sqlite' - PHP_CONFIGURE+=' --enable-mbstring' - PHP_CONFIGURE+=' --enable-gd' PHP_CONFIGURE+=' --disable-fiber-asm' - PHP_CONFIGURE+=' --with-jpeg' + + if [[ "${WLR_BUILD_FLAVOR}" == *"slim"* ]] + then + PHP_CONFIGURE+=' --disable-all' + PHP_CONFIGURE+=' --without-libxml' + PHP_CONFIGURE+=' --disable-dom' + PHP_CONFIGURE+=' --disable-simplexml' + PHP_CONFIGURE+=' --disable-xml' + PHP_CONFIGURE+=' --disable-xmlreader' + PHP_CONFIGURE+=' --disable-xmlwriter' + PHP_CONFIGURE+=' --without-sqlite3' + PHP_CONFIGURE+=' --disable-pdo' + PHP_CONFIGURE+=' --without-pdo-sqlite' + else + PHP_CONFIGURE+=' --with-sqlite3' + PHP_CONFIGURE+=' --enable-pdo' + PHP_CONFIGURE+=' --with-pdo-sqlite' + PHP_CONFIGURE+=' --enable-mbstring' + PHP_CONFIGURE+=' --enable-gd' + PHP_CONFIGURE+=' --with-jpeg' + fi if [[ "${WLR_BUILD_FLAVOR}" == *"wasmedge"* ]] then - export PHP_CONFIGURE="${PHP_CONFIGURE} --enable-mysqlnd --with-pdo-mysql --with-mysqli" - export PHP_CONFIGURE="--with-wasm-runtime=wasmedge ${PHP_CONFIGURE}" + PHP_CONFIGURE+=' --enable-mysqlnd' + PHP_CONFIGURE+=' --with-pdo-mysql' + PHP_CONFIGURE+=' --with-mysqli' + + PHP_CONFIGURE="--with-wasm-runtime=wasmedge ${PHP_CONFIGURE}" fi logStatus "Configuring build with '${PHP_CONFIGURE}'... " - ./configure --config-cache --host=wasm32-wasi host_alias=wasm32-musl-wasi --target=wasm32-wasi target_alias=wasm32-musl-wasi ${PHP_CONFIGURE} || exit 1 + ./configure \ + --config-cache \ + --host=wasm32-wasi \ + host_alias=wasm32-musl-wasi \ + --target=wasm32-wasi \ + target_alias=wasm32-musl-wasi \ + ${PHP_CONFIGURE} || exit 1 else logStatus "Skipping configure..." fi @@ -87,15 +114,17 @@ mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 WASM_OPT_ARGS=-O3 # WASM_OPT_ARGS="${WASM_OPT_ARGS} --asyncify --pass-arg=asyncify-ignore-imports" -PHP_CGI_TARGET="${WLR_OUTPUT}/bin/php-cgi${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" +PHP_CGI_TARGET="${WLR_OUTPUT}/bin/php-cgi-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" logStatus "Running wasm-opt with '${WASM_OPT_ARGS}' on php-cgi..." wasm-opt ${WASM_OPT_ARGS} -o "${PHP_CGI_TARGET}" sapi/cgi/php-cgi || exit 1 if [[ "${WLR_BUILD_FLAVOR}" == *"wasmedge"* ]] then - PHP_CLI_TARGET="${WLR_OUTPUT}/bin/php${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" + PHP_CLI_TARGET="${WLR_OUTPUT}/bin/php-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" logStatus "Running wasm-opt with '${WASM_OPT_ARGS}' for ${PHP_CLI_TARGET}..." wasm-opt ${WASM_OPT_ARGS} -o ${PHP_CLI_TARGET} sapi/cli/php || exit 1 fi +cp -v ${WLR_OUTPUT}/bin/php-* ${WLR_OUTPUT_BASE} + logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/php/php-8.2.0/wlr-env-repo.sh b/php/v8.2.0/wlr-env-repo.sh similarity index 100% rename from php/php-8.2.0/wlr-env-repo.sh rename to php/v8.2.0/wlr-env-repo.sh diff --git a/php/php-8.2.0/wlr-info.json b/php/v8.2.0/wlr-info.json similarity index 96% rename from php/php-8.2.0/wlr-info.json rename to php/v8.2.0/wlr-info.json index 56834a35..0b9bd050 100644 --- a/php/php-8.2.0/wlr-info.json +++ b/php/v8.2.0/wlr-info.json @@ -30,5 +30,10 @@ "required_file": "lib/wasm32-wasi/libsqlite3.a", "url": "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/libs%2Fsqlite%2F3.42.0%2B20230623-2993864/libsqlite-3.42.0-wasi-sdk-20.0.tar.gz" } + }, + "flavors": { + "slim": { + "deps": {} + } } } \ No newline at end of file diff --git a/php/php-8.2.0-slim/wlr-tag.sh b/php/v8.2.0/wlr-tag.sh similarity index 100% rename from php/php-8.2.0-slim/wlr-tag.sh rename to php/v8.2.0/wlr-tag.sh diff --git a/php/php-8.2.0/wlr-test.sh b/php/v8.2.0/wlr-test.sh similarity index 100% rename from php/php-8.2.0/wlr-test.sh rename to php/v8.2.0/wlr-test.sh diff --git a/php/php-8.2.6/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.6.patch b/php/v8.2.6/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.6.patch similarity index 100% rename from php/php-8.2.6/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.6.patch rename to php/v8.2.6/patches/0001-Initial-port-of-the-php-7.4.32-patch-for-php-8.2.6.patch diff --git a/php/php-8.2.6/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch b/php/v8.2.6/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch similarity index 100% rename from php/php-8.2.6/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch rename to php/v8.2.6/patches/0002-feat-Incapacitate-fibers-when-compiling-for-WASI.patch diff --git a/php/php-8.2.6/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch b/php/v8.2.6/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch similarity index 100% rename from php/php-8.2.6/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch rename to php/v8.2.6/patches/0003-fix-Add-more-ifdefs-for-php-8.2.0.patch diff --git a/php/php-8.2.6/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch b/php/v8.2.6/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch similarity index 100% rename from php/php-8.2.6/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch rename to php/v8.2.6/patches/0004-fix-Fix-memory-issues-and-introduce-WASM_WASMEDGE.patch diff --git a/php/php-8.2.6/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch b/php/v8.2.6/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch similarity index 100% rename from php/php-8.2.6/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch rename to php/v8.2.6/patches/0005-feat-Server-sockets-via-with-wasm-runtime-wasmedge.patch diff --git a/php/php-8.2.6/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch b/php/v8.2.6/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch similarity index 100% rename from php/php-8.2.6/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch rename to php/v8.2.6/patches/0006-fix-Avoid-include-syslog.h-since-it-is-not-part-of-w.patch diff --git a/php/php-8.2.6/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch b/php/v8.2.6/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch similarity index 100% rename from php/php-8.2.6/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch rename to php/v8.2.6/patches/0007-fix-Avoid-setjmp-longjmp-in-gd_jpeg.patch diff --git a/php/php-8.2.6/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch b/php/v8.2.6/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch similarity index 100% rename from php/php-8.2.6/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch rename to php/v8.2.6/patches/0008-fix-Avoid-tmpfile-in-gd_bmp.patch diff --git a/php/php-8.2.6/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch b/php/v8.2.6/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch similarity index 100% rename from php/php-8.2.6/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch rename to php/v8.2.6/patches/0009-fix-Avoid-jmp_buf-in-gd_jpeg.patch diff --git a/php/php-8.2.6/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch b/php/v8.2.6/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch similarity index 100% rename from php/php-8.2.6/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch rename to php/v8.2.6/patches/0010-chore-Add-more-logs-in-wasi_socket_ext.patch diff --git a/php/php-8.2.6/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch b/php/v8.2.6/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch similarity index 100% rename from php/php-8.2.6/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch rename to php/v8.2.6/patches/0011-fix-fastcgi-server-in-php-cgi-for-wasmedge.patch diff --git a/php/php-8.2.6/patches/0012-chore-Add-debug-logging-in-fastcgi.patch b/php/v8.2.6/patches/0012-chore-Add-debug-logging-in-fastcgi.patch similarity index 100% rename from php/php-8.2.6/patches/0012-chore-Add-debug-logging-in-fastcgi.patch rename to php/v8.2.6/patches/0012-chore-Add-debug-logging-in-fastcgi.patch diff --git a/php/php-8.2.6/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch b/php/v8.2.6/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch similarity index 100% rename from php/php-8.2.6/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch rename to php/v8.2.6/patches/0013-chore-Fixes-logs-getnameinfo-in-wasi-sock-sdk.patch diff --git a/php/php-8.2.6/patches/0014-fix-implicit-function-declaration-in-syslog.patch b/php/v8.2.6/patches/0014-fix-implicit-function-declaration-in-syslog.patch similarity index 100% rename from php/php-8.2.6/patches/0014-fix-implicit-function-declaration-in-syslog.patch rename to php/v8.2.6/patches/0014-fix-implicit-function-declaration-in-syslog.patch diff --git a/php/php-8.2.6/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch b/php/v8.2.6/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch similarity index 100% rename from php/php-8.2.6/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch rename to php/v8.2.6/patches/0015-feat-Enable-mysqlnd-and-more-network-functions-with-.patch diff --git a/php/php-8.2.6/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch b/php/v8.2.6/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch similarity index 100% rename from php/php-8.2.6/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch rename to php/v8.2.6/patches/0016-fix-implicit-function-declaration-for-bind-when-not-.patch diff --git a/php/php-8.2.6/patches/0017-fix-Patch-for-is_readable-and-is_writable-to-bypass-.patch b/php/v8.2.6/patches/0017-fix-Patch-for-is_readable-and-is_writable-to-bypass-.patch similarity index 100% rename from php/php-8.2.6/patches/0017-fix-Patch-for-is_readable-and-is_writable-to-bypass-.patch rename to php/v8.2.6/patches/0017-fix-Patch-for-is_readable-and-is_writable-to-bypass-.patch diff --git a/php/php-8.2.6/patches/0018-fix-random_bytes-failing-on-Windows.patch b/php/v8.2.6/patches/0018-fix-random_bytes-failing-on-Windows.patch similarity index 100% rename from php/php-8.2.6/patches/0018-fix-random_bytes-failing-on-Windows.patch rename to php/v8.2.6/patches/0018-fix-random_bytes-failing-on-Windows.patch diff --git a/php/php-8.2.6/wlr-build.sh b/php/v8.2.6/wlr-build.sh similarity index 94% rename from php/php-8.2.6/wlr-build.sh rename to php/v8.2.6/wlr-build.sh index 9509c0b4..d9ee79ae 100644 --- a/php/php-8.2.6/wlr-build.sh +++ b/php/v8.2.6/wlr-build.sh @@ -114,15 +114,17 @@ mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 WASM_OPT_ARGS=-O3 # WASM_OPT_ARGS="${WASM_OPT_ARGS} --asyncify --pass-arg=asyncify-ignore-imports" -PHP_CGI_TARGET="${WLR_OUTPUT}/bin/php-cgi${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" +PHP_CGI_TARGET="${WLR_OUTPUT}/bin/php-cgi-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" logStatus "Running wasm-opt with '${WASM_OPT_ARGS}' on php-cgi..." wasm-opt ${WASM_OPT_ARGS} -o "${PHP_CGI_TARGET}" sapi/cgi/php-cgi || exit 1 if [[ "${WLR_BUILD_FLAVOR}" == *"wasmedge"* ]] then - PHP_CLI_TARGET="${WLR_OUTPUT}/bin/php${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" + PHP_CLI_TARGET="${WLR_OUTPUT}/bin/php-${WLR_PACKAGE_VERSION}${WLR_BUILD_FLAVOR:+-$WLR_BUILD_FLAVOR}.wasm" logStatus "Running wasm-opt with '${WASM_OPT_ARGS}' for ${PHP_CLI_TARGET}..." wasm-opt ${WASM_OPT_ARGS} -o ${PHP_CLI_TARGET} sapi/cli/php || exit 1 fi +cp -v ${WLR_OUTPUT}/bin/php-* ${WLR_OUTPUT_BASE} + logStatus "DONE. Artifacts in ${WLR_OUTPUT}" diff --git a/php/php-8.2.6/wlr-env-repo.sh b/php/v8.2.6/wlr-env-repo.sh similarity index 100% rename from php/php-8.2.6/wlr-env-repo.sh rename to php/v8.2.6/wlr-env-repo.sh diff --git a/php/php-8.2.6/wlr-info.json b/php/v8.2.6/wlr-info.json similarity index 100% rename from php/php-8.2.6/wlr-info.json rename to php/v8.2.6/wlr-info.json diff --git a/php/php-8.2.6/wlr-tag.sh b/php/v8.2.6/wlr-tag.sh similarity index 100% rename from php/php-8.2.6/wlr-tag.sh rename to php/v8.2.6/wlr-tag.sh diff --git a/php/php-8.2.6/wlr-test.sh b/php/v8.2.6/wlr-test.sh similarity index 100% rename from php/php-8.2.6/wlr-test.sh rename to php/v8.2.6/wlr-test.sh From 2d8421ac471e1d841e6c2b1e0e38c53b6eb13b35 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Thu, 13 Jul 2023 03:30:24 +0300 Subject: [PATCH 11/12] fix: Python 3.11.3 build --- python/v3.11.3/wlr-build.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/python/v3.11.3/wlr-build.sh b/python/v3.11.3/wlr-build.sh index cfa2e236..430403b3 100644 --- a/python/v3.11.3/wlr-build.sh +++ b/python/v3.11.3/wlr-build.sh @@ -11,7 +11,7 @@ cd "${WLR_SOURCE_PATH}" if [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]] then source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_wasi_vfs.sh - wlr_wasi_vfs_setup_dependencies || exit 1 + export LDFLAGS="$(wlr_wasi_vfs_get_link_flags) ${LDFLAGS}" fi source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_pkg_config.sh @@ -80,16 +80,16 @@ then fi logStatus "Preparing artifacts... " -TARGET_PYTHON_BINARY=${WLR_OUTPUT}/bin/python.wasm +TARGET_PYTHON_BINARY=bin/python-${WLR_PACKAGE_VERSION}.wasm mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 if [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]] then - cp -v python-optimized.wasm ${TARGET_PYTHON_BINARY} || exit 1 + cp -v python-optimized.wasm ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} || exit 1 else mkdir -p ${WLR_OUTPUT}/usr 2>/dev/null || exit 1 - cp -v python-optimized.wasm ${TARGET_PYTHON_BINARY} || exit 1 + cp -v python-optimized.wasm ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} || exit 1 cp -TRv usr ${WLR_OUTPUT}/usr || exit 1 fi @@ -127,6 +127,16 @@ EOF PC_INCLUDE_SUBDIR=python3.11 wlr_pkg_config_create_pc_file "libpython3.11" "${WLR_PACKAGE_VERSION}" "${DESCRIPTION}" "${EXTRA_LINK_FLAGS}" || exit 1 WLR_PACKAGE_EXTRA_DIRS=usr wlr_package_lib || exit 1 + WLR_PACKAGE_LIST="${TARGET_PYTHON_BINARY} usr" wlr_package || exit 1 + +elif [[ "${WLR_BUILD_FLAVOR}" == *"aio"* ]]; then + # skip 'aio' in the name + FLAVOR_SUFFIX=$(echo ${WLR_BUILD_FLAVOR} | sed 's/-\?aio//g') + PUBLISHED_PYTHON_BINARY=python-${WLR_PACKAGE_VERSION}${FLAVOR_SUFFIX}.wasm + cp -v ${WLR_OUTPUT}/${TARGET_PYTHON_BINARY} ${WLR_OUTPUT_BASE}/${PUBLISHED_PYTHON_BINARY} || exit 1 + +else + WLR_PACKAGE_LIST="${TARGET_PYTHON_BINARY} usr" wlr_package || exit 1 fi logStatus "DONE. Artifacts in ${WLR_OUTPUT}" From c7dee9a05653541456237666c12bc53ae437f539 Mon Sep 17 00:00:00 2001 From: Asen Alexandrov Date: Thu, 13 Jul 2023 17:26:35 +0300 Subject: [PATCH 12/12] chore: Update developer docs --- .github/workflows/reusable-build-lib.yaml | 12 +- .../reusable-build-runtime-flavor.yaml | 10 + .../workflows/reusable-publish-assets.yaml | 16 ++ README.md | 159 +------------ docs/developers.md | 216 +++++++++++++++++- scripts/README.md | 3 + scripts/build-helpers/README.md | 3 + scripts/build-helpers/wlr_autoconf.sh | 2 +- 8 files changed, 259 insertions(+), 162 deletions(-) create mode 100644 scripts/README.md create mode 100644 scripts/build-helpers/README.md diff --git a/.github/workflows/reusable-build-lib.yaml b/.github/workflows/reusable-build-lib.yaml index 026d32d8..595ae41d 100644 --- a/.github/workflows/reusable-build-lib.yaml +++ b/.github/workflows/reusable-build-lib.yaml @@ -1,4 +1,14 @@ -name: Build a library +# Used to build an external library +# Example: +# jobs: +# build-libs-bzip2: +# strategy: +# fail-fast: false +# uses: ./.github/workflows/reusable-build-lib.yaml +# with: +# target: bzip2/v1.0.8 + +name: Build an external library on: workflow_call: inputs: diff --git a/.github/workflows/reusable-build-runtime-flavor.yaml b/.github/workflows/reusable-build-runtime-flavor.yaml index 873fe61d..6d053ccd 100644 --- a/.github/workflows/reusable-build-runtime-flavor.yaml +++ b/.github/workflows/reusable-build-runtime-flavor.yaml @@ -1,3 +1,13 @@ +# Used to build a language runtime flavor +# Example: +# jobs: +# build-php-my-flavor: +# uses: ./.github/workflows/reusable-build-runtime-flavor.yaml +# with: +# target-name: "php" +# trigger: ${{ github.event.ref }} +# flavor: "-my-flavor" + # Note: This workflow should be refactored into a custom GH action. # This will allow us to call it in job steps and have more flexibility. # Currently we can only call it as a separate job/ Thus we cannot populate diff --git a/.github/workflows/reusable-publish-assets.yaml b/.github/workflows/reusable-publish-assets.yaml index 140ae900..6458086c 100644 --- a/.github/workflows/reusable-publish-assets.yaml +++ b/.github/workflows/reusable-publish-assets.yaml @@ -1,3 +1,19 @@ +# Used to publish release assets uploaded by a previous job (e.g.`reusable-build-runtime-flavor.yaml)` +# Example +# jobs: +# build-job: +# ... +# steps: +# - uses: actions/upload-artifact@v3 +# with: +# name: php.zip +# ... +# publish: +# uses: ./.github/workflows/reusable-publish-assets.yaml +# needs: build-job +# with: +# target-name: "php" + # Note: This workflow should be refactored into a custom GH action. # This will allow us to call it in job steps and have more flexibility. on: diff --git a/README.md b/README.md index 6cd20bfa..5ba80c31 100644 --- a/README.md +++ b/README.md @@ -48,161 +48,4 @@ Here is a reference to the latest releases of all built projects. ## For developers -The rest of this document will help you if you want to build some of the assets on your own, or contribute with a patch, or add support for new release targets. - -### Getting started - -All you need in order to run these builds is to have `docker` or `podman` available in your system. You can execute the following `Makefile` targets: - -- `php/v7.3.33`, `php/v7.4.32`, - `php/v8.1.11`, `php/v8.2.0`, `php/v8.2.0-wasmedge` - - Resulting binaries are placed in `build-output/php`. - -- `python/v3.11.3` - - Resulting binaries are placed in `build-output/python`. - -- `ruby/v3.2.0` - - Resulting binaries are placed in `build-output/ruby`. - -### Build strategy - -If you are interested in knowing more about the build system and how it produces the final binaries, keep reading. - -#### Code Organization - -All build orchestration scripts are written in bash in this initial version. They start with a `wlr-` prefix (short for WebAssembly Language Runtimes). Review the [build orchestration scripts](#build-orchestration-scripts) section for more info. - -All intermediary source code checkouts and build objects get created within the `build-staging` folder. The final output gets written to the `build-output` folder. - -The patches and scripts to build different language runtimes are organized in a folder hierarchy that follows the tagged versions from the respective source code repositories. Several `wlr-` scripts are added around that to facilitate setup of a local clone of the repository, application of respective patches and building with respective build configuration options. - -For language runtimes we have something like this. - -``` -${LANGUAGE_RUNTIME_NAME} (e.g. 'php') -├── README.md (generic notes about what was patched to build this language) -├── v${VERSION_FROM_TAG_IN_REPO} (e.g. 'v7.4.32' for the 'php-7.4.32 tag from the php repo) -│   ├── README.md (generic notes about what was patched to build this version) -│   ├── patches (consecutive patches on top of the tagged version, applied before building) -│   │   ├── (e.g. '0001-Initial-port-of-7.3.33-patch-to-7.4.32.patch') -│   │   ├── (e.g. '0002-Fix-mmap-issues.-Add-readme.patch') -│   │   └── Etc... -│   ├── wlr-build-deps.sh (script that builds dependencies) -│   └── wlr-build.sh (script that builds for this tag) -└── wlr-env-repo.sh (script that sets up the source code repository for given langauge and tag) -``` - -For common shared libraries we have something similar. -``` -libs (common libraries, needed by different modules) -└── ${LIBRARY_NAME} (e.g. 'sqlite') - ├── README.md (generic notes about what was patched to build this language) - ├──${VERSION_TAG_IN_REPO} (e.g. 'version-3.39.2' from the sqlite repo) - │   ├── patches (consecutive patches on top of the tagged version, applied before building) - │   │   ├── (e.g. '0001-Patch-to-build-sqlite-3.39.2-for-wasm32-wasi.patch') - │   │   ├── (e.g. '0002-Remove-build-script-from-patched-repo.patch') - │   │   └── Etc... - │   └── wlr-build.sh (script that builds for this tag) - └── wlr-env-repo.sh (script that sets up the source code repository for given langauge and tag) -``` - -#### Build orchestration scripts - -1. The main script used to build something is `wlr-make.sh` in the root folder. It gets called with a path to the folder for a respective tag of what we want to build. - -2. It will first __source__ the `scripts/wlr-env.sh` script. This one sets all environment variables necessary to checkout and build the desired target. It gets the same path from `wlr-make.sh` and is useful when you try to build locally. - -3. Then `wlr-make.sh` will call `scripts/wlr-setup-repo.sh` to create a shallow clone of the necessary repository only for the specific tag that we want to build. On top of that it applies any relevant patches from the `patches` subfolder of the tagged version folder. - -4. As a final step `wlr-make.sh` will call `scripts/wlr-build.sh` which will build from the code in the respective repository. - -5. Before building this will call a `$LANG/$TAG/wlr-build-deps.sh` if there is any to build required dependencies and setup CFLAGS or LDFLAGS for their artifacts. Then it will call the `$LANG/$TAG/wlr-build.sh` script to build the actual target itself. - -#### Adding a new build target - -To add a build setup for a new version of something that is already configured: - -1. Add a subfolder for the respective tag version, like this: - -``` -mkdir php/v8.1.11 -``` - -2. Create a `wlr-build.sh` script in the target folder, like this: - -```console -touch php/v8.1.11/wlr-build.sh -``` - -3. Setup your build environment via `scripts/wlr-env.sh` with the target path then query the respective environment variables, like this: - -```console -source scripts/wlr-env.sh php/v8.1.11 -export | grep WLR_ -``` - -4. Create a `wlr-env-repo.sh` script in the target folder and define repository, tag, version, etc., like this: - -```console -export WLR_REPO=https://github.com/php/php-src.git -export WLR_REPO_BRANCH=php-8.1.11 -export WLR_ENV_NAME=php/php-8.1.11 -export WLR_PACKAGE_VERSION=8.1.11 -export WLR_PACKAGE_NAME=php -``` - -5. Create a local clone of the respective tag in build-staging, like this: - -```console -scripts/wlr-setup-repo.sh -``` - -6. Open your favorite IDE in the said clone to iterate building from the tag until it works, like this: - -```console -code build-staging/php/v8.1.11/checkout -``` - -7. Patch the checked out code where necessary. Add flags and build commands to the `wlr-build.sh` script in the target folder and each time rebuild like this: - -```console -scripts/wlr-build.sh -``` - -8. After you manage to get a working build, add proper lines at the end of your `wlr-build.sh` script to copy from the `build-staging` folder to the respective `build-output` location, like this: - -```bash -... -logStatus "Preparing artifacts... " -mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 - -cp sapi/cgi/php-cgi ${WLR_OUTPUT}/bin/ || exit 1 - -logStatus "DONE. Artifacts in ${WLR_OUTPUT}" - -``` - -8. Commit the patch changes from 7. into the local shallow clone. If necessary, split them into commits. Then export them to the target folder (e.g. `php/v8.1.11/patches`) like this: - -```console -scripts/wlr-update-patches.sh -``` - -9. Now add and commit the new target description folder containing the build script and respective patches to the current repository, like this: - -```console -git add php/v8.1.11 -git commit -m "Add support to build php version 8.1.11" -``` - -### Releasing - -In order to release a new version, you first have to tag the project you want to release. You can create a tag by using the `scripts/wlr-tag.sh` script. - -This script accepts the path to be released, and will create a local tag of the form `/+YYYYMMDD-`. All parameters will be automatically filled by the script, so in order to create a valid tag for PHP 8.1.11, for example, you only have to execute: - -- `scripts/wlr-tag.sh php/v8.1.11` - -This will create a tag like the following in your local repository: `php/8.1.11+20221123-d3d8901`. - -When you push the tag to the remote repository, a GitHub release will be created automatically, and relevant artifacts will be automatically published to the release. +If you want to contribute to this project or run a build on your own machine, take a look at the [./docs/developers.md](./docs/developers.md) documentation. diff --git a/docs/developers.md b/docs/developers.md index c20b195f..75ae091d 100644 --- a/docs/developers.md +++ b/docs/developers.md @@ -1,7 +1,140 @@ This document is a work in progress. +If it lacks some information that you needed, consider adding it via a PR. + +# Terminology + + - *language runtime* - this is some interpreted language runtime, which we build for wasm32-wasi. Running this runtime (interpreter) as a Wasm module allows people to run interpreted workloads on top of a Wasm Runtime. + - *external library* - there are many common low-level system libraries at the core of traditional glibc apps. We build the statically for wasm32-wasi so they can be reused in the interpreter runtimes or when porting other glibc-based apps. + - *internal library* - these are static wasm32-wasi libraries, which we provide to avoid code duplication. + +# Getting started + +All you need in order to run these builds is to have *GNU Make* along with `docker` or `podman` in your system. + + - To build any of the major runtimes you could start with `make php/`, `make python/` or `make/ruby`, then `` to see the available targets (versions and flavors). + + Here is an example build of PHP: + + ```shell-session + /home/ubuntu/wlr/ $$ make php/v8.2.6-slim + + WLR_BUILD_FLAVOR=slim make -C php v8.2.6 + make[1]: Entering directory '/home/ubuntu/wlr/php' + Cloning into '/wlr/build-staging/php/php-8.2.6-slim/checkout'... + ... + Using WASI_SDK_PATH=/wasi-sdk + php/php-8.2.6(slim) | Checking dependencies... + php/php-8.2.6(slim) | Getting dependencies for php/php-8.2.6 ... + ... + Building 'php/php-8.2.6' + ... + php/php-8.2.6(slim) | DONE. Artifacts in /wlr/build-output/php/php-8.2.6-slim + make[1]: Leaving directory '/home/ubuntu/wlr/php' + ``` + + - To build an external library you could do the same with say `make libs/libxml2/`, then `` to see the available targets (versions and flavors) . + + - To build an internal library you only need to specify the path to it, as in `make libs/wlr_bundle` + +Both runtimes and external libraries will have a subfolder that contains the build scripts and patches for the supported versions. These folder names usually follow the format `v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}`. For example `make php/v8.2.6` or `'libs/libxml2/v2.11.4`. + +# The build scripts + +All build orchestration scripts are written in bash in this initial version. They start with a `wlr-` prefix (short for WebAssembly Language Runtimes). Review the [build execution](#build-execution) section for more info on what happens during a build. + +## File organization + +### At build time +We use two working folders at build time - `build-staging` and `build-output`. + + - `build-staging` - contains all intermediary source code checkouts and build objects. It also contains the checkouts and builds of dependencies. Each target uses only its own subfolder, for example `build-staging/php/php-8.2.6-slim`. + - `build-output` - contains the final output. The built binaries can be organized in `bin`, `include`, `lib`, etc. in the build target's own subfolder (e.g. `build-output/php/php-8.2.6-slim`) for local use or testing. Publishable assets (`*{.wasm,gz,txt}`) are placed at the `build-output` root during build. + +### Build scripts and patches +The patches and build scripts are organized in sub-folders for each tagged version of the target runtime or external library. Several `wlr-` scripts are added around that to facilitate setup of a local clone of the repository, application of respective patches and building with respective build configuration options. + +For language runtimes we have something like this. + +``` +${LANGUAGE_RUNTIME_NAME} (e.g. 'php') +├── README.md (generic notes about what was patched to build this language) +└── v${VERSION_FROM_TAG_IN_REPO} (e.g. 'v7.4.32' for the 'php-7.4.32 tag from the php repo) +    ├── README.md (generic notes about what was patched to build this version) +    ├── patches (consecutive patches on top of the tagged version, applied before building) +    │   ├── (e.g. '0001-Initial-port-of-7.3.33-patch-to-7.4.32.patch') +    │   ├── (e.g. '0002-Fix-mmap-issues.-Add-readme.patch') +    │   └── Etc... +   ├── wlr-build.sh (script that builds for this version - might contain specific manually set commands, flags, etc) +    ├── wlr-env-repo.sh (describes version, repository and tag from which we build this version) +    ├── wlr-info.json [optional] (build metadata - currently only describes build dependencies) +    └── wlr-tag.sh [optional] (describes the tag format used to release a build from this version) +``` + +For common shared libraries we have something similar. +``` +libs (common libraries, needed by different modules) +└── ${LIBRARY_NAME} (e.g. 'sqlite') + ├── README.md (generic notes about what was patched to build this language) + └──${VERSION_TAG_IN_REPO} (e.g. 'version-3.39.2' from the sqlite repo) +    ├── patches (consecutive patches on top of the tagged version, applied before building) +    │   ├── (e.g. '0001-Patch-to-build-sqlite-3.39.2-for-wasm32-wasi.patch') +    │   ├── (e.g. '0002-Remove-build-script-from-patched-repo.patch') +    │   └── Etc... +   ├── wlr-build.sh (script that builds for this version - might contain specific manually set commands, flags, etc) +   ├── wlr-env-repo.sh (describes version, repository and tag from which we build this version) +    ├── wlr-info.json [optional] (build metadata - currently only describes build dependencies) +    └── wlr-tag.sh [optional] (describes the tag format used to release a build from this version) +``` + +### Helper scripts + +There is a bunch of GNU Make macros and constants in [Makefile.helpers](../Makefile.helpers), which reduce the code repetition in Makefiles. Macros should be well documented within the file itself. Some of them create targets dynamically and should be invoked via `$(eval $(call ...))`/ + +Most of the build helper scripts are located in the [scripts](../scripts/) folder. Where available, documentation for them is in-place. + +## Build execution + +The GNU Make makefiles will use build containers that have all necessary dependencies for a build. Inside the container they call on the `wlr-make.sh` script. + +1. The main script used to build something is `wlr-make.sh` in the root folder. It gets called with a path to the the `${TARGET_FOLDER}` folder that we want to build. For example `php/v8.2.6`. Build flavors (like `slim`, `wasmedge`, etc are passed via the `WLR_BUILD_FLAVOR` env variable). + +2. `wlr-make.sh` will first __source__ the `scripts/wlr-env.sh` script. This one sets all environment variables necessary to checkout and build the desired target. The staging or output folders configured here may be different depending on whether the target is built as a standalone one or as a dependency of another target. + +3. Then `wlr-make.sh` will call `scripts/wlr-setup-repo.sh` to create a shallow clone of the necessary repository only for the specific tag that we want to build. On top of that it applies any relevant patches from the `patches` subfolder of the tagged version folder. + +4. As a final step `wlr-make.sh` will call `scripts/wlr-build.sh` which will build from the code in the respective repository. + +5. First `scripts/wlr-build.sh` will use `${TARGET_FOLDER}/wlr-info.json` to determine if we need to also build or download any required dependencies. Then those are either built locally (by calling `wlr-make.sh` respectively) or downloaded. + +6. After we have all dependencies `scripts/wlr-build.sh` will call the `${TARGET_FOLDER}/wlr-build.sh` script to build the actual target itself. + +# GH Actions + +We usually have two types of actions for each project - `build-*` and `release-*`. The first is triggered on any PR change in files that affect the project, while the latter is triggered on the push of a release tag. + +**Note**: In case of several release tags on the same commit, push them to github one by one. Otherwise the `release-*` GH actions will not be triggered! + +We have a few reusable workflows, each starts with the `reusable-` prefix. They are documented and can be found in the [.github/workflows/](../.github/workflows/) folder. + # Processes +## Releasing + +In order to release a new version, you first have to tag the project you want to release. You can create a tag by using the `scripts/wlr-tag.sh` script. + +This script accepts the path to be released, and will create a local tag of the form `/+YYYYMMDD-`. All parameters will be automatically filled by the script, so in order to create a valid tag for PHP 8.1.11, for example, you only have to execute: + +```shell-session +$$ scripts/wlr-tag.sh php/v8.1.11 +``` + +This will create a tag like the following in your local repository: `php/8.1.11+20221123-d3d8901`. + +When you push the tag to the remote repository, a GitHub release will be created automatically, and relevant artifacts will be automatically published to the release. + +**Note**: See [GH Actions](#gh-actions). In case of several release tags on the same commit, push them to github one by one. Otherwise the `release-*` GH actions will not be triggered! + ## Updating Wasi-Sdk version You will need ghcr.io credentials with rights to publish to `ghcr.io/vmware-labs/wasmlabs`! @@ -11,5 +144,84 @@ This document is a work in progress. ``` make -f Makefile.builders update-all-builders ``` - - Release all independent libraries - - Bump URLs in the libraries/runtimes which depend on them, then publish them, too + - Build and release all independent libraries with the new WASI SDK version (without a `"deps"` section in a `wlr-info.json`). + - Bump `"url": "..."` fields in all `wlr-info.json` for the libraries/runtimes, which depend on them, then release them, too. + +**Note**: When you bump up the WASI SDK version this may bring in a newer version of the CLang toolchain. Often times this leads to changes in the default handling of certain warnings - e.g. what used to be only warnings are now errors. The fix is usually to add the respective flags to ignore the warning in the `wlr-build.sh` for the failing target. + +## Adding a new build target + +To add a build setup for a new version of something that is already configured: + +1. Add a subfolder for the respective tag version, like this: + +``` +mkdir php/v8.1.11 +``` + +2. Create a `wlr-build.sh` script in the target folder, like this: + +```console +touch php/v8.1.11/wlr-build.sh +``` + +3. Setup your build environment via `scripts/wlr-env.sh` with the target path then query the respective environment variables, like this: + +```console +source scripts/wlr-env.sh php/v8.1.11 +export | grep WLR_ +``` + +4. Create a `wlr-env-repo.sh` script in the target folder and define repository, tag, version, etc., like this: + +```console +export WLR_REPO=https://github.com/php/php-src.git +export WLR_REPO_BRANCH=php-8.1.11 +export WLR_ENV_NAME=php/php-8.1.11 +export WLR_PACKAGE_VERSION=8.1.11 +export WLR_PACKAGE_NAME=php +``` + +5. Create a local clone of the respective tag in build-staging, like this: + +```console +scripts/wlr-setup-repo.sh +``` + +6. Open your favorite IDE in the said clone to iterate building from the tag until it works, like this: + +```console +code build-staging/php/v8.1.11/checkout +``` + +7. Patch the checked out code where necessary. Add flags and build commands to the `wlr-build.sh` script in the target folder and each time rebuild like this: + +```console +scripts/wlr-build.sh +``` + +8. After you manage to get a working build, add proper lines at the end of your `wlr-build.sh` script to copy from the `build-staging` folder to the respective `build-output` location, like this: + +```bash +... +logStatus "Preparing artifacts... " +mkdir -p ${WLR_OUTPUT}/bin 2>/dev/null || exit 1 + +cp sapi/cgi/php-cgi ${WLR_OUTPUT}/bin/ || exit 1 + +logStatus "DONE. Artifacts in ${WLR_OUTPUT}" + +``` + +8. Commit the patch changes from 7. into the local shallow clone. If necessary, split them into commits. Then export them to the target folder (e.g. `php/v8.1.11/patches`) like this: + +```console +scripts/wlr-update-patches.sh +``` + +9. Now add and commit the new target description folder containing the build script and respective patches to the current repository, like this: + +```console +git add php/v8.1.11 +git commit -m "Add support to build php version 8.1.11" +``` diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..451c743a --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,3 @@ +[build-helpers](./build-helpers/) contains scripts for reuse in the various `${TARGET_FOLDER}/wlr-build.sh` scripts + +The purpose of the most important from the rest of the scripts is briefly discussed in [developers.md#build-execution](../docs/developers.md#build-execution). diff --git a/scripts/build-helpers/README.md b/scripts/build-helpers/README.md new file mode 100644 index 00000000..017d6b7f --- /dev/null +++ b/scripts/build-helpers/README.md @@ -0,0 +1,3 @@ +These are all scripts which are intended for sourcing within the `wlr-build.sh` scripts for build targets. + +They abstract common operations via exported bash functions. diff --git a/scripts/build-helpers/wlr_autoconf.sh b/scripts/build-helpers/wlr_autoconf.sh index d84af7ae..02948530 100755 --- a/scripts/build-helpers/wlr_autoconf.sh +++ b/scripts/build-helpers/wlr_autoconf.sh @@ -4,7 +4,7 @@ if [ "${BASH_SOURCE-}" = "$0" ]; then echo "You must source this script: \$ source $0" >&2 return fi -logStatus "Downloading latest config.guess and config.sub ... " +logStatus "Ensure we're using the latest config.guess and config.sub ... " function wlr_update_autoconf { if [[ ! -f config.guess && "$1" != "--force" ]]; then