Skip to content

Commit e54854a

Browse files
committed
Ninja support on Windows
* We also switch to /Z7 to avoid some build flakyness. * Support ninja.frag.w32 Unfortunately, that requires a hard-coded hack regarding OPcache JIT, since Ninja does not support multiple build lines to specify dependencies. * Explicitly require Ninja >= 1.7
1 parent ed92da8 commit e54854a

File tree

11 files changed

+479
-3
lines changed

11 files changed

+479
-3
lines changed

ext/json/ninja.frag.w32

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rule re2c_ext_json
2+
command = ${RE2C} ${RE2C_FLAGS} -t ext/json/php_json_scanner_defs.h -bci -o ext/json/json_scanner.c ext/json/json_scanner.re
3+
4+
build ext\json\json_scanner.c ext\json\php_json_scanner_defs.h: re2c_ext_json ext\json\json_scanner.re ext\json\json_parser.tab.h
5+
6+
rule bison_ext_json
7+
command = ${BISON} ${BISON_FLAGS} --defines -l ext/json/json_parser.y -o ext/json/json_parser.tab.c
8+
9+
build ext\json\json_parser.tab.c ext\json\json_parser.tab.h: bison_ext_json ext\json\json_parser.y

ext/opcache/jit/ninja.frag.w32

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
rule ext_opcache_jit_1
2+
command = ${PHP_CL} /nologo /Fo${BUILD_DIR}\ /Fd${BUILD_DIR}\ /Fp${BUILD_DIR}\ /FR${BUILD_DIR} /Fe${BUILD_DIR}\minilua.exe ext\opcache\jit\ir\dynasm\minilua.c
3+
4+
build ${BUILD_DIR}\minilua.exe: ext_opcache_jit_1 ext\opcache\jit\ir\dynasm\minilua.c
5+
6+
# @if exist $(BUILD_DIR)\\minilua.exe del $(BUILD_DIR)\\minilua.exe
7+
# $(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\minilua.exe ext\opcache\jit\ir\dynasm\minilua.c
8+
9+
rule ext_opcache_jit_2
10+
command = cmd /c ${BUILD_DIR}\\minilua.exe ext/opcache/jit/ir/dynasm/dynasm.lua ${DASM_FLAGS} -o $out ext/opcache/jit/ir/ir_x86.dasc
11+
12+
build ext\opcache\jit\ir\ir_emit_x86.h: ext_opcache_jit_2 ext\opcache\jit\ir\ir_x86.dasc ${BUILD_DIR}\\minilua.exe
13+
14+
# @if exist ext\opcache\jit\ir\ir_emit_x86.h del ext\opcache\jit\ir\ir_emit_x86.h
15+
# $(BUILD_DIR)\\minilua.exe ext/opcache/jit/ir/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ ext/opcache/jit/ir/ir_x86.dasc
16+
17+
rule ext_opcache_jit_3
18+
command = ${PHP_CL} /nologo /D ${IR_TARGET} /Fo${BUILD_DIR}\ /Fd${BUILD_DIR}\ /Fp${BUILD_DIR}\ /Fe${BUILD_DIR}\\gen_ir_fold_hash.exe ext\opcache\jit\ir\gen_ir_fold_hash.c
19+
20+
build ${BUILD_DIR}\gen_ir_fold_hash.exe: ext_opcache_jit_3 ext\opcache\jit\ir\gen_ir_fold_hash.c ext\opcache\jit\ir\ir_strtab.c
21+
22+
# @if exist $(BUILD_DIR)\\gen_ir_fold_hash.exe del $(BUILD_DIR)\\gen_ir_fold_hash.exe
23+
# $(PHP_CL) /D $(IR_TARGET) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /Fe$(BUILD_DIR)\\gen_ir_fold_hash.exe ext\opcache\jit\ir\gen_ir_fold_hash.c
24+
25+
rule ext_opcache_jit_4
26+
command = cmd /c ${BUILD_DIR}\\gen_ir_fold_hash.exe < ext\opcache\jit\ir\ir_fold.h > ext\opcache\jit\ir\ir_fold_hash.h
27+
28+
build ext\opcache\jit\ir\ir_fold_hash.h: ext_opcache_jit_4 ${BUILD_DIR}\\gen_ir_fold_hash.exe ext\opcache\jit\ir\ir_fold.h ext\opcache\jit\ir\ir.h
29+
30+
build ${BUILD_DIR}\ext\opcache\jit\ir\ir.obj: cc_ext_opcache_jit_ir ext\opcache\jit\ir\ir.c | ext\opcache\jit\ir\ir_fold_hash.h
31+
32+
build ${BUILD_DIR}\ext\opcache\jit\ir\ir_emit.obj: cc_ext_opcache_jit_ir ext\opcache\jit\ir\ir_emit.c | ext\opcache\jit\ir\ir_emit_x86.h
33+
34+
35+
# @if exist ext\opcache\jit\ir\ir_fold_hash.h del ext\opcache\jit\ir\ir_fold_hash.h
36+
# $(BUILD_DIR)\\gen_ir_fold_hash.exe < ext\opcache\jit\ir\ir_fold.h > ext\opcache\jit\ir\ir_fold_hash.h
37+
38+
# ${BUILD_DIR}\ext\opcache\jit\ir\ir_ra.obj: $
39+
# ext\opcache\jit\ir\ir.h $
40+
# ext\opcache\jit\ir\ir_private.h $
41+
# ext\opcache\jit\ir\ir_x86.h
42+
43+
# ${BUILD_DIR}\ext\opcache\jit\ir\ir_emit.obj: $
44+
# ext\opcache\jit\ir\ir.h $
45+
# ext\opcache\jit\ir\ir_private.h $
46+
# ext\opcache\jit\ir\ir_x86.h $
47+
# ext\opcache\jit\ir\ir_emit_x86.h
48+
49+
# ${BUILD_DIR}\ext\opcache\jit\ir\ir.obj: $
50+
# ext\opcache\jit\ir\ir.h $
51+
# ext\opcache\jit\ir\ir_private.h $
52+
# ext\opcache\jit\ir\ir_fold.h $
53+
# ext\opcache\jit\ir\ir_fold_hash.h
54+
55+
# ${BUILD_DIR}\ext\opcache\jit\zend_jit.obj: $
56+
# ext\opcache\jit\zend_jit_ir.c $
57+
# ext\opcache\jit\zend_jit_helpers.c $
58+
# ext\opcache\jit\ir\ir.h $
59+
# ext\opcache\jit\ir\ir_builder.h

