Skip to content

Commit d3b1a59

Browse files
wip
1 parent 05e8508 commit d3b1a59

17 files changed

+375
-210
lines changed

.github/workflows/main.yml

Lines changed: 139 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -14,113 +14,148 @@ on:
1414
- master
1515

1616
jobs:
17-
build:
18-
name: build / php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}
19-
20-
runs-on: ${{ matrix.os }}
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
25-
26-
name:
27-
- linux
28-
- debian
29-
- mac
30-
31-
include:
32-
# Linux
33-
- { name: linux, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 }
34-
# Debian (docker)
35-
- { name: debian, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 }
36-
# macOS
37-
- { name: mac, ts: 'nts', compiler: 'clang', os: macos-12 }
38-
17+
# build:
18+
# name: build / php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}
19+
20+
# runs-on: ${{ matrix.os }}
21+
# strategy:
22+
# fail-fast: false
23+
# matrix:
24+
# php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
25+
26+
# name:
27+
# - linux
28+
# - debian
29+
# - mac
30+
31+
# include:
32+
# # Linux
33+
# - { name: linux, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 }
34+
# # Debian (docker)
35+
# - { name: debian, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 }
36+
# # macOS
37+
# - { name: mac, ts: 'nts', compiler: 'clang', os: macos-12 }
38+
39+
# steps:
40+
# - uses: actions/checkout@v3
41+
42+
# # configure spx artifact name in next format:
43+
# # {php}-{ts}-{os.name}-{compiler}
44+
# # spx-php-8.1-nts-linux-gcc
45+
# - name: Set artifact name
46+
# id: setup-artifact
47+
# run: |
48+
# echo "spx_file_name=spx-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}" >> $GITHUB_OUTPUT
49+
50+
# - name: Build extension for Ubuntu and macOS
51+
# if: matrix.name != 'debian'
52+
# uses: ./.github/workflows/build-linux-mac-ext
53+
54+
# - name: Build extension for Debian using docker
55+
# if: matrix.name == 'debian' && matrix.php != '5.4' && matrix.php != '5.5'
56+
# uses: ./.github/workflows/build-debian-ext
57+
58+
# - name: Upload build artifacts after Failure
59+
# if: failure()
60+
# uses: actions/upload-artifact@v3
61+
# with:
62+
# name: debug-${{ steps.setup-artifact.outputs.spx_file_name }}
63+
# path: |
64+
# ${{ github.workspace }}/*.log
65+
# ${{ github.workspace }}/tests/*.log
66+
# retention-days: 7
67+
68+
# - name: Create ZIP archive with build artifact
69+
# run: |
70+
# zip -rvj ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
71+
# ./modules/spx.so LICENSE $ZIP_EXCLUDE
72+
# zip -rv ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
73+
# ./assets $ZIP_EXCLUDE
74+
# env:
75+
# ZIP_EXCLUDE: -x ".*" -x "__MACOSX" -x "*.DS_Store"
76+
77+
# - name: Check Release notes
78+
# run: |
79+
# echo "-- Parsing Release Notes from CHANGELOG"
80+
# ./.github/release-notes.sh ./CHANGELOG.md
81+
82+
# - name: Upload build artifact
83+
# uses: actions/upload-artifact@v3
84+
# with:
85+
# name: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
86+
# path: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
87+
88+
build-win:
89+
# FIXME this hacky pipeline will be cleaned later
90+
runs-on: windows-latest
3991
steps:
40-
- uses: actions/checkout@v3
41-
42-
# configure spx artifact name in next format:
43-
# {php}-{ts}-{os.name}-{compiler}
44-
# spx-php-8.1-nts-linux-gcc
45-
- name: Set artifact name
46-
id: setup-artifact
47-
run: |
48-
echo "spx_file_name=spx-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}" >> $GITHUB_OUTPUT
49-
50-
- name: Build extension for Ubuntu and macOS
51-
if: matrix.name != 'debian'
52-
uses: ./.github/workflows/build-linux-mac-ext
53-
54-
- name: Build extension for Debian using docker
55-
if: matrix.name == 'debian' && matrix.php != '5.4' && matrix.php != '5.5'
56-
uses: ./.github/workflows/build-debian-ext
57-
58-
- name: Upload build artifacts after Failure
59-
if: failure()
60-
uses: actions/upload-artifact@v3
92+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
93+
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
94+
- name: Setup PHP SDK with Developer Pack
95+
uses: zephir-lang/setup-php-sdk@fd5f1bce00956a7e8ac30faaa1ff0692d6dacdfb # v1.0
6196
with:
62-
name: debug-${{ steps.setup-artifact.outputs.spx_file_name }}
63-
path: |
64-
${{ github.workspace }}/*.log
65-
${{ github.workspace }}/tests/*.log
66-
retention-days: 7
67-
68-
- name: Create ZIP archive with build artifact
97+
php_version: '8.3'
98+
ts: 'nts'
99+
msvc: 'vs16'
100+
arch: 'x64'
101+
install_dir: 'C:\tools'
102+
cache_dir: 'C:\Temp'
103+
- name: Clone PHP-src
69104
run: |
70-
zip -rvj ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
71-
./modules/spx.so LICENSE $ZIP_EXCLUDE
72-
zip -rv ${{ steps.setup-artifact.outputs.spx_file_name }}.zip \
73-
./assets $ZIP_EXCLUDE
74-
env:
75-
ZIP_EXCLUDE: -x ".*" -x "__MACOSX" -x "*.DS_Store"
76-
77-
- name: Check Release notes
105+
git clone https://github.com/php/php-src.git C:\php-src
106+
- name: Copy SPX to PHP-src ext directory
78107
run: |
79-
echo "-- Parsing Release Notes from CHANGELOG"
80-
./.github/release-notes.sh ./CHANGELOG.md
81-
82-
- name: Upload build artifact
83-
uses: actions/upload-artifact@v3
84-
with:
85-
name: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
86-
path: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
87-
88-
release:
89-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
90-
91-
needs: [ build ]
92-
name: Create Release
93-
runs-on: ubuntu-20.04
94-
95-
steps:
96-
- name: Checkout Code
97-
uses: actions/checkout@v3
98-
with:
99-
fetch-depth: 1
100-
101-
- name: Get the release version
102-
id: get-version
108+
xcopy /e /k /h /i . C:\php-src\ext\php-spx
109+
- name: Configure and build 1
103110
run: |
104-
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
105-
106-
- name: Download SPX build artifacts
107-
id: download
108-
uses: actions/[email protected]
109-
with:
110-
path: ./build-artifacts
111-
112-
- name: Prepare Release notes
111+
cd C:\php-src
112+
./buildconf.bat
113+
- name: Configure and build 2
113114
run: |
114-
echo "-- Creating Release Notes"
115-
./.github/release-notes.sh ./CHANGELOG.md > ./release-notes.md
116-
117-
- name: Create Release
118-
uses: ncipollo/release-action@v1
119-
with:
120-
token: ${{ secrets.GITHUB_TOKEN }}
121-
name: ${{ steps.get-version.outputs.version }}
122-
tag: ${{ steps.get-version.outputs.version }}
123-
bodyFile: "./release-notes.md"
124-
allowUpdates: true
125-
artifacts: "./build-artifacts/*/*.zip"
126-
artifactContentType: application/octet-stream
115+
cd C:\php-src
116+
./configure --help
117+
./configure --disable-all --enable-cli --enable-spx
118+
- name: Configure and build 3
119+
run: |
120+
cd C:\php-src
121+
nmake
122+
123+
# release:
124+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
125+
126+
# needs: [ build ]
127+
# name: Create Release
128+
# runs-on: ubuntu-20.04
129+
130+
# steps:
131+
# - name: Checkout Code
132+
# uses: actions/checkout@v3
133+
# with:
134+
# fetch-depth: 1
135+
136+
# - name: Get the release version
137+
# id: get-version
138+
# run: |
139+
# echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
140+
141+
# - name: Download SPX build artifacts
142+
# id: download
143+
# uses: actions/[email protected]
144+
# with:
145+
# path: ./build-artifacts
146+
147+
# - name: Prepare Release notes
148+
# run: |
149+
# echo "-- Creating Release Notes"
150+
# ./.github/release-notes.sh ./CHANGELOG.md > ./release-notes.md
151+
152+
# - name: Create Release
153+
# uses: ncipollo/release-action@v1
154+
# with:
155+
# token: ${{ secrets.GITHUB_TOKEN }}
156+
# name: ${{ steps.get-version.outputs.version }}
157+
# tag: ${{ steps.get-version.outputs.version }}
158+
# bodyFile: "./release-notes.md"
159+
# allowUpdates: true
160+
# artifacts: "./build-artifacts/*/*.zip"
161+
# artifactContentType: application/octet-stream

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status][:badge-ci:]][:link-ci:]
44
![Supported PHP versions: 5.4 .. 8.x][:badge-php-versions:]
5-
![Supported platforms: GNU/Linux, macOS & FreeBSD][:badge-supported-platforms:]
5+
![Supported platforms: GNU/Linux, macOS, FreeBSD & Windows][:badge-supported-platforms:]
66
![Supported architectures: x86-64 or ARM64][:badge-supported-arch:]
77
[![License][:badge-license:]][:link-license:]
88

@@ -34,12 +34,8 @@ It differentiates itself from other similar extensions as being:
3434

3535
## Requirements
3636

37-
Platforms support is currently quite limited. Feel free to open an issue if your platform is not supported.
38-
Current requirements are:
39-
4037
* x86-64 or ARM64
41-
* **GNU/Linux**, **macOS** or **FreeBSD**
42-
* zlib dev package (e.g. zlib1g-dev on Debian based distros)
38+
* **GNU/Linux**, **macOS**, **FreeBSD** or **Windows**
4339
* PHP 5.4 to 8.3
4440

4541
## Installation
@@ -66,6 +62,12 @@ sudo make install
6662
Then add `extension=spx.so` to your *php.ini*, or in a dedicated *spx.ini* file created within the include directory.
6763
You may also want to override [default SPX configuration](#configuration) to be able to profile a web request, with [this one](#private-environment) for example for a local development environment.
6864

65+
### Windows
66+
67+
Windows is supported, with these extra limitations:
68+
- live update of flat profile in CLI (`SPX_FP_LIVE=1`) is not supported.
69+
70+
Also, consider Windows support as still being in beta.
6971

7072
### ZTS PHP (multi-thread)
7173

config.w32

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
ARG_ENABLE("spx", "Enable SPX extension", "no");
2+
3+
ARG_ENABLE("spx-dev", "Compile SPX with debugging symbols", "no");
4+
5+
if (PHP_SPX == "yes") {
6+
AC_DEFINE("HAVE_SPX", 1, "spx");
7+
8+
ADD_FLAG("CFLAGS", "/WX /Wall /Ox /wd4820 /wd4774 /wd4711 /wd4710 /wd4464");
9+
10+
if (PHP_SPX_DEV == "yes") {
11+
ADD_FLAG("CFLAGS", "/Zi");
12+
}
13+
14+
if (CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_SPX)) {
15+
ERROR("zlib OK");
16+
}
17+
18+
if (CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) {
19+
ERROR("zlib header OK");
20+
}
21+
22+
EXTENSION("spx", "src/php_spx.c \
23+
src/spx_profiler.c \
24+
src/spx_profiler_tracer.c \
25+
src/spx_profiler_sampler.c \
26+
src/spx_reporter_full.c \
27+
src/spx_reporter_fp.c \
28+
src/spx_reporter_trace.c \
29+
src/spx_metric.c \
30+
src/spx_resource_stats.c \
31+
src/spx_hmap.c \
32+
src/spx_str_builder.c \
33+
src/spx_output_stream.c \
34+
src/spx_php.c \
35+
src/spx_stdio.c \
36+
src/spx_config.c \
37+
src/spx_utils.c \
38+
src/spx_fmt.c", true);
39+
40+
ADD_MAKEFILE_FRAGMENT();
41+
}

src/php_spx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_spx_profiler_stop, 0, 0, 0)
215215
ZEND_END_ARG_INFO()
216216

