Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,45 @@ on:

jobs:
linux:
name: Linux.${{ matrix.os.label }}.${{ matrix.compiler.name }}.${{ matrix.generator }}
name: Linux ${{ matrix.os.label }} ${{ matrix.compiler.name }} ${{ matrix.generator.name }}
runs-on: ${{ matrix.os.label }}
strategy:
fail-fast: false
matrix:
os:
- { label: ubuntu-latest }
compiler:
- { name: GNU, CC: gcc, CXX: g++, packages: gcc g++ }
- { name: Clang, CC: clang, CXX: clang++, packages: clang llvm-dev }
build_type:
- Release
- { name: GNU, CC: gcc, CXX: g++ }
- { name: Clang, CC: clang, CXX: clang++ }
generator:
- Unix Makefiles
- {
name: "Unix Makefiles",
build_options: "",
test_options: "",
install_options: ""
}
- {
name: "Ninja Multi-Config",
build_options: "--config Release",
test_options: "--build-config Release",
install_options: "--config Release"
}
php:
- 8.3-dev
env:
CC: ${{ matrix.compiler.CC }}
CXX: ${{ matrix.compiler.CXX }}
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
CMAKE_BUILD_TYPE: Release
steps:
- name: Install compiler ${{ matrix.compiler.name }}
run: |
sudo apt-get update
sudo apt-get -y install ${{ matrix.compiler.packages }}

- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
build-essential \
gcc \
g++ \
clang \
llvm-dev \
re2c \
bison \
libxml2-dev \
Expand Down Expand Up @@ -119,8 +127,10 @@ jobs:

- name: Configure and build PHP
run: |
cmake --preset all-enabled -DCMAKE_INSTALL_PREFIX=/usr
cmake --build --preset all-enabled -j
cmake --preset all-enabled \
-DCMAKE_INSTALL_PREFIX=/usr \
-G "${{ matrix.generator.name }}"
cmake --build --preset all-enabled ${{ matrix.generator.build_options }}

- name: Setup SNMP agents
run: |
Expand All @@ -136,11 +146,15 @@ jobs:

- name: Run tests
if: ${{ always() }}
run: ctest --preset all-enabled
run: ctest --preset all-enabled ${{ matrix.generator.test_options }}

- name: Install PHP
if: ${{ always() }}
run: sudo "${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake" --install php-build/all-enabled/php -j $(nproc)
run: |
sudo "${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake" \
--install php-build/all-enabled/php \
-j $(nproc) \
${{ matrix.generator.install_options }}

- name: Setup shared standalone extension
if: ${{ always() }}
Expand All @@ -149,11 +163,13 @@ jobs:
cd php-build/all-enabled/php-src/ext/phantom
cmake \
-B cmake-build \
-DPHP_EXT_PHANTOM=ON \
-DPHP_EXT_PHANTOM_SHARED=ON
cmake --build cmake-build -j
ctest --test-dir cmake-build -j --verbose
sudo "${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake" --install cmake-build
-G "${{ matrix.generator.name }}"
cmake --build cmake-build -j ${{ matrix.generator.build_options }}
ctest --test-dir cmake-build -j --verbose ${{ matrix.generator.test_options }}
sudo "${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake" \
--install cmake-build \
-j $(nproc) \
${{ matrix.generator.install_options }}
php -d extension=phantom -m | grep phantom

