Skip to content

Commit 4fe71b6

Browse files
committed
Sync flags and build types
- This now adds the compilation options for the DebugAssertions build type, which is based on the RelWithDebInfo. - RE2C and Bison flags and arguments improved few steps forward. - RE2C prehistoric versions -c option added automatically when header option is used
1 parent 5a04d63 commit 4fe71b6

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ if(BISON_FOUND)
470470
zend_ini_parser
471471
zend_ini_parser.y
472472
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.c
473-
COMPILE_FLAGS "-Wall -d"
474-
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/zend_ini_parser.output
473+
COMPILE_FLAGS "${PHP_DEFAULT_BISON_FLAGS}"
474+
VERBOSE REPORT_FILE zend_ini_parser.output
475475
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.h
476476
)
477477

@@ -482,8 +482,8 @@ if(BISON_FOUND)
482482
zend_language_parser
483483
zend_language_parser.y
484484
${CMAKE_CURRENT_SOURCE_DIR}/zend_language_parser.c
485-
COMPILE_FLAGS "-Wall -d"
486-
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/zend_language_parser.output
485+
COMPILE_FLAGS "${PHP_DEFAULT_BISON_FLAGS}"
486+
VERBOSE REPORT_FILE zend_language_parser.output
487487
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zend_language_parser.h
488488
)
489489

cmake/cmake/BuildTypes.cmake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ block()
2222
allowedBuildTypes
2323
Debug # Debug info, assertions, not optimized.
2424
DebugAssertions # Custom PHP debug build type with assertions enabled
25-
# in the release mode. TODO: Adjust the flags.
26-
MinSizeRel # Optimized for size rather than speed.
25+
# in the RelWithDebInfo mode: optimized, debug info,
26+
# assertions.
27+
MinSizeRel # Same as Release but optimized for size rather than
28+
# speed.
2729
Release # No debug info, no assertions, optimized.
2830
RelWithDebInfo # Debug info, optimized, no assertions.
2931
)
@@ -51,3 +53,14 @@ target_compile_definitions(
5153
INTERFACE
5254
$<IF:$<CONFIG:Debug,DebugAssertions>,ZEND_DEBUG=1,ZEND_DEBUG=0>
5355
)
56+
57+
# Set CMAKE_<LANG>_FLAGS_<CONFIG> variables for the DebugAssertions build type.
58+
foreach(prefix CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS)
59+
string(
60+
REGEX REPLACE
61+
"(-DNDEBUG|/DNDEBUG)"
62+
""
63+
${prefix}_DEBUGASSERTIONS
64+
"${${prefix}_RELWITHDEBINFO}"
65+
)
66+
endforeach()

cmake/cmake/Requirements.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ if(
7272
TYPE REQUIRED
7373
PURPOSE "Necessary to generate PHP parser files."
7474
)
75+
# TODO: Add Bison options based on the build type.
76+
#set(PHP_DEFAULT_BISON_FLAGS "-Wall $<$<CONFIG:Release,MinSizeRel>:-l>")
77+
set(PHP_DEFAULT_BISON_FLAGS "-Wall")
7578
endif()
7679

7780
# Check if re2c is required.
@@ -93,7 +96,11 @@ if(
9396
endif()
9497

9598
set(RE2C_ENABLE_DOWNLOAD TRUE)
96-
set(RE2C_DEFAULT_OPTIONS --no-generation-date)
99+
set(
100+
RE2C_DEFAULT_OPTIONS
101+
--no-generation-date # Suppress date output in the generated file.
102+
$<$<CONFIG:Release,MinSizeRel>:-i> # Do not output line directives.
103+
)
97104

98105
find_package(RE2C 1.0.3)
99106
set_package_properties(

cmake/cmake/modules/FindRE2C.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ function(re2c_target)
260260

261261
list(APPEND outputs ${header})
262262

263-
# Before version 1.2 also --bit-vectors (-c) option is required when header
264-
# option is used.
263+
# When header option is used before version 1.2, also the '-c' option is
264+
# required. Before 1.1 -c long variant is '--start-conditions' and after 1.1
265+
# '--conditions'.
265266
if(RE2C_VERSION VERSION_LESS_EQUAL 1.2)
266-
list(APPEND options "--bit-vectors")
267+
list(APPEND options -c)
267268
endif()
268269

269270
# Since version 3.0, --header is the new alias option for --type-header.

cmake/ext/json/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ if(BISON_FOUND)
3131
php_json_parser
3232
json_parser.y
3333
${CMAKE_CURRENT_SOURCE_DIR}/json_parser.tab.c
34-
COMPILE_FLAGS "-Wall --defines -l"
34+
COMPILE_FLAGS "${PHP_DEFAULT_BISON_FLAGS}"
35+
VERBOSE REPORT_FILE json_parser.tab.output
3536
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/json_parser.tab.h
3637
)
3738

@@ -45,7 +46,7 @@ if(RE2C_FOUND)
4546
json_scanner.re
4647
${CMAKE_CURRENT_SOURCE_DIR}/json_scanner.c
4748
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/php_json_scanner_defs.h
48-
OPTIONS -bci
49+
OPTIONS -bc
4950
)
5051
endif()
5152

cmake/sapi/phpdbg/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ if(BISON_FOUND)
206206
php_phpdbg_parser
207207
phpdbg_parser.y
208208
${CMAKE_CURRENT_SOURCE_DIR}/phpdbg_parser.c
209-
COMPILE_FLAGS "-Wall -d"
210-
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/phpdbg_parser.output
209+
COMPILE_FLAGS "${PHP_DEFAULT_BISON_FLAGS}"
210+
VERBOSE REPORT_FILE phpdbg_parser.output
211211
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/phpdbg_parser.h
212212
)
213213

0 commit comments

Comments
 (0)