217217
ZEND_BEGIN_ARG_INFO_EX(arginfo_spx_profiler_full_report_set_custom_metadata_str, 0, 0, 1)
218-
#if PHP_API_VERSION >= 20151012
218+
#if ZEND_MODULE_API_NO >= 20151012
219219
ZEND_ARG_TYPE_INFO(0, customMetadataStr, IS_STRING, 0)
220220
#else
221221
ZEND_ARG_INFO(0, customMetadataStr)
@@ -437,7 +437,7 @@ static PHP_FUNCTION(spx_profiler_stop)
437437
profiling_handler_stop();
438438

439439
if (context.profiling_handler.full_report_key[0]) {
440-
#if PHP_API_VERSION >= 20151012
440+
#if ZEND_MODULE_API_NO >= 20151012
441441
RETURN_STRING(context.profiling_handler.full_report_key);
442442
#else
443443
RETURN_STRING(context.profiling_handler.full_report_key, 1);
@@ -448,13 +448,13 @@ static PHP_FUNCTION(spx_profiler_stop)
448448
static PHP_FUNCTION(spx_profiler_full_report_set_custom_metadata_str)
449449
{
450450
char * custom_metadata_str;
451-
#if PHP_API_VERSION >= 20151012
451+
#if ZEND_MODULE_API_NO >= 20151012
452452
size_t custom_metadata_str_len;
453453
#else
454454
int custom_metadata_str_len;
455455
#endif
456456

457-
#if PHP_API_VERSION >= 20170718
457+
#if ZEND_MODULE_API_NO >= 20170718
458458
ZEND_PARSE_PARAMETERS_START(1, 1)
459459
Z_PARAM_STRING(custom_metadata_str, custom_metadata_str_len)
460460
ZEND_PARSE_PARAMETERS_END();

src/php_spx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
# include "config.h"
2121
#endif
2222

23+
#ifdef _WIN32
24+
# pragma warning(push, 0)
25+
#endif
2326
#include "main/php.h"
27+
#ifdef _WIN32
28+
# pragma warning(pop)
29+
#endif
2430

2531
/* linux 2.6+ or OSX */
2632
#if !defined(linux) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__FreeBSD__)

0 commit comments

Comments
 (0)