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

📄 cdl_exec.cxx

📁 ecos实时嵌入式操作系统
💻 CXX
📖 第 1 页 / 共 3 页
字号:
//####COPYRIGHTBEGIN####//                                                                          // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.// Copyright (C) 2003 John Dallaway//// This program 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) // 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 // 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., // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------//                                                                          //####COPYRIGHTEND####//==========================================================================////      cdl_exec.cxx////      The implementation of each ecosconfig command////==========================================================================//==========================================================================//#####DESCRIPTIONBEGIN####                                             //// Author(s):           jld// Date:                1999-11-08////####DESCRIPTIONEND####//==========================================================================#ifdef _MSC_VER#include <direct.h> /* for getcwd() */#else#include <unistd.h> /* for getcwd() */#endif#ifdef __CYGWIN__#include <windows.h>#include <sys/param.h>  /* for MAXPATHLEN */#include <sys/cygwin.h> /* for cygwin_conv_to_win32_path() */#endif#include "build.hxx"#include "cdl_exec.hxx"// ----------------------------------------------------------------------------bool cdl_exec::quiet            = false;bool cdl_exec::verbose          = false;bool cdl_exec::ignore_errors    = false;bool cdl_exec::no_updates       = false;bool cdl_exec::debug_level_set  = false;int  cdl_exec::debug_level      = 0;cdl_exec::cdl_exec (const std::string repository_arg, const std::string savefile_arg,                    const std::string install_arg, bool no_resolve_arg)    : repository(repository_arg),      savefile(savefile_arg),      install_prefix(install_arg),      no_resolve(no_resolve_arg),      pkgdata (NULL),      interp (NULL),      config (NULL){    // The inference callback does not actually do anything at present.    // In future it may be useful for diagnostic purposes.    CdlTransactionBody::set_inference_callback_fn (&inference_callback);        // Automatic inference is always disabled. The inference engine    // only gets invoked explicitly, after a suitable transaction callback    // has been invoked. The problem here is that the transaction callback    // has to report changes made by the inference engine but there is    // no way of distinguishing between inferred values that come out of    // savefiles and inferred values determined by the inference engine.    CdlTransactionBody::disable_automatic_inference ();}voidcdl_exec::set_quiet_mode(bool new_val){    quiet = new_val;}voidcdl_exec::set_verbose_mode(bool new_val){    verbose = new_val;    CdlPackagesDatabaseBody::set_verbose(new_val);}voidcdl_exec::set_ignore_errors_mode(bool new_val){    ignore_errors = new_val;}voidcdl_exec::set_no_updates_mode(bool new_val){    no_updates = new_val;}voidcdl_exec::set_debug_level(int new_level){    debug_level_set = true;    debug_level = new_level;}// ----------------------------------------------------------------------------voidcdl_exec::init(bool load_config){    pkgdata = CdlPackagesDatabaseBody::make(repository, &diagnostic_handler, &diagnostic_handler);    interp  = CdlInterpreterBody::make();    if (load_config) {        config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);    }}// ----------------------------------------------------------------------------voidcdl_exec::delete_cdl_data (){    if (0 != config) {        delete config;        config = 0;    }    if (0 != interp) {        delete interp;        interp = 0;    }    if (0 != pkgdata) {        delete pkgdata;        pkgdata = 0;    }}// ----------------------------------------------------------------------------bool cdl_exec::cmd_new (const std::string cdl_hardware,                        const std::string cdl_template /* = "default" */,                        const std::string cdl_version /* = "" */){    bool status = false;    try {        init(false);                config = CdlConfigurationBody::make ("eCos", pkgdata, interp);        // The hardware and template should be loaded in a single transaction.        // Validating the target name etc. can be left to libcdl.        CdlLocalTransaction transact(config);        config->set_hardware(transact.get(), resolve_hardware_alias(cdl_hardware), &diagnostic_handler, &diagnostic_handler);        config->set_template(transact.get(), cdl_template, cdl_version, &diagnostic_handler, &diagnostic_handler);        transact.body();        transact.destroy();        if (debug_level_set) {            this->update_debug_level();        }                // Unless inference has been suppressed, make sure that the        // inference engine gets invoked and that its results get        // reported.        if (!no_resolve) {            CdlTransactionBody::set_callback_fn(&transaction_callback);            config->resolve_all_conflicts();        }        // Now report any conflicts which the inference engine could not report.         report_conflicts();        // A savefile should be generated/updated even if there are conflicts.        // Otherwise the user does not have a chance to edit the savefile        // and fix things.        if (!no_updates) {            config->save (savefile);        }        if (ignore_errors || (0 == config->get_all_conflicts().size())) {            status = true;        }    } catch (CdlStringException exception) {        exception_handler (exception);    } catch (...) {        exception_handler ();    }    delete_cdl_data ();    return status;}// ----------------------------------------------------------------------------boolcdl_exec::cmd_target (const std::string cdl_target){    bool status = false;    try {        init(true);        config->set_hardware (resolve_hardware_alias (cdl_target), &diagnostic_handler, &diagnostic_handler);        if (debug_level_set) {            this->update_debug_level();        }        if (!no_resolve) {            CdlTransactionBody::set_callback_fn(&transaction_callback);            config->resolve_all_conflicts();        }        report_conflicts();        if (!no_updates) {            config->save (savefile);        }        if (ignore_errors || (0 == config->get_all_conflicts().size())) {            status = true;        }    } catch (CdlStringException exception) {        exception_handler (exception);    } catch (...) {        exception_handler ();    }    delete_cdl_data ();    return status;}// ----------------------------------------------------------------------------boolcdl_exec::cmd_template (const std::string cdl_template, const std::string cdl_version /* = "" */){    bool status = false;    try {        init(true);        config->set_template (cdl_template, cdl_version, &diagnostic_handler, &diagnostic_handler);        if (debug_level_set) {            this->update_debug_level();        }        if (!no_resolve) {            CdlTransactionBody::set_callback_fn(&transaction_callback);            config->resolve_all_conflicts();        }        report_conflicts();        if (!no_updates) {            config->save (savefile);        }        if (ignore_errors || (0 == config->get_all_conflicts().size())) {            status = true;        }    } catch (CdlStringException exception) {        exception_handler (exception);    } catch (...) {        exception_handler ();    }    delete_cdl_data ();    return status;}// ----------------------------------------------------------------------------boolcdl_exec::cmd_export (const std::string cdl_savefile){    bool status = false;    try {        init(true);        if (debug_level_set) {            this->update_debug_level();        }        if (!no_resolve) {            CdlTransactionBody::set_callback_fn(&transaction_callback);            config->resolve_all_conflicts();        }        report_conflicts();        // Exporting to another file should only happen if the        // configuration is conflict-free. This is different from        // updating the savefile.        if (ignore_errors || (0 == config->get_all_conflicts().size())) {            if (!no_updates) {                config->save (cdl_savefile, /* minimal = */ true);            }            status = true;        }    } catch (CdlStringException exception) {        exception_handler (exception);    } catch (...) {        exception_handler ();    }    delete_cdl_data ();    return status;}// ----------------------------------------------------------------------------boolcdl_exec::cmd_import (const std::string cdl_savefile){    bool status = false;    try {        init(true);        config->add(cdl_savefile, &diagnostic_handler, &diagnostic_handler);        if (debug_level_set) {            this->update_debug_level();        }        if (!no_resolve) {            CdlTransactionBody::set_callback_fn(&transaction_callback);            config->resolve_all_conflicts();        }        report_conflicts();        if (!no_updates) {            config->save (savefile);        }

⌨️ 快捷键说明

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