⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 build.cxx

📁 移植到WLIT项目的redboot源代码
💻 CXX
📖 第 1 页 / 共 5 页
字号:
    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.");            }        }    }        std::string data    = prop->get_string();    std::string target;    std::string deps;    std::string rules;    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);    }}intCdlBuildableBody::parse_make(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_make", "result %d");    static 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;}// ----------------------------------------------------------------------------// syntax: make_object <target> <rules>//// The rules here are much the same as for the "make" property.static voidparse_make_object_final_check(CdlInterpreter interp, CdlProperty_String prop){    CYG_REPORT_FUNCNAME("parse_make_object_final_check");    CYG_PRECONDITION_CLASSC(interp);    CYG_PRECONDITION_CLASSC(prop);    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.");            }        }    }        std::string data    = prop->get_string();    std::string target;    std::string deps;    std::string rules;    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);    }}intCdlBuildableBody::parse_make_object(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_make_object", "result %d");    static char* options[] = {        "library:",        "priority:",        0    };    int result = CdlParse::parse_string_property(interp, argc, argv, CdlPropertyId_MakeObject, options,                                                 &parse_make_object_final_check);        CYG_REPORT_RETVAL(result);    return result;}// ----------------------------------------------------------------------------// Syntax: object <file1> <file2> ...intCdlBuildableBody::parse_object(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_object", "result %d");    static char* options[] = {        "library:",        0    };    int result = CdlParse::parse_stringvector_property(interp, argc, argv, CdlPropertyId_Object, options, 0, true);        CYG_REPORT_RETVAL(result);    return result;}// ----------------------------------------------------------------------------// Syntax: build_proc { tcl code }intCdlBuildableBody::parse_build_proc(CdlInterpreter interp, int argc, char** argv){    CYG_REPORT_FUNCNAMETYPE("parse_build_proc", "result %d");    int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_BuildProc, 0, 0);    CYG_REPORT_RETVAL(result);    return result;}//}}}//{{{  update_build_info()              // ----------------------------------------------------------------------------// Most of the work is done in update_all_build_info(). The update_build_info()// merely checks the active and enabled state first.voidCdlBuildableBody::update_build_info(CdlBuildInfo_Loadable& build_info, std::string library) const{    CYG_REPORT_FUNCNAME("CdlBuildable::update_build_info");    CYG_REPORT_FUNCARG2XV(this, &build_info);    CYG_PRECONDITION_THISC();    CYG_PRECONDITIONC("" != library);    if (!is_active()) {        CYG_REPORT_RETURN();        return;    }    CdlConstValuable valuable = dynamic_cast<CdlConstValuable>(this);    if (0 != valuable) {        if (!valuable->is_enabled()) {            CYG_REPORT_RETURN();            return;        }    }    update_all_build_info(build_info, library);        CYG_REPORT_RETURN();}//}}}//{{{  update_all_build_info()          // ----------------------------------------------------------------------------// There are four properties to be considered, each of which may occur// multiple times: "compile", "object", "make_object", and "make".// Each of these will result in separate additions to the build_info// structure.voidCdlBuildableBody::update_all_build_info(CdlBuildInfo_Loadable& build_info, std::string package_library) const{    CYG_REPORT_FUNCNAME("CdlBuildable::update_all_build_info");    CYG_REPORT_FUNCARG2XV(this, &build_info);    CYG_PRECONDITION_THISC();    CYG_PRECONDITIONC("" != package_library);    // Get some information about the owning loadable first.    CdlLoadable loadable        = get_owner();    CYG_ASSERT_CLASSC(loadable);    std::string directory       = loadable->get_directory();    CYG_ASSERTC("" != directory);    CdlInterpreter interp       = loadable->get_interpreter();    CYG_ASSERT_CLASSC(interp);    // The interpreter needs some information about the locations    // of various things. This code has to be kept in step with    // CdlLoadable::find_relative_file()    interp->set_variable("::cdl_topdir", get_toplevel()->get_directory());    interp->set_variable("::cdl_pkgdir", directory);    // For many packages the sources will reside in a src subdirectory.    // For simple packages the sources may live directly at the toplevel    bool has_src_subdir    = loadable->has_subdirectory("src");    // NOTE: the object property is not yet supported    std::vector<CdlProperty> compile_properties;    get_properties(CdlPropertyId_Compile, compile_properties);    std::vector<CdlProperty> makeobject_properties;    get_properties(CdlPropertyId_MakeObject, makeobject_properties);    std::vector<CdlProperty> make_properties;    get_properties(CdlPropertyId_Make, make_properties);    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);            }        }    }    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);    }        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);    }        CYG_REPORT_RETURN();}//}}}//}}}//{{{  CdlBuildLoadableBody             //{{{  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";// The pattern that should be used to identify header files.// FIXME: this information should come out of a data filechar* CdlBuildLoadableBody::default_headers_glob_pattern = "*.h *.hxx *.inl *.si *.inc";//}}}//{{{  The simple stuff                         // ----------------------------------------------------------------------------CdlBuildLoadableBody::CdlBuildLoadableBody()    : CdlLoadableBody(){    CYG_REPORT_FUNCNAME("CdlBuildLoadable:: default constructor");    CYG_REPORT_FUNCARG1XV(this);    // There is no data to initialize    cdlbuildloadablebody_cookie = CdlBuildLoadableBody_Magic;    CYGDBG_MEMLEAK_CONSTRUCTOR();        CYG_POSTCONDITION_THISC();    CYG_REPORT_RETURN();}CdlBuildLoadableBody::~CdlBuildLoadableBody(){    CYG_REPORT_FUNCNAME("CdlBuildLoadable:: destructor");    CYG_REPORT_FUNCARG1XV(this);    CYG_PRECONDITION_THISC();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -