Skip to content

Commit 2649e47

Browse files
wip
1 parent dedb474 commit 2649e47

20 files changed

+466
-227
lines changed

.github/workflows/main.yml

+161-108
Original file line numberDiff line numberDiff line change
@@ -14,113 +14,166 @@ 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', '8.4' ]
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-13 }
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-
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-
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', '8.4' ]
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-13 }
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-old:
89+
# # FIXME this hacky pipeline will be cleaned later
90+
# runs-on: windows-latest
91+
# steps:
92+
# - name: Install zlib
93+
# run: |
94+
# vcpkg.exe install zlib
95+
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
96+
# - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
97+
# - name: Setup PHP SDK with Developer Pack
98+
# uses: zephir-lang/setup-php-sdk@fd5f1bce00956a7e8ac30faaa1ff0692d6dacdfb # v1.0
99+
# with:
100+
# php_version: '8.3'
101+
# ts: 'nts'
102+
# msvc: 'vs16'
103+
# arch: 'x64'
104+
# install_dir: 'C:\tools'
105+
# cache_dir: 'C:\Temp'
106+
# - name: Clone PHP-src
107+
# run: |
108+
# git clone https://github.com/php/php-src.git C:\php-src
109+
# - name: Copy SPX to PHP-src ext directory
110+
# run: |
111+
# xcopy /e /k /h /i . C:\php-src\ext\php-spx
112+
# - name: Configure and build 1
113+
# run: |
114+
# cd C:\php-src
115+
# ./buildconf.bat
116+
# - name: Configure and build 2
117+
# run: |
118+
# cd C:\php-src
119+
# ./configure --help
120+
# ./configure --disable-all --enable-cli --enable-spx
121+
# - name: Configure and build 3
122+
# run: |
123+
# cd C:\php-src
124+
# nmake
125+
126+
build-win:
127+
runs-on: windows-latest
95128
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
103-
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
113-
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
129+
- name: Build the extension
130+
uses: php/php-windows-builder/extension@5106db21e6a35781bff937be3c9e1e56d7b17789
119131
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
132+
#extension-url: https://github.com/xdebug/xdebug
133+
#extension-ref: '3.3.1'
134+
php-version: '8.3'
135+
ts: nts
136+
run-tests: false
137+
arch: x64
138+
args: --enable-spx
139+
libs: zlib
140+
141+
# release:
142+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
143+
144+
# needs: [ build ]
145+
# name: Create Release
146+
# runs-on: ubuntu-20.04
147+
148+
# steps:
149+
# - name: Checkout Code
150+
# uses: actions/checkout@v3
151+
# with:
152+
# fetch-depth: 1
153+
154+
# - name: Get the release version
155+
# id: get-version
156+
# run: |
157+
# echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
158+
159+
# - name: Download SPX build artifacts
160+
# id: download
161+
# uses: actions/[email protected]
162+
# with:
163+
# path: ./build-artifacts
164+
165+
# - name: Prepare Release notes
166+
# run: |
167+
# echo "-- Creating Release Notes"
168+
# ./.github/release-notes.sh ./CHANGELOG.md > ./release-notes.md
169+
170+
# - name: Create Release
171+
# uses: ncipollo/release-action@v1
172+
# with:
173+
# token: ${{ secrets.GITHUB_TOKEN }}
174+
# name: ${{ steps.get-version.outputs.version }}
175+
# tag: ${{ steps.get-version.outputs.version }}
176+
# bodyFile: "./release-notes.md"
177+
# allowUpdates: true
178+
# artifacts: "./build-artifacts/*/*.zip"
179+
# artifactContentType: application/octet-stream

README.md

+11-9
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: 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+
* **Linux**, **macOS**, **FreeBSD** or **Windows**
4339
* PHP 5.4 to 8.4
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

@@ -78,7 +80,7 @@ Also, consider ZTS PHP support as still being in beta.
7880

7981
### Linux, PHP-FPM & I/O stats
8082

81-
On GNU/Linux, SPX uses procfs (i.e. by reading files under `/proc` directory) to get some stats for the current process or thread. This is what is done under the hood when you select at least one of these metrics: `mor`, `io`, `ior` or `iow`.
83+
On Linux, SPX uses procfs (i.e. by reading files under `/proc` directory) to get some stats for the current process or thread. This is what is done under the hood when you select at least one of these metrics: `mor`, `io`, `ior` or `iow`.
8284

8385
But, on most PHP-FPM setups, you will have a permission issue preventing SPX to open a file under `/proc/self` directory.
8486
This is due to the fact that PHP-FPM master process runs as root when child processes run as another unprivileged user.
@@ -315,7 +317,7 @@ Here is the list of available metrics to collect. By default only _Wall time_ an
315317

316318
_\*: Allocated and freed byte counts will not be collected if you use a custom allocator or if you force the libc one through the `USE_ZEND_ALLOC` environment variable set to `0`._
317319

318-
_\*\*: RSS & I/O metrics are not supported on macOS and FreeBSD. On GNU/Linux you should [read this if you use PHP-FPM](#linux-php-fpm--io-stats)._
320+
_\*\*: RSS & I/O metrics are not supported on macOS and FreeBSD. On Linux you should [read this if you use PHP-FPM](#linux-php-fpm--io-stats)._
319321

320322
### Command line script
321323

@@ -504,7 +506,7 @@ See the [LICENSE][:link-license:] file for more information.
504506
[:link-ci:]: https://github.com/NoiseByNorthwest/php-spx/actions/workflows/main.yml
505507

506508
[:badge-php-versions:]: https://img.shields.io/badge/php-5.4--8.4-blue.svg
507-
[:badge-supported-platforms:]: https://img.shields.io/badge/platform-GNU/Linux%20|%20macOS%20|%20FreeBSD%20-yellow
509+
[:badge-supported-platforms:]: https://img.shields.io/badge/platform-Linux%20|%20macOS%20|%20FreeBSD%20-yellow
508510
[:badge-supported-arch:]: https://img.shields.io/badge/architecture-x86--64%20|%20ARM64%20-silver
509511

510512
[:badge-license:]: https://img.shields.io/github/license/NoiseByNorthwest/php-spx

config.w32

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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", "/Ox /Wall /WX /W2 /wd4820 /wd4774 /wd4711 /wd4710 /wd4464");
9+
10+
if (PHP_SPX_DEV == "yes") {
11+
ADD_FLAG("CFLAGS", "/Zi");
12+
}
13+
14+
if (
15+
! CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_ZLIB) ||
16+
! CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)
17+
) {
18+
ERROR("zlib not found");
19+
}
20+
21+
EXTENSION("spx", "src/php_spx.c \
22+
src/spx_profiler.c \
23+
src/spx_profiler_tracer.c \
24+
src/spx_profiler_sampler.c \
25+
src/spx_reporter_full.c \
26+
src/spx_reporter_fp.c \
27+
src/spx_reporter_trace.c \
28+
src/spx_metric.c \
29+
src/spx_resource_stats.c \
30+
src/spx_hmap.c \
31+
src/spx_str_builder.c \
32+
src/spx_output_stream.c \
33+
src/spx_php.c \
34+
src/spx_stdio.c \
35+
src/spx_config.c \
36+
src/spx_utils.c \
37+
src/spx_fmt.c", true);
38+
39+
ADD_MAKEFILE_FRAGMENT();
40+
}

0 commit comments

Comments
 (0)