Skip to content

Support for generating executables

Compare
Choose a tag to compare
@fredemmott fredemmott released this 20 Feb 22:37
58be8fb

This release adds the following to the CodegenFile class:

  • setShebangLine(string s);
  • setShebangLinef(format, ...);
  • setPseudoMainHeader(string);
  • setPseudoMainHeaderf(format, ...);
  • setPseudoMainFooter(string);
  • setPseudoMainFooterf(format, ...);

For example:

$factory->codegenFile($path)
  ->setShebangLine('#!/usr/bin/env hhvm')
  ->setPseudoMainHeader('require_once("vendor/autoload.php");')
  ->addFunction($factory->codegenFunction('main')/*... */ )
  ->setPseudoMainFooter('main();')
  ->save();

These new methods can not be used with <?hh // strict files - as <?hh // strict bans pseudomain code, it's not currently possible to have strict scripts in Hack.