summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2019-02-24 13:01:57 +0100
committerPeter Kokot <peterkokot@gmail.com>2019-03-16 23:51:05 +0100
commite525ce30a56767cb5bd71221dd98bdc09f3ee60f (patch)
treee00939b451157febdd53faac366a90262d4a0c29 /scripts
parent78ab79b9164420679da7aba1f7195335d656afda (diff)
downloadphp-git-e525ce30a56767cb5bd71221dd98bdc09f3ee60f.tar.gz
Move distribution generator script to scripts/dev
The more proper place for shell scripts dedicated for development, and releasing PHP should be the scripts/dev directory. Having a cleaner root project directory helps find the main README.md and files relevant to install PHP. These scripts are also used by the release managers mostly who create release packages and aren't used often by the majority of developers working on and installing PHP.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/genfiles101
-rwxr-xr-xscripts/dev/makedist157
2 files changed, 258 insertions, 0 deletions
diff --git a/scripts/dev/genfiles b/scripts/dev/genfiles
new file mode 100755
index 0000000000..6384225749
--- /dev/null
+++ b/scripts/dev/genfiles
@@ -0,0 +1,101 @@
+#!/bin/sh
+#
+# +----------------------------------------------------------------------+
+# | PHP Version 7 |
+# +----------------------------------------------------------------------+
+# | 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://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
+
+# Parser generator
+YACC=${YACC:-bison}
+YACC="$YACC -y -l"
+
+# Lexer generator
+RE2C=${RE2C:-re2c}
+RE2C_FLAGS="-i"
+
+# Current path to return to it later. This enables running script from any path.
+original_path=`pwd`
+
+# Project root directory
+project_root=`CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P`
+cd $project_root
+
+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
+
+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
+
+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
+ echo "Cleaning file $f"
+ cp $f $f.orig
+ grep -v '^#line ' $f.orig > $f
+ rm -f $f.orig
+done
+
+# Return to the original directory.
+cd $original_path
diff --git a/scripts/dev/makedist b/scripts/dev/makedist
new file mode 100755
index 0000000000..84c2facba8
--- /dev/null
+++ b/scripts/dev/makedist
@@ -0,0 +1,157 @@
+#!/bin/sh
+#
+# Distribution generator for git
+#
+# Usage: makedist version
+# Example: makedist 5.4.1
+# Example: makedist 5.3.5RC1
+#
+# To work, this script needs a consistent tagging of all releases.
+# Each release of a package should have a tag of the form
+#
+# php-X.Y.Z[sub]
+#
+# The distribution ends up in a .tar.gz file that contains the distribution
+# in a directory called php-<version>.
+# A .tar.bz2 file is also created.
+#
+# Written by Stig Bakken <ssb@guardian.no> 1997-05-28.
+# Adapted to git by Stanislav Malyshev <stas@php.net>
+
+# Go to project root directory.
+cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P)
+
+if test "$#" != "1"; then
+ echo "Usage: makedist <version>" >&2
+ exit 1
+fi
+
+VER=$1 ; shift
+
+old_IFS="$IFS"
+IFS=.
+eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /g'`
+if test "${1}" -lt "3" -o "${1}" = "3" -a "${2}" -eq "0" -a "${3}" -lt "2"; then
+ echo "You will need bison >= 3.0.2 if you want to regenerate the Zend parser (found ${1}.${2}.${3})."
+ exit 2
+fi
+eval set `re2c --version| grep 're2c' | cut -d ' ' -f 2 | sed -e 's/\./ /g'`
+if test "${2}" -lt "13" -o "${2}" -eq "13" -a "${3}" -lt "5"; then
+ echo "You will need re2c >= 0.13.5 if you want to regenerate the Zend scanner (found ${1}.${2}.${3})."
+ exit 2
+fi
+IFS="$old_IFS"
+
+if test "x$PHPROOT" = "x"; then
+ PHPROOT=git@git.php.net:php-src.git;
+fi
+
+LT_TARGETS='build/ltmain.sh build/config.guess build/config.sub'
+
+if echo '\c' | grep -s c >/dev/null 2>&1
+then
+ ECHO_N="echo -n"
+ ECHO_C=""
+else
+ ECHO_N="echo"
+ ECHO_C='\c'
+fi
+
+MY_OLDPWD=`pwd`
+
+# the destination .tar.gz file
+ARCHIVE=$MY_OLDPWD/php-$VER.tar
+
+# temporary directory used to check out files from SVN
+DIR=php-$VER
+DIRPATH=$MY_OLDPWD/$DIR
+
+if test -d "$DIRPATH"; then
+ echo "The directory $DIR" >&2
+ echo "already exists, rename or remove it and run makedist again." >&2
+ exit 1
+fi
+
+# Export PHP
+$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
+git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
+echo ""
+
+cd $DIR || exit 5
+
+# hide away our own versions of libtool-generated files
+for i in $LT_TARGETS; do
+ if test -f "$i"; then
+ mv $i $i.bak
+ cp $i.bak $i
+ fi
+done
+
+# generate some files so people don't need bison, re2c and autoconf
+# to install
+set -x
+./buildconf --force
+
+# remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
+# when a user runs buildconf in the distribution.
+rm -f buildmk.stamp
+
+./scripts/dev/genfiles
+
+# now restore our versions of libtool-generated files
+for i in $LT_TARGETS; do
+ test -f "$i" && mv $i.bak $i
+done
+
+# removing junk files
+find . -name \*.orig -print0 | xargs -0 rm
+rm -fr autom4te.cache/
+
+# touching everything to be packaged
+find $MY_OLDPWD/php-$VER -exec touch -c {} \;
+
+# tweak zendparse to be exported through ZEND_API
+# NOTE this has to be revisited once bison supports foreign skeletons
+# and that bison version is used. Read /usr/share/bison/README for more
+sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.c
+sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
+sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
+
+# download pear
+$ECHO_N "makedist: Attempting to download PEAR's phar archive"
+if test ! -x wget; then
+ wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
+ if [ "x$?" != "x0" ]
+ then
+ $ECHO_N "Pear download failed";
+ exit 7
+ fi
+else
+ $ECHO_N "Missing wget binary needed for pear download";
+ exit 7
+fi
+
+cd $MY_OLDPWD
+$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
+rm -f $ARCHIVE.gz
+tar cf $ARCHIVE php-$VER || exit 8
+gzip -9 $ARCHIVE || exit 9
+echo ""
+
+$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
+rm -f $ARCHIVE.bz2
+tar cf $ARCHIVE php-$VER || exit 10
+bzip2 -9 $ARCHIVE || exit 11
+echo ""
+
+$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
+rm -f $ARCHIVE.xz
+tar cf $ARCHIVE php-$VER || exit 10
+xz -9 $ARCHIVE || exit 12
+echo ""
+
+$ECHO_N "makedist: cleaning up...$ECHO_C"
+rm -rf $DIRPATH || exit 13
+echo ""
+
+exit 0