Created
March 4, 2015 10:19
-
-
Save garex/b0fa539903746e67ad6c to your computer and use it in GitHub Desktop.
Compile hh files and run without sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function log { | |
echo | |
echo "-- $1 --" | |
} | |
function run { | |
echo "# $1" | |
sh -c "$1" | |
} | |
log "Create www dir" | |
run "mkdir --parents www" | |
log "Create our hack file" | |
echo "<?hh echo 'Hello from Hack! ' . date(DateTime::ATOM) . PHP_EOL;" > www/cool.php | |
run "cat www/cool.php" | |
log "Run it just as it is from command line (with disabled typechecker)" | |
run "hhvm -vHack.Lang.LookForTypechecker=0 www/cool.php" | |
log "Clean up bytecodes" | |
run "rm -f hhvm.hh*bc" | |
log "Compile repo" | |
run "rm -rf /tmp/hphp_*" | |
run "ln -s $(which hhvm) hphp" | |
run "./hphp --config-value EnableHipHopSyntax=1 --config-value UseHHBBC=0 --target hhbc --keep-tempdir=1 --log=3 --input-dir www" | |
run "rm --force ./hphp" | |
run "mv $(find /tmp/hphp_* -name hhvm.hhbc | head -1) ." | |
log "Optimize it with hhbbc" | |
run "ln -s $(which hhvm) hhbbc" | |
run "./hhbbc" | |
run "rm --force ./hhbbc" | |
log "Remove unoptimized repo" | |
run "rm hhvm.hhbc" | |
log "Remove source code" | |
run "rm --force www/*" | |
log "Now we dont' have anything in run directory" | |
run "ls -laR" | |
log "Run it from command line from repo" | |
run "cd www && hhvm -vRepo.Authoritative=true -vRepo.Local.Path=../hhvm.hhbbc --file=cool.php" | |
log "Finish" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment