Skip to content

Commit

Permalink
Merge branch 'master' into nicer-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdalpino committed Sep 19, 2023
2 parents adb0a10 + 50325a9 commit 0322315
Show file tree
Hide file tree
Showing 68 changed files with 205 additions and 5,462 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/ci-ext.sh

This file was deleted.

66 changes: 60 additions & 6 deletions .github/workflows/ci-ext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,72 @@ jobs:
matrix:
image:
- php:7.4-cli
- php:7.4-cli-alpine
- php:8.0-cli
- php:8.0-cli-alpine
- php:8.1-cli
- php:8.1-cli-alpine
- php:8.2-cli
- php:8.2-cli-alpine

name: Image ${{ matrix.image }}
runs-on: ubuntu-latest
container: ${{ matrix.image }}
steps:
- name: Pull docker image
run: docker pull ${{ matrix.image }}

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install system dependencies (Alpine)
if: contains(matrix.image, 'alpine')
run: |
apk update
. /etc/os-release
case "$VERSION_ID" in
3.11.* | 3.12.* | 3.13.* | 3.14.* | 3.15.* | 3.16.* | 3.17.*)
apk update && apk add $PHPIZE_DEPS lapack lapack-dev openblas-dev
if [ ! -e /usr/lib/liblapacke.so ]; then
# Fix for Alpine 3.15, 3.16 and 3.17
ln -s /usr/lib/liblapacke.so.3 /usr/lib/liblapacke.so
fi
;;
*)
apk add $PHPIZE_DEPS liblapack lapack-dev openblas-dev
;;
esac
- name: Install system dependencies (Debian)
if: ${{ !contains(matrix.image, 'alpine') }}
run: |
apt-get update -q
apt-get install -qy gfortran liblapack-dev libopenblas-dev liblapacke-dev
- name: Create working directory
run: |
rm -rf /tmp/tensor-package
mkdir /tmp/tensor-package
- name: Create PECL package
run: |
cd /tmp/tensor-package
pecl package "$GITHUB_WORKSPACE/package.xml"
- name: Compile PECL package
run: |
cd /tmp/tensor-package
MAKE="make -j$(nproc)" pecl install tensor-*.tgz
- name: Enable PHP extension
run: docker-php-ext-enable tensor

- name: Check for PHP startup warnings
run: |
php -d display_errors=stderr -d display_startup_errors=1 -d error_reporting=-1 -r ';' 2>/tmp/php-startup-warnings
if [ -s /tmp/php-startup-warnings ]; then
echo 'The PHP extension was successfully installed, but PHP raised these warnings:' >&2
cat /tmp/php-startup-warnings >&2
exit 1
fi
echo "PHP didn't raise any warnings at startup."
- name: Compile
run: docker run --rm -v "$GITHUB_WORKSPACE:/app" ${{ matrix.image }} /app/.github/workflows/ci-ext.sh
- name: Inspect PHP extension
run: php --ri tensor
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.dSYM
*.deps
*.tgz
*.dep

zephir.phar
autom4te.cache/
Expand Down
39 changes: 21 additions & 18 deletions build-ext
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,45 @@ const CONFIG_M4_PATH = './ext/config.m4';
const EXECINFO_MATCH = "PHP_SUBST(TENSOR_SHARED_LIBADD)\n";
const EXECINFO_PATCH = <<<'EOT'
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
if test $have_backtrace_symbols = no; then
LDFLAGS="${LDFLAGS:-} -lexecinfo"
AC_CANONICAL_BUILD
if test "$build_os" = linux-musl; then
CPPFLAGS="${CPPFLAGS:-} -DALPINE_LINUX"
else
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
if test $have_backtrace_symbols = no; then
LDFLAGS="${LDFLAGS:-} -lexecinfo"
fi
fi

EOT
;

chdir(__DIR__);

echo 'Reading config.m4 file';

echo 'Reading config.m4 file... ';
$configM4Contents = file_get_contents(CONFIG_M4_PATH);

if (!$configM4Contents) {
fwrite(STDERR, "Failed to read the config.m4 file!\n");

exit(1);
}
echo "done.\n";

echo 'Applying libexec patch';

echo 'Applying libexec patch... ';
if (strpos($configM4Contents, EXECINFO_MATCH) === false) {
fwrite(STDERR, "Patch entrypoint not found!\n");
fwrite(STDERR, "patch entrypoint not found!\n");

exit(1);
} elseif (strpos($configM4Contents, trim(EXECINFO_PATCH)) !== false) {
echo "Already applied.\n";
echo "already applied.\n";
} else {
$configM4Contents = str_replace(EXECINFO_MATCH, EXECINFO_MATCH . EXECINFO_PATCH, $configM4Contents);
}

echo 'Saving config.m4 file';

if (!file_put_contents(CONFIG_M4_PATH, $configM4Contents)) {
fwrite(STDERR, "Failed to write the config.m4 file\n");

exit(1);
echo "done.\n";
echo 'Saving config.m4 file... ';
if (!file_put_contents(CONFIG_M4_PATH, $configM4Contents)) {
fwrite(STDERR, "Failed to write the config.m4 file\n");

exit(1);
}
echo "done.\n";
}
11 changes: 8 additions & 3 deletions ext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ if test "$PHP_TENSOR" = "yes"; then
done
PHP_SUBST(TENSOR_SHARED_LIBADD)

AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
if test $have_backtrace_symbols = no; then
LDFLAGS="${LDFLAGS:-} -lexecinfo"
AC_CANONICAL_BUILD
if test "$build_os" = linux-musl; then
CPPFLAGS="${CPPFLAGS:-} -DALPINE_LINUX"
else
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
if test $have_backtrace_symbols = no; then
LDFLAGS="${LDFLAGS:-} -lexecinfo"
fi
fi

old_CPPFLAGS=$CPPFLAGS
Expand Down
96 changes: 0 additions & 96 deletions ext/include/arithmetic.dep

This file was deleted.

Loading

0 comments on commit 0322315

Please sign in to comment.