Page MenuHomePhabricator

D21064.diff
No OneTemporary

D21064.diff

diff --git a/support/xhpast/Makefile b/support/xhpast/Makefile
--- a/support/xhpast/Makefile
+++ b/support/xhpast/Makefile
@@ -1,6 +1,7 @@
BISONFLAGS = --verbose --name-prefix xhpast
CPPFLAGS = -fPIC -Wall
FLEXFLAGS = -CFr
+XHPAST_VERSION := $(shell ./bin/xhpast-generate-version.php)
ifdef DEBUG
BISONFLAGS += --debug
@@ -64,7 +65,7 @@
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) -o $@ $<
-node_names.hpp parser_nodes.php: generate_nodes.php
+node_names.hpp parser_nodes.php: bin/xhpast-generate-nodes.php
php -f $<
parser.yacc.o: scanner.lex.hpp
@@ -74,4 +75,4 @@
$(AR) -crs $@ $^
xhpast: xhpast.cpp libxhpast.a
- $(CXX) $(CPPFLAGS) -o $@ $^
+ $(CXX) $(CPPFLAGS) -D XHPAST_VERSION='"$(XHPAST_VERSION)"' -o $@ $^
diff --git a/support/xhpast/generate_nodes.php b/support/xhpast/bin/xhpast-generate-nodes.php
rename from support/xhpast/generate_nodes.php
rename to support/xhpast/bin/xhpast-generate-nodes.php
--- a/support/xhpast/generate_nodes.php
+++ b/support/xhpast/bin/xhpast-generate-nodes.php
@@ -1,9 +1,16 @@
#!/usr/bin/env php
<?php
-require_once dirname(__FILE__).'/../../scripts/__init_script__.php';
+$arcanist_root = dirname(dirname(dirname(dirname(__FILE__))));
+require_once $arcanist_root.'/support/init/init-script.php';
+
+$xhpast_root = dirname(dirname(__FILE__));
+
+$hpp_outpath = $xhpast_root.'/node_names.hpp';
+$php_outpath = $xhpast_root.'/parser_nodes.php';
$offset = 9000;
+
$nodes = array(
'n_PROGRAM',
'n_SYMBOL_NAME',
@@ -132,9 +139,9 @@
foreach ($nodes as $node => $value) {
$hpp .= "#define {$node} {$value}\n";
}
-Filesystem::writeFile(
- Filesystem::resolvePath('node_names.hpp', dirname(__FILE__)),
- $hpp);
+
+
+Filesystem::writeFile($hpp_outpath, $hpp);
echo pht('Wrote C++ definition.')."\n";
$at = '@';
@@ -158,7 +165,7 @@
}
EOPHP;
-Filesystem::writeFile(
- Filesystem::resolvePath('parser_nodes.php', dirname(__FILE__)),
- $php);
+
+Filesystem::writeFile($php_outpath, $php);
+
echo pht('Wrote PHP definition.')."\n";
diff --git a/support/xhpast/bin/xhpast-generate-version.php b/support/xhpast/bin/xhpast-generate-version.php
new file mode 100755
--- /dev/null
+++ b/support/xhpast/bin/xhpast-generate-version.php
@@ -0,0 +1,8 @@
+#!/usr/bin/env php
+<?php
+
+$arcanist_root = dirname(dirname(dirname(dirname(__FILE__))));
+require_once $arcanist_root.'/support/init/init-script.php';
+
+echo PhutilXHPASTBinary::EXPECTED_VERSION;
+echo "\n";
diff --git a/support/xhpast/xhpast.cpp b/support/xhpast/xhpast.cpp
--- a/support/xhpast/xhpast.cpp
+++ b/support/xhpast/xhpast.cpp
@@ -9,10 +9,13 @@
int xhpast_process(std::string &in);
void print_node(xhpast::Node *node);
+#ifndef XHPAST_VERSION
+#error Define XHPAST_VERSION when building XHPAST.
+#endif
+
int main(int argc, char* argv[]) {
if (argc != 1) {
- // Coupling: modify also src/parser/xhpast/bin/PhutilXHPASTBinary.php
- cout << "7.1.4\n";
+ cout << XHPAST_VERSION << "\n";
return 0;
}

File Metadata

Mime Type
text/plain
Expires
Sun, May 12, 12:11 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6272995
Default Alt Text
D21064.diff (2 KB)

Event Timeline