Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15385565
D21064.id.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
D21064.id.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 10:51 PM (2 w, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704291
Default Alt Text
D21064.id.diff (2 KB)
Attached To
Mode
D21064: Remove duplication of XHPAST version in PHP and C code
Attached
Detach File
Event Timeline
Log In to Comment