Arquivos
hhvm/hphp/runtime/ext_hhvm/make_systemlib.sh
T
Daniel Sloof c494c3a145 Don't use "echo -n" in /bin/sh scripts on MacOSX
The shell builtin implementation of echo on MacOSX
doesn't respect the -n flag.  This is the only usage of it
in our stack so far and we can avoid it by hiding the generated
token from the linter in a different way.
2013-07-18 17:28:44 -07:00

57 linhas
1.3 KiB
Bash
Arquivo Executável

#!/bin/sh
cd $FBCODE_DIR
# fbconfig passes a couple --foo arguments.
shift;
shift;
SYSTEMLIB=$INSTALL_DIR/systemlib.php
# If we put the line we're generating into this file,
# then the linter will think the generator itself
# is generated. Encode it into a variable for safe keeping.
AT="@"
echo "<?hh" > ${SYSTEMLIB}
echo "// {$AT}generated" >> ${SYSTEMLIB}
for i in $@; do
if [ ! -f "$i" ]; then
echo "File $i is in the index, but does not exist" >&2
exit 1
fi
BN=`basename $i`
BNPHP=`basename $BN .php`
BNHHAS=`basename $BN .hhas`
if [ "$BNPHP.php" = "$BN" ]; then
# First, .php files are included with their open tags stripped
HEADER=`head -1 $i | cut -c 1-5`
if [ ! "${HEADER}" = "<?php" ]; then
echo "Unexpected header in file $i" >&2
exit 1
fi
echo "" >> ${SYSTEMLIB}
cat $i | grep -v '<?php' >> ${SYSTEMLIB}
else
if [ ! "$BNHHAS.hhas" = "$BN" ]; then
echo "File $i is neither PHP not HHAS source" >&2
exit 1
fi
fi
done
echo "" >> ${SYSTEMLIB}
echo "<?hhas" >> ${SYSTEMLIB}
# Then .hhas files are included en-masse
for i in $@; do
BN=`basename $i`
BNHHAS=`basename $BN .hhas`
if [ "$BNHHAS.hhas" = "$BN" ]; then
echo "" >> ${SYSTEMLIB}
cat $i >> ${SYSTEMLIB}
fi
done