Skip to content

Ninja support on Windows #17445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions ext/json/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rule re2c_ext_json
command = ${RE2C} ${RE2C_FLAGS} -t ext/json/php_json_scanner_defs.h -bci -o ext/json/json_scanner.c ext/json/json_scanner.re

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

rule bison_ext_json
command = ${BISON} ${BISON_FLAGS} --defines -l ext/json/json_parser.y -o ext/json/json_parser.tab.c

build ext\json\json_parser.tab.c ext\json\json_parser.tab.h: bison_ext_json ext\json\json_parser.y
59 changes: 59 additions & 0 deletions ext/opcache/jit/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
rule ext_opcache_jit_1
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

build ${BUILD_DIR}\minilua.exe: ext_opcache_jit_1 ext\opcache\jit\ir\dynasm\minilua.c

# @if exist $(BUILD_DIR)\\minilua.exe del $(BUILD_DIR)\\minilua.exe
# $(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

rule ext_opcache_jit_2
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

build ext\opcache\jit\ir\ir_emit_x86.h: ext_opcache_jit_2 ext\opcache\jit\ir\ir_x86.dasc ${BUILD_DIR}\\minilua.exe

# @if exist ext\opcache\jit\ir\ir_emit_x86.h del ext\opcache\jit\ir\ir_emit_x86.h
# $(BUILD_DIR)\\minilua.exe ext/opcache/jit/ir/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ ext/opcache/jit/ir/ir_x86.dasc

rule ext_opcache_jit_3
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

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

# @if exist $(BUILD_DIR)\\gen_ir_fold_hash.exe del $(BUILD_DIR)\\gen_ir_fold_hash.exe
# $(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

rule ext_opcache_jit_4
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

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

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

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


# @if exist ext\opcache\jit\ir\ir_fold_hash.h del ext\opcache\jit\ir\ir_fold_hash.h
# $(BUILD_DIR)\\gen_ir_fold_hash.exe < ext\opcache\jit\ir\ir_fold.h > ext\opcache\jit\ir\ir_fold_hash.h

# ${BUILD_DIR}\ext\opcache\jit\ir\ir_ra.obj: $
# ext\opcache\jit\ir\ir.h $
# ext\opcache\jit\ir\ir_private.h $
# ext\opcache\jit\ir\ir_x86.h

# ${BUILD_DIR}\ext\opcache\jit\ir\ir_emit.obj: $
# ext\opcache\jit\ir\ir.h $
# ext\opcache\jit\ir\ir_private.h $
# ext\opcache\jit\ir\ir_x86.h $
# ext\opcache\jit\ir\ir_emit_x86.h

# ${BUILD_DIR}\ext\opcache\jit\ir\ir.obj: $
# ext\opcache\jit\ir\ir.h $
# ext\opcache\jit\ir\ir_private.h $
# ext\opcache\jit\ir\ir_fold.h $
# ext\opcache\jit\ir\ir_fold_hash.h

# ${BUILD_DIR}\ext\opcache\jit\zend_jit.obj: $
# ext\opcache\jit\zend_jit_ir.c $
# ext\opcache\jit\zend_jit_helpers.c $
# ext\opcache\jit\ir\ir.h $
# ext\opcache\jit\ir\ir_builder.h
7 changes: 7 additions & 0 deletions ext/pdo/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule re2c_ext_pdo
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re

build ext\pdo\pdo_sql_parser.c: re2c_ext_pdo ext\pdo\pdo_sql_parser.re

# cd $(PHP_SRC_DIR)
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re
7 changes: 7 additions & 0 deletions ext/pdo_mysql/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule re2c_pdo_mysql
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re

build ext\pdo_mysql\mysql_sql_parser.c: re2c_pdo_mysql ext\pdo_mysql\mysql_sql_parser.re

# cd $(PHP_SRC_DIR)
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_mysql/mysql_sql_parser.c ext/pdo_mysql/mysql_sql_parser.re
7 changes: 7 additions & 0 deletions ext/pdo_pgsql/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule re2c_ext_pdo_pgsql
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re

build ext\pdo_pgsql\pgsql_sql_parser.c: re2c_ext_pdo_pgsql ext\pdo_pgsql\pgsql_sql_parser.re

# cd $(PHP_SRC_DIR)
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_pgsql/pgsql_sql_parser.c ext/pdo_pgsql/pgsql_sql_parser.re
7 changes: 7 additions & 0 deletions ext/pdo_sqlite/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rule re2c_ext_pdo_sqlite
command = ${RE2C} ${RE2C_FLAGS} -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re

build ext\pdo_sqlite\sqlite_sql_parser.c: re2c_ext_pdo_sqlite ext\pdo_sqlite\sqlite_sql_parser.re

# cd $(PHP_SRC_DIR)
# $(RE2C) $(RE2C_FLAGS) -o ext/pdo_sqlite/sqlite_sql_parser.c ext/pdo_sqlite/sqlite_sql_parser.re
4 changes: 4 additions & 0 deletions ext/phar/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule re2c_ext_phar
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re

build ext\phar\phar_path_check.c: re2c_ext_phar ext\phar\phar_path_check.re
15 changes: 15 additions & 0 deletions ext/standard/ninja.frag.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rule re2c_ext_standard_1
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re

build ext\standard\var_unserializer.c: re2c_ext_standard_1 ext\standard\var_unserializer.re

