mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Remove duplication of XHPAST version in PHP and C code
Summary: Depends on D21063. Ref T13492. Currently, XHPAST defines a version in both PHP code and C code, and they must be kept in sync. Switch to a single definition in PHP, then carry it through the build pipeline into C. Test Plan: Did a clean rebuild of XHPAST, saw a version number carried in from PHP. Ran "xhpast --version". Maniphest Tasks: T13492 Differential Revision: https://secure.phabricator.com/D21064
This commit is contained in:
parent
763ac445dc
commit
6d15c6ea48
4 changed files with 30 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
BISONFLAGS = --verbose --name-prefix xhpast
|
BISONFLAGS = --verbose --name-prefix xhpast
|
||||||
CPPFLAGS = -fPIC -Wall
|
CPPFLAGS = -fPIC -Wall
|
||||||
FLEXFLAGS = -CFr
|
FLEXFLAGS = -CFr
|
||||||
|
XHPAST_VERSION := $(shell ./bin/xhpast-generate-version.php)
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
BISONFLAGS += --debug
|
BISONFLAGS += --debug
|
||||||
|
@ -64,7 +65,7 @@ endif
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) -c $(CPPFLAGS) -o $@ $<
|
$(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 $<
|
php -f $<
|
||||||
|
|
||||||
parser.yacc.o: scanner.lex.hpp
|
parser.yacc.o: scanner.lex.hpp
|
||||||
|
@ -74,4 +75,4 @@ libxhpast.a: scanner.lex.o parser.yacc.o
|
||||||
$(AR) -crs $@ $^
|
$(AR) -crs $@ $^
|
||||||
|
|
||||||
xhpast: xhpast.cpp libxhpast.a
|
xhpast: xhpast.cpp libxhpast.a
|
||||||
$(CXX) $(CPPFLAGS) -o $@ $^
|
$(CXX) $(CPPFLAGS) -D XHPAST_VERSION='"$(XHPAST_VERSION)"' -o $@ $^
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?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;
|
$offset = 9000;
|
||||||
|
|
||||||
$nodes = array(
|
$nodes = array(
|
||||||
'n_PROGRAM',
|
'n_PROGRAM',
|
||||||
'n_SYMBOL_NAME',
|
'n_SYMBOL_NAME',
|
||||||
|
@ -132,9 +139,9 @@ $hpp = '';
|
||||||
foreach ($nodes as $node => $value) {
|
foreach ($nodes as $node => $value) {
|
||||||
$hpp .= "#define {$node} {$value}\n";
|
$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";
|
echo pht('Wrote C++ definition.')."\n";
|
||||||
|
|
||||||
$at = '@';
|
$at = '@';
|
||||||
|
@ -158,7 +165,7 @@ $php .= <<<EOPHP
|
||||||
}
|
}
|
||||||
|
|
||||||
EOPHP;
|
EOPHP;
|
||||||
Filesystem::writeFile(
|
|
||||||
Filesystem::resolvePath('parser_nodes.php', dirname(__FILE__)),
|
Filesystem::writeFile($php_outpath, $php);
|
||||||
$php);
|
|
||||||
echo pht('Wrote PHP definition.')."\n";
|
echo pht('Wrote PHP definition.')."\n";
|
8
support/xhpast/bin/xhpast-generate-version.php
Executable file
8
support/xhpast/bin/xhpast-generate-version.php
Executable file
|
@ -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";
|
|
@ -9,10 +9,13 @@ int xhpastparse(void*, xhpast::Node **);
|
||||||
int xhpast_process(std::string &in);
|
int xhpast_process(std::string &in);
|
||||||
void print_node(xhpast::Node *node);
|
void print_node(xhpast::Node *node);
|
||||||
|
|
||||||
|
#ifndef XHPAST_VERSION
|
||||||
|
#error Define XHPAST_VERSION when building XHPAST.
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
// Coupling: modify also src/parser/xhpast/bin/PhutilXHPASTBinary.php
|
cout << XHPAST_VERSION << "\n";
|
||||||
cout << "7.1.4\n";
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue