export
+<<<<<<< HEAD
PHP ?= 7.4
+=======
+PHP ?= 8.0
+>>>>>>> 3cab5c6 (support for github workflow steps)
JOBS ?= 2
PHP_MIRROR ?= https://php.net/distributions/
TMPDIR ?= /tmp
-makdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+mkfile := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
+makdir := $(dir $(mkfile))
-ifdef TRAVIS
-prefix ?= $(HOME)/cache/php-$(PHP)-$(shell env |grep -E '^with_|^enable_' | tr -c '[a-zA-Z_]' -)
-else
-prefix ?= $(TMPDIR)/php-$(PHP)-$(shell env |grep -E '^with_|^enable_' | tr -c '[a-zA-Z_]' -)
+ifeq (,$(findstring printenv,$(MAKECMDGOALS)))
+mkargs := $(shell $(MAKE) -f $(mkfile) printenv | sed -n -e 's,with_,,gp' -e 's,enable_,,gp' | tr -c '[a-zA-Z_]' -)
endif
+
+prefix ?= $(TMPDIR)/php-$(PHP)-$(mkargs)
exec_prefix ?= $(prefix)
bindir = $(exec_prefix)/bin
srcdir = $(prefix)/src
-ifdef TRAVIS_BUILD_DIR
-curdir ?= $(TRAVIS_BUILD_DIR)
-else
# CURDIR is a make builtin
curdir ?= $(CURDIR)
-endif
enable_maintainer_zts ?= no
enable_debug ?= no
.PHONY: all
all: php
+.PHONY: printenv
+printenv:
+ @env | grep -E 'prefix=|dir=' | grep -v config_file_scan_dir | sort
+ @env | grep -E '^PHP|^PECL' | sort
+ @env | grep -E '^with_|^enable_' | grep -Ev 'php_config|config_file_scan_dir' | sort
+
.PHONY: versions
versions: $(PHP_RELEASES)
grep "^$(PHP)" $< | cut -f1-2
.PHONY: pecl-check
pecl-check:
@if test -z "$(PECL)"; then echo "No pecl extension specified, e.g. PECL=pecl_http:http"; exit 1; fi
- if test -d $(PECL_DIR)/.git; then cd $(PECL_DIR)/; git pull; fi
+ if test -d $(PECL_DIR)/.git; then cd $(PECL_DIR)/; git pull || test -z "$$CI"; fi
.PHONY: pecl-clean
pecl-clean:
-# travis-pecl
+# pecl-ci
-These few lines of code support building and testing PHP extensions on Travis-CI.
+These few lines of code support building and testing PHP extensions on CI.
## Usage
First, we'll add this repo to our extension as submodule:
- git submodule add -n travis-pecl https://github.com/m6w6/travis-pecl.git travis/pecl
+ git submodule add -n pecl-ci https://github.com/m6w6/pecl-ci.git scripts/ci
git submodule update --init
Let's build a `.travis.yml`by example. We'll use a simple PHP script, e.g. `gen_travis_yml.php`,
<?php
# instantiate the generator
- $gen = include "travis/pecl/gen-matrix.php";
+ $gen = include "scripts/ci/gen-matrix.php";
# generate the matrix
$env = $gen([
before_script:
# build the matrix' PHP version
- - make -f travis/pecl/Makefile php
+ - make -f scripts/ci/Makefile php
# build the extension, the PECL variable expects the extension name
# and optionally the soname and a specific version of the extension
# separeated by double colon, e.g. PECL=myext:ext:1.7.5
- - make -f travis/pecl/Makefile ext PECL=myext
+ - make -f scripts/ci/Makefile ext PECL=myext
script:
# run the PHPT test suite
- - make -f travis/pecl/Makefile test
+ - make -f scripts/ci/Makefile test
That's it, more TBD.
<?php
-return function() {
- foreach (func_get_args() as $array) {
- $apc = [];
- foreach ($array as $key => $values) {
- if (is_numeric($key) && is_string($values)) {
- // switch on yes/no
- $key = $values;
- $values = ["no", "yes"];
- } else if (is_numeric($key) && is_array($values)) {
- // mutually enasbled options
- $vpc = [];
- foreach ($values as $yes) {
- $mpc = "$yes=yes ";
- foreach ($values as $no) {
- if ($yes === $no) {
- continue;
- }
- $mpc .= "$no=no ";
- }
- $vpc[] = $mpc;
- }
- $key = null;
- $values = $vpc;
- }
+return new class {
+ function github(array $matrix) {
+ $idx = function($job_id) {
+ static $ids = [];
+
+ $parts = explode("-", $job_id);
+ $count = end($parts);
+ if (is_numeric($count)) {
+ unset($parts[key($parts)]);
+ }
+
+ $base = implode("-", $parts);
+ if (isset($ids[$base])) {
+ $ids[$base]++;
+ } else {
+ $ids[$base] = 0;
+ }
+ $parts[] = $ids[$base];
+
+ return implode("-", $parts);
+ };
+
+ $all_jobs = [];
+ foreach ($matrix as $id => $array) {
+ $jobs = [];
+ foreach ($array as $key => $values) {
+ if (is_numeric($key) && is_string($values)) {
+ // duplicate each job and switch on yes/no
+ if (!$jobs) {
+ $jobs[$idx($id)][$values] = "yes";
+ $jobs[$idx($id)][$values] = "no";
+ } else {
+ foreach (array_keys($jobs) as $job_id) {
+ $jobs[$job_id][$values] = "yes";
+ $job_idx = $idx($job_id);
+ $jobs[$job_idx] = $jobs[$job_id];
+ $jobs[$job_idx][$values] = "no";
+ }
+ }
+ } else if (is_numeric($key) && is_array($values)) {
+ // multiplicate each job for each mutually enabled combination of options
+ $all_mut = [];
+ foreach ($values as $yes) {
+ $mut = [$yes => "yes"];
+ foreach ($values as $no) {
+ if ($yes !== $no) {
+ $mut[$no] = "no";
+ }
+ }
+ $all_mut[] = $mut;
+ }
+
+ if (!$jobs) {
+ foreach ($all_mut as $mut) {
+ $jobs[$idx($id)] = $mut;
+ }
+ } else {
+ foreach (array_keys($jobs) as $job_id) {
+ foreach ($all_mut as $i => $mut) {
+ $mut_job = array_merge($jobs[$job_id], $mut);
+ if ($i == 0) {
+ $jobs[$job_id] = $mut_job;
+ } else {
+ $jobs[$idx($job_id)] = $mut_job;
+ }
+ }
+ }
+ }
+ } else {
+ // multiplicate all jobs for each value
+ if (!$jobs) {
+ foreach ((array) $values as $val) {
+ $jobs[$idx($id)][$key] = $val;
+ }
+ } else {
+ foreach (array_keys($jobs) as $job_id) {
+ foreach ((array) $values as $i => $val) {
+ if ($i == 0) {
+ $jobs[$job_id][$key] = $val;
+ } else {
+ $job_idx = $idx($job_id);
+ $jobs[$job_idx] = $jobs[$job_id];
+ $jobs[$job_idx][$key] = $val;
+ }
+ }
+ }
+ }
+ }
+ }
+ $all_jobs[] = $jobs;
+ }
+ return array_merge(...$all_jobs);
+ }
+ function travis(array $matrix) {
+ $xpc = [];
+ foreach ($matrix as $id => $array) {
+ $apc = [];
+ foreach ($array as $key => $values) {
+ if (is_numeric($key) && is_string($values)) {
+ // switch on yes/no
+ $key = $values;
+ $values = ["no", "yes"];
+ } else if (is_numeric($key) && is_array($values)) {
+ // mutually enabled options
+ $vpc = [];
+ foreach ($values as $yes) {
+ $mpc = "$yes=yes ";
+ foreach ($values as $no) {
+ if ($yes === $no) {
+ continue;
+ }
+ $mpc .= "$no=no ";
+ }
+ $vpc[] = $mpc;
+ }
+ $key = null;
+ $values = $vpc;
+ }
- if (empty($apc)) {
- // seed
- foreach ((array) $values as $val) {
- $apc[] = strlen($key) ? "$key=$val" : $val;
- }
- } else {
- // combine
- $cpc = $apc;
- $apc = [];
- foreach ((array) $values as $val) {
- foreach ($cpc as $e) {
- $apc[] = strlen($key) ? "$e $key=$val" : "$e $val";
- }
- }
- }
- }
- $xpc[] = $apc;
- }
- return $xpc;
+ if (empty($apc)) {
+ // seed
+ foreach ((array) $values as $val) {
+ $apc[] = strlen($key) ? "$key=$val" : $val;
+ }
+ } else {
+ // combine
+ $cpc = $apc;
+ $apc = [];
+ foreach ((array) $values as $val) {
+ foreach ($cpc as $e) {
+ $apc[] = strlen($key) ? "$e $key=$val" : "$e $val";
+ }
+ }
+ }
+ }
+ $xpc[$id] = $apc;
+ }
+ return $xpc;
+ }
+ function __invoke(...$args) {
+ return $this->travis(...$args); // BC
+ }
};