3 //==========================================================================
7 // libcdl support for building and for header file generation
9 //==========================================================================
10 //####COPYRIGHTBEGIN####
12 // ----------------------------------------------------------------------------
13 // Copyright (C) 2002, 2003 Bart Veer
14 // Copyright (C) 1999, 2000, 2001 Red Hat, Inc.
16 // This file is part of the eCos host tools.
18 // This program is free software; you can redistribute it and/or modify it
19 // under the terms of the GNU General Public License as published by the Free
20 // Software Foundation; either version 2 of the License, or (at your option)
23 // This program is distributed in the hope that it will be useful, but WITHOUT
24 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
28 // You should have received a copy of the GNU General Public License along with
29 // this program; if not, write to the Free Software Foundation, Inc.,
30 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 // ----------------------------------------------------------------------------
34 //####COPYRIGHTEND####
35 //==========================================================================
36 //#####DESCRIPTIONBEGIN####
39 // Contributors: bartv
42 //####DESCRIPTIONEND####
43 //==========================================================================
48 // ----------------------------------------------------------------------------
49 #include "cdlconfig.h"
51 // Get the infrastructure types, assertions, tracing and similar
53 #include <cyg/infra/cyg_ass.h>
54 #include <cyg/infra/cyg_trac.h>
56 // <cdl.hxx> defines everything implemented in this module.
57 // It implicitly supplies <string>, <vector> and <map> because
58 // the class definitions rely on these headers.
59 #include <cdlcore.hxx>
65 // ----------------------------------------------------------------------------
66 CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlBuildLoadableBody);
67 CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlBuildableBody);
68 CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlDefineLoadableBody);
69 CYGDBG_DEFINE_MEMLEAK_COUNTER(CdlDefinableBody);
72 //{{{ CdlBuildableBody
76 // ----------------------------------------------------------------------------
77 // There is little data specific to a buildable. The only distinguishing
78 // feature is the set of properties that are supported, plus a handful
79 // of functions to extract that information.
81 CdlBuildableBody::CdlBuildableBody()
83 CYG_REPORT_FUNCNAME("CdlBuildable:: default constructor");
84 CYG_REPORT_FUNCARG1XV(this);
86 // There is no data to initialize yet
87 cdlbuildablebody_cookie = CdlBuildableBody_Magic;
88 CYGDBG_MEMLEAK_CONSTRUCTOR();
90 CYG_POSTCONDITION_THISC();
94 CdlBuildableBody::~CdlBuildableBody()
96 CYG_REPORT_FUNCNAME("CdlBuildable:: destructor");
97 CYG_REPORT_FUNCARG1XV(this);
98 CYG_PRECONDITION_THISC();
100 cdlbuildablebody_cookie = CdlBuildableBody_Invalid;
101 CYGDBG_MEMLEAK_DESTRUCTOR();
106 // ----------------------------------------------------------------------------
109 CdlBuildableBody::get_class_name() const
111 CYG_REPORT_FUNCNAME("CdlBuildable::get_class_name");
112 CYG_PRECONDITION_THISC();
117 // ----------------------------------------------------------------------------
120 CdlBuildableBody::check_this(cyg_assert_class_zeal zeal) const
122 if (CdlBuildableBody_Magic != cdlbuildablebody_cookie) {
125 CYGDBG_MEMLEAK_CHECKTHIS();
126 return CdlNodeBody::check_this(zeal);
130 //{{{ Add and check property parsers
132 // ----------------------------------------------------------------------------
135 CdlBuildableBody::add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers)
137 CYG_REPORT_FUNCNAME("CdlBuildable::add_property_parsers");
139 static CdlInterpreterCommandEntry commands[] =
141 CdlInterpreterCommandEntry("compile", &CdlBuildableBody::parse_compile ),
142 CdlInterpreterCommandEntry("object", &CdlBuildableBody::parse_object ),
143 CdlInterpreterCommandEntry("make_object", &CdlBuildableBody::parse_make_object),
144 CdlInterpreterCommandEntry("make", &CdlBuildableBody::parse_make ),
145 CdlInterpreterCommandEntry("build_proc", &CdlBuildableBody::parse_build_proc ),
146 CdlInterpreterCommandEntry("", 0 ),
149 for (int i = 0; commands[i].command != 0; i++) {
150 std::vector<CdlInterpreterCommandEntry>::const_iterator j;
151 for (j = parsers.begin(); j != parsers.end(); j++) {
152 if (commands[i].name == j->name) {
153 if (commands[i].command != j->command) {
154 CYG_FAIL("Property names are being re-used");
159 if (j == parsers.end()) {
160 parsers.push_back(commands[i]);
163 CdlNodeBody::add_property_parsers(parsers);
169 CdlBuildableBody::check_properties(CdlInterpreter interp)
171 CYG_REPORT_FUNCNAME("CdlBuildable::check_properties");
172 CYG_REPORT_FUNCARG2XV(this, interp);
173 CYG_PRECONDITION_THISC();
174 CYG_PRECONDITION_CLASSC(interp);
176 // There are no real constraints on the number of compile
178 // TODO: check that the relevant sources files exist,
179 // unless marked appropriately (build_proc can create
180 // new source files).
182 CdlNodeBody::check_properties(interp);
188 //{{{ Property parsers
190 // ----------------------------------------------------------------------------
191 // Syntax: compile <file1 file2 ...>
193 // There are a couple of checks that could be performed here:
195 // 1) does each listed file actually exist? Unfortunately that approach
196 // falls foul of build_proc, which is allowed to generate source files
199 // 2) does the file have a recognised suffix such as .c or .cxx. This
200 // relies libcdl having some way of knowing how to treat different
203 // For now there are no validity checks.
205 // A future extension may allow dependencies to be listed, as an
206 // option. This would allow component vendors to specify that
207 // particular custom build steps should happen before particular
208 // compilations, a more robust approach than the current priority
212 CdlBuildableBody::parse_compile(CdlInterpreter interp, int argc, const char* argv[])
214 CYG_REPORT_FUNCNAMETYPE("parse_compile", "result %d");
215 static char* options[] = {
220 int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_Compile, options, 0, true);
222 CYG_REPORT_RETVAL(result);
226 // ----------------------------------------------------------------------------
227 // A utility to break a custom build step down into its three components.
229 // A custom build step takes the form:
233 // This utility function takes a single string of this form and breaks
234 // it down into its constituent parts.
236 // NOTE: this will need lots of extra code in future to allow for
237 // escaped characters, spaces in filenames, etc. For now just keep
241 CdlBuildableBody::split_custom_build_step(std::string str_data, std::string& target, std::string& deps, std::string& rules,
242 std::string& error_msg)
244 CYG_REPORT_FUNCNAMETYPE("CdlBuildable::split_custom_build_step", "result %d");
251 const char* data = str_data.c_str();
253 // Skip any leading white space, and make sure that this leaves some real data.
254 while (('\0' != *data) && isspace(*data)) {
258 error_msg = "no data in custom build_step";
259 CYG_REPORT_RETVAL(false);
263 // Now extract the target. This consists of any sequence of characters
264 // upto space, tab, colon.
265 for ( ; ('\0' != *data) && (':' != *data) && (' ' != *data) && ('\t' != *data); data++) {
268 // Discard any spaces or tabs, they are of no interest
269 while ((' ' == *data) || ('\t' == *data)) {
272 // The current character should be a colon
274 error_msg = "expecting a colon `;' after the target `" + target + "'";
275 CYG_REPORT_RETVAL(false);
279 // Move past the colon, and skip any further spaces or tabs
281 while (('\0' != *data) && ((' ' == *data) || ('\t' == *data))) {
285 // Everything from here until the end of line should be part of the deps field,
286 // including white space.
287 while (('\0' != *data) && ('\n' != *data) && (';' != *data)) {
292 error_msg = "expecting dependency list after `" + target + ":'";
293 CYG_REPORT_RETVAL(false);
297 // Having some rules is compulsory.
299 error_msg = "expecting one or more rules after the dependency list";
300 CYG_REPORT_RETVAL(false);
303 // We are currently at \n or ;, move on to the actual rules
307 // Rules consist of one or more lines. Any leading white space on a given
308 // line should be discarded.
309 while ('\0' != *data) {
310 // Processing the current rule. Skip leading spaces and tabs
311 while ((' ' == *data) || ('\t' == *data)) {
314 // Now add everything up to the next newline or EOD to the rules.
315 while (('\0' != *data) && ('\n' != *data)) {
319 // Terminate this line of the rules with a newline, even if that
320 // character is absent from the raw data.
323 // And ignore the newline in the raw data itself
329 // Better make sure that there are some rules. All of the looping above
330 // may just have left white space
332 error_msg = "no rules provided";
333 CYG_REPORT_RETVAL(false);
339 CYG_REPORT_RETVAL(true);
344 // ----------------------------------------------------------------------------
345 // syntax: make <target> <rules>
347 // There is rather a lot of checking to be done.
349 // 1) the priority should be valid. In particular it should be a number
350 // within a reasonable range.
352 // 2) the rules should take the form:
353 // <target> : <deps> ;|\n rules
355 // Where the target should be a single file, identical to the
356 // first property argument.
359 parse_make_final_check(CdlInterpreter interp, CdlProperty_String prop)
361 CYG_REPORT_FUNCNAME("parse_make_final_check");
362 CYG_PRECONDITION_CLASSC(interp);
363 CYG_PRECONDITION_CLASSC(prop);
365 std::string prio_string = prop->get_option("priority");
366 if ("" != prio_string) {
368 if (!Cdl::string_to_integer(prio_string, tmp)) {
369 CdlParse::report_property_parse_error(interp, prop,
370 "Invalid priority option, priorities should be simple numbers.");
372 if ((tmp < 1) || (tmp > 1024)) {
373 CdlParse::report_property_parse_error(interp, prop,
374 "Invalid priority value, priorities should be in the range 1 to 1024.");
379 std::string data = prop->get_string();
383 std::string error_msg;
385 if (!CdlBuildableBody::split_custom_build_step(data, target, deps, rules, error_msg)) {
386 CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
391 CdlBuildableBody::parse_make(CdlInterpreter interp, int argc, const char* argv[])
393 CYG_REPORT_FUNCNAMETYPE("parse_make", "result %d");
394 static char* options[] = {
399 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Make, options, &parse_make_final_check);
401 CYG_REPORT_RETVAL(result);
406 // ----------------------------------------------------------------------------
407 // syntax: make_object <target> <rules>
409 // The rules here are much the same as for the "make" property.
412 parse_make_object_final_check(CdlInterpreter interp, CdlProperty_String prop)
414 CYG_REPORT_FUNCNAME("parse_make_object_final_check");
415 CYG_PRECONDITION_CLASSC(interp);
416 CYG_PRECONDITION_CLASSC(prop);
419 std::string prio_string = prop->get_option("priority");
420 if ("" != prio_string) {
422 if (!Cdl::string_to_integer(prio_string, tmp)) {
423 CdlParse::report_property_parse_error(interp, prop,
424 "Invalid priority option, priorities should be simple numbers.");
426 if ((tmp < 1) || (tmp > 1024)) {
427 CdlParse::report_property_parse_error(interp, prop,
428 "Invalid priority value, priorities should be in the range 1 to 1024.");
433 std::string data = prop->get_string();
437 std::string error_msg;
439 if (!CdlBuildableBody::split_custom_build_step(data, target, deps, rules, error_msg)) {
440 CdlParse::report_property_parse_error(interp, prop, "Invalid custom build step, " + error_msg);
445 CdlBuildableBody::parse_make_object(CdlInterpreter interp, int argc, const char* argv[])
447 CYG_REPORT_FUNCNAMETYPE("parse_make_object", "result %d");
448 static char* options[] = {
454 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_MakeObject, options,
455 &parse_make_object_final_check);
457 CYG_REPORT_RETVAL(result);
462 // ----------------------------------------------------------------------------
463 // Syntax: object <file1> <file2> ...
466 CdlBuildableBody::parse_object(CdlInterpreter interp, int argc, const char* argv[])
468 CYG_REPORT_FUNCNAMETYPE("parse_object", "result %d");
469 static char* options[] = {
474 int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_Object, options, 0, true);
476 CYG_REPORT_RETVAL(result);
480 // ----------------------------------------------------------------------------
481 // Syntax: build_proc { tcl code }
484 CdlBuildableBody::parse_build_proc(CdlInterpreter interp, int argc, const char* argv[])
486 CYG_REPORT_FUNCNAMETYPE("parse_build_proc", "result %d");
488 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_BuildProc, 0, 0);
490 CYG_REPORT_RETVAL(result);
495 //{{{ update_build_info()
497 // ----------------------------------------------------------------------------
498 // Most of the work is done in update_all_build_info(). The update_build_info()
499 // merely checks the active and enabled state first.
501 CdlBuildableBody::update_build_info(CdlBuildInfo_Loadable& build_info, std::string library) const
503 CYG_REPORT_FUNCNAME("CdlBuildable::update_build_info");
504 CYG_REPORT_FUNCARG2XV(this, &build_info);
505 CYG_PRECONDITION_THISC();
506 CYG_PRECONDITIONC("" != library);
513 CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(this);
515 if (!valuable->is_enabled()) {
521 update_all_build_info(build_info, library);
527 //{{{ update_all_build_info()
529 // ----------------------------------------------------------------------------
530 // There are four properties to be considered, each of which may occur
531 // multiple times: "compile", "object", "make_object", and "make".
532 // Each of these will result in separate additions to the build_info
536 CdlBuildableBody::update_all_build_info(CdlBuildInfo_Loadable& build_info, std::string package_library) const
538 CYG_REPORT_FUNCNAME("CdlBuildable::update_all_build_info");
539 CYG_REPORT_FUNCARG2XV(this, &build_info);
540 CYG_PRECONDITION_THISC();
541 CYG_PRECONDITIONC("" != package_library);
543 // Get some information about the owning loadable first.
544 CdlLoadable loadable = get_owner();
545 CYG_ASSERT_CLASSC(loadable);
546 std::string directory = loadable->get_directory();
547 CYG_ASSERTC("" != directory);
548 CdlInterpreter interp = loadable->get_interpreter();
549 CYG_ASSERT_CLASSC(interp);
551 // The interpreter needs some information about the locations
552 // of various things. This code has to be kept in step with
553 // CdlLoadable::find_relative_file()
554 interp->set_variable("::cdl_topdir", get_toplevel()->get_directory());
555 interp->set_variable("::cdl_pkgdir", directory);
557 // For many packages the sources will reside in a src subdirectory.
558 // For simple packages the sources may live directly at the toplevel
559 bool has_src_subdir = loadable->has_subdirectory("src");
561 // NOTE: the object property is not yet supported
562 std::vector<CdlProperty> compile_properties;
563 get_properties(CdlPropertyId_Compile, compile_properties);
564 std::vector<CdlProperty> makeobject_properties;
565 get_properties(CdlPropertyId_MakeObject, makeobject_properties);
566 std::vector<CdlProperty> make_properties;
567 get_properties(CdlPropertyId_Make, make_properties);
568 std::vector<CdlProperty>::const_iterator prop_i;
570 for (prop_i = compile_properties.begin(); prop_i != compile_properties.end(); prop_i++) {
571 CdlProperty_StringVector compile_prop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
572 CYG_LOOP_INVARIANT_CLASSC(compile_prop);
574 // Does this property have a library option?
575 std::string current_library = compile_prop->get_option("library");
576 if ("" == current_library) {
577 current_library = package_library;
580 const std::vector<std::string>& files = compile_prop->get_strings();
581 std::vector<std::string>::const_iterator file_i;
583 for (file_i = files.begin(); file_i != files.end(); file_i++) {
585 // For each listed file, try to find it. If this is unsuccessful
586 // then assume that the file will be generated later on.
587 std::string path = loadable->find_relative_file(*file_i, "src");
589 if (has_src_subdir) {
590 path = "src/" + *file_i;
596 // Now check whether or not the specified file is already present.
597 std::vector<CdlBuildInfo_Compile>::const_iterator info_i;
598 for (info_i = build_info.compiles.begin(); info_i != build_info.compiles.end(); info_i++) {
599 if ((current_library == info_i->library) && (path == info_i->source)) {
603 if (info_i == build_info.compiles.end()) {
604 CdlBuildInfo_Compile new_info;
605 new_info.library = current_library;
606 new_info.source = path;
607 build_info.compiles.push_back(new_info);
612 for (prop_i = makeobject_properties.begin(); prop_i != makeobject_properties.end(); prop_i++) {
613 CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
614 CYG_LOOP_INVARIANT_CLASSC(prop);
616 // Does thie property have a library option?
617 std::string current_library = prop->get_option("library");
618 if ("" == current_library) {
619 current_library = package_library;
622 // How about a priority field? The default priority for make_object is 100
623 // We can rely on the validation done during the parsing process
624 cdl_int priority = 100;
625 std::string priority_option = prop->get_option("priority");
626 if ("" != priority_option) {
627 Cdl::string_to_integer(priority_option, priority);
630 // What we need now is the separate target, deps, and rules. These
631 // can be obtained via a utility. The raw data will have been validated
633 std::string raw_data = prop->get_string();
637 std::string error_msg;
640 result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
641 CYG_ASSERTC(true == result);
643 // Construct a local object, then copy it into the vector
644 CdlBuildInfo_MakeObject local_copy;
645 local_copy.priority = priority;
646 local_copy.library = current_library;
647 local_copy.object = target;
648 local_copy.deps = deps;
649 local_copy.rules = rules;
651 build_info.make_objects.push_back(local_copy);
654 for (prop_i = make_properties.begin(); prop_i != make_properties.end(); prop_i++) {
655 CdlProperty_String prop = dynamic_cast<CdlProperty_String>(*prop_i);
656 CYG_LOOP_INVARIANT_CLASSC(prop);
658 // Is there a priority field? The default priority for make is
659 // 300 We can rely on the validation done during the parsing
661 cdl_int priority = 300;
662 std::string priority_option = prop->get_option("priority");
663 if ("" != priority_option) {
664 Cdl::string_to_integer(priority_option, priority);
667 // What we need now is the separate target, deps, and rules. These
668 // can be obtained via a utility. The raw data will have been validated
670 std::string raw_data = prop->get_string();
674 std::string error_msg;
677 result = CdlBuildableBody::split_custom_build_step(raw_data, target, deps, rules, error_msg);
678 CYG_ASSERTC(true == result);
680 // Construct a local object, then copy it into the vector
681 CdlBuildInfo_Make local_copy;
682 local_copy.priority = priority;
683 local_copy.target = target;
684 local_copy.deps = deps;
685 local_copy.rules = rules;
687 build_info.makes.push_back(local_copy);
696 //{{{ CdlBuildLoadableBody
698 //{{{ Class variables
700 // ----------------------------------------------------------------------------
701 // This variable controls the default library that should be generated.
702 // Some applications may wish to override this.
703 char* CdlBuildLoadableBody::default_library_name = "libtarget.a";
705 // The pattern that should be used to identify header files.
706 // FIXME: this information should come out of a data file
707 char* CdlBuildLoadableBody::default_headers_glob_pattern = "*.h *.hxx *.inl *.si *.inc";
710 //{{{ The simple stuff
712 // ----------------------------------------------------------------------------
714 CdlBuildLoadableBody::CdlBuildLoadableBody()
717 CYG_REPORT_FUNCNAME("CdlBuildLoadable:: default constructor");
718 CYG_REPORT_FUNCARG1XV(this);
720 // There is no data to initialize
721 cdlbuildloadablebody_cookie = CdlBuildLoadableBody_Magic;
722 CYGDBG_MEMLEAK_CONSTRUCTOR();
724 CYG_POSTCONDITION_THISC();
728 CdlBuildLoadableBody::~CdlBuildLoadableBody()
730 CYG_REPORT_FUNCNAME("CdlBuildLoadable:: destructor");
731 CYG_REPORT_FUNCARG1XV(this);
732 CYG_PRECONDITION_THISC();
734 cdlbuildloadablebody_cookie = CdlBuildLoadableBody_Invalid;
735 CYGDBG_MEMLEAK_DESTRUCTOR();
740 // ----------------------------------------------------------------------------
743 CdlBuildLoadableBody::get_class_name() const
745 CYG_REPORT_FUNCNAME("CdlBuildLoadable::get_class_name");
746 CYG_PRECONDITION_THISC();
748 return "build_loadable";
751 // ----------------------------------------------------------------------------
754 CdlBuildLoadableBody::check_this(cyg_assert_class_zeal zeal) const
756 if (CdlBuildLoadableBody_Magic != cdlbuildloadablebody_cookie) {
759 CYGDBG_MEMLEAK_CHECKTHIS();
760 return CdlContainerBody::check_this(zeal) && CdlNodeBody::check_this(zeal);
764 //{{{ Property parsers
766 // ----------------------------------------------------------------------------
769 CdlBuildLoadableBody::add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers)
771 CYG_REPORT_FUNCNAME("CdlBuildLoadable::add_property_parsers");
773 static CdlInterpreterCommandEntry commands[] =
775 CdlInterpreterCommandEntry("library", &CdlBuildLoadableBody::parse_library ),
776 CdlInterpreterCommandEntry("makefile", &CdlBuildLoadableBody::parse_makefile ),
777 CdlInterpreterCommandEntry("include_dir", &CdlBuildLoadableBody::parse_include_dir ),
778 CdlInterpreterCommandEntry("include_files", &CdlBuildLoadableBody::parse_include_files ),
779 CdlInterpreterCommandEntry("", 0 )
782 for (int i = 0; commands[i].command != 0; i++) {
783 std::vector<CdlInterpreterCommandEntry>::const_iterator j;
784 for (j = parsers.begin(); j != parsers.end(); j++) {
785 if (commands[i].name == j->name) {
786 if (commands[i].command != j->command) {
787 CYG_FAIL("Property names are being re-used");
792 if (j == parsers.end()) {
793 parsers.push_back(commands[i]);
801 CdlBuildLoadableBody::check_properties(CdlInterpreter interp)
803 CYG_REPORT_FUNCNAME("CdlBuildLoadable::check_properties");
804 CYG_REPORT_FUNCARG2XV(this, interp);
805 CYG_PRECONDITION_THISC();
806 CYG_PRECONDITION_CLASSC(interp);
808 CdlNodeBody::check_properties(interp);
813 // ----------------------------------------------------------------------------
814 // syntax: library <filename>
816 // NOTE: there should probably be a check that the library name is in
817 // a valid format, i.e. libxxx.a
820 CdlBuildLoadableBody::parse_library(CdlInterpreter interp, int argc, const char* argv[])
822 CYG_REPORT_FUNCNAMETYPE("parse_library", "result %d");
824 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Library, 0, 0);
826 CYG_REPORT_RETVAL(result);
830 // ----------------------------------------------------------------------------
831 // syntax: makefile <filename>
833 // NOTE: possibly there should be a check that the makefile exists.
834 // Do we want to allow build_proc's to generate makefiles?
836 CdlBuildLoadableBody::parse_makefile(CdlInterpreter interp, int argc, const char* argv[])
838 CYG_REPORT_FUNCNAMETYPE("parse_makefile", "result %d");
840 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Makefile, 0, 0);
842 CYG_REPORT_RETVAL(result);
846 // ----------------------------------------------------------------------------
847 // syntax: include_dir <directory name>
849 CdlBuildLoadableBody::parse_include_dir(CdlInterpreter interp, int argc, const char* argv[])
851 CYG_REPORT_FUNCNAMETYPE("parse_include_dir", "result %d");
853 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_IncludeDir, 0, 0);
855 CYG_REPORT_RETVAL(result);
859 // ----------------------------------------------------------------------------
860 // Syntax: include_files <file1 file2 ...>
862 // This lists the header files that should be copied into the install tree
863 // as part of the build operation. In the absence of an include_files property
864 // there should be an include subdirectory, and all files in that subdirectory
865 // are assumed to be exportable headers.
867 // NOTE: add a finalizer to check that the files exist or get created.
870 CdlBuildLoadableBody::parse_include_files(CdlInterpreter interp, int argc, const char* argv[])
872 CYG_REPORT_FUNCNAMETYPE("parse_include_files", "result %d");
874 int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_IncludeFiles, 0, 0, true);
876 CYG_REPORT_RETVAL(result);
881 //{{{ update_build_info()
883 // ----------------------------------------------------------------------------
884 // This utility routine takes care of filling in a Buildinfo_Loadable
885 // structure with the appropriate header file information. This involves
888 // 1) there may be an include_dir property. This affects the destination
889 // of any header files that are listed.
891 // 2) the loadable may or may not have an include subdirectory. For
892 // non-trivial packages the include subdirectory provides a clean
893 // way of separating interface and implementation. For simple
894 // packages it is too heavyweight.
896 // 3) there may be one or more include_files property. If so then these
897 // specify all the files that should be exported.
899 // 4) otherwise if there is an include subdirectory then we need to
900 // know all the header files in that subdirectory. A Tcl script is
903 // 5) otherwise all the header files below the package directory itself
907 update_header_file_info(CdlConstBuildLoadable loadable, CdlBuildInfo_Loadable& build_info)
909 CYG_REPORT_FUNCNAME("update_header_file_info");
910 CYG_REPORT_FUNCARG2XV(loadable, &build_info);
911 CYG_PRECONDITION_CLASSC(loadable);
913 std::string dest_dir = "";
914 CdlProperty include_dir_prop = loadable->get_property(CdlPropertyId_IncludeDir);
915 if (0 != include_dir_prop) {
916 CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(include_dir_prop);
917 CYG_ASSERT_CLASSC(strprop);
918 dest_dir = strprop->get_string();
921 bool has_include_subdir = loadable->has_subdirectory("include");
923 std::vector<CdlProperty> include_file_properties;
924 loadable->get_properties(CdlPropertyId_IncludeFiles, include_file_properties);
925 if (include_file_properties.size() > 0) {
926 std::vector<CdlProperty>::const_iterator prop_i;
927 for (prop_i = include_file_properties.begin(); prop_i != include_file_properties.end(); prop_i++) {
929 CdlProperty_StringVector strvprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
930 CYG_ASSERT_CLASSC(strvprop);
932 const std::vector<std::string>& filenames = strvprop->get_strings();
933 std::vector<std::string>::const_iterator file_i;
934 for (file_i = filenames.begin(); file_i != filenames.end(); file_i++) {
935 std::string path = loadable->find_relative_file(*file_i, "include");
936 // Assume that the header file will be generated by a build_proc
938 if (has_include_subdir) {
939 path = "include/" + *file_i;
944 CdlBuildInfo_Header local_copy;
945 local_copy.source = path;
946 local_copy.destination = "";
947 if ("" != dest_dir) {
948 local_copy.destination = dest_dir + "/";
950 // At this stage "path" may begin with "include/", which should not
951 // be present in the destination.
952 const char* tmp = path.c_str();
953 if (0 == strncmp("include/", tmp, 8)) {
954 local_copy.destination += &(tmp[8]);
956 local_copy.destination += path;
958 build_info.headers.push_back(local_copy);
965 // It is necessary to search for the appropriate files.
966 CdlInterpreter interp = loadable->get_interpreter();
967 std::string path = loadable->get_toplevel()->get_directory() + "/" + loadable->get_directory();
968 if (has_include_subdir) {
969 std::vector<std::string> files;
970 std::vector<std::string>::const_iterator file_i;
971 interp->locate_all_files(path + "/include", files);
972 for (file_i = files.begin(); file_i != files.end(); file_i++) {
973 // NOTE: for now discard any header files in the pkgconf subdirectory
974 if (0 == strncmp("pkgconf/", file_i->c_str(), 8)) {
977 if ('~' == *(file_i->rbegin())) {
980 CdlBuildInfo_Header local_copy;
981 local_copy.source = "include/" + *file_i;
982 local_copy.destination = "";
983 if ("" != dest_dir) {
984 local_copy.destination = dest_dir + "/";
986 local_copy.destination += *file_i;
987 build_info.headers.push_back(local_copy);
990 // Look for all header files, which for now means files with
991 // a .h, .hxx, .inl or .inc extension.
992 // FIXME: the definition of what constitutes a header file
993 // should not be hard-wired here.
994 std::vector<std::string> files;
995 std::vector<std::string>::const_iterator file_i;
996 interp->locate_all_files(path, files);
997 for (file_i = files.begin(); file_i != files.end(); file_i++) {
999 // Problems with libstdc++ versions, use C comparisons instead.
1000 const char* c_string = file_i->c_str();
1001 unsigned int len = strlen(c_string);
1002 if (((len >= 2) && (0 == strncmp(c_string + len - 2, ".h", 2))) ||
1003 ((len >= 4) && (0 == strncmp(c_string + len - 4, ".hxx", 4))) ||
1004 ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inl", 4))) ||
1005 ((len >= 4) && (0 == strncmp(c_string + len - 4, ".inc", 4)))) {
1007 CdlBuildInfo_Header local_copy;
1008 local_copy.source = *file_i;
1009 local_copy.destination = "";
1010 if ("" != dest_dir) {
1011 local_copy.destination = dest_dir + "/";
1013 local_copy.destination += *file_i;
1014 build_info.headers.push_back(local_copy);
1019 CYG_REPORT_RETURN();
1023 // ----------------------------------------------------------------------------
1024 // Updating a loadable build's info involves two steps. First, there
1025 // is some information associated with the loadable as a whole such as
1026 // header files. Second, each buildable in the loadable (including itself)
1027 // may contain properties such as compile etc. This is all handled via
1028 // a CdlBuildable member function.
1031 CdlBuildLoadableBody::update_build_info(CdlBuildInfo& build_info) const
1033 CYG_REPORT_FUNCNAME("CdlBuildLoadable::update_build_info");
1034 CYG_REPORT_FUNCARG2XV(this, &build_info);
1035 CYG_PRECONDITION_THISC();
1037 // It is not possible to disable a loadable itself: either the
1038 // loadable is present or it is not (although in some cases users
1039 // may be able to change versions). However, because of reparenting
1040 // it is possible for a loadable to be below a disabled container,
1041 // and hence it is still necessary to check whether or not the
1042 // loadable is active.
1044 CYG_REPORT_RETURN();
1048 // Time to add a new CdlBuildInfo_Loadable object to the current
1049 // vector. The name and directory can be filled in straightaway,
1050 // the vectors will all be initialized to empty.
1051 CdlBuildInfo_Loadable tmp_info;
1052 build_info.entries.push_back(tmp_info);
1053 CdlBuildInfo_Loadable& this_info = *(build_info.entries.rbegin());
1054 this_info.name = get_name();
1055 this_info.directory = get_directory();
1057 // Take care of the header files
1058 update_header_file_info(this, this_info);
1060 // Work out the library name appropriate for this loadable.
1061 // There may be a library property, otherwise the global default
1063 std::string loadable_library = default_library_name;
1064 if (has_property(CdlPropertyId_Library)) {
1065 CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
1066 loadable_library = strprop->get_string();
1069 const std::vector<CdlNode>& contents = get_owned();
1070 std::vector<CdlNode>::const_iterator node_i;
1071 for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
1072 CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
1073 if (0 != buildable) {
1074 buildable->update_build_info(this_info, loadable_library);
1078 CYG_REPORT_RETURN();
1081 // This is much the same as the above, but there is no test for
1082 // active either at the loadable level or for the individual buildables.
1084 CdlBuildLoadableBody::update_all_build_info(CdlBuildInfo& build_info) const
1086 CYG_REPORT_FUNCNAME("CdlBuildLoadable::update_all_build_info");
1087 CYG_REPORT_FUNCARG2XV(this, &build_info);
1088 CYG_PRECONDITION_THISC();
1090 CdlBuildInfo_Loadable tmp_info;
1091 build_info.entries.push_back(tmp_info);
1092 CdlBuildInfo_Loadable& this_info = *(build_info.entries.rbegin());
1093 this_info.name = get_name();
1094 this_info.directory = get_directory();
1096 std::string loadable_library = default_library_name;
1097 if (has_property(CdlPropertyId_Library)) {
1098 CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_Library));
1099 loadable_library = strprop->get_string();
1102 const std::vector<CdlNode>& contents = get_owned();
1103 std::vector<CdlNode>::const_iterator node_i;
1104 for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
1105 CdlBuildable buildable = dynamic_cast<CdlBuildable>(*node_i);
1106 if (0 != buildable) {
1107 buildable->update_build_info(this_info, loadable_library);
1111 CYG_REPORT_RETURN();
1112 CYG_REPORT_RETURN();
1118 //{{{ Version number #define's
1120 // ----------------------------------------------------------------------------
1121 // Given a package xxxPKG_A_B_C with a version V1_2_3, generate additional
1122 // #define's of the form:
1124 // #define xxxNUM_A_B_C_VERSION_MAJOR 1
1125 // #define xxxNUM_A_B_C_VERSION_MINOR 2
1126 // #define xxxNUM_A_B_C_VERSION_RELEASE 3
1128 // The goal here is to allow application code to cope with API
1129 // changes (which of course should be a rare event but cannot be
1130 // eliminated completely). C preprocessor #if statements are
1131 // essentially limited to numerical values, so there is no easy
1132 // way of coping with V1_2_3 at the preprocessor level. However it
1133 // is possible to cope with VERSION_NUMBER #define's.
1135 // Note that only application code and third party packages are
1138 // These #define's go into system.h, alongside the main definition of
1139 // the package. There seems to be little point in putting them in the
1140 // package's own configuration header.
1142 // There are three problems. First, what should be done for packages
1143 // which do not follow the naming conventions? Given a completely
1144 // random package rather than something like xxxPKG_..., what symbol
1145 // names should be used? Basically, if the package does not follow the
1146 // naming convention then there is no safe way of generating new
1147 // symbols. Any names that are chosen might clash. Of course even for
1148 // packages that do follow the naming convention a clash is still
1149 // possible, just a lot less likely.
1151 // Conclusion: if a package does not follow the naming convention, do
1152 // not generate version #define's for it.
1154 // Second, what happens if a different version numbering scheme is
1155 // used? For example the release number might be absent. Version
1156 // numbering schemes might change between releases, but application
1157 // code may still check the #define's.
1159 // Third and related, what should happen for "current" and anoncvs? Do
1160 // we want to look at what other versions are installed and bump one
1163 // Conclusion: the version #define's always have to be generated,
1164 // even if they are not present in the version string, to allow
1165 // application code to test these symbols anyway. A safe default is
1166 // necessary, and -1 is probably the best bet. For example, if
1167 // the version is bumped from 1.3.287 to 1.4 then the release number
1168 // for the latter is set to -1. Another possible default would be
1169 // 0, but that could cause problems for packages that start counting
1170 // from 0 (not a common practice, but...)
1172 // This leaves the question of what to do about "current". Chances are
1173 // that "current" comes from anoncvs and is always more recent than
1174 // any official release, so when comparing versions "current" should
1175 // always be greater than anything else. This can be achieved by using
1176 // a sufficiently large number for the major version. In practice
1177 // it is cleaner to have another #define to indicate the current
1178 // version, and then define package versions to match, i.e.:
1180 // #define CYGNUM_VERSION_CURRENT 0x7fffff00
1182 // #define xxxNUM_A_B_C_VERSION_MAJOR CYGNUM_VERSION_CURRENT
1183 // #define xxxNUM_A_B_C_VERSION_MINOR -1
1184 // #define xxxNUM_A_B_C_VERSION_RELEASE -1
1186 // All comparisons should now work sensibly. Leaving a little bit
1187 // of slack for VERSION_CURRENT seems like a good precaution.
1190 system_h_add_version_header(Tcl_Channel system_h)
1192 CYG_REPORT_FUNCNAME("system_h_add_version_header");
1193 Tcl_Write(system_h, "#define CYGNUM_VERSION_CURRENT 0x7fffff00\n", -1);
1194 CYG_REPORT_RETURN();
1198 system_h_add_package_versioning(Tcl_Channel system_h, std::string name, std::string value)
1200 CYG_REPORT_FUNCNAME("system_h_add_package_versioning");
1205 // The first thing to check is that the package name can be used
1206 // as the basis for the version symbols.
1209 for (i = 0; i < name.size(); i++) {
1210 if ('_' == name[i]) {
1212 if ((name[i-3] == 'P') && (name[i-2] == 'K') && (name[i-1] == 'G')) {
1219 if (name.size() >= 256) {
1223 CYG_REPORT_RETURN();
1227 strcpy(name_buf, name.c_str());
1229 // Change from xxxPKG to xxxNUM
1230 name_buf[i - 3] = 'N';
1231 name_buf[i - 2] = 'U';
1232 name_buf[i - 1] = 'M';
1234 // Now determine the version strings.
1235 std::string major = "-1";
1236 std::string minor = "-1";
1237 std::string release = "-1";
1238 if ("current" == value) {
1239 major = "CYGNUM_VERSION_CURRENT";
1241 Cdl::split_version_string(value, major, minor, release);
1244 sprintf(line_buf, "#define %s_VERSION_MAJOR %s\n", name_buf, major.c_str());
1245 Tcl_Write(system_h, line_buf, -1);
1246 sprintf(line_buf, "#define %s_VERSION_MINOR %s\n", name_buf, minor.c_str());
1247 Tcl_Write(system_h, line_buf, -1);
1248 sprintf(line_buf, "#define %s_VERSION_RELEASE %s\n", name_buf, release.c_str());
1249 Tcl_Write(system_h, line_buf, -1);
1251 CYG_REPORT_RETURN();
1255 //{{{ CdlDefinableBody
1259 // ----------------------------------------------------------------------------
1261 CdlDefinableBody::CdlDefinableBody()
1263 CYG_REPORT_FUNCNAME("CdlDefinable:: default constructor");
1264 CYG_REPORT_FUNCARG1XV(this);
1266 // There is no data to initialize
1267 cdldefinablebody_cookie = CdlDefinableBody_Magic;
1268 CYGDBG_MEMLEAK_CONSTRUCTOR();
1270 CYG_POSTCONDITION_THISC();
1271 CYG_REPORT_RETURN();
1274 CdlDefinableBody::~CdlDefinableBody()
1276 CYG_REPORT_FUNCNAME("CdlDefinable:: destructor");
1277 CYG_REPORT_FUNCARG1XV(this);
1278 CYG_PRECONDITION_THISC();
1280 cdldefinablebody_cookie = CdlDefinableBody_Invalid;
1281 CYGDBG_MEMLEAK_DESTRUCTOR();
1283 CYG_REPORT_RETURN();
1286 // ----------------------------------------------------------------------------
1289 CdlDefinableBody::get_class_name() const
1291 CYG_REPORT_FUNCNAME("CdlDefinable::get_class_name");
1292 CYG_PRECONDITION_THISC();
1293 CYG_REPORT_RETURN();
1297 // ----------------------------------------------------------------------------
1300 CdlDefinableBody::check_this(cyg_assert_class_zeal zeal) const
1302 if (CdlDefinableBody_Magic != cdldefinablebody_cookie) {
1305 CYGDBG_MEMLEAK_CHECKTHIS();
1306 return CdlNodeBody::check_this(zeal);
1310 //{{{ add_property_parser() and check_properties()
1312 // ----------------------------------------------------------------------------
1315 CdlDefinableBody::add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers)
1317 CYG_REPORT_FUNCNAME("CdlDefinable::add_property_parsers");
1319 static CdlInterpreterCommandEntry commands[] =
1321 CdlInterpreterCommandEntry("no_define", &parse_no_define ),
1322 CdlInterpreterCommandEntry("define", &parse_define ),
1323 CdlInterpreterCommandEntry("define_format", &parse_define_format ),
1324 CdlInterpreterCommandEntry("define_proc", &parse_define_proc ),
1325 CdlInterpreterCommandEntry("if_define", &parse_if_define ),
1326 CdlInterpreterCommandEntry("", 0 )
1329 for (int i = 0; commands[i].command != 0; i++) {
1330 std::vector<CdlInterpreterCommandEntry>::const_iterator j;
1331 for (j = parsers.begin(); j != parsers.end(); j++) {
1332 if (commands[i].name == j->name) {
1333 if (commands[i].command != j->command) {
1334 CYG_FAIL("Property names are being re-used");
1339 if (j == parsers.end()) {
1340 parsers.push_back(commands[i]);
1343 CdlNodeBody::add_property_parsers(parsers);
1345 CYG_REPORT_RETURN();
1349 CdlDefinableBody::check_properties(CdlInterpreter interp)
1351 CYG_REPORT_FUNCNAME("CdlDefinable::check_properties");
1352 CYG_REPORT_FUNCARG2XV(this, interp);
1353 CYG_PRECONDITION_THISC();
1354 CYG_PRECONDITION_CLASSC(interp);
1356 // There should be at most one each of no_define and define_format.
1357 if (count_properties(CdlPropertyId_NoDefine) > 1) {
1358 CdlParse::report_error(interp, "", "There should be at most one no_define property.");
1360 if (count_properties(CdlPropertyId_DefineFormat) > 1) {
1361 CdlParse::report_error(interp, "", "There should be at most one define_format property.");
1363 if (has_property(CdlPropertyId_NoDefine) && has_property(CdlPropertyId_DefineFormat)) {
1364 CdlParse::report_error(interp, "", "The no_define and define_format properties are mutually exclusive.");
1366 // FIXME: the define_format property only makes sense for certain
1367 // flavors. However the flavor property may not have been processed yet.
1369 CdlNodeBody::check_properties(interp);
1371 CYG_REPORT_RETURN();
1375 //{{{ Definable properties
1377 // ----------------------------------------------------------------------------
1378 // Syntax: no_define
1380 CdlDefinableBody::parse_no_define(CdlInterpreter interp, int argc, const char* argv[])
1382 CYG_REPORT_FUNCNAMETYPE("parse_no_define", "result %d");
1384 int result = CdlParse::parse_minimal_property(interp, argc, argv, CdlPropertyId_NoDefine, 0, 0);
1386 CYG_REPORT_RETVAL(result);
1390 // ----------------------------------------------------------------------------
1391 // syntax: define <symbol>
1393 // The argument to "define" should be a valid C preprocessor symbol.
1395 parse_define_final_check(CdlInterpreter interp, CdlProperty_String prop)
1397 CYG_REPORT_FUNCNAME("parse_define_final_check");
1398 CYG_PRECONDITION_CLASSC(prop);
1399 CYG_PRECONDITION_CLASSC(interp);
1401 const std::string& str = prop->get_string();
1403 if (!Cdl::is_valid_c_preprocessor_symbol(str)) {
1404 CdlParse::report_property_parse_error(interp, prop, str + " is not a valid C preprocessor symbol");
1407 // There may be a file option. At this stage the only valid filename
1408 // that can be used here is system.h
1409 std::string file_option = prop->get_option("file");
1410 if (("" != file_option) && ("system.h" != file_option)) {
1411 CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
1414 // FIXME: validate the format string
1416 CYG_REPORT_RETURN();
1420 CdlDefinableBody::parse_define(CdlInterpreter interp, int argc, const char* argv[])
1422 CYG_REPORT_FUNCNAMETYPE("parse_define", "result %d");
1424 static char* options[] = {
1429 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_Define, options, &parse_define_final_check);
1431 CYG_REPORT_RETVAL(result);
1436 // ----------------------------------------------------------------------------
1437 // syntax: define_format <string>
1439 // FIXME: it is possible to apply some checks to the string, e.g. that there
1440 // is only one conversion operation.
1442 // FIXME: also check that the flavor is sensible, define_format has no effect
1445 // FIXME: enforce mutual exclusion with no_define
1448 CdlDefinableBody::parse_define_format(CdlInterpreter interp, int argc, const char* argv[])
1450 CYG_REPORT_FUNCNAMETYPE("parse_format", "result %d");
1452 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_DefineFormat, 0, 0);
1454 CYG_REPORT_RETVAL(result);
1457 // ----------------------------------------------------------------------------
1458 // syntax: define_proc <tclcode>
1460 CdlDefinableBody::parse_define_proc(CdlInterpreter interp, int argc, const char* argv[])
1462 CYG_REPORT_FUNCNAMETYPE("parse_define_proc", "result %d");
1464 int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_DefineProc, 0, 0);
1466 CYG_REPORT_RETVAL(result);
1470 // ----------------------------------------------------------------------------
1471 // Syntax: if_define sym1 sym2
1474 parse_if_define_final_check(CdlInterpreter interp, CdlProperty_StringVector prop)
1476 CYG_REPORT_FUNCNAME("parse_if_define_final_check");
1477 CYG_PRECONDITION_CLASSC(interp);
1478 CYG_PRECONDITION_CLASSC(prop);
1480 // There should be exactly two entries in the vector, and both of them should be
1481 // valid preprocessor symbols.
1482 const std::vector<std::string>& strings = prop->get_strings();
1484 if (2 != strings.size()) {
1485 CdlParse::report_property_parse_error(interp, prop, "There should be exactly two arguments.");
1487 if (!Cdl::is_valid_c_preprocessor_symbol(strings[0])) {
1488 CdlParse::report_property_parse_error(interp, prop, strings[0] + " is not a valid C preprocessor symbol.");
1490 if (!Cdl::is_valid_c_preprocessor_symbol(strings[1])) {
1491 CdlParse::report_property_parse_error(interp, prop, strings[1] + " is not a valid C preprocessor symbol.");
1494 // There may be a file option. At this stage the only valid filename
1495 // that can be used here is system.h
1496 std::string file_option = prop->get_option("file");
1497 if (("" != file_option) && ("system.h" != file_option)) {
1498 CdlParse::report_property_parse_error(interp, prop, "Invalid -file option " + file_option);
1503 CdlDefinableBody::parse_if_define(CdlInterpreter interp, int argc, const char* argv[])
1505 CYG_REPORT_FUNCNAMETYPE("parse_if_define", "result %d");
1511 int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_IfDefine, options,
1512 &parse_if_define_final_check, false);
1514 CYG_REPORT_RETVAL(result);
1519 //{{{ generate_config_header()
1521 // ----------------------------------------------------------------------------
1522 // This code needs to allow for the following properties.
1524 // 1) no_define. This suppresses the default #define generation.
1526 // 2) define_format <format_string.
1528 // 3) define [-file <filename>][-format <format_string>] symbol
1535 CdlDefinableBody::generate_config_header(Tcl_Channel this_hdr, Tcl_Channel system_h) const
1537 CYG_REPORT_FUNCNAME("CdlDefinable::generate_config_header");
1538 CYG_REPORT_FUNCARG1XV(this);
1539 CYG_PRECONDITION_THISC();
1541 CdlLoadable loadable = get_owner();
1542 CdlInterpreter interp = loadable->get_interpreter();
1544 // This definable is known to be active. However it may or may not be enabled.
1545 CYG_PRECONDITIONC(is_active());
1547 std::string name = get_name();
1548 CdlValueFlavor flavor = CdlValueFlavor_Bool;
1549 std::string value = "1";
1550 CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(this);
1551 if (0 != valuable) {
1552 // It is always possible to check the enabled() flag.
1553 if (!valuable->is_enabled()) {
1554 CYG_REPORT_RETURN();
1557 // The value is only valid for BoolData and Data flavors, and may
1558 // not have been provided. If there is no value then this option
1559 // should not generate a #define
1560 flavor = valuable->get_flavor();
1561 if ((CdlValueFlavor_BoolData == flavor) || (CdlValueFlavor_Data == flavor)) {
1562 value = valuable->get_value();
1566 // Flavor and value are now both set to sensible strings.
1567 // First, check the no_define property. If this is present then the default
1568 // #define generation should be suppressed.
1569 if (!has_property(CdlPropertyId_NoDefine)) {
1571 // OK, it is necessary to generate at least one #define.
1572 // If this node is actually a loadable then the #define should go
1573 // into system.h, otherwise into the current header
1574 Tcl_Channel chan = this_hdr;
1575 if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
1579 // For flavors None and Bool, there should be just one #define
1580 if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
1581 std::string define = "#define " + name + " 1\n";
1582 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1584 // If there is a format string then that controls the default
1586 if (!has_property(CdlPropertyId_DefineFormat)) {
1587 std::string define = "#define " + name + " " + value + "\n";
1588 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1590 CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(get_property(CdlPropertyId_DefineFormat));
1591 CYG_ASSERT_CLASSC(strprop);
1592 std::string format = strprop->get_string();
1593 std::string cmd = "return \"#define " + name + " [format " + format + " " + value + "]\n\"";
1595 if (TCL_OK != interp->eval(cmd, define)) {
1596 throw CdlInputOutputException("Internal error executing tcl fragment to process define_format property");
1598 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1601 // There may also be a separate #define of the form <name>_<value>,
1602 // if that is a valid preprocessor symbol.
1603 std::string tmp = name + "_" + value;
1604 if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
1605 tmp = "#define "+ tmp + "\n";
1606 Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
1609 // For loadables, add additional version information to system_h
1610 if (dynamic_cast<CdlConstLoadable>((CdlConstNode)this) == loadable) {
1611 system_h_add_package_versioning(system_h, name, value);
1616 // Next, check for any additional define properties
1617 std::vector<CdlProperty> define_props;
1618 get_properties(CdlPropertyId_Define, define_props);
1619 std::vector<CdlProperty>::const_iterator prop_i;
1620 for (prop_i = define_props.begin(); prop_i != define_props.end(); prop_i++) {
1621 CdlProperty_String strprop = dynamic_cast<CdlProperty_String>(*prop_i);
1622 CYG_ASSERT_CLASSC(strprop);
1623 std::string symbol = strprop->get_string();
1625 std::string file = strprop->get_option("file");
1626 Tcl_Channel chan = this_hdr;
1627 if (("" != file) && ("system.h" == file)) {
1631 if ((CdlValueFlavor_None == flavor) || (CdlValueFlavor_Bool == flavor)) {
1632 std::string define = "#define " + symbol + " 1\n";
1633 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1635 std::string format = strprop->get_option("format");
1637 std::string define = "#define " + symbol + " " + value + "\n";
1638 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1640 std::string cmd = "return \"#define " + symbol + " [format " + format + " " + value + "]\n\"";
1642 if (TCL_OK != interp->eval(cmd, define)) {
1643 throw CdlInputOutputException("Internal error executing tcl fragment to process format option");
1645 Tcl_Write(chan, const_cast<char*>(define.c_str()), -1);
1648 std::string tmp = symbol + "_" + value;
1649 if (Cdl::is_valid_c_preprocessor_symbol(tmp)) {
1650 tmp = "#define " + tmp + "\n";
1651 Tcl_Write(chan, const_cast<char*>(tmp.c_str()), -1);
1656 // Now check for if_define properties
1657 std::vector<CdlProperty> if_define_props;
1658 get_properties(CdlPropertyId_IfDefine, if_define_props);
1659 for (prop_i = if_define_props.begin(); prop_i != if_define_props.end(); prop_i++) {
1660 CdlProperty_StringVector strprop = dynamic_cast<CdlProperty_StringVector>(*prop_i);
1661 CYG_ASSERT_CLASSC(strprop);
1662 CYG_ASSERTC(2 == strprop->get_number_of_strings());
1664 std::string sym1 = strprop->get_string(0);
1665 std::string sym2 = strprop->get_string(1);
1667 Tcl_Channel chan = this_hdr;
1668 std::string file = strprop->get_option("file");
1669 if (("" != file) && ("system.h" == file)) {
1672 std::string data = "#ifdef " + sym1 + "\n# define " + sym2 + " 1\n#endif\n";
1673 Tcl_Write(chan, const_cast<char*>(data.c_str()), -1);
1676 // And define_proc properties
1677 std::vector<CdlProperty> define_proc_props;
1678 get_properties(CdlPropertyId_DefineProc, define_proc_props);
1679 for (prop_i = define_proc_props.begin(); prop_i != define_proc_props.end(); prop_i++) {
1680 CdlProperty_TclCode codeprop = dynamic_cast<CdlProperty_TclCode>(*prop_i);
1681 CYG_ASSERT_CLASSC(codeprop);
1683 cdl_tcl_code code = codeprop->get_code();
1685 if (TCL_OK != interp->eval(code, result)) {
1686 throw CdlInputOutputException("Error evaluating define_proc property for " + name + "\n" + result);
1691 CYG_REPORT_RETURN();
1697 //{{{ CdlDefineLoadableBody
1701 // ----------------------------------------------------------------------------
1703 CdlDefineLoadableBody::CdlDefineLoadableBody()
1705 CYG_REPORT_FUNCNAME("CdlDefineLoadable:: default constructor");
1706 CYG_REPORT_FUNCARG1XV(this);
1708 cdldefineloadablebody_cookie = CdlDefineLoadableBody_Magic;
1709 CYGDBG_MEMLEAK_CONSTRUCTOR();
1711 CYG_POSTCONDITION_THISC();
1712 CYG_REPORT_RETURN();
1715 CdlDefineLoadableBody::~CdlDefineLoadableBody()
1717 CYG_REPORT_FUNCNAME("CdlDefineLoadable:: destructor");
1718 CYG_REPORT_FUNCARG1XV(this);
1719 CYG_PRECONDITION_THISC();
1721 cdldefineloadablebody_cookie = CdlDefineLoadableBody_Invalid;
1722 CYGDBG_MEMLEAK_DESTRUCTOR();
1724 CYG_REPORT_RETURN();
1727 // ----------------------------------------------------------------------------
1730 CdlDefineLoadableBody::get_class_name() const
1732 CYG_REPORT_FUNCNAME("CdlDefineLoadable::get_class_name");
1733 CYG_PRECONDITION_THISC();
1734 CYG_REPORT_RETURN();
1735 return "define_loadable";
1738 // ----------------------------------------------------------------------------
1741 CdlDefineLoadableBody::check_this(cyg_assert_class_zeal zeal) const
1743 if (CdlDefineLoadableBody_Magic != cdldefineloadablebody_cookie) {
1746 CYGDBG_MEMLEAK_CHECKTHIS();
1747 return CdlLoadableBody::check_this(zeal) && CdlNodeBody::check_this(zeal);
1751 //{{{ Property parsing
1753 // ----------------------------------------------------------------------------
1756 CdlDefineLoadableBody::add_property_parsers(std::vector<CdlInterpreterCommandEntry>& parsers)
1758 CYG_REPORT_FUNCNAME("CdlDefineLoadable::add_property_parsers");
1760 static CdlInterpreterCommandEntry commands[] =
1762 CdlInterpreterCommandEntry("define_header", &parse_define_header),
1763 CdlInterpreterCommandEntry("", 0 )
1766 for (int i = 0; commands[i].command != 0; i++) {
1767 std::vector<CdlInterpreterCommandEntry>::const_iterator j;
1768 for (j = parsers.begin(); j != parsers.end(); j++) {
1769 if (commands[i].name == j->name) {
1770 if (commands[i].command != j->command) {
1771 CYG_FAIL("Property names are being re-used");
1776 if (j == parsers.end()) {
1777 parsers.push_back(commands[i]);
1780 CdlNodeBody::add_property_parsers(parsers);
1782 CYG_REPORT_RETURN();
1786 CdlDefineLoadableBody::check_properties(CdlInterpreter interp)
1788 CYG_REPORT_FUNCNAME("CdlDefineLoadable::check_properties");
1789 CYG_REPORT_FUNCARG2XV(this, interp);
1790 CYG_PRECONDITION_THISC();
1791 CYG_PRECONDITION_CLASSC(interp);
1793 // There should be at most one define_header property
1794 int count = count_properties(CdlPropertyId_DefineHeader);
1796 CdlParse::report_error(interp, "", "There should be at most one define_header property.");
1798 // FIXME: filename validation
1800 CdlNodeBody::check_properties(interp);
1802 CYG_REPORT_RETURN();
1805 // ----------------------------------------------------------------------------
1806 // syntax: define_header <header file name>
1808 CdlDefineLoadableBody::parse_define_header(CdlInterpreter interp, int argc, const char* argv[])
1810 CYG_REPORT_FUNCNAMETYPE("parse_define_header", "result %d");
1812 int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_DefineHeader, 0, 0);
1814 CYG_REPORT_RETVAL(result);
1819 //{{{ generate_config_header()
1821 // ----------------------------------------------------------------------------
1823 CdlDefineLoadableBody::generate_config_header(Tcl_Channel this_hdr, Tcl_Channel system_h) const
1825 CYG_REPORT_FUNCNAME("CdlDefineLoadable::generate_config_header");
1826 CYG_REPORT_FUNCARG1XV(this);
1827 CYG_PRECONDITION_THISC();
1829 CdlInterpreter interp = get_interpreter();
1830 Tcl_RegisterChannel(interp->get_tcl_interpreter(), this_hdr);
1831 Tcl_RegisterChannel(interp->get_tcl_interpreter(), system_h);
1833 CdlInterpreterBody::ContextSupport(interp, std::string("Package ") + this->get_name() + ", header file generation");
1836 interp->set_variable("::cdl_header", Tcl_GetChannelName(this_hdr));
1837 interp->set_variable("::cdl_system_header", Tcl_GetChannelName(system_h));
1839 const std::vector<CdlNode>& contents = get_owned();
1840 std::vector<CdlNode>::const_iterator node_i;
1841 for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
1842 CdlDefinable definable = dynamic_cast<CdlDefinable>(*node_i);
1843 if (0 == definable) {
1846 if (!definable->is_active()) {
1849 definable->generate_config_header(this_hdr, system_h);
1852 interp->unset_variable("::cdl_header");
1853 interp->unset_variable("::cdl_system_header");
1855 Tcl_UnregisterChannel(interp->get_tcl_interpreter(), this_hdr);
1856 Tcl_UnregisterChannel(interp->get_tcl_interpreter(), system_h);
1860 Tcl_UnregisterChannel(interp->get_tcl_interpreter(), this_hdr);
1861 Tcl_UnregisterChannel(interp->get_tcl_interpreter(), system_h);
1863 CYG_REPORT_RETURN();
1867 //{{{ get_config_headers()
1869 // ----------------------------------------------------------------------------
1870 // What header file should be generated for this loadable?
1872 // If there is a define_header property then this should be used.
1873 // Otherwise a filename is constructed from the loadable's name.
1876 CdlDefineLoadableBody::get_config_header() const
1878 CYG_REPORT_FUNCNAME("CdlDefineLoadable::get_config_headers");
1879 CYG_REPORT_FUNCARG1XV(this);
1880 CYG_PRECONDITION_THISC();
1882 std::string result = "";
1883 CdlProperty prop = get_property(CdlPropertyId_DefineHeader);
1885 CdlProperty_String string_prop = dynamic_cast<CdlProperty_String>(prop);
1886 CYG_ASSERT_CLASSC(string_prop);
1887 result = string_prop->get_string();
1889 std::string tmp = get_name();
1890 result = Cdl::get_short_form(tmp);
1893 CYG_REPORT_RETURN();
1902 //{{{ CdlToplevel::get_build_info()
1904 // ----------------------------------------------------------------------------
1905 // Essentially this code involves iterating over the loadables vector,
1906 // looking for BuildLoadables and invoking their update_build_info()
1907 // member function. In addition, if there is currently some data in
1908 // the build_info vector (probably from a previous call) then that
1912 CdlToplevelBody::get_build_info(CdlBuildInfo& build_info)
1914 CYG_REPORT_FUNCNAME("CdlToplevel::get_build_info");
1915 CYG_REPORT_FUNCARG2XV(this, &build_info);
1916 CYG_PRECONDITION_THISC();
1918 if (0 != build_info.entries.size()) {
1919 build_info.entries.clear();
1922 const std::vector<CdlLoadable>& loadables = get_loadables();
1923 std::vector<CdlLoadable>::const_iterator load_i;
1924 for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
1925 CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
1927 bl->update_build_info(build_info);
1931 CYG_REPORT_RETURN();
1935 //{{{ CdlToplevel::get_all_build_info()
1937 // ----------------------------------------------------------------------------
1938 // This is just like get_build_info(), but calls a different
1939 // BuildLoadable member.
1942 CdlToplevelBody::get_all_build_info(CdlBuildInfo& build_info)
1944 CYG_REPORT_FUNCNAME("CdlToplevel::get_all_build_info");
1945 CYG_REPORT_FUNCARG2XV(this, &build_info);
1946 CYG_PRECONDITION_THISC();
1948 if (0 != build_info.entries.size()) {
1949 build_info.entries.clear();
1952 const std::vector<CdlLoadable>& loadables = get_loadables();
1953 std::vector<CdlLoadable>::const_iterator load_i;
1954 for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
1955 CdlConstBuildLoadable bl = dynamic_cast<CdlConstBuildLoadable>(*load_i);
1957 bl->update_all_build_info(build_info);
1961 CYG_REPORT_RETURN();
1965 //{{{ CdlToplevel::generate_config_headers()
1967 // ----------------------------------------------------------------------------
1968 // Generating the config headers. This involves the following steps:
1970 // 1) for every DefineLoadable, find out what header file should
1971 // be generated. Note that some loadables may share a header file.
1973 // 2) create a temporary version of system.h. Note that it is not
1974 // a good idea to just overwrite an existing system.h, chances
1975 // are pretty good that the file will not have changed, and
1976 // updating it unnecessarily will result in unnecessary rebuilds
1977 // due to header file dependencies.
1979 // 3) for each file that should be generated, create a temporary
1980 // version and allow all applicable loadables to update it.
1982 // A utility to compare two files and do the right thing.
1983 // This requires some simple Tcl code.
1985 compare_and_copy(CdlInterpreter interp, std::string file1, std::string file2)
1987 CYG_REPORT_FUNCNAME("compare_and_copy");
1988 CYG_PRECONDITION_CLASSC(interp);
1989 CYG_PRECONDITIONC("" != file1);
1990 CYG_PRECONDITIONC("" != file2);
1991 CYG_PRECONDITIONC(file1 != file2);
1993 static char compare_and_copy_script[] = "\
1994 if {[file exists \"$::cdl_compare_and_copy_file2\"] == 0} { \n\
1995 catch { file rename -- $::cdl_compare_and_copy_file1 $::cdl_compare_and_copy_file2} \n\
1998 set fd [open \"$::cdl_compare_and_copy_file1\" r] \n\
1999 set data1 [read $fd] \n\
2001 set fd [open \"$::cdl_compare_and_copy_file2\" r] \n\
2002 set data2 [read $fd] \n\
2004 if {$data1 == $data2} { \n\
2005 file delete \"$::cdl_compare_and_copy_file1\" \n\
2007 catch { file rename -force -- $::cdl_compare_and_copy_file1 $::cdl_compare_and_copy_file2 } \n\
2011 interp->set_variable("::cdl_compare_and_copy_file1", file1);
2012 interp->set_variable("::cdl_compare_and_copy_file2", file2);
2013 std::string tcl_result;
2014 if (TCL_OK != interp->eval(compare_and_copy_script, tcl_result)) {
2015 throw CdlInputOutputException("internal error manipulating temporary header " + file1 + " and target " + file2 +
2021 CdlToplevelBody::generate_config_headers(std::string directory)
2023 CYG_REPORT_FUNCNAME("CdlToplevel::generate_config_headers");
2024 CYG_REPORT_FUNCARG1XV(this);
2025 CYG_PRECONDITION_THISC();
2026 CYG_ASSERTC("" != directory);
2028 // Replace any backslashes in the path with forward slashes. The
2029 // latter are used throughout the library
2030 // NOTE: this is not i18n-friendly.
2031 for (unsigned int i = 0; i < directory.size(); i++) {
2032 if ('\\' == directory[i]) {
2037 CdlInterpreter interp = get_interpreter();
2038 std::string tcl_result;
2039 if ((TCL_OK != interp->eval("file isdirectory \"" + directory + "\"", tcl_result)) ||
2040 (tcl_result != "1")) {
2041 throw CdlInputOutputException("target " + directory + " is not a valid existing directory.");
2044 std::vector<std::pair<CdlDefineLoadable, std::string> > headers;
2045 const std::vector<CdlLoadable>& loadables = get_loadables();
2046 std::vector<CdlLoadable>::const_iterator load_i;
2047 for (load_i = loadables.begin(); load_i != loadables.end(); load_i++) {
2048 CdlDefineLoadable tmp = dynamic_cast<CdlDefineLoadable>(*load_i);
2050 std::string hdr = tmp->get_config_header();
2051 headers.push_back(std::make_pair(tmp, hdr));
2055 static char banner_format[] =
2056 "#ifndef CYGONCE_PKGCONF_%s\n\
2057 #define CYGONCE_PKGCONF_%s\n\
2059 * File <pkgconf/%s>\n\
2061 * This file is generated automatically by the configuration\n\
2062 * system. It should not be edited. Any changes to this file\n\
2063 * may be overwritten.\n\
2067 // Create three channels which Tcl will use for standard streams
2068 // if these streams do not already exist. This avoids a Tcl
2069 // problem which can prevent closure of system.h. (FIXME)
2070 Tcl_Channel stdin_chan = Tcl_OpenFileChannel(interp->get_tcl_interpreter(), "nul", "w", 0666);
2071 Tcl_Channel stdout_chan = Tcl_OpenFileChannel(interp->get_tcl_interpreter(), "nul", "w", 0666);
2072 Tcl_Channel stderr_chan = Tcl_OpenFileChannel(interp->get_tcl_interpreter(), "nul", "w", 0666);
2073 Tcl_RegisterChannel(0, stdin_chan);
2074 Tcl_RegisterChannel(0, stdout_chan);
2075 Tcl_RegisterChannel(0, stderr_chan);
2077 // Assume for now that files __libcdl_file1 and __libcdl_file2 are
2078 // legal on all platforms of interest, and that nobody is going to
2080 std::string system_h_name = directory + "/__libcdl_file1";
2081 Tcl_Channel system_h = Tcl_OpenFileChannel(interp->get_tcl_interpreter(),
2082 const_cast<char*>(system_h_name.c_str()), "w", 0666);
2083 if (0 == system_h) {
2084 throw CdlInputOutputException("Unable to open file " + system_h_name + "\n" +
2085 interp->get_result());
2087 // The channel will be registered and unregistered in several
2088 // different interpreters. This call prevents the channel from
2089 // disappearing prematurely.
2090 Tcl_RegisterChannel(0, system_h);
2092 // Make sure that this operation is undone if necessary.
2094 // Now fill in system.h with the appropriate data. Start with the banner.
2095 char local_buf[512];
2096 sprintf(local_buf, banner_format, "SYSTEM_H", "SYSTEM_H", "system.h");
2097 Tcl_Write(system_h, local_buf, -1);
2099 // Add generic version information
2100 system_h_add_version_header(system_h);
2102 // The rest of system.h will be filled in by the following loop.
2104 // Walk down the previously constructed headers vector, create
2105 // appropriate files, and let each DefineLoadable fill in the
2107 std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator outer_i;
2108 std::vector<std::pair<CdlDefineLoadable, std::string> >::iterator inner_i;
2109 for (outer_i = headers.begin(); outer_i != headers.end(); outer_i++) {
2110 if ("" == outer_i->second) {
2113 std::string target_name = outer_i->second;
2114 std::string header_name = directory + "/__libcdl_file2";
2115 Tcl_Channel header_h = Tcl_OpenFileChannel(interp->get_tcl_interpreter(),
2116 const_cast<char*>(header_name.c_str()), "w", 0666);
2117 if (0 == header_h) {
2118 throw CdlInputOutputException("Unable to open file " + header_name + "\n" +
2119 interp->get_result());
2121 // The channel may be used in several different interpreters, so
2122 // do an extra register operation
2123 Tcl_RegisterChannel(0, header_h);
2126 // Output the banner. This requires an all-upper-case version of the
2128 std::string upper_case;
2129 for (unsigned int i = 0; i < target_name.size(); i++) {
2130 if (islower(target_name[i])) {
2131 upper_case += toupper(target_name[i]);
2132 } else if ('.' == target_name[i]) {
2135 upper_case += target_name[i];
2138 sprintf(local_buf, banner_format, upper_case.c_str(), upper_case.c_str(), target_name.c_str());
2139 Tcl_Write(header_h, local_buf, -1);
2141 // Now iterate over all the loadables looking for ones which
2142 // should generate #define's for this header, and invoke the
2143 // appropriate member function.
2144 for (inner_i = outer_i; inner_i != headers.end(); inner_i++) {
2145 if (inner_i->second == target_name) {
2146 inner_i->first->generate_config_header(header_h, system_h);
2147 inner_i->second = "";
2151 // The header file has now been updated. Close it and decide whether
2152 // or not to replace the old version
2153 Tcl_Write(header_h, "\n#endif\n", -1);
2155 Tcl_UnregisterChannel(0, header_h);
2158 Tcl_UnregisterChannel(0, header_h);
2159 compare_and_copy(interp, header_name, directory + "/" + target_name);
2162 Tcl_Write(system_h, "\n#endif\n", -1);
2164 Tcl_UnregisterChannel(0, system_h);
2168 // This call to UnregisterChannel automatically closes the
2169 // channel, there is no need for an explicit Tcl_Close() call.
2170 Tcl_UnregisterChannel(0, system_h);
2172 Tcl_UnregisterChannel(0, stderr_chan);
2173 Tcl_UnregisterChannel(0, stdout_chan);
2174 Tcl_UnregisterChannel(0, stdin_chan);
2176 compare_and_copy(interp, system_h_name, directory +"/system.h");
2180 //{{{ CdlToplevel::get_config_headers()
2182 // ----------------------------------------------------------------------------
2183 // Return details of the header files that should be generated. This
2184 // allows higher-level code to detect files that should no longer
2185 // be present, amongst other uses.
2187 // The main complication is that some packages may wish to share the
2188 // same header file, especially hardware packages.
2191 CdlToplevelBody::get_config_headers(std::vector<std::string>& headers)
2193 CYG_REPORT_FUNCNAME("CdlToplevelBody::get_config_headers");
2194 CYG_REPORT_FUNCARG2XV(this, &headers);
2195 CYG_PRECONDITION_THISC();
2197 // Allow the vector argument to be re-used in multiple calls.
2198 // Strictly speaking this is better done at the application
2199 // level, but the behaviour is consistent with get_build_info();
2202 // There will always be a system.h header file with details
2203 // of the loadables.
2204 // FIXME: the name of this file should probably be controllable
2205 headers.push_back("system.h");
2207 // Now check each loadable and adds its header file, assuming
2209 const std::vector<CdlLoadable>& loadables = get_loadables();
2210 std::vector<CdlLoadable>::const_iterator i;
2211 for (i = loadables.begin(); i != loadables.end(); i++) {
2212 CdlDefineLoadable current = dynamic_cast<CdlDefineLoadable>(*i);
2214 std::string its_file = current->get_config_header();
2215 CYG_LOOP_INVARIANTC("" != its_file);
2216 if (std::find(headers.begin(), headers.end(), its_file) == headers.end()) {
2217 headers.push_back(its_file);
2222 CYG_REPORT_RETURN();
2226 //{{{ CdlToplevel::generate_build_tree()
2229 CdlToplevelBody::generate_build_tree(std::string build_tree, std::string install_tree)