windows:
Expand All @@ -172,4 +188,4 @@ jobs:
- name: Build and install
run: |
${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake --preset windows
${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake --build --preset windows -j
${{ steps.cmake-and-ninja.outputs.cmake-path }}/cmake --build --preset windows
56 changes: 38 additions & 18 deletions cmake/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,18 @@
"cacheVariables": {
"PHP_THREAD_SAFETY": true
}
},
{
"name": "default-ninja",
"inherits": "default",
"displayName": "Ninja generator with default PHP configuration",
"description": "Ninja generator with default PHP configuration",
"binaryDir": "${sourceDir}/php-build/default-ninja",
"generator": "Ninja"
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
"configurePreset": "default",
"jobs": 0
},
{
"name": "default-ts",
"inherits": "default",
"configurePreset": "default-ts"
},
{
"name": "default-ninja",
"configurePreset": "default-ninja"
}
],
"testPresets": [
Expand All @@ -64,17 +54,47 @@
"output": {
"shortProgress": true,
"verbosity": "verbose"
},
"execution": {
"jobs": 0
}
},
{
"name": "default-ts",
"configurePreset": "default-ts",
"inherits": "default"
"inherits": "default",
"configurePreset": "default-ts"
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
}
]
},
{
"name": "default-ninja",
"configurePreset": "default-ninja",
"inherits": "default"
"name": "default-with-tests",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
}
]
}
2 changes: 1 addition & 1 deletion cmake/cmake/Configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ if(NOT PHP_EXTENSION_DIR)
CACHE PHP_EXTENSION_DIR
PROPERTY
VALUE
"${CMAKE_INSTALL_LIBDIR}/php/$<TARGET_PROPERTY:PHP::Zend,PHP_ZEND_MODULE_API_NO>$<$<BOOL:$<TARGET_PROPERTY:PHP::config,PHP_THREAD_SAFETY>>:-zts>$<$<BOOL:$<CONFIG>>:-$<CONFIG>>"
"${CMAKE_INSTALL_LIBDIR}/php/$<TARGET_PROPERTY:PHP::Zend,PHP_ZEND_MODULE_API_NO>$<$<BOOL:$<TARGET_PROPERTY:PHP::config,PHP_THREAD_SAFETY>>:-zts>"
)

# This would resemble the PHP Autotools --with-layout=GNU:
Expand Down
38 changes: 35 additions & 3 deletions cmake/cmake/PHPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ find_package(PHP [<version>] [COMPONENTS <components>...])

The following components are available:

* `Interpreter`
* `Development`
* `Embed`
* `Interpreter` - finds the PHP command-line interpreter executable.
* `Development` - finds PHP headers required to build PHP extensions or
applications.
* `Embed` - finds the PHP embed SAPI library.
* `SapiCgi` - finds the PHP CGI SAPI command-line executable.
* `SapiFpm` - finds the PHP FPM SAPI executable.
* `SapiLitespeed` - finds the PHP LiteSpeed SAPI command line executable.
* `SapiPhpdbg` - finds the PHP Debugger SAPI command line executable.
* `SapiPhpdbgLib` - finds the PHP Debugger SAPI library.

If no components are specified, by default, the `Interpreter` and `Development`
components are searched.
Expand All @@ -37,6 +43,32 @@ The following imported targets are provided:
* `PHP::EmbedShared`
* `PHP::EmbedStatic`

* `PHP::sapi::cgi`

Interface imported target encapsulating usage requirements for the PHP CGI
SAPI executable. Available when the `SapiCgi` component is found.

* `PHP::sapi::fpm`

Interface imported target encapsulating the usage requirements for the PHP
FPM SAPI executable. Available when the `SapiFpm` component is found.

* `PHP::sapi::litespeed`

Interface imported target encapsulating the usage requirements for the PHP
LiteSpeed SAPI executable. Available when the `SapiLitespeed` component is
found.

* `PHP::sapi::phpdbg`

Interface imported target encapsulating usage requirements for the PHP
Debugger SAPI executable. Available when the `SapiPhpdbg` component is found.

* `PHP::sapi::phpdbglib`

Interface imported target encapsulating the usage requirements for the PHP
Debugger SAPI library. Available when the `SapiPhpdbgLib` component is found.

## Result variables

The following variables are set:
Expand Down
8 changes: 1 addition & 7 deletions cmake/cmake/modules/PHP/Extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,9 @@ function(_php_extension_post_configure)
set(library_output_dir "${CMAKE_CURRENT_BINARY_DIR}/modules")
endif()

