Skip to content

Instantly share code, notes, and snippets.

@baskan
Forked from garex/compile-n-run-hh.sh
Last active August 29, 2015 14:23
Show Gist options
  • Save baskan/d0be0eacc9d5f6a07003 to your computer and use it in GitHub Desktop.
Save baskan/d0be0eacc9d5f6a07003 to your computer and use it in GitHub Desktop.
#!/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