Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15395661
D11629.id27986.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11629.id27986.diff
View Options
diff --git a/scripts/build_xhpast.php b/scripts/build_xhpast.php
new file mode 100755
--- /dev/null
+++ b/scripts/build_xhpast.php
@@ -0,0 +1,7 @@
+#!/usr/bin/env php
+<?php
+
+require_once dirname(__FILE__).'/__init_script__.php';
+
+PhutilXHPASTBinary::build();
+echo "Build successful!\n";
diff --git a/scripts/build_xhpast.sh b/scripts/build_xhpast.sh
deleted file mode 100755
--- a/scripts/build_xhpast.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-set -e
-
-ROOT=`dirname $0`"/../support/xhpast"
-
-USE_GMAKE=1
-command -v gmake >/dev/null 2>&1 || USE_GMAKE=0
-
-echo
-echo "Building XHPAST..."
-echo
-
-cd $ROOT
-if [ $USE_GMAKE -eq 1 ]; then
- gmake clean all install
-else
- make clean all install
-fi
-
-echo
-echo "Testing xhpast works"
-echo
-if ! ./xhpast --version
-then
- echo
- echo >&2 "xhpast is broken :("
- echo >&2 "Maybe try \`STATIC=1 ./build_xhpast.sh\` if the error"
- echo >&2 "is linker-related?"
- echo
- exit 2
-fi
-
-echo
-echo "Build successful!"
-echo
diff --git a/src/parser/xhpast/bin/PhutilXHPASTBinary.php b/src/parser/xhpast/bin/PhutilXHPASTBinary.php
--- a/src/parser/xhpast/bin/PhutilXHPASTBinary.php
+++ b/src/parser/xhpast/bin/PhutilXHPASTBinary.php
@@ -27,7 +27,27 @@
* @return void
*/
public static function build() {
- execx('%s', self::getBuildPath());
+ if (Filesystem::binaryExists('gmake')) {
+ $command = 'gmake';
+ } else {
+ $command = 'make';
+ }
+
+ $root = phutil_get_library_root('phutil');
+ $path = Filesystem::resolvePath($root.'/../support/xhpast');
+
+ // Run the build.
+ execx(
+ '%s -C %s %Ls',
+ $command,
+ $path,
+ array('clean', 'all', 'install'));
+
+ // Test the binary.
+ if (!self::isAvailable()) {
+ throw new Exception('xhpast is broken.');
+ }
+
self::$version = null;
}
@@ -37,24 +57,16 @@
* @return string
*/
public static function getBuildInstructions() {
+ $root = phutil_get_library_root('phutil');
+ $make = Filesystem::resolvePath($root.'/../scripts/build_xhpast.php');
+
return phutil_console_format(
"%s:\n\n \$ %s\n",
pht(
"Your version of '%s' is unbuilt or out of date. Run this ".
"script to build it",
'xhpast'),
- self::getBuildPath());
- }
-
- /**
- * Returns the path to the script used to build XHPAST.
- *
- * @return string
- */
- private static function getBuildPath() {
- $root = phutil_get_library_root('phutil');
- $make = $root.'/../scripts/build_xhpast.sh';
- return Filesystem::resolvePath($make);
+ $make);
}
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 17, 8:47 AM (5 d, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7708167
Default Alt Text
D11629.id27986.diff (2 KB)
Attached To
Mode
D11629: Move XHPAST build script to PHP
Attached
Detach File
Event Timeline
Log In to Comment