get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if(NOT is_multi_config)
string(APPEND library_output_dir "/$<CONFIG>")
endif()

set_property(
TARGET php_ext_${extension}
PROPERTY LIBRARY_OUTPUT_DIRECTORY "${library_output_dir}"
PROPERTY LIBRARY_OUTPUT_DIRECTORY "${library_output_dir}/$<CONFIG>"
)
endif()
endif()
Expand Down
53 changes: 40 additions & 13 deletions cmake/cmake/modules/PHP/Internal/Testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function(php_testing_add)
COMMAND
${CMAKE_COMMAND}
-P
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/run-tests.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/$<CONFIG>/run-tests.cmake
)

set_tests_properties(PhpRunTests PROPERTIES RUN_SERIAL TRUE)
Expand Down Expand Up @@ -79,12 +79,6 @@ function(_php_testing_post_configure)
return()
endif()

set(extension_dir "${CMAKE_CURRENT_BINARY_DIR}/modules")
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config)
string(APPEND extension_dir "/$<CONFIG>")
endif()

cmake_host_system_information(RESULT processors QUERY NUMBER_OF_LOGICAL_CORES)

set(parallel "")
Expand All @@ -109,12 +103,44 @@ function(_php_testing_post_configure)
endif()
endforeach()

file(
if(TARGET PHP::sapi::cgi)
set(php_cgi "$<TARGET_FILE:PHP::sapi::cgi>")
else()
set(php_cgi "")
endif()

if(TARGET PHP::sapi::phpdbg)
set(php_phpdbg "$<TARGET_FILE:PHP::sapi::phpdbg>")
else()
set(php_phpdbg "")
endif()

if(TARGET PHP::sapi::fpm)
set(php_fpm "$<TARGET_FILE:PHP::sapi::fpm>")
else()
set(php_fpm "")
endif()

string(
CONFIGURE
OUTPUT CMakeFiles/PHP/run-tests.cmake
CONTENT [[
[[
cmake_minimum_required(VERSION 4.2...4.3)

# Configure PHP CGI SAPI that some tests require.
if(NOT DEFINED ENV{TEST_PHP_CGI_EXECUTABLE} AND EXISTS "@php_cgi@")
set(ENV{TEST_PHP_CGI_EXECUTABLE} "@php_cgi@")
endif()

# Configure PHP Debugger SAPI that some tests require.
if(NOT DEFINED ENV{TEST_PHPDBG_EXECUTABLE} AND EXISTS "@php_phpdbg@")
set(ENV{TEST_PHPDBG_EXECUTABLE} "@php_phpdbg@")
endif()

# Configure PHP FPM SAPI that some tests require.
if(NOT DEFINED ENV{TEST_PHP_FPM_EXECUTABLE} AND EXISTS "@php_fpm@")
set(ENV{TEST_PHP_FPM_EXECUTABLE} "@php_fpm@")
endif()

execute_process(
COMMAND
"$<TARGET_FILE:@php_executable@>"
Expand All @@ -124,7 +150,7 @@ function(_php_testing_post_configure)
-d memory_limit=-1
"@run_tests@"
-n
-d extension_dir="@extension_dir@"
-d extension_dir="@CMAKE_CURRENT_BINARY_DIR@/modules/$<CONFIG>"
--show-diff
@options@
@parallel@
Expand All @@ -133,11 +159,12 @@ function(_php_testing_post_configure)
COMMAND_ERROR_IS_FATAL ANY
)
]]
content
@ONLY
)
file(
GENERATE
OUTPUT CMakeFiles/PHP/run-tests.cmake
INPUT ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/run-tests.cmake
OUTPUT CMakeFiles/PHP/$<CONFIG>/run-tests.cmake
CONTENT "${content}"
)
endfunction()
Loading
Loading