diff --git a/src/parser/xhpast/bin/xhpast_parse.php b/src/parser/xhpast/bin/xhpast_parse.php --- a/src/parser/xhpast/bin/xhpast_parse.php +++ b/src/parser/xhpast/bin/xhpast_parse.php @@ -54,10 +54,24 @@ */ function xhpast_get_parser_future($data) { if (!xhpast_is_available()) { - throw new Exception(xhpast_get_build_instructions()); + try { + // Try to build XHPAST automatically. If we can't then just ask the user + // to build it themselves. + xhpast_build(); + } catch (CommandException $e) { + throw new Exception(xhpast_get_build_instructions()); + } } $future = new ExecFuture('%s', xhpast_get_binary_path()); $future->write($data); return $future; } + +/** + * @group xhpast + */ +function xhpast_build() { + $root = phutil_get_library_root('phutil'); + execx('%s', $root.'/../scripts/build_xhpast.sh'); +}