ext/pdo/ninja.frag.w32

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rule re2c_ext_pdo
2+
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re
3+
4+
build ext\pdo\pdo_sql_parser.c: re2c_ext_pdo ext\pdo\pdo_sql_parser.re
5+
6+
# cd $(PHP_SRC_DIR)
7+
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re

ext/pdo_mysql/ninja.frag.w32

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rule re2c_pdo_mysql
2+
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re
3+
4+
build ext\pdo_mysql\mysql_sql_parser.c: re2c_pdo_mysql ext\pdo_mysql\mysql_sql_parser.re
5+
6+
# cd $(PHP_SRC_DIR)
7+
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re

ext/pdo_pgsql/ninja.frag.w32

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rule re2c_ext_pdo_pgsql
2+
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re
3+
4+
build ext\pdo_pgsql\pgsql_sql_parser.c: re2c_ext_pdo_pgsql ext\pdo_pgsql\pgsql_sql_parser.re
5+
6+
# cd $(PHP_SRC_DIR)
7+
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re

ext/pdo_sqlite/ninja.frag.w32

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rule re2c_ext_pdo_sqlite
2+
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re
3+
4+
build ext\pdo_sqlite\sqlite_sql_parser.c: re2c_ext_pdo_sqlite ext\pdo_sqlite\sqlite_sql_parser.re
5+
6+
# cd $(PHP_SRC_DIR)
7+
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re

ext/phar/ninja.frag.w32

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rule re2c_ext_phar
2+
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re
3+
4+
build ext\phar\phar_path_check.c: re2c_ext_phar ext\phar\phar_path_check.re

ext/standard/ninja.frag.w32

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
rule re2c_ext_standard_1
2+
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re
3+
4+
build ext\standard\var_unserializer.c: re2c_ext_standard_1 ext\standard\var_unserializer.re
5+
6+
rule re2c_ext_standard_2
7+
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re
8+
9+
build ext\standard\url_scanner_ex.c: re2c_ext_standard_2 ext\standard\url_scanner_ex.re
10+
11+
#$(BUILD_DIR)\ext\standard\basic_functions.obj: $(PHP_SRC_DIR)\Zend\zend_language_parser.h
12+
13+
#$(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.exe: $(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.c
14+
# cd $(PHP_SRC_DIR)\ext\standard\tests\helpers
15+
# $(PHP_CL) /nologo bad_cmd.c