rule re2c_ext_standard_2
command = ${RE2C} ${RE2C_FLAGS} -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re

build ext\standard\url_scanner_ex.c: re2c_ext_standard_2 ext\standard\url_scanner_ex.re

#$(BUILD_DIR)\ext\standard\basic_functions.obj: $(PHP_SRC_DIR)\Zend\zend_language_parser.h

#$(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.exe: $(PHP_SRC_DIR)\ext\standard\tests\helpers\bad_cmd.c
# cd $(PHP_SRC_DIR)\ext\standard\tests\helpers
# $(PHP_CL) /nologo bad_cmd.c
77 changes: 77 additions & 0 deletions win32/build/build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# +----------------------------------------------------------------------+
# | Copyright (c) The PHP Group |
# +----------------------------------------------------------------------+
# | This source file is subject to version 3.01 of the PHP license, |
# | that is bundled with this package in the file LICENSE, and is |
# | available through the world-wide-web at the following url: |
# | https://www.php.net/license/3_01.txt |
# | If you did not receive a copy of the PHP license and are unable to |
# | obtain it through the world-wide-web, please send a note to |
# | [email protected] so we can mail you a copy immediately. |
# +----------------------------------------------------------------------+
# | Author: Wez Furlong <[email protected]> |
# +----------------------------------------------------------------------+
#
# This is the ninja template for the win32 build

CC="${PHP_CL}"
LD="${LINK}"
MC="${MC}"
MT="${MT}"
RE2C="${RE2C}"
PGOMGR="${PGOMGR}"
PHP_BUILD=${PHP_BUILD}

# See https://ninja-build.org/manual.html#_deps
# msvc_deps_prefix = Hinweis: Einlesen der Datei:

MCFILE=${BUILD_DIR}\wsyslog.rc

rule bison_php
command = ${BISON} ${BISON_FLAGS} --output=$out -v -d $in
description = bison $in

build Zend\zend_ini_parser.c: bison_php Zend\zend_ini_parser.y
build Zend\zend_language_parser.c: bison_php Zend\zend_language_parser.y
build sapi\phpdbg\phpdbg_parser.c: bison_php sapi\phpdbg\phpdbg_parser.y

rule re2c_php_ini
command = ${RE2C} ${RE2C_FLAGS} --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
description = re2c $in

build Zend\zend_ini_scanner.c | Zend\zend_ini_scanner_defs.h: re2c_php_ini Zend\zend_ini_scanner.l

rule re2c_php_language
command = ${RE2C} ${RE2C_FLAGS} --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
description = re2c $in

build Zend\zend_language_scanner.c Zend\zend_language_scanner_defs.h: re2c_php_language Zend\zend_language_scanner.l

rule re2c_phpdbg
command = ${RE2C} ${RE2C_FLAGS} -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
description = re2c $in

build sapi\phpdbg\phpdbg_lexer.c: re2c_phpdbg sapi\phpdbg\phpdbg_lexer.l

rule mc_php
command = ${MC} -h win32\ -r ${BUILD_DIR}\ -x ${BUILD_DIR}\ $in
description = mc $in

build ${MCFILE}: mc_php win32\build\wsyslog.mc

PHPDLL_RES=${BUILD_DIR}\${PHPDLL}.res

# FIXME: why isn't that defined in Makefile?
RC=rc.exe

rule rc_php
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
description = rc $in

build ${PHPDLL_RES}: rc_php win32\build\template.rc || ${BUILD_DIR}\\wsyslog.rc

rule ld_php
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}
description = ld $out

build ${BUILD_DIR}\${PHPLIB}: phony ${BUILD_DIR}\${PHPDLL}
8 changes: 8 additions & 0 deletions win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ MFO.WriteLine('\t$(PHP_ASSEMBLER) $(FIBER_ASM_FLAGS) $(BUILD_DIR)\\Zend\\jump_$(
MFO.WriteLine('$(BUILD_DIR)\\Zend\\make_' + FIBER_ASM_ABI + '.obj: Zend\\asm\\make_' + FIBER_ASM_ABI + '.asm');
MFO.WriteLine('\t$(PHP_ASSEMBLER) $(FIBER_ASM_FLAGS) $(BUILD_DIR)\\Zend\\make_$(FIBER_ASM_ABI).obj Zend\\asm\\make_$(FIBER_ASM_ABI).asm');

NFO.WriteBlankLines(1);
NFO.WriteLine('rule as_fiber');
NFO.WriteLine(' command = cmd /c ${PHP_ASSEMBLER} ${FIBER_ASM_FLAGS} $out $in > NUL');
NFO.WriteLine(' description = as $in');
NFO.WriteBlankLines(1);
NFO.WriteLine('build ${BUILD_DIR}\\Zend\\jump_' + FIBER_ASM_ABI + '.obj: as_fiber Zend\\asm\\jump_' + FIBER_ASM_ABI + '.asm');
NFO.WriteLine('build ${BUILD_DIR}\\Zend\\make_' + FIBER_ASM_ABI + '.obj: as_fiber Zend\\asm\\make_' + FIBER_ASM_ABI + '.asm');

ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
if (VS_TOOLSET && VCVERS >= 1914) {
ADD_FLAG("CFLAGS_BD_ZEND", "/d2FuncCache1");
Expand Down
Loading