-//{{{ Banner
+//{{{ Banner
//==========================================================================
//
//
//==========================================================================
//####COPYRIGHTBEGIN####
-//
+//
// ----------------------------------------------------------------------------
// Copyright (C) 2002, 2003 Bart Veer
// Copyright (C) 1999, 2000, 2001 Red Hat, Inc.
//
// This file is part of the eCos host tools.
//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 2 of the License, or (at your option)
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
-//
-// This program is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
-//
+//
// You should have received a copy of the GNU General Public License along with
-// this program; if not, write to the Free Software Foundation, Inc.,
+// this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// ----------------------------------------------------------------------------
-//
+//
//####COPYRIGHTEND####
//==========================================================================
-//#####DESCRIPTIONBEGIN####
+//#####DESCRIPTIONBEGIN####
//
// Author(s): bartv
// Contributors: bartv
//==========================================================================
//}}}
-//{{{ #include's
+//{{{ #include's
// ----------------------------------------------------------------------------
#include <string.h>
//}}}
-//{{{ Statics
+//{{{ Statics
// ----------------------------------------------------------------------------
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlBuildLoadableBody);
CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlDefinableBody);
//}}}
-//{{{ CdlBuildableBody
+//{{{ CdlBuildableBody
-//{{{ Basics
+//{{{ Basics
// ----------------------------------------------------------------------------
// There is little data specific to a buildable. The only distinguishing
// There is no data to initialize yet
cdlbuildablebody_cookie = CdlBuildableBody_Magic;
CYGDBG_MEMLEAK_CONSTRUCTOR();
-
+
CYG_POSTCONDITION_THISC();
CYG_REPORT_RETURN();
}
cdlbuildablebody_cookie = CdlBuildableBody_Invalid;
CYGDBG_MEMLEAK_DESTRUCTOR();
-
+
CYG_REPORT_RETURN();
}
CdlBuildableBody::check_this(cyg_assert_class_zeal zeal) const
{
if (CdlBuildableBody_Magic != cdlbuildablebody_cookie) {
- return false;
+ return false;
}
CYGDBG_MEMLEAK_CHECKTHIS();
return CdlNodeBody::check_this(zeal);
}
//}}}
-//{{{ Add and check property parsers
+//{{{ Add and check property parsers
// ----------------------------------------------------------------------------
static CdlInterpreterCommandEntry commands[] =
{
- CdlInterpreterCommandEntry("compile", &CdlBuildableBody::parse_compile ),
- CdlInterpreterCommandEntry("object", &CdlBuildableBody::parse_object ),
- CdlInterpreterCommandEntry("make_object", &CdlBuildableBody::parse_make_object),
- CdlInterpreterCommandEntry("make", &CdlBuildableBody::parse_make ),
- CdlInterpreterCommandEntry("build_proc", &CdlBuildableBody::parse_build_proc ),
- CdlInterpreterCommandEntry("", 0 ),
+ CdlInterpreterCommandEntry("compile", &CdlBuildableBody::parse_compile ),
+ CdlInterpreterCommandEntry("object", &CdlBuildableBody::parse_object ),
+ CdlInterpreterCommandEntry("make_object", &CdlBuildableBody::parse_make_object),
+ CdlInterpreterCommandEntry("make", &CdlBuildableBody::parse_make ),
+ CdlInterpreterCommandEntry("build_proc", &CdlBuildableBody::parse_build_proc ),
+ CdlInterpreterCommandEntry("", 0 ),
};
for (int i = 0; commands[i].command != 0; i++) {
- std::vector<CdlInterpreterCommandEntry>::const_iterator j;
- for (j = parsers.begin(); j != parsers.end(); j++) {
- if (commands[i].name == j->name) {
- if (commands[i].command != j->command) {
- CYG_FAIL("Property names are being re-used");
- }
- break;
- }
- }
- if (j == parsers.end()) {
- parsers.push_back(commands[i]);
- }
+ std::vector<CdlInterpreterCommandEntry>::const_iterator j;
+ for (j = parsers.begin(); j != parsers.end(); j++) {
+ if (commands[i].name == j->name) {
+ if (commands[i].command != j->command) {
+ CYG_FAIL("Property names are being re-used");
+ }
+ break;
+ }
+ }
+ if (j == parsers.end()) {
+ parsers.push_back(commands[i]);
+ }
}
CdlNodeBody::add_property_parsers(parsers);
-
+
CYG_REPORT_RETURN();
}
// TODO: check that the relevant sources files exist,
// unless marked appropriately (build_proc can create
// new source files).
-
+
CdlNodeBody::check_properties(interp);
-
+
CYG_REPORT_RETURN();
}
//}}}
-//{{{ Property parsers
+//{{{ Property parsers
// ----------------------------------------------------------------------------
// Syntax: compile <file1 file2 ...>
// scheme.
int
-CdlBuildableBody::parse_compile(CdlInterpreter interp, int argc, const char* argv[])
+CdlBuildableBody::parse_compile(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_compile", "result %d");
- static char* options[] = {
- "library:",
- 0
+ static const char *options[] = {
+ "library:",
+ 0
};
int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_Compile, options, 0, true);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
// rules
//
// This utility function takes a single string of this form and breaks
-// it down into its constituent parts.
+// it down into its constituent parts.
//
// NOTE: this will need lots of extra code in future to allow for
// escaped characters, spaces in filenames, etc. For now just keep
bool
CdlBuildableBody::split_custom_build_step(std::string str_data, std::string& target, std::string& deps, std::string& rules,
- std::string& error_msg)
+ std::string& error_msg)
{
CYG_REPORT_FUNCNAMETYPE("CdlBuildable::split_custom_build_step", "result %d");
// Skip any leading white space, and make sure that this leaves some real data.
while (('\0' != *data) && isspace(*data)) {
- data++;
+ data++;
}
if ('\0' == *data) {
- error_msg = "no data in custom build_step";
- CYG_REPORT_RETVAL(false);
- return false;
+ error_msg = "no data in custom build_step";
+ CYG_REPORT_RETVAL(false);
+ return false;
}
// Now extract the target. This consists of any sequence of characters
// upto space, tab, colon.
for ( ; ('\0' != *data) && (':' != *data) && (' ' != *data) && ('\t' != *data); data++) {
- target += *data;
+ target += *data;
}
// Discard any spaces or tabs, they are of no interest
while ((' ' == *data) || ('\t' == *data)) {
- data++;
+ data++;
}
// The current character should be a colon
if (':' != *data) {
- error_msg = "expecting a colon `;' after the target `" + target + "'";
- CYG_REPORT_RETVAL(false);
- return false;
+ error_msg = "expecting a colon `;' after the target `" + target + "'";
+ CYG_REPORT_RETVAL(false);
+ return false;
}
// Move past the colon, and skip any further spaces or tabs
data++;
while (('\0' != *data) && ((' ' == *data) || ('\t' == *data))) {
- data++;
+ data++;
}
// Everything from here until the end of line should be part of the deps field,
- // including white space.
+ // including white space.
while (('\0' != *data) && ('\n' != *data) && (';' != *data)) {
- deps += *data++;
+ deps += *data++;
}
if ("" == deps) {
- error_msg = "expecting dependency list after `" + target + ":'";
- CYG_REPORT_RETVAL(false);
- return false;
+ error_msg = "expecting dependency list after `" + target + ":'";
+ CYG_REPORT_RETVAL(false);
+ return false;
}
// Having some rules is compulsory.
if ('\0' == *data) {
- error_msg = "expecting one or more rules after the dependency list";
- CYG_REPORT_RETVAL(false);
- return false;
+ error_msg = "expecting one or more rules after the dependency list";
+ CYG_REPORT_RETVAL(false);
+ return false;
} else {
- // We are currently at \n or ;, move on to the actual rules
- data++;
+ // We are currently at \n or ;, move on to the actual rules
+ data++;
}
// Rules consist of one or more lines. Any leading white space on a given
// line should be discarded.
while ('\0' != *data) {
- // Processing the current rule. Skip leading spaces and tabs
- while ((' ' == *data) || ('\t' == *data)) {
- data++;
- }
- // Now add everything up to the next newline or EOD to the rules.
- while (('\0' != *data) && ('\n' != *data)) {
- rules += *data++;
- }
+ // Processing the current rule. Skip leading spaces and tabs
+ while ((' ' == *data) || ('\t' == *data)) {
+ data++;
+ }
+ // Now add everything up to the next newline or EOD to the rules.
+ while (('\0' != *data) && ('\n' != *data)) {
+ rules += *data++;
+ }
- // Terminate this line of the rules with a newline, even if that
- // character is absent from the raw data.
- rules += '\n';
+ // Terminate this line of the rules with a newline, even if that
+ // character is absent from the raw data.
+ rules += '\n';
- // And ignore the newline in the raw data itself
- if ('\n' == *data) {
- data++;
- }
+ // And ignore the newline in the raw data itself
+ if ('\n' == *data) {
+ data++;
+ }
}
// Better make sure that there are some rules. All of the looping above
// may just have left white space
if ("" == rules) {
- error_msg = "no rules provided";
- CYG_REPORT_RETVAL(false);
- return false;
+ error_msg = "no rules provided";
+ CYG_REPORT_RETVAL(false);
+ return false;
}
// Everything is ok.
-
+
CYG_REPORT_RETVAL(true);
return true;
}
std::string prio_string = prop->get_option("priority");
if ("" != prio_string) {
- cdl_int tmp = 1;
- if (!Cdl::string_to_integer(prio_string, tmp)) {
- CdlParse::report_property_parse_error(interp, prop,
- "Invalid priority option, priorities should be simple numbers.");
- } else {
- if ((tmp < 1) || (tmp > 1024)) {
- CdlParse::report_property_parse_error(interp, prop,
- "Invalid priority value, priorities should be in the range 1 to 1024.");
- }
- }
- }
-
+ cdl_int tmp = 1;
+ if (!Cdl::string_to_integer(prio_string, tmp)) {
+ CdlParse::report_property_parse_error(interp, prop,
+ "Invalid priority option, priorities should be simple numbers.");
+ } else {
+ if ((tmp < 1) || (tmp > 1024)) {
+ CdlParse::report_property_parse_error(interp, prop,
+ "Invalid priority value, priorities should be in the range 1 to 1024.");
+ }
+ }
+ }
+
std::string data = prop->get_string();
std::string target;
std::string deps;
std::string error_msg;
if (!CdlBuildableBody::split_custom_build_step(data, target, deps, rules, error_msg)) {
- CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
+ CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
}
}
CdlBuildableBody::parse_make(CdlInterpreter interp, int argc, const char* argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_make", "result %d");
- static char* options[] = {
- "priority:",
- 0
+ static const char* options[] = {
+ "priority:",
+ 0
};
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Make, options, &parse_make_final_check);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
std::string prio_string = prop->get_option("priority");
if ("" != prio_string) {
- cdl_int tmp = 1;
- if (!Cdl::string_to_integer(prio_string, tmp)) {
- CdlParse::report_property_parse_error(interp, prop,
- "Invalid priority option, priorities should be simple numbers.");
- } else {
- if ((tmp < 1) || (tmp > 1024)) {
- CdlParse::report_property_parse_error(interp, prop,
- "Invalid priority value, priorities should be in the range 1 to 1024.");
- }
- }
- }
-
+ cdl_int tmp = 1;
+ if (!Cdl::string_to_integer(prio_string, tmp)) {
+ CdlParse::report_property_parse_error(interp, prop,
+ "Invalid priority option, priorities should be simple numbers.");
+ } else {
+ if ((tmp < 1) || (tmp > 1024)) {
+ CdlParse::report_property_parse_error(interp, prop,
+ "Invalid priority value, priorities should be in the range 1 to 1024.");
+ }
+ }
+ }
+
std::string data = prop->get_string();
std::string target;
std::string deps;
std::string error_msg;
if (!CdlBuildableBody::split_custom_build_step(data, target, deps, rules, error_msg)) {
- CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
+ CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
}
}
CdlBuildableBody::parse_make_object(CdlInterpreter interp, int argc, const char* argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_make_object", "result %d");
- static char* options[] = {
- "library:",
- "priority:",
- 0
+ static const char* options[] = {
+ "library:",
+ "priority:",
+ 0
};
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_MakeObject, options,
- &parse_make_object_final_check);
-
+ &parse_make_object_final_check);
+
CYG_REPORT_RETVAL(result);
return result;
}
CdlBuildableBody::parse_object(CdlInterpreter interp, int argc, const char* argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_object", "result %d");
- static char* options[] = {
- "library:",
- 0
+ static const char* options[] = {
+ "library:",
+ 0
};
int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_Object, options, 0, true);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
}
//}}}
-//{{{ update_build_info()
+//{{{ update_build_info()
// ----------------------------------------------------------------------------
// Most of the work is done in update_all_build_info(). The update_build_info()
CYG_PRECONDITIONC("" != library);
if (!is_active()) {
- CYG_REPORT_RETURN();
- return;
+ CYG_REPORT_RETURN();
+ return;
}
CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(this);
if (0 != valuable) {
- if (!valuable->is_enabled()) {
- CYG_REPORT_RETURN();
- return;
- }
+ if (!valuable->is_enabled()) {
+ CYG_REPORT_RETURN();
+ return;
+ }
}
update_all_build_info(build_info, library);
-
+
CYG_REPORT_RETURN();
}
//}}}
-//{{{ update_all_build_info()
+//{{{ update_all_build_info()
// ----------------------------------------------------------------------------
// There are four properties to be considered, each of which may occur
std::vector<CdlProperty>::const_iterator prop_i;
for (prop_i = compile_properties.begin(); prop_i != compile_properties.end(); prop_i++) {
- CdlProperty_StringVector compile_prop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
- CYG_LOOP_INVARIANT_CLASSC(compile_prop);
-
- // Does this property have a library option?
- std::string current_library = compile_prop->get_option("library");
- if ("" == current_library) {
- current_library = package_library;
- }
-
- const std::vector<std::string>& files = compile_prop->get_strings();
- std::vector<std::string>::const_iterator file_i;
-
- for (file_i = files.begin(); file_i != files.end(); file_i++) {
-
- // For each listed file, try to find it. If this is unsuccessful
- // then assume that the file will be generated later on.
- std::string path = loadable->find_relative_file(*file_i, "src");
- if ("" == path) {
- if (has_src_subdir) {
- path = "src/" + *file_i;
- } else {
- path = *file_i;
- }
- }
-
- // Now check whether or not the specified file is already present.
- std::vector<CdlBuildInfo_Compile>::const_iterator info_i;
- for (info_i = build_info.compiles.begin(); info_i != build_info.compiles.end(); info_i++) {
- if ((current_library == info_i->library) && (path == info_i->source)) {
- break;
- }
- }
- if (info_i == build_info.compiles.end()) {
- CdlBuildInfo_Compile new_info;
- new_info.library = current_library;
- new_info.source = path;
- build_info.compiles.push_back(new_info);
- }
- }
+ CdlProperty_StringVector compile_prop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
+ CYG_LOOP_INVARIANT_CLASSC(compile_prop);
+
+ // Does this property have a library option?
+ std::string current_library = compile_prop->get_option("library");
+ if ("" == current_library) {
+ current_library = package_library;
+ }
+
+ const std::vector<std::string>& files = compile_prop->get_strings();
+ std::vector<std::string>::const_iterator file_i;
+
+ for (file_i = files.begin(); file_i != files.end(); file_i++) {
+
+ // For each listed file, try to find it. If this is unsuccessful
+ // then assume that the file will be generated later on.
+ std::string path = loadable->find_relative_file(*file_i, "src");
+ if ("" == path) {
+ if (has_src_subdir) {
+ path = "src/" + *file_i;
+ } else {
+ path = *file_i;
+ }
+ }
+
+ // Now check whether or not the specified file is already present.
+ std::vector<CdlBuildInfo_Compile>::const_iterator info_i;
+ for (info_i = build_info.compiles.begin(); info_i != build_info.compiles.end(); info_i++) {
+ if ((current_library == info_i->library) && (path == info_i->source)) {
+ break;
+ }
+ }
+ if (info_i == build_info.compiles.end()) {
+ CdlBuildInfo_Compile new_info;
+ new_info.library = current_library;
+ new_info.source = path;
+ build_info.compiles.push_back(new_info);
+ }
+ }
}
for (prop_i = makeobject_properties.begin(); prop_i != makeobject_properties.end(); prop_i++) {
- CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
- CYG_LOOP_INVARIANT_CLASSC(prop);
-
- // Does thie property have a library option?
- std::string current_library = prop->get_option("library");
- if ("" == current_library) {
- current_library = package_library;
- }
-
- // How about a priority field? The default priority for make_object is 100
- // We can rely on the validation done during the parsing process
- cdl_int priority = 100;
- std::string priority_option = prop->get_option("priority");
- if ("" != priority_option) {
- Cdl::string_to_integer(priority_option, priority);
- }
-
- // What we need now is the separate target, deps, and rules. These
- // can be obtained via a utility. The raw data will have been validated
- // already.
- std::string raw_data = prop->get_string();
- std::string target;
- std::string deps;
- std::string rules;
- std::string error_msg;
- bool result;
-
- result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
- CYG_ASSERTC(true == result);
-
- // Construct a local object, then copy it into the vector
- CdlBuildInfo_MakeObject local_copy;
- local_copy.priority = priority;
- local_copy.library = current_library;
- local_copy.object = target;
- local_copy.deps = deps;
- local_copy.rules = rules;
-
- build_info.make_objects.push_back(local_copy);
- }
-
+ CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
+ CYG_LOOP_INVARIANT_CLASSC(prop);
+
+ // Does thie property have a library option?
+ std::string current_library = prop->get_option("library");
+ if ("" == current_library) {
+ current_library = package_library;
+ }
+
+ // How about a priority field? The default priority for make_object is 100
+ // We can rely on the validation done during the parsing process
+ cdl_int priority = 100;
+ std::string priority_option = prop->get_option("priority");
+ if ("" != priority_option) {
+ Cdl::string_to_integer(priority_option, priority);
+ }
+
+ // What we need now is the separate target, deps, and rules. These
+ // can be obtained via a utility. The raw data will have been validated
+ // already.
+ std::string raw_data = prop->get_string();
+ std::string target;
+ std::string deps;
+ std::string rules;
+ std::string error_msg;
+ bool result;
+
+ result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
+ CYG_ASSERTC(true == result);
+
+ // Construct a local object, then copy it into the vector
+ CdlBuildInfo_MakeObject local_copy;
+ local_copy.priority = priority;
+ local_copy.library = current_library;
+ local_copy.object = target;
+ local_copy.deps = deps;
+ local_copy.rules = rules;
+
+ build_info.make_objects.push_back(local_copy);
+ }
+
for (prop_i = make_properties.begin(); prop_i != make_properties.end(); prop_i++) {
- CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
- CYG_LOOP_INVARIANT_CLASSC(prop);
-
- // Is there a priority field? The default priority for make is
- // 300 We can rely on the validation done during the parsing
- // process
- cdl_int priority = 300;
- std::string priority_option = prop->get_option("priority");
- if ("" != priority_option) {
- Cdl::string_to_integer(priority_option, priority);
- }
-
- // What we need now is the separate target, deps, and rules. These
- // can be obtained via a utility. The raw data will have been validated
- // already.
- std::string raw_data = prop->get_string();
- std::string target;
- std::string deps;
- std::string rules;
- std::string error_msg;
- bool result;
-
- result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
- CYG_ASSERTC(true == result);
-
- // Construct a local object, then copy it into the vector
- CdlBuildInfo_Make local_copy;
- local_copy.priority = priority;
- local_copy.target = target;
- local_copy.deps = deps;
- local_copy.rules = rules;
-
- build_info.makes.push_back(local_copy);
- }
-
+ CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
+ CYG_LOOP_INVARIANT_CLASSC(prop);
+
+ // Is there a priority field? The default priority for make is
+ // 300 We can rely on the validation done during the parsing
+ // process
+ cdl_int priority = 300;
+ std::string priority_option = prop->get_option("priority");
+ if ("" != priority_option) {
+ Cdl::string_to_integer(priority_option, priority);
+ }
+
+ // What we need now is the separate target, deps, and rules. These
+ // can be obtained via a utility. The raw data will have been validated
+ // already.
+ std::string raw_data = prop->get_string();
+ std::string target;
+ std::string deps;
+ std::string rules;
+ std::string error_msg;
+ bool result;
+
+ result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
+ CYG_ASSERTC(true == result);
+
+ // Construct a local object, then copy it into the vector
+ CdlBuildInfo_Make local_copy;
+ local_copy.priority = priority;
+ local_copy.target = target;
+ local_copy.deps = deps;
+ local_copy.rules = rules;
+
+ build_info.makes.push_back(local_copy);
+ }
+
CYG_REPORT_RETURN();
}
//}}}
//}}}
-//{{{ CdlBuildLoadableBody
+//{{{ CdlBuildLoadableBody
-//{{{ Class variables
+//{{{ Class variables
// ----------------------------------------------------------------------------
// This variable controls the default library that should be generated.
// Some applications may wish to override this.
-char* CdlBuildLoadableBody::default_library_name = "libtarget.a";
+const char* CdlBuildLoadableBody::default_library_name = "libtarget.a";
// The pattern that should be used to identify header files.
// FIXME: this information should come out of a data file
-char* CdlBuildLoadableBody::default_headers_glob_pattern = "*.h *.hxx *.inl *.si *.inc";
+const char* CdlBuildLoadableBody::default_headers_glob_pattern = "*.h *.hxx *.inl *.si *.inc";
//}}}
-//{{{ The simple stuff
+//{{{ The simple stuff
// ----------------------------------------------------------------------------
// There is no data to initialize
cdlbuildloadablebody_cookie = CdlBuildLoadableBody_Magic;
CYGDBG_MEMLEAK_CONSTRUCTOR();
-
+
CYG_POSTCONDITION_THISC();
CYG_REPORT_RETURN();
}
cdlbuildloadablebody_cookie = CdlBuildLoadableBody_Invalid;
CYGDBG_MEMLEAK_DESTRUCTOR();
-
+
CYG_REPORT_RETURN();
}
CdlBuildLoadableBody::check_this(cyg_assert_class_zeal zeal) const
{
if (CdlBuildLoadableBody_Magic != cdlbuildloadablebody_cookie) {
- return false;
+ return false;
}
CYGDBG_MEMLEAK_CHECKTHIS();
return CdlContainerBody::check_this(zeal) && CdlNodeBody::check_this(zeal);
}
//}}}
-//{{{ Property parsers
+//{{{ Property parsers
// ----------------------------------------------------------------------------
static CdlInterpreterCommandEntry commands[] =
{
- CdlInterpreterCommandEntry("library", &CdlBuildLoadableBody::parse_library ),
- CdlInterpreterCommandEntry("makefile", &CdlBuildLoadableBody::parse_makefile ),
- CdlInterpreterCommandEntry("include_dir", &CdlBuildLoadableBody::parse_include_dir ),
- CdlInterpreterCommandEntry("include_files", &CdlBuildLoadableBody::parse_include_files ),
- CdlInterpreterCommandEntry("", 0 )
+ CdlInterpreterCommandEntry("library", &CdlBuildLoadableBody::parse_library ),
+ CdlInterpreterCommandEntry("makefile", &CdlBuildLoadableBody::parse_makefile ),
+ CdlInterpreterCommandEntry("include_dir", &CdlBuildLoadableBody::parse_include_dir ),
+ CdlInterpreterCommandEntry("include_files", &CdlBuildLoadableBody::parse_include_files ),
+ CdlInterpreterCommandEntry("", 0 )
};
for (int i = 0; commands[i].command != 0; i++) {
- std::vector<CdlInterpreterCommandEntry>::const_iterator j;
- for (j = parsers.begin(); j != parsers.end(); j++) {
- if (commands[i].name == j->name) {
- if (commands[i].command != j->command) {
- CYG_FAIL("Property names are being re-used");
- }
- break;
- }
- }
- if (j == parsers.end()) {
- parsers.push_back(commands[i]);
- }
- }
-
+ std::vector<CdlInterpreterCommandEntry>::const_iterator j;
+ for (j = parsers.begin(); j != parsers.end(); j++) {
+ if (commands[i].name == j->name) {
+ if (commands[i].command != j->command) {
+ CYG_FAIL("Property names are being re-used");
+ }
+ break;
+ }
+ }
+ if (j == parsers.end()) {
+ parsers.push_back(commands[i]);
+ }
+ }
+
CYG_REPORT_RETURN();
}
CYG_PRECONDITION_CLASSC(interp);
CdlNodeBody::check_properties(interp);
-
+
CYG_REPORT_RETURN();
}
CYG_REPORT_FUNCNAMETYPE("parse_library", "result %d");
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Library, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
CYG_REPORT_FUNCNAMETYPE("parse_makefile", "result %d");
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Makefile, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
CYG_REPORT_FUNCNAMETYPE("parse_include_dir", "result %d");
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_IncludeDir, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
CYG_REPORT_FUNCNAMETYPE("parse_include_files", "result %d");
int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_IncludeFiles, 0, 0, true);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
//}}}
-//{{{ update_build_info()
+//{{{ update_build_info()
// ----------------------------------------------------------------------------
// This utility routine takes care of filling in a Buildinfo_Loadable
std::string dest_dir = "";
CdlProperty include_dir_prop = loadable->get_property(CdlPropertyId_IncludeDir);
if (0 != include_dir_prop) {
- CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(include_dir_prop);
- CYG_ASSERT_CLASSC(strprop);
- dest_dir = strprop->get_string();
+ CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(include_dir_prop);
+ CYG_ASSERT_CLASSC(strprop);
+ dest_dir = strprop->get_string();
}
bool has_include_subdir = loadable->has_subdirectory("include");
std::vector<CdlProperty> include_file_properties;
loadable->get_properties(CdlPropertyId_IncludeFiles, include_file_properties);
if (include_file_properties.size() > 0) {
- std::vector<CdlProperty>::const_iterator prop_i;
- for (prop_i = include_file_properties.begin(); prop_i != include_file_properties.end(); prop_i++) {
-
- CdlProperty_StringVector strvprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
- CYG_ASSERT_CLASSC(strvprop);
-
- const std::vector<std::string>& filenames = strvprop->get_strings();
- std::vector<std::string>::const_iterator file_i;
- for (file_i = filenames.begin(); file_i != filenames.end(); file_i++) {
- std::string path = loadable->find_relative_file(*file_i, "include");
- // Assume that the header file will be generated by a build_proc
- if ("" == path) {
- if (has_include_subdir) {
- path = "include/" + *file_i;
- } else {
- path = *file_i;
- }
- }
- CdlBuildInfo_Header local_copy;
- local_copy.source = path;
- local_copy.destination = "";
- if ("" != dest_dir) {
- local_copy.destination = dest_dir + "/";
- }
- // At this stage "path" may begin with "include/", which should not
- // be present in the destination.
- const char* tmp = path.c_str();
- if (0 == strncmp("include/", tmp, 8)) {
- local_copy.destination += &(tmp[8]);
- } else {
- local_copy.destination += path;
- }
- build_info.headers.push_back(local_copy);
- }
- }
- CYG_REPORT_RETURN();
- return;
+ std::vector<CdlProperty>::const_iterator prop_i;
+ for (prop_i = include_file_properties.begin(); prop_i != include_file_properties.end(); prop_i++) {
+
+ CdlProperty_StringVector strvprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
+ CYG_ASSERT_CLASSC(strvprop);
+
+ const std::vector<std::string>& filenames = strvprop->get_strings();
+ std::vector<std::string>::const_iterator file_i;
+ for (file_i = filenames.begin(); file_i != filenames.end(); file_i++) {
+ std::string path = loadable->find_relative_file(*file_i, "include");
+ // Assume that the header file will be generated by a build_proc
+ if ("" == path) {
+ if (has_include_subdir) {
+ path = "include/" + *file_i;
+ } else {
+ path = *file_i;
+ }
+ }
+ CdlBuildInfo_Header local_copy;
+ local_copy.source = path;
+ local_copy.destination = "";
+ if ("" != dest_dir) {
+ local_copy.destination = dest_dir + "/";
+ }
+ // At this stage "path" may begin with "include/", which should not
+ // be present in the destination.
+ const char* tmp = path.c_str();
+ if (0 == strncmp("include/", tmp, 8)) {
+ local_copy.destination += &(tmp[8]);
+ } else {
+ local_copy.destination += path;
+ }
+ build_info.headers.push_back(local_copy);
+ }
+ }
+ CYG_REPORT_RETURN();
+ return;
}
// It is necessary to search for the appropriate files.
CdlInterpreter interp = loadable->get_interpreter();
std::string path = loadable->get_toplevel()->get_directory() + "/" + loadable->get_directory();
if (has_include_subdir) {
- std::vector<std::string> files;
- std::vector<std::string>::const_iterator file_i;
- interp->locate_all_files(path + "/include", files);
- for (file_i = files.begin(); file_i != files.end(); file_i++) {
- // NOTE: for now discard any header files in the pkgconf subdirectory
- if (0 == strncmp("pkgconf/", file_i->c_str(), 8)) {
- continue;
- }
- if ('~' == *(file_i->rbegin())) {
- continue;
- }
- CdlBuildInfo_Header local_copy;
- local_copy.source = "include/" + *file_i;
- local_copy.destination = "";
- if ("" != dest_dir) {
- local_copy.destination = dest_dir + "/";
- }
- local_copy.destination += *file_i;
- build_info.headers.push_back(local_copy);
- }
+ std::vector<std::string> files;
+ std::vector<std::string>::const_iterator file_i;
+ interp->locate_all_files(path + "/include", files);
+ for (file_i = files.begin(); file_i != files.end(); file_i++) {
+ // NOTE: for now discard any header files in the pkgconf subdirectory
+ if (0 == strncmp("pkgconf/", file_i->c_str(), 8)) {
+ continue;
+ }
+ if ('~' == *(file_i->rbegin())) {
+ continue;
+ }
+ CdlBuildInfo_Header local_copy;
+ local_copy.source = "include/" + *file_i;
+ local_copy.destination = "";
+ if ("" != dest_dir) {
+ local_copy.destination = dest_dir + "/";
+ }
+ local_copy.destination += *file_i;
+ build_info.headers.push_back(local_copy);
+ }
} else {
- // Look for all header files, which for now means files with
- // a .h, .hxx, .inl or .inc extension.
- // FIXME: the definition of what constitutes a header file
- // should not be hard-wired here.
- std::vector<std::string> files;
- std::vector<std::string>::const_iterator file_i;
- interp->locate_all_files(path, files);
- for (file_i = files.begin(); file_i != files.end(); file_i++) {
-
- // Problems with libstdc++ versions, use C comparisons instead.
- const char* c_string = file_i->c_str();
- unsigned int len = strlen(c_string);
- if (((len >= 2) && (0 == strncmp(c_string + len - 2, ".h", 2))) ||
- ((len >= 4) && (0 == strncmp(c_string + len - 4, ".hxx", 4))) ||
- ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inl", 4))) ||
- ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inc", 4)))) {
-
- CdlBuildInfo_Header local_copy;
- local_copy.source = *file_i;
- local_copy.destination = "";
- if ("" != dest_dir) {
- local_copy.destination = dest_dir + "/";
- }
- local_copy.destination += *file_i;
- build_info.headers.push_back(local_copy);
- }
- }
+ // Look for all header files, which for now means files with
+ // a .h, .hxx, .inl or .inc extension.
+ // FIXME: the definition of what constitutes a header file
+ // should not be hard-wired here.
+ std::vector<std::string> files;
+ std::vector<std::string>::const_iterator file_i;
+ interp->locate_all_files(path, files);
+ for (file_i = files.begin(); file_i != files.end(); file_i++) {
+
+ // Problems with libstdc++ versions, use C comparisons instead.
+ const char* c_string = file_i->c_str();
+ unsigned int len = strlen(c_string);
+ if (((len >= 2) && (0 == strncmp(c_string + len - 2, ".h", 2))) ||
+ ((len >= 4) && (0 == strncmp(c_string + len - 4, ".hxx", 4))) ||
+ ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inl", 4))) ||
+ ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inc", 4)))) {
+
+ CdlBuildInfo_Header local_copy;
+ local_copy.source = *file_i;
+ local_copy.destination = "";
+ if ("" != dest_dir) {
+ local_copy.destination = dest_dir + "/";
+ }
+ local_copy.destination += *file_i;
+ build_info.headers.push_back(local_copy);
+ }
+ }
}
CYG_REPORT_RETURN();
// and hence it is still necessary to check whether or not the
// loadable is active.
if (!is_active()) {
- CYG_REPORT_RETURN();
- return;
+ CYG_REPORT_RETURN();
+ return;
}
// Time to add a new CdlBuildInfo_Loadable object to the current
// Take care of the header files
update_header_file_info(this, this_info);
-
+
// Work out the library name appropriate for this loadable.
// There may be a library property, otherwise the global default
// should be used.
std::string loadable_library = default_library_name;
if (has_property(CdlPropertyId_Library)) {
- CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
- loadable_library = strprop->get_string();
+ CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
+ loadable_library = strprop->get_string();
}
-
+
const std::vector<CdlNode>& contents = get_owned();
std::vector<CdlNode>::const_iterator node_i;
for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
- CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
- if (0 != buildable) {
- buildable->update_build_info(this_info, loadable_library);
- }
+ CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
+ if (0 != buildable) {
+ buildable->update_build_info(this_info, loadable_library);
+ }
}
-
+
CYG_REPORT_RETURN();
}
std::string loadable_library = default_library_name;
if (has_property(CdlPropertyId_Library)) {
- CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
- loadable_library = strprop->get_string();
+ CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
+ loadable_library = strprop->get_string();
}
-
+
const std::vector<CdlNode>& contents = get_owned();
std::vector<CdlNode>::const_iterator node_i;
for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
- CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
- if (0 != buildable) {
- buildable->update_build_info(this_info, loadable_library);
- }
+ CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
+ if (0 != buildable) {
+ buildable->update_build_info(this_info, loadable_library);
+ }
}
-
+
CYG_REPORT_RETURN();
CYG_REPORT_RETURN();
}
//}}}
//}}}
-//{{{ Version number #define's
+//{{{ Version number #define's
// ----------------------------------------------------------------------------
// Given a package xxxPKG_A_B_C with a version V1_2_3, generate additional
// is possible to cope with VERSION_NUMBER #define's.
//
// Note that only application code and third party packages are
-// affected.
+// affected.
//
// These #define's go into system.h, alongside the main definition of
// the package. There seems to be little point in putting them in the
char name_buf[256];
char line_buf[512];
-
+
// The first thing to check is that the package name can be used
// as the basis for the version symbols.
bool ok = false;
unsigned int i;
for (i = 0; i < name.size(); i++) {
- if ('_' == name[i]) {
- if (3 < i) {
- if ((name[i-3] == 'P') && (name[i-2] == 'K') && (name[i-1] == 'G')) {
- ok = true;
- }
- }
- break;
- }
+ if ('_' == name[i]) {
+ if (3 < i) {
+ if ((name[i-3] == 'P') && (name[i-2] == 'K') && (name[i-1] == 'G')) {
+ ok = true;
+ }
+ }
+ break;
+ }
}
if (name.size() >= 256) {
- ok = false;
+ ok = false;
}
if (!ok) {
- CYG_REPORT_RETURN();
- return;
+ CYG_REPORT_RETURN();
+ return;
}
strcpy(name_buf, name.c_str());
-
+
// Change from xxxPKG to xxxNUM
name_buf[i - 3] = 'N';
name_buf[i - 2] = 'U';
std::string minor = "-1";
std::string release = "-1";
if ("current" == value) {
- major = "CYGNUM_VERSION_CURRENT";
+ major = "CYGNUM_VERSION_CURRENT";
} else {
- Cdl::split_version_string(value, major, minor, release);
+ Cdl::split_version_string(value, major, minor, release);
}
sprintf(line_buf, "#define %s_VERSION_MAJOR %s\n", name_buf, major.c_str());
Tcl_Write(system_h, line_buf, -1);
sprintf(line_buf, "#define %s_VERSION_RELEASE %s\n", name_buf, release.c_str());
Tcl_Write(system_h, line_buf, -1);
-
+
CYG_REPORT_RETURN();
}
//}}}
-//{{{ CdlDefinableBody
+//{{{ CdlDefinableBody
-//{{{ Basics
+//{{{ Basics
// ----------------------------------------------------------------------------
// There is no data to initialize
cdldefinablebody_cookie = CdlDefinableBody_Magic;
CYGDBG_MEMLEAK_CONSTRUCTOR();
-
+
CYG_POSTCONDITION_THISC();
CYG_REPORT_RETURN();
}
cdldefinablebody_cookie = CdlDefinableBody_Invalid;
CYGDBG_MEMLEAK_DESTRUCTOR();
-
+
CYG_REPORT_RETURN();
}
CdlDefinableBody::check_this(cyg_assert_class_zeal zeal) const
{
if (CdlDefinableBody_Magic != cdldefinablebody_cookie) {
- return false;
+ return false;
}
CYGDBG_MEMLEAK_CHECKTHIS();
return CdlNodeBody::check_this(zeal);
}
//}}}
-//{{{ add_property_parser() and check_properties()
+//{{{ add_property_parser() and check_properties()
// ----------------------------------------------------------------------------
static CdlInterpreterCommandEntry commands[] =
{
- CdlInterpreterCommandEntry("no_define", &parse_no_define ),
- CdlInterpreterCommandEntry("define", &parse_define ),
- CdlInterpreterCommandEntry("define_format", &parse_define_format ),
- CdlInterpreterCommandEntry("define_proc", &parse_define_proc ),
- CdlInterpreterCommandEntry("if_define", &parse_if_define ),
- CdlInterpreterCommandEntry("", 0 )
+ CdlInterpreterCommandEntry("no_define", &parse_no_define ),
+ CdlInterpreterCommandEntry("define", &parse_define ),
+ CdlInterpreterCommandEntry("define_format", &parse_define_format ),
+ CdlInterpreterCommandEntry("define_proc", &parse_define_proc ),
+ CdlInterpreterCommandEntry("if_define", &parse_if_define ),
+ CdlInterpreterCommandEntry("", 0 )
};
for (int i = 0; commands[i].command != 0; i++) {
- std::vector<CdlInterpreterCommandEntry>::const_iterator j;
- for (j = parsers.begin(); j != parsers.end(); j++) {
- if (commands[i].name == j->name) {
- if (commands[i].command != j->command) {
- CYG_FAIL("Property names are being re-used");
- }
- break;
- }
- }
- if (j == parsers.end()) {
- parsers.push_back(commands[i]);
- }
+ std::vector<CdlInterpreterCommandEntry>::const_iterator j;
+ for (j = parsers.begin(); j != parsers.end(); j++) {
+ if (commands[i].name == j->name) {
+ if (commands[i].command != j->command) {
+ CYG_FAIL("Property names are being re-used");
+ }
+ break;
+ }
+ }
+ if (j == parsers.end()) {
+ parsers.push_back(commands[i]);
+ }
}
CdlNodeBody::add_property_parsers(parsers);
-
+
CYG_REPORT_RETURN();
}
// There should be at most one each of no_define and define_format.
if (count_properties(CdlPropertyId_NoDefine) > 1) {
- CdlParse::report_error(interp, "", "There should be at most one no_define property.");
+ CdlParse::report_error(interp, "", "There should be at most one no_define property.");
}
if (count_properties(CdlPropertyId_DefineFormat) > 1) {
- CdlParse::report_error(interp, "", "There should be at most one define_format property.");
+ CdlParse::report_error(interp, "", "There should be at most one define_format property.");
}
if (has_property(CdlPropertyId_NoDefine) && has_property(CdlPropertyId_DefineFormat)) {
- CdlParse::report_error(interp, "", "The no_define and define_format properties are mutually exclusive.");
+ CdlParse::report_error(interp, "", "The no_define and define_format properties are mutually exclusive.");
}
// FIXME: the define_format property only makes sense for certain
// flavors. However the flavor property may not have been processed yet.
-
+
CdlNodeBody::check_properties(interp);
-
+
CYG_REPORT_RETURN();
}
//}}}
-//{{{ Definable properties
+//{{{ Definable properties
// ----------------------------------------------------------------------------
// Syntax: no_define
int
-CdlDefinableBody::parse_no_define(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefinableBody::parse_no_define(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_no_define", "result %d");
int result = CdlParse::parse_minimal_property(interp, argc, argv, CdlPropertyId_NoDefine, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
CYG_REPORT_FUNCNAME("parse_define_final_check");
CYG_PRECONDITION_CLASSC(prop);
CYG_PRECONDITION_CLASSC(interp);
-
+
const std::string& str = prop->get_string();
if (!Cdl::is_valid_c_preprocessor_symbol(str)) {
- CdlParse::report_property_parse_error(interp, prop, str + " is not a valid C preprocessor symbol");
+ CdlParse::report_property_parse_error(interp, prop, str + " is not a valid C preprocessor symbol");
}
// There may be a file option. At this stage the only valid filename
// that can be used here is system.h
std::string file_option = prop->get_option("file");
if (("" != file_option) && ("system.h" != file_option)) {
- CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
+ CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
}
// FIXME: validate the format string
-
+
CYG_REPORT_RETURN();
}
int
-CdlDefinableBody::parse_define(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefinableBody::parse_define(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_define", "result %d");
- static char* options[] = {
- "file:",
- "format:",
- 0
+ static const char *options[] = {
+ "file:",
+ "format:",
+ 0
};
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Define, options, &parse_define_final_check);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
// FIXME: enforce mutual exclusion with no_define
int
-CdlDefinableBody::parse_define_format(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefinableBody::parse_define_format(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_format", "result %d");
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_DefineFormat, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
// ----------------------------------------------------------------------------
// syntax: define_proc <tclcode>
int
-CdlDefinableBody::parse_define_proc(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefinableBody::parse_define_proc(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_define_proc", "result %d");
int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_DefineProc, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
CYG_REPORT_FUNCNAME("parse_if_define_final_check");
CYG_PRECONDITION_CLASSC(interp);
CYG_PRECONDITION_CLASSC(prop);
-
+
// There should be exactly two entries in the vector, and both of them should be
// valid preprocessor symbols.
const std::vector<std::string>& strings = prop->get_strings();
if (2 != strings.size()) {
- CdlParse::report_property_parse_error(interp, prop, "There should be exactly two arguments.");
+ CdlParse::report_property_parse_error(interp, prop, "There should be exactly two arguments.");
}
if (!Cdl::is_valid_c_preprocessor_symbol(strings[0])) {
- CdlParse::report_property_parse_error(interp, prop, strings[0] + " is not a valid C preprocessor symbol.");
+ CdlParse::report_property_parse_error(interp, prop, strings[0] + " is not a valid C preprocessor symbol.");
}
if (!Cdl::is_valid_c_preprocessor_symbol(strings[1])) {
- CdlParse::report_property_parse_error(interp, prop, strings[1] + " is not a valid C preprocessor symbol.");
+ CdlParse::report_property_parse_error(interp, prop, strings[1] + " is not a valid C preprocessor symbol.");
}
-
+
// There may be a file option. At this stage the only valid filename
// that can be used here is system.h
std::string file_option = prop->get_option("file");
if (("" != file_option) && ("system.h" != file_option)) {
- CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
+ CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
}
}
int
-CdlDefinableBody::parse_if_define(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefinableBody::parse_if_define(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_if_define", "result %d");
- char* options[] = {
- "file:",
- 0
+ const char *options[] = {
+ "file:",
+ 0
};
int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_IfDefine, options,
- &parse_if_define_final_check, false);
-
+ &parse_if_define_final_check, false);
+
CYG_REPORT_RETVAL(result);
return result;
}
//}}}
-//{{{ generate_config_header()
+//{{{ generate_config_header()
// ----------------------------------------------------------------------------
// This code needs to allow for the following properties.
//
-// 1) no_define. This suppresses the default #define generation.
+// 1) no_define. This suppresses the default #define generation.
//
// 2) define_format <format_string.
//
CdlLoadable loadable = get_owner();
CdlInterpreter interp = loadable->get_interpreter();
-
+
// This definable is known to be active. However it may or may not be enabled.
CYG_PRECONDITIONC(is_active());
std::string value = "1";
CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(this);
if (0 != valuable) {
- // It is always possible to check the enabled() flag.
- if (!valuable->is_enabled()) {
- CYG_REPORT_RETURN();
- return;
- }
- // The value is only valid for BoolData and Data flavors, and may
- // not have been provided. If there is no value then this option
- // should not generate a #define
- flavor = valuable->get_flavor();
- if ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor)) {
- value = valuable->get_value();
- }
+ // It is always possible to check the enabled() flag.
+ if (!valuable->is_enabled()) {
+ CYG_REPORT_RETURN();
+ return;
+ }
+ // The value is only valid for BoolData and Data flavors, and may
+ // not have been provided. If there is no value then this option
+ // should not generate a #define
+ flavor = valuable->get_flavor();
+ if ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor)) {
+ value = valuable->get_value();
+ }
}
// Flavor and value are now both set to sensible strings.
// #define generation should be suppressed.
if (!has_property(CdlPropertyId_NoDefine)) {
- // OK, it is necessary to generate at least one #define.
- // If this node is actually a loadable then the #define should go
- // into system.h, otherwise into the current header
- Tcl_Channel chan = this_hdr;
- if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
- chan = system_h;
- }
-
- // For flavors None and Bool, there should be just one #define
- if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
- std::string define = "#define " + name + " 1\n";
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- } else {
- // If there is a format string then that controls the default
- // value display.
- if (!has_property(CdlPropertyId_DefineFormat)) {
- std::string define = "#define " + name + " " + value + "\n";
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- } else {
- CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_DefineFormat));
- CYG_ASSERT_CLASSC(strprop);
- std::string format = strprop->get_string();
- std::string cmd = "return \"#define " + name + " [format " + format + " " + value + "]\n\"";
- std::string define;
- if (TCL_OK != interp->eval(cmd, define)) {
- throw CdlInputOutputException("Internal error executing tcl fragment to process define_format property");
- }
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- }
-
- // There may also be a separate #define of the form <name>_<value>,
- // if that is a valid preprocessor symbol.
- std::string tmp = name + "_" + value;
- if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
- tmp = "#define "+ tmp + "\n";
- Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
- }
-
- // For loadables, add additional version information to system_h
- if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
- system_h_add_package_versioning(system_h, name, value);
- }
- }
+ // OK, it is necessary to generate at least one #define.
+ // If this node is actually a loadable then the #define should go
+ // into system.h, otherwise into the current header
+ Tcl_Channel chan = this_hdr;
+ if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
+ chan = system_h;
+ }
+
+ // For flavors None and Bool, there should be just one #define
+ if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
+ std::string define = "#define " + name + " 1\n";
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ } else {
+ // If there is a format string then that controls the default
+ // value display.
+ if (!has_property(CdlPropertyId_DefineFormat)) {
+ std::string define = "#define " + name + " " + value + "\n";
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ } else {
+ CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_DefineFormat));
+ CYG_ASSERT_CLASSC(strprop);
+ std::string format = strprop->get_string();
+ std::string cmd = "return \"#define " + name + " [format " + format + " " + value + "]\n\"";
+ std::string define;
+ if (TCL_OK != interp->eval(cmd, define)) {
+ throw CdlInputOutputException("Internal error executing tcl fragment to process define_format property");
+ }
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ }
+
+ // There may also be a separate #define of the form <name>_<value>,
+ // if that is a valid preprocessor symbol.
+ std::string tmp = name + "_" + value;
+ if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
+ tmp = "#define "+ tmp + "\n";
+ Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
+ }
+
+ // For loadables, add additional version information to system_h
+ if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
+ system_h_add_package_versioning(system_h, name, value);
+ }
+ }
}
// Next, check for any additional define properties
get_properties(CdlPropertyId_Define, define_props);
std::vector<CdlProperty>::const_iterator prop_i;
for (prop_i = define_props.begin(); prop_i != define_props.end(); prop_i++) {
- CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(*prop_i);
- CYG_ASSERT_CLASSC(strprop);
- std::string symbol = strprop->get_string();
-
- std::string file = strprop->get_option("file");
- Tcl_Channel chan = this_hdr;
- if (("" != file) && ("system.h" == file)) {
- chan = system_h;
- }
-
- if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
- std::string define = "#define " + symbol + " 1\n";
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- } else {
- std::string format = strprop->get_option("format");
- if ("" == format) {
- std::string define = "#define " + symbol + " " + value + "\n";
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- } else {
- std::string cmd = "return \"#define " + symbol + " [format " + format + " " + value + "]\n\"";
- std::string define;
- if (TCL_OK != interp->eval(cmd, define)) {
- throw CdlInputOutputException("Internal error executing tcl fragment to process format option");
- }
- Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
- }
-
- std::string tmp = symbol + "_" + value;
- if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
- tmp = "#define " + tmp + "\n";
- Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
- }
- }
+ CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(*prop_i);
+ CYG_ASSERT_CLASSC(strprop);
+ std::string symbol = strprop->get_string();
+
+ std::string file = strprop->get_option("file");
+ Tcl_Channel chan = this_hdr;
+ if (("" != file) && ("system.h" == file)) {
+ chan = system_h;
+ }
+
+ if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
+ std::string define = "#define " + symbol + " 1\n";
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ } else {
+ std::string format = strprop->get_option("format");
+ if ("" == format) {
+ std::string define = "#define " + symbol + " " + value + "\n";
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ } else {
+ std::string cmd = "return \"#define " + symbol + " [format " + format + " " + value + "]\n\"";
+ std::string define;
+ if (TCL_OK != interp->eval(cmd, define)) {
+ throw CdlInputOutputException("Internal error executing tcl fragment to process format option");
+ }
+ Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
+ }
+
+ std::string tmp = symbol + "_" + value;
+ if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
+ tmp = "#define " + tmp + "\n";
+ Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
+ }
+ }
}
// Now check for if_define properties
std::vector<CdlProperty> if_define_props;
get_properties(CdlPropertyId_IfDefine, if_define_props);
for (prop_i = if_define_props.begin(); prop_i != if_define_props.end(); prop_i++) {
- CdlProperty_StringVector strprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
- CYG_ASSERT_CLASSC(strprop);
- CYG_ASSERTC(2 == strprop->get_number_of_strings());
+ CdlProperty_StringVector strprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
+ CYG_ASSERT_CLASSC(strprop);
+ CYG_ASSERTC(2 == strprop->get_number_of_strings());
- std::string sym1 = strprop->get_string(0);
- std::string sym2 = strprop->get_string(1);
+ std::string sym1 = strprop->get_string(0);
+ std::string sym2 = strprop->get_string(1);
- Tcl_Channel chan = this_hdr;
- std::string file = strprop->get_option("file");
- if (("" != file) && ("system.h" == file)) {
- chan = system_h;
- }
- std::string data = "#ifdef " + sym1 + "\n# define " + sym2 + " 1\n#endif\n";
- Tcl_Write(chan, const_cast<char*>(data.c_str()), -1);
+ Tcl_Channel chan = this_hdr;
+ std::string file = strprop->get_option("file");
+ if (("" != file) && ("system.h" == file)) {
+ chan = system_h;
+ }
+ std::string data = "#ifdef " + sym1 + "\n# define " + sym2 + " 1\n#endif\n";
+ Tcl_Write(chan, const_cast<char*>(data.c_str()), -1);
}
// And define_proc properties
std::vector<CdlProperty> define_proc_props;
get_properties(CdlPropertyId_DefineProc, define_proc_props);
for (prop_i = define_proc_props.begin(); prop_i != define_proc_props.end(); prop_i++) {
- CdlProperty_TclCode codeprop = dynamic_cast<CdlProperty_TclCode>(*prop_i);
- CYG_ASSERT_CLASSC(codeprop);
+ CdlProperty_TclCode codeprop = dynamic_cast<CdlProperty_TclCode>(*prop_i);
+ CYG_ASSERT_CLASSC(codeprop);
- cdl_tcl_code code = codeprop->get_code();
- std::string result;
- if (TCL_OK != interp->eval(code, result)) {
- throw CdlInputOutputException("Error evaluating define_proc property for " + name + "\n" + result);
- }
+ cdl_tcl_code code = codeprop->get_code();
+ std::string result;
+ if (TCL_OK != interp->eval(code, result)) {
+ throw CdlInputOutputException("Error evaluating define_proc property for " + name + "\n" + result);
+ }
}
-
-
+
+
CYG_REPORT_RETURN();
}
//}}}
//}}}
-//{{{ CdlDefineLoadableBody
+//{{{ CdlDefineLoadableBody
-//{{{ Basics
+//{{{ Basics
// ----------------------------------------------------------------------------
cdldefineloadablebody_cookie = CdlDefineLoadableBody_Magic;
CYGDBG_MEMLEAK_CONSTRUCTOR();
-
+
CYG_POSTCONDITION_THISC();
CYG_REPORT_RETURN();
}
cdldefineloadablebody_cookie = CdlDefineLoadableBody_Invalid;
CYGDBG_MEMLEAK_DESTRUCTOR();
-
+
CYG_REPORT_RETURN();
}
CdlDefineLoadableBody::check_this(cyg_assert_class_zeal zeal) const
{
if (CdlDefineLoadableBody_Magic != cdldefineloadablebody_cookie) {
- return false;
+ return false;
}
CYGDBG_MEMLEAK_CHECKTHIS();
return CdlLoadableBody::check_this(zeal) && CdlNodeBody::check_this(zeal);
}
//}}}
-//{{{ Property parsing
+//{{{ Property parsing
// ----------------------------------------------------------------------------
static CdlInterpreterCommandEntry commands[] =
{
- CdlInterpreterCommandEntry("define_header", &parse_define_header),
- CdlInterpreterCommandEntry("", 0 )
+ CdlInterpreterCommandEntry("define_header", &parse_define_header),
+ CdlInterpreterCommandEntry("", 0 )
};
for (int i = 0; commands[i].command != 0; i++) {
- std::vector<CdlInterpreterCommandEntry>::const_iterator j;
- for (j = parsers.begin(); j != parsers.end(); j++) {
- if (commands[i].name == j->name) {
- if (commands[i].command != j->command) {
- CYG_FAIL("Property names are being re-used");
- }
- break;
- }
- }
- if (j == parsers.end()) {
- parsers.push_back(commands[i]);
- }
+ std::vector<CdlInterpreterCommandEntry>::const_iterator j;
+ for (j = parsers.begin(); j != parsers.end(); j++) {
+ if (commands[i].name == j->name) {
+ if (commands[i].command != j->command) {
+ CYG_FAIL("Property names are being re-used");
+ }
+ break;
+ }
+ }
+ if (j == parsers.end()) {
+ parsers.push_back(commands[i]);
+ }
}
CdlNodeBody::add_property_parsers(parsers);
-
+
CYG_REPORT_RETURN();
}
// There should be at most one define_header property
int count = count_properties(CdlPropertyId_DefineHeader);
if (count> 1) {
- CdlParse::report_error(interp, "", "There should be at most one define_header property.");
+ CdlParse::report_error(interp, "", "There should be at most one define_header property.");
}
// FIXME: filename validation
-
+
CdlNodeBody::check_properties(interp);
-
+
CYG_REPORT_RETURN();
}
// ----------------------------------------------------------------------------
// syntax: define_header <header file name>
int
-CdlDefineLoadableBody::parse_define_header(CdlInterpreter interp, int argc, const char* argv[])
+CdlDefineLoadableBody::parse_define_header(CdlInterpreter interp, int argc, const char *argv[])
{
CYG_REPORT_FUNCNAMETYPE("parse_define_header", "result %d");
int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_DefineHeader, 0, 0);
-
+
CYG_REPORT_RETVAL(result);
return result;
}
//}}}
-//{{{ generate_config_header()
+//{{{ generate_config_header()
// ----------------------------------------------------------------------------
void
Tcl_RegisterChannel(interp->get_tcl_interpreter(), system_h);
CdlInterpreterBody::ContextSupport(interp, std::string("Package ") + this->get_name() + ", header file generation");
-
+
try {
- interp->set_variable("::cdl_header", Tcl_GetChannelName(this_hdr));
- interp->set_variable("::cdl_system_header", Tcl_GetChannelName(system_h));
-
- const std::vector<CdlNode>& contents = get_owned();
- std::vector<CdlNode>::const_iterator node_i;
- for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
- CdlDefinable definable = dynamic_cast<CdlDefinable>(*node_i);
- if (0 == definable) {
- continue;
- }
- if (!definable->is_active()) {
- continue;
- }
- definable->generate_config_header(this_hdr, system_h);
- }
-
- interp->unset_variable("::cdl_header");
- interp->unset_variable("::cdl_system_header");
+ interp->set_variable("::cdl_header", Tcl_GetChannelName(this_hdr));
+ interp->set_variable("::cdl_system_header", Tcl_GetChannelName(system_h));
+
+ const std::vector<CdlNode>& contents = get_owned();
+ std::vector<CdlNode>::const_iterator node_i;
+ for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
+ CdlDefinable definable = dynamic_cast<CdlDefinable>(*node_i);
+ if (0 == definable) {
+ continue;
+ }
+ if (!definable->is_active()) {
+ continue;
+ }
+ definable->generate_config_header(this_hdr, system_h);
+ }
+
+ interp->unset_variable("::cdl_header");
+ interp->unset_variable("::cdl_system_header");
} catch(...) {
- Tcl_UnregisterChannel(interp->get_tcl_interpreter(), this_hdr);
- Tcl_UnregisterChannel(interp->get_tcl_interpreter(), system_h);
- throw;
+ Tcl_UnregisterChannel(interp->get_tcl_interpreter(), this_hdr);
+ Tcl_UnregisterChannel(interp->get_tcl_interpreter(), system_h);
+ throw;
}
-
+
Tcl_UnregisterChannel(interp->get_tcl_interpreter(), this_hdr);
Tcl_UnregisterChannel(interp->get_tcl_interpreter(), system_h);
-
+
CYG_REPORT_RETURN();
}
//}}}
-//{{{ get_config_headers()
+//{{{ get_config_headers()
// ----------------------------------------------------------------------------
// What header file should be generated for this loadable?
std::string result = "";
CdlProperty prop = get_property(CdlPropertyId_DefineHeader);
if (0 != prop) {
- CdlProperty_String string_prop = dynamic_cast<CdlProperty_String>(prop);
- CYG_ASSERT_CLASSC(string_prop);
- result = string_prop->get_string();
+ CdlProperty_String string_prop = dynamic_cast<CdlProperty_String>(prop);
+ CYG_ASSERT_CLASSC(string_prop);
+ result = string_prop->get_string();
} else {
- std::string tmp = get_name();
- result = Cdl::get_short_form(tmp);
- result += ".h";
+ std::string tmp = get_name();
+ result = Cdl::get_short_form(tmp);
+ result += ".h";
}
CYG_REPORT_RETURN();
return result;
//}}}
//}}}
-//{{{ CdlToplevel
+//{{{ CdlToplevel
-//{{{ CdlToplevel::get_build_info()
+//{{{ CdlToplevel::get_build_info()
// ----------------------------------------------------------------------------
// Essentially this code involves iterating over the loadables vector,
CYG_PRECONDITION_THISC();
if (0 != build_info.entries.size()) {
- build_info.entries.clear();
+ build_info.entries.clear();
}
const std::vector<CdlLoadable>& loadables = get_loadables();
std::vector<CdlLoadable>::const_iterator load_i;
for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
- CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
- if (0 != bl) {
- bl->update_build_info(build_info);
- }
+ CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
+ if (0 != bl) {
+ bl->update_build_info(build_info);
+ }
}
CYG_REPORT_RETURN();
}
//}}}
-//{{{ CdlToplevel::get_all_build_info()
+//{{{ CdlToplevel::get_all_build_info()
// ----------------------------------------------------------------------------
// This is just like get_build_info(), but calls a different
CYG_PRECONDITION_THISC();
if (0 != build_info.entries.size()) {
- build_info.entries.clear();
+ build_info.entries.clear();
}
const std::vector<CdlLoadable>& loadables = get_loadables();
std::vector<CdlLoadable>::const_iterator load_i;
for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
- CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
- if (0 != bl) {
- bl->update_all_build_info(build_info);
- }
+ CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
+ if (0 != bl) {
+ bl->update_all_build_info(build_info);
+ }
}
CYG_REPORT_RETURN();
}
//}}}
-//{{{ CdlToplevel::generate_config_headers()
+//{{{ CdlToplevel::generate_config_headers()
// ----------------------------------------------------------------------------
// Generating the config headers. This involves the following steps:
interp->set_variable("::cdl_compare_and_copy_file2", file2);
std::string tcl_result;
if (TCL_OK != interp->eval(compare_and_copy_script, tcl_result)) {
- throw CdlInputOutputException("internal error manipulating temporary header " + file1 + " and target " + file2 +
- "\n" + tcl_result);
+ throw CdlInputOutputException("internal error manipulating temporary header " + file1 + " and target " + file2 +
+ "\n" + tcl_result);
}
}
// latter are used throughout the library
// NOTE: this is not i18n-friendly.
for (unsigned int i = 0; i < directory.size(); i++) {
- if ('\\' == directory[i]) {
- directory[i] = '/';
- }
+ if ('\\' == directory[i]) {
+ directory[i] = '/';
+ }
}
-
+
CdlInterpreter interp = get_interpreter();
std::string tcl_result;
if ((TCL_OK != interp->eval("file isdirectory \"" + directory + "\"", tcl_result)) ||
- (tcl_result != "1")) {
- throw CdlInputOutputException("target " + directory + " is not a valid existing directory.");
+ (tcl_result != "1")) {
+ throw CdlInputOutputException("target " + directory + " is not a valid existing directory.");
}
-
+
std::vector<std::pair<CdlDefineLoadable, std::string> > headers;
const std::vector<CdlLoadable>& loadables = get_loadables();
std::vector<CdlLoadable>::const_iterator load_i;
for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
- CdlDefineLoadable tmp = dynamic_cast<CdlDefineLoadable>(*load_i);
- if (0 != tmp) {
- std::string hdr = tmp->get_config_header();
- headers.push_back(std::make_pair(tmp, hdr));
- }
+ CdlDefineLoadable tmp = dynamic_cast<CdlDefineLoadable>(*load_i);
+ if (0 != tmp) {
+ std::string hdr = tmp->get_config_header();
+ headers.push_back(std::make_pair(tmp, hdr));
+ }
}
static char banner_format[] =
// export to these.
std::string system_h_name = directory + "/__libcdl_file1";
Tcl_Channel system_h = Tcl_OpenFileChannel(interp->get_tcl_interpreter(),
- const_cast<char*>(system_h_name.c_str()), "w", 0666);
+ const_cast<char*>(system_h_name.c_str()), "w", 0666);
if (0 == system_h) {
- throw CdlInputOutputException("Unable to open file " + system_h_name + "\n" +
- interp->get_result());
+ throw CdlInputOutputException("Unable to open file " + system_h_name + "\n" +
+ interp->get_result());
}
// The channel will be registered and unregistered in several
// different interpreters. This call prevents the channel from
// Make sure that this operation is undone if necessary.
try {
- // Now fill in system.h with the appropriate data. Start with the banner.
- char local_buf[512];
- sprintf(local_buf, banner_format, "SYSTEM_H", "SYSTEM_H", "system.h");
- Tcl_Write(system_h, local_buf, -1);
-
- // Add generic version information
- system_h_add_version_header(system_h);
-
- // The rest of system.h will be filled in by the following loop.
- //
- // Walk down the previously constructed headers vector, create
- // appropriate files, and let each DefineLoadable fill in the
- // file for itself.
- std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator outer_i;
- std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator inner_i;
- for (outer_i = headers.begin(); outer_i != headers.end(); outer_i++) {
- if ("" == outer_i->second) {
- continue;
- }
- std::string target_name = outer_i->second;
- std::string header_name = directory + "/__libcdl_file2";
- Tcl_Channel header_h = Tcl_OpenFileChannel(interp->get_tcl_interpreter(),
- const_cast<char*>(header_name.c_str()), "w", 0666);
- if (0 == header_h) {
- throw CdlInputOutputException("Unable to open file " + header_name + "\n" +
- interp->get_result());
- }
- // The channel may be used in several different interpreters, so
- // do an extra register operation
- Tcl_RegisterChannel(0, header_h);
-
- try {
- // Output the banner. This requires an all-upper-case version of the
- // header name.
- std::string upper_case;
- for (unsigned int i = 0; i < target_name.size(); i++) {
- if (islower(target_name[i])) {
- upper_case += toupper(target_name[i]);
- } else if ('.' == target_name[i]) {
- upper_case += '_';
- } else {
- upper_case += target_name[i];
- }
- }
- sprintf(local_buf, banner_format, upper_case.c_str(), upper_case.c_str(), target_name.c_str());
- Tcl_Write(header_h, local_buf, -1);
-
- // Now iterate over all the loadables looking for ones which
- // should generate #define's for this header, and invoke the
- // appropriate member function.
- for (inner_i = outer_i; inner_i != headers.end(); inner_i++) {
- if (inner_i->second == target_name) {
- inner_i->first->generate_config_header(header_h, system_h);
- inner_i->second = "";
- }
- }
-
- // The header file has now been updated. Close it and decide whether
- // or not to replace the old version
- Tcl_Write(header_h, "\n#endif\n", -1);
- } catch(...) {
- Tcl_UnregisterChannel(0, header_h);
- throw;
- }
- Tcl_UnregisterChannel(0, header_h);
- compare_and_copy(interp, header_name, directory + "/" + target_name);
- }
-
- Tcl_Write(system_h, "\n#endif\n", -1);
+ // Now fill in system.h with the appropriate data. Start with the banner.
+ char local_buf[512];
+ sprintf(local_buf, banner_format, "SYSTEM_H", "SYSTEM_H", "system.h");
+ Tcl_Write(system_h, local_buf, -1);
+
+ // Add generic version information
+ system_h_add_version_header(system_h);
+
+ // The rest of system.h will be filled in by the following loop.
+ //
+ // Walk down the previously constructed headers vector, create
+ // appropriate files, and let each DefineLoadable fill in the
+ // file for itself.
+ std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator outer_i;
+ std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator inner_i;
+ for (outer_i = headers.begin(); outer_i != headers.end(); outer_i++) {
+ if ("" == outer_i->second) {
+ continue;
+ }
+ std::string target_name = outer_i->second;
+ std::string header_name = directory + "/__libcdl_file2";
+ Tcl_Channel header_h = Tcl_OpenFileChannel(interp->get_tcl_interpreter(),
+ const_cast<char*>(header_name.c_str()), "w", 0666);
+ if (0 == header_h) {
+ throw CdlInputOutputException("Unable to open file " + header_name + "\n" +
+ interp->get_result());
+ }
+ // The channel may be used in several different interpreters, so
+ // do an extra register operation
+ Tcl_RegisterChannel(0, header_h);
+
+ try {
+ // Output the banner. This requires an all-upper-case version of the
+ // header name.
+ std::string upper_case;
+ for (unsigned int i = 0; i < target_name.size(); i++) {
+ if (islower(target_name[i])) {
+ upper_case += toupper(target_name[i]);
+ } else if ('.' == target_name[i]) {
+ upper_case += '_';
+ } else {
+ upper_case += target_name[i];
+ }
+ }
+ sprintf(local_buf, banner_format, upper_case.c_str(), upper_case.c_str(), target_name.c_str());
+ Tcl_Write(header_h, local_buf, -1);
+
+ // Now iterate over all the loadables looking for ones which
+ // should generate #define's for this header, and invoke the
+ // appropriate member function.
+ for (inner_i = outer_i; inner_i != headers.end(); inner_i++) {
+ if (inner_i->second == target_name) {
+ inner_i->first->generate_config_header(header_h, system_h);
+ inner_i->second = "";
+ }
+ }
+
+ // The header file has now been updated. Close it and decide whether
+ // or not to replace the old version
+ Tcl_Write(header_h, "\n#endif\n", -1);
+ } catch(...) {
+ Tcl_UnregisterChannel(0, header_h);
+ throw;
+ }
+ Tcl_UnregisterChannel(0, header_h);
+ compare_and_copy(interp, header_name, directory + "/" + target_name);
+ }
+
+ Tcl_Write(system_h, "\n#endif\n", -1);
} catch(...) {
- Tcl_UnregisterChannel(0, system_h);
- throw;
+ Tcl_UnregisterChannel(0, system_h);
+ throw;
}
-
+
// This call to UnregisterChannel automatically closes the
// channel, there is no need for an explicit Tcl_Close() call.
Tcl_UnregisterChannel(0, system_h);
}
//}}}
-//{{{ CdlToplevel::get_config_headers()
+//{{{ CdlToplevel::get_config_headers()
// ----------------------------------------------------------------------------
// Return details of the header files that should be generated. This
const std::vector<CdlLoadable>& loadables = get_loadables();
std::vector<CdlLoadable>::const_iterator i;
for (i = loadables.begin(); i != loadables.end(); i++) {
- CdlDefineLoadable current = dynamic_cast<CdlDefineLoadable>(*i);
- if (0 != current) {
- std::string its_file = current->get_config_header();
- CYG_LOOP_INVARIANTC("" != its_file);
- if (std::find(headers.begin(), headers.end(), its_file) == headers.end()) {
- headers.push_back(its_file);
- }
- }
+ CdlDefineLoadable current = dynamic_cast<CdlDefineLoadable>(*i);
+ if (0 != current) {
+ std::string its_file = current->get_config_header();
+ CYG_LOOP_INVARIANTC("" != its_file);
+ if (std::find(headers.begin(), headers.end(), its_file) == headers.end()) {
+ headers.push_back(its_file);
+ }
+ }
}
CYG_REPORT_RETURN();
}
//}}}
-//{{{ CdlToplevel::generate_build_tree()
+//{{{ CdlToplevel::generate_build_tree()
void
CdlToplevelBody::generate_build_tree(std::string build_tree, std::string install_tree)