mirror of
https://github.com/php/php-src.git
synced 2024-09-21 01:47:25 +00:00
Refactor genif.sh
Changes: - Coding style fixes - ${1+"$@"} replaced with "$@" [1] - EXTRA_MODULE_PTRS variable is not used anymore - awk tool defined via environment variable - srcdir determined automatically from the genif.sh location [1] https://www.in-ulm.de/~mascheck/various/bourne_args/ Closes GH-4372
This commit is contained in:
parent
392398bfe6
commit
900de30b0f
@ -1,39 +1,53 @@
|
||||
#! /bin/sh
|
||||
#!/bin/sh
|
||||
#
|
||||
# Generate internal functions file content based on the provided extensions.
|
||||
#
|
||||
# SYNOPSIS:
|
||||
# genif.sh <template> <extensions>
|
||||
#
|
||||
# ARGUMENTS:
|
||||
# template Path to internal functions template file.
|
||||
# extensions Space delimited list of provided extensions and their locations.
|
||||
#
|
||||
# ENVIRONMENT:
|
||||
# The following optional variables are supported:
|
||||
#
|
||||
# AWK Path to the awk program or its command name.
|
||||
# AWK=/path/to/awk genif.sh ...
|
||||
#
|
||||
# USAGE EXAMPLE:
|
||||
# AWK=nawk ./build/genif.sh ./main/internal_functions.c.in "date;ext/date spl;ext/spl" > ./main/internal_functions.c
|
||||
|
||||
# replacement for genif.pl
|
||||
AWK=${AWK:-awk}
|
||||
template=$1
|
||||
shift
|
||||
extensions="$@"
|
||||
|
||||
infile=$1
|
||||
shift
|
||||
srcdir=$1
|
||||
shift
|
||||
extra_module_ptrs=$1
|
||||
shift
|
||||
awk=$1
|
||||
shift
|
||||
|
||||
if test -z "$infile" || test -z "$srcdir"; then
|
||||
echo "please supply infile and srcdir" >&2
|
||||
exit 1
|
||||
if test -z "$template"; then
|
||||
echo "Please supply template." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
header_list=
|
||||
olddir=`pwd`
|
||||
cd $srcdir
|
||||
olddir=$(pwd)
|
||||
|
||||
module_ptrs="$extra_module_ptrs`echo $@ | $awk -f ./build/order_by_dep.awk`"
|
||||
# Go to project root.
|
||||
cd $(CDPATH= cd -- "$(dirname -- "$0")/../" && pwd -P)
|
||||
|
||||
for ext in ${1+"$@"} ; do
|
||||
ext_dir=`echo "$ext" | cut -d ';' -f 2`
|
||||
header_list="$header_list $ext_dir/*.h*"
|
||||
module_ptrs="$(echo $extensions | $AWK -f ./build/order_by_dep.awk)"
|
||||
|
||||
for ext in $extensions; do
|
||||
ext_dir=$(echo "$ext" | cut -d ';' -f 2)
|
||||
header_list="$header_list $ext_dir/*.h*"
|
||||
done
|
||||
|
||||
includes=`$awk -f ./build/print_include.awk $header_list`
|
||||
includes=$($AWK -f ./build/print_include.awk $header_list)
|
||||
|
||||
cd $olddir
|
||||
|
||||
cat $infile | \
|
||||
sed \
|
||||
-e "s'@EXT_INCLUDE_CODE@'$includes'" \
|
||||
-e "s'@EXT_MODULE_PTRS@'$module_ptrs'" \
|
||||
-e 's/@NEWLINE@/\
|
||||
cat $template | \
|
||||
sed \
|
||||
-e "s'@EXT_INCLUDE_CODE@'$includes'" \
|
||||
-e "s'@EXT_MODULE_PTRS@'$module_ptrs'" \
|
||||
-e 's/@NEWLINE@/\
|
||||
/g'
|
||||
|
@ -1620,12 +1620,10 @@ FEO
|
||||
dnl Run this only when generating all the files.
|
||||
if test -n "\$REDO_ALL"; then
|
||||
echo "creating main/internal_functions.c"
|
||||
extensions="$EXT_STATIC"
|
||||
sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in $srcdir "$EXTRA_MODULE_PTRS" $AWK \$extensions > main/internal_functions.c
|
||||
AWK="$AWK" sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in "$EXT_STATIC" > main/internal_functions.c
|
||||
|
||||
echo "creating main/internal_functions_cli.c"
|
||||
cli_extensions="$EXT_CLI_STATIC"
|
||||
sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in $srcdir "$EXTRA_MODULE_PTRS" $AWK \$cli_extensions > main/internal_functions_cli.c
|
||||
AWK="$AWK" sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in "$EXT_CLI_STATIC" > main/internal_functions_cli.c
|
||||
|
||||
if test "$PHP_SAPI" = "apache2handler"; then
|
||||
if test "$APACHE_VERSION" -ge 2004001; then
|
||||
|
Loading…
Reference in New Issue
Block a user