Skip to content

Commit be64775

Browse files
author
NoiseByNorthwest
committed
WIP
1 parent 103695d commit be64775

File tree

5 files changed

+127
-12
lines changed

5 files changed

+127
-12
lines changed

.github/workflows/main.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ on:
1616
jobs:
1717
build:
1818
name: build / php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}
19+
# FIXME temporary disabled
20+
if: false
1921
runs-on: ${{ matrix.os }}
2022
strategy:
2123
fail-fast: false
@@ -87,8 +89,64 @@ jobs:
8789
name: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
8890
path: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip
8991

92+
build-win-old:
93+
# FIXME this hacky pipeline will be cleaned later
94+
if: false
95+
runs-on: windows-latest
96+
steps:
97+
- name: Install zlib
98+
run: |
99+
vcpkg.exe install zlib
100+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
101+
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
102+
- name: Setup PHP SDK with Developer Pack
103+
uses: zephir-lang/setup-php-sdk@fd5f1bce00956a7e8ac30faaa1ff0692d6dacdfb # v1.0
104+
with:
105+
php_version: '8.3'
106+
ts: 'nts'
107+
msvc: 'vs16'
108+
arch: 'x64'
109+
install_dir: 'C:\tools'
110+
cache_dir: 'C:\Temp'
111+
- name: Clone PHP-src
112+
run: |
113+
git clone https://github.com/php/php-src.git C:\php-src
114+
- name: Copy SPX to PHP-src ext directory
115+
run: |
116+
xcopy /e /k /h /i . C:\php-src\ext\php-spx
117+
- name: Configure and build 1
118+
run: |
119+
cd C:\php-src
120+
./buildconf.bat
121+
- name: Configure and build 2
122+
run: |
123+
cd C:\php-src
124+
./configure --help
125+
./configure --disable-all --enable-cli --enable-spx
126+
- name: Configure and build 3
127+
run: |
128+
cd C:\php-src
129+
nmake
130+
131+
build-win:
132+
runs-on: windows-latest
133+
steps:
134+
- name: Build the extension
135+
uses: php/php-windows-builder/extension@5199585cd19be6fb11e6b229d4b662649dc79ac8
136+
#uses: php/php-windows-builder/extension@2a031a68a7ed21340248d07946a8f655faf1d6aa
137+
with:
138+
#extension-url: https://github.com/xdebug/xdebug
139+
#extension-ref: '3.3.1'
140+
php-version: '8.3'
141+
ts: nts
142+
run-tests: false
143+
arch: x64
144+
args: --enable-spx
145+
libs: zlib
146+
90147
release:
91-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
148+
# FIXME temporary disabled
149+
if: false && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
92150

93151
needs: [ build ]
94152
name: Create Release

Makefile.frag.w32

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
spx_ui_assets_dir = $(PHP_PREFIX)/share/misc/php-spx/assets/web-ui
3+
4+
install-spx-ui-assets:
5+
@echo "Installing SPX web UI to: $(spx_ui_assets_dir)"
6+
@mkdir -p $(spx_ui_assets_dir)
7+
@cp -r assets/web-ui/* $(spx_ui_assets_dir)
8+
9+
install: $(all_targets) $(install_targets) install-spx-ui-assets

README.md

Lines changed: 11 additions & 9 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: 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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
base_dir = get_define('BUILD_DIR');
9+
WScript.Echo("Creating " + base_dir + "\\src" + "...");
10+
FSO.CreateFolder(base_dir+"\\src");
11+
12+
ADD_FLAG("CFLAGS", "/Ox /Wall /W2 /wd4820 /wd4774 /wd4711 /wd4710 /wd4464 /wd4005");
13+
14+
if (PHP_SPX_DEV == "yes") {
15+
ADD_FLAG("CFLAGS", "/Zi");
16+
}
17+
18+
if (
19+
! CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_ZLIB) ||
20+
! CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)
21+
) {
22+
ERROR("zlib not found");
23+
}
24+
25+
AC_DEFINE("SPX_HTTP_UI_ASSETS_DIR", PHP_PREFIX.replace(/\\/g, "/") + "/share/misc/php-spx/assets/web-ui");
26+
27+
EXTENSION("spx", "src/php_spx.c \
28+
src/spx_profiler.c \
29+
src/spx_profiler_tracer.c \
30+
src/spx_profiler_sampler.c \
31+
src/spx_reporter_full.c \
32+
src/spx_reporter_fp.c \
33+
src/spx_reporter_trace.c \
34+
src/spx_metric.c \
35+
src/spx_resource_stats.c \
36+
src/spx_hmap.c \
37+
src/spx_str_builder.c \
38+
src/spx_output_stream.c \
39+
src/spx_php.c \
40+
src/spx_stdio.c \
41+
src/spx_config.c \
42+
src/spx_utils.c \
43+
src/spx_fmt.c", true);
44+
45+
ADD_MAKEFILE_FRAGMENT();
46+
}

src/php_spx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include "main/php.h"
2424

2525
/* linux 2.6+ or OSX */
26-
#if !defined(linux) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__FreeBSD__)
27-
# error "Only Linux-based OSes, Apple MacOS and FreeBSD are supported"
26+
#if !defined(linux) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__FreeBSD__) && !defined(_WIN32)
27+
# error "Only Linux-based OSes, Apple MacOS, FreeBSD and Windows are supported"
2828
#endif
2929

3030
#if (defined(_MSC_VER) && !(defined(_M_X64) || defined(_M_ARM64))) || (!defined(_MSC_VER) && !(defined(__x86_64__) || defined(__aarch64__)))

0 commit comments

Comments
 (0)