Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zeriyoshi committed Jul 1, 2024
0 parents commit 5994081
Show file tree
Hide file tree
Showing 61 changed files with 3,128 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "colopl_timeshifter",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"maelvalais.autoconf"
]
}
},
"dockerComposeFile": "../compose.yaml",
"service": "dev",
"workspaceFolder": "/usr/src/php/ext/extension"
}
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
17 changes: 17 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
42 changes: 42 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
ubuntu_2204_php81_origin_deb:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
arch: ["arm64v8", "amd64"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Build Container
uses: docker/build-push-action@v5
with:
build-args: ARCH=${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./build/ubuntu2204/Dockerfile
load: true
tags: "pskel-build-ubuntu2204-${{ matrix.arch }}"
- name: Build Extension with Container
run: |
mkdir "artifacts"
docker run --env VERSION="${{ github.ref_name }}" --rm -v"$(pwd)/artifacts:/tmp/artifacts" -i "pskel-build-ubuntu2204-${{ matrix.arch }}"
- name: Upload deb Packages
uses: actions/upload-artifact@v4
with:
name: ubuntu_2204_debs-${{ matrix.arch }}
path: artifacts/
49 changes: 49 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI
on: [push, pull_request]
jobs:
CI:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
arch: ["amd64", "arm64v8", "s390x"]
version: ["8.1", "8.2", "8.3"]
type: ["cli", "zts"]
distro: ["bookworm", "alpine"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64,s390x"
- name: Setup buildx
uses: docker/setup-buildx-action@v3
- name: Build container
run: |
docker compose build --pull --no-cache --build-arg IMAGE=${{ matrix.arch }}/php --build-arg TAG=${{ matrix.version }}-${{ matrix.type }}-${{ matrix.distro }} --build-arg PSKEL_SKIP_DEBUG=${{ matrix.arch != 'amd64' && '1' || '' }}
- name: Run tests
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION=1 dev
- name: Test extension with PHP Debug Build
if: matrix.arch == 'amd64'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_DEBUG=1 dev
- name: Test extension with Valgrind
if: matrix.arch == 'amd64'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_VALGRIND=1 dev
- name: Test extension with LLVM Sanitizer (MemorySanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_MSAN=1 dev
- name: Test extension with LLVM Sanitizer (AddressSanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_ASAN=1 dev
- name: Test extension with LLVM Sanitizer (UndefinedBehaviorSanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_UBSAN=1 dev
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/
/vendor/
composer.lock
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "ext/third_party/timelib"]
path = ext/third_party/timelib
url = https://github.com/derickr/timelib.git
[submodule "derickr/timelib"]
path = ext/third_party/timelib
url = https://github.com/derickr/timelib.git
129 changes: 129 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
ARG IMAGE=php
ARG TAG=8.3-cli

FROM ${IMAGE}:${TAG}

ARG PSKEL_SKIP_DEBUG=""
ARG PSKEL_EXTRA_CONFIGURE_OPTIONS=""

ENV USE_ZEND_ALLOC=0
ENV ZEND_DONT_UNLOAD_MODULES=1
ENV PSKEL_SKIP_DEBUG=${PSKEL_SKIP_DEBUG}
ENV PSKEL_EXTRA_CONFIGURE_OPTIONS=${PSKEL_EXTRA_CONFIGURE_OPTIONS}

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

RUN if test -f "/etc/debian_version"; then \
apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y \
"build-essential" "bison" "valgrind" "llvm" "clang" "zlib1g-dev" "libsqlite3-dev" "git" "unzip" && \
if test "${PSKEL_SKIP_DEBUG}" = ""; then \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--with-valgrind \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fsanitize=memory -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=memory" ./configure \
--includedir="/usr/local/include/clang-msan-php" --program-prefix="clang-msan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-memory-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fsanitize=address -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=address" ./configure \
--includedir="/usr/local/include/clang-asan-php" --program-prefix="clang-asan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-address-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fsanitize=undefined -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined" ./configure \
--includedir="/usr/local/include/clang-ubsan-php" --program-prefix="clang-ubsan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-undefined-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/debug-php" --program-prefix="debug-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete; \
fi; \
elif test -f "/etc/alpine-release"; then \
apk add --no-cache ${PHPIZE_DEPS} "bison" "valgrind" "valgrind-dev" "zlib-dev" "sqlite-dev" "git" "unzip" && \
if test "${PSKEL_SKIP_DEBUG}" = ""; then \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--with-valgrind \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/debug-php" --program-prefix="debug-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete; \
fi; \
fi && \
docker-php-source extract

WORKDIR "/usr/src/php"

COPY ./ext /ext

COPY ./ci.sh /usr/bin/ci
68 changes: 68 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
--------------------------------------------------------------------

Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].

4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from [email protected]. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"

5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.

6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".

THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------

This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.

The PHP Group can be contacted via Email at [email protected].

For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.

PHP includes the Zend Engine, freely available at
<http://www.zend.com>.
Loading

0 comments on commit 5994081

Please sign in to comment.