summaryrefslogtreecommitdiff
path: root/genfiles
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2018-11-10 02:47:26 +0100
committerPeter Kokot <peterkokot@gmail.com>2018-11-11 02:55:46 +0100
commitf0251a8b16631edf06830e08698cef5d76c1e01b (patch)
tree8a2fefe158a2d1cda48fd70bc697ea85e62e9828 /genfiles
parent1c873c119133c6d5ef13b635cba820236fa5848d (diff)
downloadphp-git-f0251a8b16631edf06830e08698cef5d76c1e01b.tar.gz
Remove lexer files generated by RE2C
This patch removes generated lexer files by re2c during the build process so they are not tracked by Git yet can be still shipped when PHP is released. The genfiles script additionally provides generation of these lexer files when creating a release of the PHP source code. The genfiles script refactorings: - added file header - echoing steps instead of comments - cleaning only lines starting with `#line` - eval removed in favor of direct executed commands - the debug mode `set -x` removed - script can be called from any path - improved comments
Diffstat (limited to 'genfiles')
-rwxr-xr-xgenfiles111
1 files changed, 88 insertions, 23 deletions
diff --git a/genfiles b/genfiles
index be44af70d6..9d0eaed5f4 100755
--- a/genfiles
+++ b/genfiles
@@ -1,36 +1,101 @@
-#! /bin/sh
+#!/bin/sh
+#
+# +----------------------------------------------------------------------+
+# | PHP Version 7 |
+# +----------------------------------------------------------------------+
+# | Copyright (c) 1997-2018 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://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 |
+# | license@php.net so we can mail you a copy immediately. |
+# +----------------------------------------------------------------------+
+# | Authors: Sascha Schumann <sascha@schumann.cx> |
+# +----------------------------------------------------------------------+
+#
+# This script generates PHP lexer and parser files required to build PHP. The
+# generated files are ignored in the Git repository and packaged during the PHP
+# release process into the release installation archive download. This way the
+# bison and re2c dependencies are not required to build PHP when downloading
+# release archive.
+#
+# Usage: genfiles
+#
+# Environment:
+# The following environment variables can override default generators paths.
+#
+# YACC Parser generator program, default bison
+# RE2C Lexer generator program, default re2c
+#
+# For example:
+# YACC=/path/to/bison ./genfiles
-if [ -z $YACC ]; then
- YACC="bison"
-fi
+# Parser generator
+YACC=${YACC:-bison}
YACC="$YACC -y -l"
-if [ -z $RE2C ]; then
- RE2C="re2c"
-fi
+# Lexer generator
+RE2C=${RE2C:-re2c}
+RE2C_FLAGS="-i"
-# Generate Zend parser and lexer files
-STD="make -f Zend/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=Zend builddir=Zend top_srcdir=."
-(eval "$STD Zend/zend_language_parser.c Zend/zend_language_scanner.c Zend/zend_ini_parser.c Zend/zend_ini_scanner.c")
+# Current path to return to it later. This enables running script from any path.
+original_path=`pwd`
-# Generate phpdbg parser and lexer files
-STD="make -f sapi/phpdbg/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=."
-(eval "$STD sapi/phpdbg/phpdbg_parser.c sapi/phpdbg/phpdbg_lexer.c")
+# Project root directory
+project_root=`CDPATH= cd -- "$(dirname -- "$0")" && pwd -P`
+cd $project_root
-# Generate json parser and lexer files
-STD="make -f ext/json/Makefile.frag RE2C='$RE2C' RE2C_FLAGS='-i' YACC='$YACC' srcdir=ext/json builddir=ext/json top_srcdir=."
-(eval "$STD ext/json/json_parser.tab.c ext/json/json_scanner.c")
+echo "Generating Zend parser and lexer files"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=Zend builddir=Zend top_srcdir=. \
+ -f Zend/Makefile.frag \
+ Zend/zend_language_parser.c \
+ Zend/zend_language_scanner.c \
+ Zend/zend_ini_parser.c \
+ Zend/zend_ini_scanner.c
-set -x
+echo "Generating phpdbg parser and lexer files"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=. \
+ -f sapi/phpdbg/Makefile.frag \
+ sapi/phpdbg/phpdbg_parser.c \
+ sapi/phpdbg/phpdbg_lexer.c
-CLEANUP_FILES=" \
- ext/pdo/pdo_sql_parser.c \
- ext/date/lib/parse_date.c \
- ext/standard/url_scanner_ex.c \
+echo "Generating json extension parser and lexer files"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=ext/json builddir=ext/json top_srcdir=. \
+ -f ext/json/Makefile.frag \
+ ext/json/json_parser.tab.c \
+ ext/json/json_scanner.c
+
+echo "Generating PDO lexer file"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/pdo builddir=ext/pdo top_srcdir=. \
+ -f ext/pdo/Makefile.frag \
+ ext/pdo/pdo_sql_parser.c
+
+echo "Generating standard extension lexer files"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/standard builddir=ext/standard top_srcdir=. \
+ -f ext/standard/Makefile.frag \
ext/standard/var_unserializer.c \
+ ext/standard/url_scanner_ex.c
+
+echo "Generating phar extension lexer file"
+make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/phar builddir=ext/phar top_srcdir=. \
+ -f ext/phar/Makefile.frag \
+ ext/phar/phar_path_check.c
+
+# Clean debug #line XY info from the bundled lexer files.
+cleanup_files=" \
+ ext/date/lib/parse_date.c \
+ ext/date/lib/parse_iso_intervals.c \
"
-for f in $CLEANUP_FILES; do
+for f in $cleanup_files; do
+ echo "Cleaning file $f"
cp $f $f.orig
- grep -v '#line ' $f.orig > $f
+ grep -v '^#line ' $f.orig > $f
+ rm -f $f.orig
done
+
+# Return to the original directory.
+cd $original_path