From: "Timothy Schaeffer" <tschaeffer@dramail.com>
To: <ecos-patches@ecos.sourceware.org>
Subject: Patch: add options to ecosconfig to controll location of build and install directories.
Date: Mon, 03 Mar 2008 18:48:00 -0000 [thread overview]
Message-ID: <138905EB75AB0D44B6A0ECD251A92EA797084E@sdra00198.intranet.dra-inc.net> (raw)
I had sent this to the ecos-discuss, not knowing about this mailing list.
I happened to read about it on the faq. I've been using this modified
version for a while and would like to know if there is any interest in
submitting it to the repository.
I have made some modifications to the source which should do what I want
without changing existing usage.
In summary:
I added a --build-prefix=<build_dir> option, which puts the build files
into <build_dir> instead of the current directory. If --prefix is not
given, the install tree will be in <build_dir>/install.
I added a --install-prefix=<install_dir> as a synonym for --prefix,
to be consistent with --build-prefix, and more explicit than --prefix.
I added a -C, --use-configtool-paths option, which uses the base name of
the config file to determine the default build and install prefixes.
E.g. if I give
$ ecosconfig -C tree
I get ecos_build, ecos_install in the current directory, just as
configtool does.
$ ecosconfig --config=this_project.ecc
gives me this_project_(install|build) in the current directory,
$ econconfig --config=/path/to/my_project.ecc
gives my /path/to/my_project_(install|build)/, and so on.
The --(build|install)-prefix options override these severally, so you
can still do weird things if you want.
I changed the sgml docs to include instructions for using these options.
Using ecosconfig w/o these options should work like it did before.
Except that it will reject project files which don't have the .ecc
extension, like configtool does.
The Patch:
Index: doc/sgml/user-guide/configuration.sgml
===================================================================
RCS file: /cvs/ecos/ecos/doc/sgml/user-guide/configuration.sgml,v
retrieving revision 1.3
diff -u -r1.3 configuration.sgml
--- doc/sgml/user-guide/configuration.sgml 12 Feb 2003 18:36:13 -0000 1.3
+++ doc/sgml/user-guide/configuration.sgml 3 Mar 2008 16:59:26 -0000
@@ -138,6 +138,7 @@
</VARLISTENTRY>
<VARLISTENTRY>
<TERM><OPTION>--prefix=<dir></OPTION></TERM>
+<TERM><OPTION>--install-prefix=<dir></OPTION></TERM>
<LISTITEM>
<PARA>Specifies an alternative location for the
install tree. By default, the install tree resides
@@ -145,7 +146,36 @@
directory in the build tree. Developers may prefer
to locate the build tree in a temporary file
hierarchy but keep the install tree in a more
- permanent location.</PARA>
+ permanent location. The argument should be an
+ absolute path name.</PARA>
+</LISTITEM>
+</VARLISTENTRY>
+<VARLISTENTRY>
+<TERM><OPTION>--build-prefix=<dir></OPTION></TERM>
+<LISTITEM>
+<PARA>Specifies an alternative location for the build tree. By
+ default, the build tree is the current
+ directory. Developers may prefer to locate the build
+ tree separate from the install tree. The argument
+ should be an absolute path name.</PARA>
+</LISTITEM>
+</VARLISTENTRY>
+<VARLISTENTRY>
+<TERM><OPTION>--use-configtool-paths</OPTION></TERM>
+<TERM><OPTION>-C</OPTION></TERM>
+<LISTITEM>
+<PARA>Change the default build prefix (the current directory) and
+ install prefix (install directory in the build tree) to mimic the
+ paths used by <COMMAND>configtool</COMMAND>. Specifically, if the
+ config file is given by <OPTION>--config=/path/to/X.ecc</OPTION>,
+ the build tree is built in
+ <filename>/path/to/X_build</filename> and the install tree is put in
+ <filename>/path/to/X_install</filename>. If <filename>X.ecc</filename>
+ is in the current directory, <filename>X_build</filename>
+ and <filename>X_install</filename> will be also; you needn't give
+ the path of <filename>X.ecc</filename>. An explicit <OPTION>--build-prefix</OPTION> or
+ <OPTION>--install-prefix</OPTION> (or <OPTION>--prefix</OPTION>)
+ will overide these defaults.</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
Index: host/tools/configtool/standalone/common/cdl_exec.cxx
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/cdl_exec.cxx,v
retrieving revision 1.15
diff -u -r1.15 cdl_exec.cxx
--- host/tools/configtool/standalone/common/cdl_exec.cxx 2 Jan 2006 21:14:22 -0000 1.15
+++ host/tools/configtool/standalone/common/cdl_exec.cxx 3 Mar 2008 16:59:27 -0000
@@ -62,10 +62,12 @@
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)
+ const std::string install_arg, const std::string build_tree_arg,
+ bool no_resolve_arg)
: repository(repository_arg),
savefile(savefile_arg),
install_prefix(install_arg),
+ build_tree(build_tree_arg),
no_resolve(no_resolve_arg),
pkgdata (NULL),
interp (NULL),
@@ -480,20 +482,8 @@
// Do nothing
}
else if (ignore_errors || (0 == config->get_all_conflicts().size())) {
-#ifdef _MSC_VER
- char cwd [_MAX_PATH + 1];
-#else
- char cwd [PATH_MAX + 1];
-#endif
- getcwd (cwd, sizeof cwd);
-#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);
-#endif
- config->generate_config_headers (install_prefix.empty () ? "install/include/pkgconf" : install_prefix + "/include/pkgconf");
+ generate_build_tree (config, build_tree, install_prefix);
+ config->generate_config_headers (install_prefix + "/include/pkgconf");
status = true;
#ifdef __CYGWIN__
char buf[100];
Index: host/tools/configtool/standalone/common/cdl_exec.hxx
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/cdl_exec.hxx,v
retrieving revision 1.4
diff -u -r1.4 cdl_exec.hxx
--- host/tools/configtool/standalone/common/cdl_exec.hxx 20 May 2002 22:19:28 -0000 1.4
+++ host/tools/configtool/standalone/common/cdl_exec.hxx 3 Mar 2008 16:59:27 -0000
@@ -26,7 +26,9 @@
class cdl_exec {
public:
- cdl_exec (const std::string repository_tree, const std::string savefile_name, const std::string install_tree, bool no_resolve);
+ cdl_exec (const std::string repository_tree, const std::string savefile_name,
+ const std::string install_tree, const std::string build_tree,
+ bool no_resolve);
bool cmd_new (const std::string cdl_hardware, const std::string cdl_template = "default", const std::string cdl_version = "");
bool cmd_tree ();
bool cmd_check ();
@@ -54,6 +56,7 @@
std::string repository;
std::string savefile;
std::string install_prefix;
+ std::string build_tree;
bool no_resolve;
static bool debug_level_set;
static int debug_level;
Index: host/tools/configtool/standalone/common/ecosconfig.cxx
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/common/ecosconfig.cxx,v
retrieving revision 1.15
diff -u -r1.15 ecosconfig.cxx
--- host/tools/configtool/standalone/common/ecosconfig.cxx 11 Jul 2006 09:56:14 -0000 1.15
+++ host/tools/configtool/standalone/common/ecosconfig.cxx 3 Mar 2008 16:59:27 -0000
@@ -57,12 +57,90 @@
#define DEFAULT_SAVE_FILE "ecos.ecc"
static char* tool = "ecosconfig";
+
+static bool
+get_arg_parm(const char * parmname, const char * parmdesc,
+ std::string & outval, int & command_index,
+ const int argc, char * argv [])
+
+{
+ bool args_ok = true;
+ const char * arg = argv[command_index];
+ size_t parmlen = strlen(parmname);
+ std::string argval = outval;
+
+ if ("" != argval) {
+ fprintf(stderr, "%s: the `%s' option should be used only once.\n", tool, parmname);
+ args_ok = false;
+ } else {
+ if ('=' == arg[parmlen]) {
+ argval = std::string(arg + parmlen + 1);
+ if ("" == argval) {
+ fprintf(stderr, "%s: missing %s after `%s='\n", tool, parmdesc, parmname);
+ args_ok = false;
+ }
+ } else if ('\0' == arg[parmlen]) {
+ command_index++;
+ if (command_index == argc) {
+ fprintf(stderr, "%s: missing %s after `%s'\n", tool, parmdesc, parmname);
+ args_ok = false;
+ } else {
+ argval = argv[command_index];
+ }
+ } else {
+ fprintf(stderr, "%s: invalid option `%s'\n", tool, arg);
+ args_ok = false;
+ }
+ }
+ if (args_ok) {
+ outval = argval;
+ }
+ return args_ok;
+}
+
+
+// The path must already exist for this to work.
+static std::string get_full_path(const std::string & path)
+{
+ char * fp = NULL;
+#ifdef _MSC_VER
+ char toolpath [_MAX_PATH + 1];
+ fp = _fullpath (toolpath, path.c_str(), sizeof (toolpath)); // get the absolute path to the tool
+#else
+ char toolpath [MAXPATHLEN + 1];
+ fp = realpath (path.c_str(), toolpath); // get the absolute path to the tool
+#endif
+ return std::string(fp != NULL ? fp : path);
+}
+
+
+static std::string get_cwd()
+{
+ char * pcwd;
+#ifdef _MSC_VER
+ char cwd [_MAX_PATH + 1];
+#else
+ char cwd [PATH_MAX + 1];
+#endif
+ getcwd (cwd, sizeof cwd);
+#ifdef __CYGWIN__
+ char cwd_win32 [MAXPATHLEN + 1];
+ cygwin_conv_to_win32_path (cwd, cwd_win32);
+ pcwd = cwd_win32;
+#else
+ pcwd = cwd;
+#endif
+ return std::string(pcwd);
+}
+
+
int main (int argc, char * argv []) {
// process command qualifiers
std::string repository; // --srcdir=
std::string savefile; // --config=
- std::string install_prefix; // --prefix=
+ std::string install_prefix; // --(install-)?prefix=
+ std::string build_prefix; // --build-prefix=
bool version = false; // --version
bool no_resolve = false; // --no-resolve
bool quiet = false; // -q, --quiet
@@ -71,6 +149,7 @@
bool no_updates = false; // -n, --no-updates,
bool help = false; // --help
bool enable_debug_set = false; // --enable-debug or --disable-debug
+ bool use_configtool_paths = false; // --use-configtool-paths or -C
int debug_level = 0; // --enable-debug=[0|1|2]
#ifdef __CYGWIN__
@@ -97,6 +176,8 @@
} else if ((0 == strcmp(arg, "-v")) || (0 == strcmp(arg, "--verbose"))) {
verbose = true;
quiet = false;
+ } else if ((0 == strcmp(arg, "-C")) || (0 == strcmp(arg, "--use-configtool-paths"))) {
+ use_configtool_paths = true;
} else if ((0 == strcmp(arg, "-i")) || (0 == strcmp(arg, "--ignore-errors"))) {
// Duplicate use of -i and the other flags is harmless.
ignore_errors = true;
@@ -113,79 +194,30 @@
enable_debug_set = true;
debug_level = 0;
} else if (0 == strncmp(arg, "--srcdir", 8)) {
- // Duplicate use of --srcdir and other data-containing options should
- // be marked as an error.
- if ("" != repository) {
- fprintf(stderr, "%s: the `--srcdir' option should be used only once.\n", tool);
- args_ok = false;
- } else {
- if ('=' == arg[8]) {
- repository = std::string(arg + 9);
- if ("" == repository) {
- fprintf(stderr, "%s: missing component repository after `--srcdir='\n", tool);
- args_ok = false;
- }
- } else if ('\0' == arg[8]) {
- command_index++;
- if (command_index == argc) {
- fprintf(stderr, "%s: missing component repository after `--srcdir'\n", tool);
- args_ok = false;
- } else {
- repository = argv[command_index];
- }
- } else {
- fprintf(stderr, "%s: invalid option `%s'\n", tool, arg);
- args_ok = false;
- }
- }
+ bool this_arg_ok = get_arg_parm("--srcdir", "component repository",
+ repository, command_index,
+ argc, argv);
+ args_ok = args_ok && this_arg_ok;
} else if (0 == strncmp(arg, "--config", 8)) {
- if ("" != savefile) {
- fprintf(stderr, "%s: the `--config' option should be used only once.\n", tool);
- args_ok = false;
- } else {
- if ('=' == arg[8]) {
- savefile = std::string(arg + 9);
- if ("" == savefile) {
- fprintf(stderr, "%s: missing configuration savefile after `--config='\n", tool);
- args_ok = false;
- }
- } else if ('\0' == arg[8]) {
- command_index++;
- if (command_index == argc) {
- fprintf(stderr, "%s: missing configuration savefile after `--config'\n", tool);
- args_ok = false;
- } else {
- savefile = argv[command_index];
- }
- } else {
- fprintf(stderr, "%s: invalid option `%s'\n", tool, arg);
- args_ok = false;
- }
- }
+ bool this_arg_ok = get_arg_parm("--config", "configuration savefile",
+ savefile, command_index,
+ argc, argv);
+ args_ok = args_ok && this_arg_ok;
} else if (0 == strncmp(arg, "--prefix", 8)) {
- if ("" != install_prefix) {
- fprintf(stderr, "%s: the `--prefix' option should be used only once.\n", tool);
- args_ok = false;
- } else {
- if ('=' == arg[8]) {
- install_prefix = std::string(arg + 9);
- if ("" == install_prefix) {
- fprintf(stderr, "%s: missing install prefix after `--prefix='\n", tool);
- args_ok = false;
- }
- } else if ('\0' == arg[8]) {
- command_index++;
- if (command_index == argc) {
- fprintf(stderr, "%s: missing install prefix after `--prefix'\n", tool);
- args_ok = false;
- } else {
- install_prefix = argv[command_index];
- }
- } else {
- fprintf(stderr, "%s: invalid option `%s'\n", tool, arg);
- args_ok = false;
- }
- }
+ bool this_arg_ok = get_arg_parm("--prefix", "install prefix",
+ install_prefix, command_index,
+ argc, argv);
+ args_ok = args_ok && this_arg_ok;
+ } else if (0 == strncmp(arg, "--install-prefix", 16)) {
+ bool this_arg_ok = get_arg_parm("--install-prefix", "install prefix",
+ install_prefix, command_index,
+ argc, argv);
+ args_ok = args_ok && this_arg_ok;
+ } else if (0 == strncmp(arg, "--build-prefix", 14)) {
+ bool this_arg_ok = get_arg_parm("--build-prefix", "build prefix",
+ build_prefix, command_index,
+ argc, argv);
+ args_ok = args_ok && this_arg_ok;
} else {
// The argument is not a qualifier
// However, none of the sub-commands begin with a -
@@ -197,20 +229,6 @@
}
}
-#if 0
- printf("args_ok is %d\n", args_ok);
- printf("help is %d\n", help);
- printf("version is %d\n", version);
- printf("no_resolve is %d\n", no_resolve);
- printf("quiet is %d\n", quiet);
- printf("verbose is %d\n", verbose);
- printf("no-updates is %d\n", no_updates);
- printf("ignore_errors is %d\n", ignore_errors);
- printf("repository is %s\n", repository.c_str());
- printf("savefile is %s\n", savefile.c_str());
- printf("install_prefix is %s\n", install_prefix.c_str());
- exit(EXIT_SUCCESS);
-#endif
// Usually argv[command_index] will be a sub-command, unless
// --help or --version has been used.
@@ -237,6 +255,29 @@
if (savefile.empty ()) { // if the save file was not specified on the command line
savefile = DEFAULT_SAVE_FILE; // use the default save file
}
+ savefile = get_full_path(savefile);
+ if (savefile.size() < 4 || savefile.substr(savefile.size() - 4) != ".ecc") {
+ fprintf(stderr, "%s is not a project file.\n", savefile.c_str());
+ return EXIT_FAILURE;
+ }
+
+ if ( ! use_configtool_paths ) {
+ if (build_prefix.empty()) {
+ build_prefix = get_cwd();
+ }
+ if (install_prefix.empty()) {
+ install_prefix = build_prefix + "/install";
+ }
+ } else {
+ std::string ecc_prefix = savefile.substr(0, savefile.size() - 4);
+ if (build_prefix.empty()) {
+ build_prefix = ecc_prefix + "_build";
+ }
+ if (install_prefix.empty()) {
+ install_prefix = ecc_prefix + "_install";
+ }
+ }
+
// find the repository
if (repository.empty ()) { // if the repository was not specified on the command line
@@ -245,16 +286,7 @@
repository = env_var;
} else { // the ECOS_REPOSITORY environment variable is not defined
// assume that the tool is located in the root of the repository
-#ifdef _MSC_VER
- char toolpath [_MAX_PATH + 1];
- _fullpath (toolpath, argv [0], sizeof (toolpath)); // get the absolute path to the tool
-#else
- // NOTE: portability problem. realpath() is not a POSIX function.
- // Alternative code may be needed on some platforms.
- char toolpath [MAXPATHLEN + 1];
- realpath (argv [0], toolpath); // get the absolute path to the tool
-#endif
- repository = toolpath;
+ repository = get_full_path(argv[0]);
for (unsigned int n = repository.size () - 1; n > 0; n--) { // for each char starting at the tail
if (('\\' == repository [n]) || ('/' == repository [n])) { // if the char is a directory separator
repository.resize (n); // remove the filename from the filepath
@@ -273,9 +305,25 @@
}
#endif
+#if 0
+ printf("args_ok is %d\n", args_ok);
+ printf("help is %d\n", help);
+ printf("version is %d\n", version);
+ printf("no_resolve is %d\n", no_resolve);
+ printf("quiet is %d\n", quiet);
+ printf("verbose is %d\n", verbose);
+ printf("no-updates is %d\n", no_updates);
+ printf("ignore_errors is %d\n", ignore_errors);
+ printf("repository is %s\n", repository.c_str());
+ printf("savefile is %s\n", savefile.c_str());
+ printf("install_prefix is %s\n", install_prefix.c_str());
+ printf("build_prefix is %s\n", build_prefix.c_str());
+ exit(EXIT_SUCCESS);
+#endif
+
// Initialize the cdl_exec code (not quite sure why this needs a
// separate object rather than just a bunch of statics).
- cdl_exec exec (trim_path (repository), savefile, trim_path (install_prefix), no_resolve);
+ cdl_exec exec (trim_path (repository), savefile, trim_path (install_prefix), trim_path (build_prefix), no_resolve);
cdl_exec::set_quiet_mode(quiet);
cdl_exec::set_verbose_mode(verbose);
cdl_exec::set_ignore_errors_mode(ignore_errors);
@@ -442,6 +490,9 @@
printf (" qualifiers are:\n");
printf (" --config=FILE : the configuration file\n");
printf (" --prefix=DIRECTORY : the install prefix\n");
+ printf (" --install-prefix=DIRECTORY : the install prefix (same as --prefix)\n");
+ printf (" --build-prefix=DIRECTORY : the build prefix\n");
+ printf (" -C, --use-configtool-paths : make default install and build prefixes like configtool's\n");
printf (" --srcdir=DIRECTORY : the source repository\n");
printf (" --no-resolve : disable conflict resolution\n");
printf (" --version : show version and copyright\n");
reply other threads:[~2008-03-03 18:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=138905EB75AB0D44B6A0ECD251A92EA797084E@sdra00198.intranet.dra-inc.net \
--to=tschaeffer@dramail.com \
--cc=ecos-patches@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).