-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ereslibre/build-environment
feat: add common build environment
- Loading branch information
Showing
14 changed files
with
203 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build PHP | ||
on: | ||
push: | ||
# By specifying branches explicitly, we avoid this workflow from | ||
# running on tag push. We have a dedicated workflow to be ran when | ||
# a tag is pushed. | ||
branches: | ||
- "*" | ||
pull_request: | ||
jobs: | ||
build-php: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: [7.3.33, 7.4.32] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Build PHP | ||
run: make php/php-${{ matrix.version }} | ||
- name: Upload php-cgi-${{ matrix.version }}.wasm artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: php-cgi-${{ matrix.version }}.wasm | ||
path: php/build-output/php/php-${{ matrix.version }}/bin/php-cgi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Release PHP | ||
on: | ||
push: | ||
tags: | ||
- php/* | ||
jobs: | ||
release-php: | ||
strategy: | ||
matrix: | ||
version: [7.3.33, 7.4.32] | ||
runs-on: ubuntu-latest | ||
env: | ||
BINARYEN_VERSION: 110 | ||
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: 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
run: make php/php-${{ matrix.version }} | ||
- name: Rename 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
shell: bash | ||
run: | | ||
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{,.wasm} | ||
- name: Setup binaryen | ||
# 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
shell: bash | ||
run: | | ||
wget https://github.com/WebAssembly/binaryen/releases/download/version_${{ env.BINARYEN_VERSION }}/binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz | ||
tar -xf binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz --strip-components=1 -C /opt | ||
rm binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz | ||
- name: Optimize 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
shell: bash | ||
run: | | ||
sudo /opt/bin/wasm-opt -Os -o php/build-output/php/php-${{ matrix.version }}/bin/php-cgi.size-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-cgi.wasm | ||
sudo /opt/bin/wasm-opt -O -o php/build-output/php/php-${{ matrix.version }}/bin/php-cgi.speed-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-cgi.wasm | ||
- name: Append version to 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
run: | | ||
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{,-${{ matrix.version }}}.wasm | ||
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{,-${{ matrix.version }}}.size-optimized.wasm | ||
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{,-${{ matrix.version }}}.speed-optimized.wasm | ||
- name: 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: github.event.ref == format('refs/tags/php/{0}', matrix.version) | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}.wasm | ||
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}.size-optimized.wasm | ||
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}.speed-optimized.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ubuntu:latest@sha256:4b1d0c4a2d2aaf63b37111f34eb9fa89fa1bf53dd6e4ca954d47caebca4005c2 | ||
ARG WASI_SDK_VERSION=16 | ||
ENV WASI_SDK=wasi-sdk-${WASI_SDK_VERSION} | ||
ENV WASI_SDK_ROOT=/wasi-sdk | ||
RUN apt update && \ | ||
DEBIAN_FRONTEND=noninteractive apt install -y \ | ||
autoconf \ | ||
automake \ | ||
build-essential \ | ||
clang \ | ||
git \ | ||
pkg-config \ | ||
wget | ||
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/${WASI_SDK}/${WASI_SDK}.0-linux.tar.gz && \ | ||
mkdir /wasi-sdk && \ | ||
tar xf ${WASI_SDK}.0-linux.tar.gz --strip-components=1 -C ${WASI_SDK_ROOT} && \ | ||
rm ${WASI_SDK}.0-linux.tar.gz | ||
ADD . /wlr | ||
WORKDIR /wlr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This Makefile contains the main targets for all supported language runtimes | ||
|
||
.PHONY: php/php-* | ||
php/php-*: | ||
make -C php $(subst php/php-,php-,$@) | ||
|
||
.PHONY: clean | ||
clean: | ||
make -C php clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BUILDER_ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
.PHONY: wasi-builder-16 | ||
wasi-builder-16: | ||
docker build --build-arg WASI_SDK_VERSION=16 -f ${BUILDER_ROOT_DIR}/Dockerfile.wasi-builder -t ghcr.io/vmware-labs/wasi-builder:16 ${BUILDER_ROOT_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
# About | ||
|
||
Build scripts and patches for the sqlite3 library. | ||
# Prerequisites | ||
|
||
1. All build operations rely on WASISDK. You could get it from here - https://github.com/WebAssembly/wasi-sdk | ||
|
||
2. The sqlite build uses autoconf make and libtool. On a ubuntu machine you may need to do | ||
|
||
```console | ||
sudo apt update && sudo apt install autoconf make libtool-bin -y | ||
``` | ||
|
||
3. Before building define WASI_SDK_ROOT to point to a local installation of WasiSDK. For example | ||
|
||
```console | ||
export WASI_SDK_ROOT=/opt/wasi-sdk | ||
``` | ||
|
||
# References | ||
|
||
The patch and approach have been greatly influenced by the changes in [rcarmo/wasi-sqlite](https://github.com/rcarmo/wasi-sqlite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build-output | ||
build-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ARG WASI_SDK_VERSION=16 | ||
FROM ghcr.io/vmware-labs/wasi-builder:${WASI_SDK_VERSION} | ||
RUN DEBIAN_FRONTEND=noninteractive apt install -y \ | ||
bison \ | ||
re2c \ | ||
libsqlite3-dev \ | ||
tcl | ||
ADD . /wlr/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
WASI_SDK_VERSION ?= 16 | ||
|
||
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
include ../Makefile.builders | ||
|
||
.PHONY: php-builder | ||
php-builder: wasi-builder-16 | ||
docker build -f ${ROOT_DIR}/Dockerfile --build-arg WASI_SDK_VERSION=$(WASI_SDK_VERSION) -t ghcr.io/vmware-labs/php-builder:wasi-$(WASI_SDK_VERSION) ${ROOT_DIR} | ||
|
||
.PHONY: php-* | ||
php-*: php-builder | ||
mkdir -p build-output build-staging | ||
docker run --rm -v ${ROOT_DIR}/build-output:/wlr/build-output -v ${ROOT_DIR}/build-staging:/wlr/build-staging ghcr.io/vmware-labs/php-builder:wasi-${WASI_SDK_VERSION} ./wl-make.sh php/$@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build-output build-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.