Add logging for comparison behaviors
[hiphop-php.git] / hphp / system / make_systemlib.sh
blob3bc6c3215a0e0198dd03cdd89e385b90a2f555d2
1 #!/bin/sh
3 cd $FBCODE_DIR
5 # fbconfig passes a couple --foo arguments.
6 shift;
7 shift;
9 SYSTEMLIB=$INSTALL_DIR/systemlib.php
11 # If we put the line we're generating into this file, then the linter will think
12 # the generator itself is generated. Encode it into a variable for safe
13 # keeping.
14 AT="@"
16 echo "<?hh // partial" > ${SYSTEMLIB}
17 echo "// {$AT}generated" >> ${SYSTEMLIB}
19 for i in $@; do
20 if [ ! -f "$i" ]; then
21 echo "File '$i' is in system/php.txt, but does not exist" >&2
22 exit 1
25 BN=$(basename $i)
26 BNPHP=$(basename $BN .php)
27 BNNSPHP=$(basename $BN .ns.php)
28 BNHHAS=$(basename $BN .hhas)
29 if [ "$BNPHP.php" = "$BN" ]; then
30 # First, .php files are included with their open tags stripped.
31 if head -1 $i | grep -qv '^<?\(php\|hh\)'; then
32 echo "Unexpected header in file '$i'" >&2
33 exit 1
35 echo "" >> ${SYSTEMLIB}
36 if [ ! "$BNNSPHP.ns.php" = "$BN" ]; then
37 echo "namespace {" >> ${SYSTEMLIB}
39 tail -n +2 $i >> ${SYSTEMLIB}
40 if [ ! "$BNNSPHP.ns.php" = "$BN" ]; then
41 echo "}" >> ${SYSTEMLIB}
43 else
44 if [ ! "$BNHHAS.hhas" = "$BN" ]; then
45 echo "File '$i' is neither PHP nor HHAS source" >&2
46 exit 1
49 done
51 echo "" >> ${SYSTEMLIB}
52 echo "<?hhas" >> ${SYSTEMLIB}
54 # Then .hhas files are included en-masse.
55 for i in $@; do
56 BN=$(basename $i)
57 BNHHAS=$(basename $BN .hhas)
58 if [ "$BNHHAS.hhas" = "$BN" ]; then
59 echo "" >> ${SYSTEMLIB}
60 cat $i >> ${SYSTEMLIB}
62 done