summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-09-09 08:40:13 +1000
committerChris Johns <chrisj@rtems.org>2014-09-09 08:40:13 +1000
commit6cfee6a10df3b3d5d4fd5de55215506641dd82c9 (patch)
tree30588ef72eb4712a10206f3e8c763c57ea953815
parent42f6be76c9b79c4501ed766177e634bbe44198d4 (diff)
linkers: If no RTEMS path is provied see if the prefix can be used.
-rw-r--r--rld.cpp32
-rw-r--r--rld.h10
-rw-r--r--rtems-ld.cpp18
-rw-r--r--rtems-tld.cpp13
4 files changed, 66 insertions, 7 deletions
diff --git a/rld.cpp b/rld.cpp
index ca29297..fe11c06 100644
--- a/rld.cpp
+++ b/rld.cpp
@@ -39,6 +39,15 @@
namespace rld
{
static int verbose_level = 0;
+
+ /**
+ * The program's command line.
+ */
+ static std::string cmdline;
+
+ /**
+ * The program name as set by the caller.
+ */
static std::string progname;
/**
@@ -206,6 +215,24 @@ namespace rld
}
void
+ set_cmdline (int argc, char* argv[])
+ {
+ cmdline.clear ();
+ for (int arg = 0; arg < argc; ++arg)
+ {
+ std::string a = argv[arg];
+ cmdline += ' ' + a;
+ }
+ cmdline = rld::trim (cmdline);
+ }
+
+ const std::string
+ get_cmdline ()
+ {
+ return cmdline;
+ }
+
+ void
set_progname (const std::string& progname_)
{
progname = rld::path::path_abs (progname_);
@@ -233,10 +260,9 @@ namespace rld
get_prefix ()
{
std::string pp = get_program_path ();
- std::cout << "PP=" << pp << std::endl;
if (rld::path::basename (pp) == "bin")
- pp = rld::path::dirname (pp);
- return pp;
+ return rld::path::dirname (pp);
+ return "";
}
void
diff --git a/rld.h b/rld.h
index 115b7b8..f86ef34 100644
--- a/rld.h
+++ b/rld.h
@@ -200,6 +200,16 @@ namespace rld
typedef std::vector < std::string > strings;
/**
+ * Set the command line.
+ */
+ void set_cmdline (int argc, char* argv[]);
+
+ /**
+ * Get the command line.
+ */
+ const std::string get_cmdline ();
+
+ /**
* Set the progname.
*/
void set_progname (const std::string& progname);
diff --git a/rtems-ld.cpp b/rtems-ld.cpp
index f678cde..6177e99 100644
--- a/rtems-ld.cpp
+++ b/rtems-ld.cpp
@@ -198,6 +198,8 @@ main (int argc, char* argv[])
bool warnings = false;
bool one_file = false;
+ rld::set_cmdline (argc, argv);
+
libpaths.push_back (".");
while (true)
@@ -329,11 +331,19 @@ main (int argc, char* argv[])
}
}
+ /*
+ * Set the program name.
+ */
+ rld::set_progname (argv[0]);
+
argc -= optind;
argv += optind;
if (rld::verbose () || map)
+ {
std::cout << "RTEMS Linker " << rld::version () << std::endl;
+ std::cout << " " << rld::get_cmdline () << std::endl;
+ }
/*
* If there are no object files there is nothing to link.
@@ -355,9 +365,13 @@ main (int argc, char* argv[])
*/
if (!rtems_arch_bsp.empty ())
{
- if (rtems_path.empty ())
+ const std::string& prefix = rld::get_prefix ();
+ if (rtems_path.empty () && prefix.empty ())
throw rld::error ("No RTEMS path provide with arch/bsp", "options");
- rld::rtems::set_path (rtems_path);
+ if (!rtems_path.empty ())
+ rld::rtems::set_path (rtems_path);
+ else
+ rld::rtems::set_path (prefix);
rld::rtems::set_arch_bsp (rtems_arch_bsp);
}
diff --git a/rtems-tld.cpp b/rtems-tld.cpp
index ea9518c..417b904 100644
--- a/rtems-tld.cpp
+++ b/rtems-tld.cpp
@@ -972,6 +972,8 @@ main (int argc, char* argv[])
std::string rtems_path;
std::string rtems_arch_bsp;
+ rld::set_cmdline (argc, argv);
+
while (true)
{
int opt = ::getopt_long (argc, argv, "hvwkVc:l:E:f:C:r:B:W:", rld_opts, NULL);
@@ -1051,16 +1053,23 @@ main (int argc, char* argv[])
argv += optind;
if (rld::verbose ())
+ {
std::cout << "RTEMS Trace Linker " << rld::version () << std::endl;
+ std::cout << " " << rld::get_cmdline () << std::endl;
+ }
/*
* Load the arch/bsp value if provided.
*/
if (!rtems_arch_bsp.empty ())
{
- if (rtems_path.empty ())
+ const std::string& prefix = rld::get_prefix ();
+ if (rtems_path.empty () && prefix.empty ())
throw rld::error ("No RTEMS path provide with arch/bsp", "options");
- rld::rtems::set_path (rtems_path);
+ if (!rtems_path.empty ())
+ rld::rtems::set_path (rtems_path);
+ else
+ rld::rtems::set_path (prefix);
rld::rtems::set_arch_bsp (rtems_arch_bsp);
}