Skip to content

Commit 0e7a562

Browse files
committed
Fix Bison and Re2c to skip regenerating files
Using only symbolic file (non-existing on disk) regenerates parser and lexer files on consecutive build phases.
1 parent 948a882 commit 0e7a562

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

cmake/cmake/modules/PHP/Bison.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,16 @@ function(php_bison name input output)
401401
_php_bison_process_header_option()
402402
_php_bison_process_verbose_option()
403403

404-
# Generate name for the symbolic file for the custom command below.
405-
string(MAKE_C_IDENTIFIER "${name}_${input}" symbolic_name)
404+
# Generate timestamp file name for the custom command below.
405+
string(MAKE_C_IDENTIFIER "${name}_${input}" id)
406+
set(
407+
timestamp
408+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/Bison/${id}.timestamp
409+
)
410+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/Bison)
406411

407412
if(role STREQUAL "PROJECT")
408-
add_custom_target(${name} SOURCES ${input} DEPENDS ${symbolic_name})
413+
add_custom_target(${name} SOURCES ${input} DEPENDS ${timestamp})
409414
endif()
410415

411416
# Skip generation, if generated files are provided by the release archive.
@@ -439,7 +444,8 @@ function(php_bison name input output)
439444
# the same generated source file is used by multiple project
440445
# libraries/targets.
441446
add_custom_command(
442-
OUTPUT ${symbolic_name}
447+
OUTPUT ${timestamp}
448+
COMMAND ${CMAKE_COMMAND} -E touch ${timestamp}
443449
${commands}
444450
DEPENDS
445451
${input}
@@ -450,7 +456,6 @@ function(php_bison name input output)
450456
COMMAND_EXPAND_LISTS
451457
WORKING_DIRECTORY ${parsed_WORKING_DIRECTORY}
452458
)
453-
set_source_files_properties(${symbolic_name} PROPERTIES SYMBOLIC TRUE)
454459

455460
add_custom_command(OUTPUT ${outputs} DEPENDS ${name} ${codegen})
456461
endfunction()

cmake/cmake/modules/PHP/Re2c.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,15 @@ function(php_re2c name input output)
387387
_php_re2c_process_header_option()
388388

389389
# Generate name for the symbolic file for the custom command below.
390-
string(MAKE_C_IDENTIFIER "${name}_${input}" symbolic_name)
390+
string(MAKE_C_IDENTIFIER "${name}_${input}" id)
391+
set(
392+
timestamp
393+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/Re2c/${id}.timestamp
394+
)
395+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PHP/Re2c)
391396

392397
if(role STREQUAL "PROJECT")
393-
add_custom_target(${name} SOURCES ${input} DEPENDS ${symbolic_name})
398+
add_custom_target(${name} SOURCES ${input} DEPENDS ${timestamp})
394399
endif()
395400

396401
# Skip generation, if generated files are provided by the release archive.
@@ -425,7 +430,8 @@ function(php_re2c name input output)
425430
# the same generated source file is used by multiple project
426431
# libraries/targets.
427432
add_custom_command(
428-
OUTPUT ${symbolic_name}
433+
OUTPUT ${timestamp}
434+
COMMAND ${CMAKE_COMMAND} -E touch ${timestamp}
429435
${commands}
430436
DEPENDS
431437
${input}
@@ -437,7 +443,6 @@ function(php_re2c name input output)
437443
${codegen}
438444
WORKING_DIRECTORY ${parsed_WORKING_DIRECTORY}
439445
)
440-
set_source_files_properties(${symbolic_name} PROPERTIES SYMBOLIC TRUE)
441446

442447
add_custom_command(OUTPUT ${outputs} DEPENDS ${name} ${codegen})
443448
endfunction()

0 commit comments

Comments
 (0)