win32/build/build.ninja

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# +----------------------------------------------------------------------+
2+
# | Copyright (c) The PHP Group |
3+
# +----------------------------------------------------------------------+
4+
# | This source file is subject to version 3.01 of the PHP license, |
5+
# | that is bundled with this package in the file LICENSE, and is |
6+
# | available through the world-wide-web at the following url: |
7+
# | https://www.php.net/license/3_01.txt |
8+
# | If you did not receive a copy of the PHP license and are unable to |
9+
# | obtain it through the world-wide-web, please send a note to |
10+
# | [email protected] so we can mail you a copy immediately. |
11+
# +----------------------------------------------------------------------+
12+
# | Author: Wez Furlong <[email protected]> |
13+
# +----------------------------------------------------------------------+
14+
#
15+
# This is the ninja template for the win32 build
16+
17+
CC="${PHP_CL}"
18+
LD="${LINK}"
19+
MC="${MC}"
20+
MT="${MT}"
21+
RE2C="${RE2C}"
22+
PGOMGR="${PGOMGR}"
23+
PHP_BUILD=${PHP_BUILD}
24+
25+
# See https://ninja-build.org/manual.html#_deps
26+
# msvc_deps_prefix = Hinweis: Einlesen der Datei:
27+
28+
MCFILE=${BUILD_DIR}\wsyslog.rc
29+
30+
rule bison_php
31+
command = ${BISON} ${BISON_FLAGS} --output=$out -v -d $in
32+
description = bison $in
33+
34+
build Zend\zend_ini_parser.c: bison_php Zend\zend_ini_parser.y
35+
build Zend\zend_language_parser.c: bison_php Zend\zend_language_parser.y
36+
build sapi\phpdbg\phpdbg_parser.c: bison_php sapi\phpdbg\phpdbg_parser.y
37+
38+
rule re2c_php_ini
39+
command = ${RE2C} ${RE2C_FLAGS} --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
40+
description = re2c $in
41+
42+
build Zend\zend_ini_scanner.c | Zend\zend_ini_scanner_defs.h: re2c_php_ini Zend\zend_ini_scanner.l
43+
44+
rule re2c_php_language
45+
command = ${RE2C} ${RE2C_FLAGS} --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
46+
description = re2c $in
47+
48+
build Zend\zend_language_scanner.c Zend\zend_language_scanner_defs.h: re2c_php_language Zend\zend_language_scanner.l
49+
50+
rule re2c_phpdbg
51+
command = ${RE2C} ${RE2C_FLAGS} -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
52+
description = re2c $in
53+
54+
build sapi\phpdbg\phpdbg_lexer.c: re2c_phpdbg sapi\phpdbg\phpdbg_lexer.l
55+
56+
rule mc_php
57+
command = ${MC} -h win32\ -r ${BUILD_DIR}\ -x ${BUILD_DIR}\ $in
58+
description = mc $in
59+
60+
build ${MCFILE}: mc_php win32\build\wsyslog.mc
61+
62+
PHPDLL_RES=${BUILD_DIR}\${PHPDLL}.res
63+
64+
# FIXME: why isn't that defined in Makefile?
65+
RC=rc.exe
66+
67+
rule rc_php
68+
command = ${RC} /nologo /fo $out /d FILE_DESCRIPTION="\"PHP Script Interpreter\"" /d FILE_NAME="\"${PHPDLL}\"" /d PRODUCT_NAME="\"PHP Script Interpreter\"" /I${BUILD_DIR} /d MC_INCLUDE="\"${MCFILE}\"" $in
69+
description = rc $in
70+
71+
build ${PHPDLL_RES}: rc_php win32\build\template.rc || ${BUILD_DIR}\\wsyslog.rc
72+
73+
rule ld_php
74+
command = ${LD} ${PHP_GLOBAL_OBJS_RESP} ${STATIC_EXT_OBJS_RESP} ${STATIC_EXT_LIBS} ${LIBS} ${ASM_OBJS} ${PHPDLL_RES} /out:$out ${PHP8_PGD_OPTION} ${PHP_LDFLAGS} ${LDFLAGS} ${STATIC_EXT_LDFLAGS}
75+
description = ld $out
76+
77+
build ${BUILD_DIR}\${PHPLIB}: phony ${BUILD_DIR}\${PHPDLL}

win32/build/config.w32

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ MFO.WriteLine('\t$(PHP_ASSEMBLER) $(FIBER_ASM_FLAGS) $(BUILD_DIR)\\Zend\\jump_$(
275275
MFO.WriteLine('$(BUILD_DIR)\\Zend\\make_' + FIBER_ASM_ABI + '.obj: Zend\\asm\\make_' + FIBER_ASM_ABI + '.asm');
276276
MFO.WriteLine('\t$(PHP_ASSEMBLER) $(FIBER_ASM_FLAGS) $(BUILD_DIR)\\Zend\\make_$(FIBER_ASM_ABI).obj Zend\\asm\\make_$(FIBER_ASM_ABI).asm');
277277

278+
NFO.WriteBlankLines(1);
279+
NFO.WriteLine('rule as_fiber');
280+
NFO.WriteLine(' command = cmd /c ${PHP_ASSEMBLER} ${FIBER_ASM_FLAGS} $out $in > NUL');
281+
NFO.WriteLine(' description = as $in');
282+
NFO.WriteBlankLines(1);
283+
NFO.WriteLine('build ${BUILD_DIR}\\Zend\\jump_' + FIBER_ASM_ABI + '.obj: as_fiber Zend\\asm\\jump_' + FIBER_ASM_ABI + '.asm');
284+
NFO.WriteLine('build ${BUILD_DIR}\\Zend\\make_' + FIBER_ASM_ABI + '.obj: as_fiber Zend\\asm\\make_' + FIBER_ASM_ABI + '.asm');
285+
278286
ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
279287
if (VS_TOOLSET && VCVERS >= 1914) {
280288
ADD_FLAG("CFLAGS_BD_ZEND", "/d2FuncCache1");

0 commit comments

Comments
 (0)