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

📄 cdl_exec.cxx

📁 eCos1.31版
💻 CXX
📖 第 1 页 / 共 2 页
字号:
//####COPYRIGHTBEGIN####//                                                                          // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// 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 <sys/cygwin.h> /* for cygwin_conv_to_win32_path() */#endif#include "build.hxx"#include "cdl_exec.hxx"cdl_exec::cdl_exec (const std::string repository_tree, const std::string savefile_name, const std::string install_tree, bool no_resolve) :	pkgdata (NULL),	interp (NULL),	config (NULL) {	repository = repository_tree;	savefile = savefile_name;	install_prefix = install_tree;	CdlTransactionBody::set_inference_callback_fn (&inference_callback);	if (no_resolve) {		CdlTransactionBody::disable_automatic_inference ();	}}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 {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::make ("eCos", pkgdata, interp);		config->set_hardware (resolve_hardware_alias (cdl_hardware), &diagnostic_handler, &diagnostic_handler);		if (pkgdata->is_known_template (cdl_template) && ! cdl_version.empty ()) {			const std::vector<std::string> & versions = pkgdata->get_template_versions (cdl_template);			if (versions.end () == std::find (versions.begin (), versions.end (), cdl_version)) {				throw CdlStringException ("Unknown version " + cdl_version);			}		}		config->set_template (cdl_template, cdl_version, &diagnostic_handler, &diagnostic_handler);		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_target (const std::string cdl_target) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		config->set_hardware (resolve_hardware_alias (cdl_target), &diagnostic_handler, &diagnostic_handler);		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_template (const std::string cdl_template, const std::string cdl_version /* = "" */) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		if (pkgdata->is_known_template (cdl_template) && ! cdl_version.empty ()) {			const std::vector<std::string> & versions = pkgdata->get_template_versions (cdl_template);			if (versions.end () == std::find (versions.begin (), versions.end (), cdl_version)) {				throw CdlStringException ("Unknown version " + cdl_version);			}		}		config->set_template (cdl_template, cdl_version, &diagnostic_handler, &diagnostic_handler);		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_export (const std::string cdl_savefile) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		config->save (cdl_savefile, /* minimal = */ true);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_import (const std::string cdl_savefile) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		config->add (cdl_savefile, &diagnostic_handler, &diagnostic_handler);		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_add (const std::vector<std::string> cdl_packages) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		for (unsigned int n = 0; n < cdl_packages.size (); n++) {			config->load_package (resolve_package_alias (cdl_packages [n]), "", &diagnostic_handler, &diagnostic_handler);		}		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_remove (const std::vector<std::string> cdl_packages) {	unsigned int n;	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		for (n = 0; n < cdl_packages.size (); n++) {			if (! config->lookup (resolve_package_alias (cdl_packages [n]))) {				throw CdlStringException ("Unknown package " + cdl_packages [n]);			}		}		for (n = 0; n < cdl_packages.size (); n++) {			config->unload_package (resolve_package_alias (cdl_packages [n]));		}		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_version (const std::string cdl_version, const std::vector<std::string> cdl_packages) {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		for (unsigned int n = 0; n < cdl_packages.size (); n++) {			config->change_package_version (resolve_package_alias (cdl_packages [n]), cdl_version, &diagnostic_handler, &diagnostic_handler, true);		}		config->save (savefile);		status = true;	} catch (CdlStringException exception) {		exception_handler (exception);	} catch (...) {		exception_handler ();	}	delete_cdl_data ();	return status;}bool cdl_exec::cmd_tree () {	bool status = false;	try {		pkgdata = CdlPackagesDatabaseBody::make (repository);		interp = CdlInterpreterBody::make ();		config = CdlConfigurationBody::load (savefile, pkgdata, interp, &diagnostic_handler, &diagnostic_handler);		char * cwd = getcwd (NULL, 0);#ifdef __CYGWIN__		char cwd_win32 [MAXPATHLEN + 1];		cygwin_conv_to_win32_path (cwd, cwd_win32);		generate_build_tree (config, cwd_win32, install_prefix);#else		generate_build_tree (config, cwd, install_prefix);

⌨️ 快捷键说明

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