mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
Do not generate constants php files from Thrift when they will be empty
Summary: That's just silly Reviewed By: peter, dreiss Test Plan: Generate PHP from a .thrift with no constants. Notice there is no _constants.php generated. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8440605c27
commit
12a3b4e002
@ -23,8 +23,6 @@ void t_php_generator::init_generator() {
|
||||
// Make output file
|
||||
string f_types_name = get_out_dir()+program_name_+"_types.php";
|
||||
f_types_.open(f_types_name.c_str());
|
||||
string f_consts_name = get_out_dir()+program_name_+"_constants.php";
|
||||
f_consts_.open(f_consts_name.c_str());
|
||||
|
||||
// Print header
|
||||
f_types_ <<
|
||||
@ -42,13 +40,17 @@ void t_php_generator::init_generator() {
|
||||
f_types_ << endl;
|
||||
|
||||
// Print header
|
||||
f_consts_ <<
|
||||
"<?php" << endl <<
|
||||
autogen_comment() <<
|
||||
"include_once $GLOBALS['THRIFT_ROOT'].'/packages/" + program_name_ + "/" + program_name_ + "_types.php';" << endl <<
|
||||
endl <<
|
||||
"$GLOBALS['" << program_name_ << "_CONSTANTS'] = array(); " << endl <<
|
||||
endl;
|
||||
if (!program_->get_consts().empty()) {
|
||||
string f_consts_name = get_out_dir()+program_name_+"_constants.php";
|
||||
f_consts_.open(f_consts_name.c_str());
|
||||
f_consts_ <<
|
||||
"<?php" << endl <<
|
||||
autogen_comment() <<
|
||||
"include_once $GLOBALS['THRIFT_ROOT'].'/packages/" + program_name_ + "/" + program_name_ + "_types.php';" << endl <<
|
||||
endl <<
|
||||
"$GLOBALS['" << program_name_ << "_CONSTANTS'] = array(); " << endl <<
|
||||
endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,8 +69,10 @@ void t_php_generator::close_generator() {
|
||||
f_types_ << "?>" << endl;
|
||||
f_types_.close();
|
||||
|
||||
f_consts_ << "?>" << endl;
|
||||
f_consts_.close();
|
||||
if (!program_->get_consts().empty()) {
|
||||
f_consts_ << "?>" << endl;
|
||||
f_consts_.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user