Skip to content

Commit

Permalink
Fix nits for ext/tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
petk committed Feb 26, 2025
1 parent 737f636 commit fa7e72b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmake/cmake/Requirements.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ find_package(Sendmail)

################################################################################
# Find PHP installed on the system for generating stub files (*_arginfo.h),
# Zend/zend_vm_gen.php, ext/tokenizer/tokenizer_data_gen.php and similar where
# it can be used. Otherwise the built cli sapi is used at the build phase.
# Minimum supported version for gen_stub.php is PHP 7.4.
# Zend/zend_vm_gen.php, and similar where it can be used. Otherwise the built
# cli SAPI is used at the build phase. Minimum supported version for
# gen_stub.php is PHP 7.4.
################################################################################
find_package(PHPSystem 7.4)
7 changes: 3 additions & 4 deletions cmake/ext/tokenizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ target_sources(
tokenizer.stub.php
)

# The tokenizer extension depends on the generated Zend scanner and parser.
add_dependencies(php_ext_tokenizer Zend::Zend)

# Generate tokenizer data source files.
if(EXISTS ${PHP_SOURCE_DIR}/Zend/zend_language_parser.y)
# The tokenizer extension depends on the generated Zend scanner and parser.
add_dependencies(php_ext_tokenizer Zend::Zend)

add_custom_command(
OUTPUT
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data.stub.php
Expand All @@ -79,7 +79,6 @@ if(EXISTS ${PHP_SOURCE_DIR}/Zend/zend_language_parser.y)
${PHP_SOURCE_DIR}/Zend/zend_language_parser.y
COMMAND
${CMAKE_COMMAND}
-D PHP_SOURCE_DIR=${PHP_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateTokenizerData.cmake
COMMENT
"[ext/tokenizer] Regenerating tokenizer_data.c and tokenizer_data.stub.php"
Expand Down
11 changes: 6 additions & 5 deletions cmake/ext/tokenizer/cmake/GenerateTokenizerData.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# This is CMake-based alternative of ext/tokenizer/tokenizer_data_gen.php
#
# This is CMake-based alternative of ext/tokenizer/tokenizer_data_gen.php.
# Run as:
# cmake -D PHP_SOURCE_DIR=<php-src> -P GenerateTokenizerData.cmake
# cmake -P [...ext/tokenizer/cmake/]GenerateTokenizerData.cmake

cmake_minimum_required(VERSION 3.25...3.31)

if(NOT CMAKE_SCRIPT_MODE_FILE)
message(FATAL_ERROR "This is a command-line script.")
endif()

if(NOT PHP_SOURCE_DIR)
message(FATAL_ERROR "PHP_SOURCE_DIR variable is required.")
set(PHP_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)

if(NOT EXISTS ${PHP_SOURCE_DIR}/Zend/zend_language_parser.y)
message(FATAL_ERROR "Zend/zend_language_parser.y not found.")
endif()

set(regex "^%token [^T]*(T_[^ \n]+)")
Expand Down

0 comments on commit fa7e72b

Please sign in to comment.