From 8c841a582f45d8a6cc1b3c439d4f660099e34d1b Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 1 Sep 2014 13:26:47 +1000 Subject: rld: Split the file into a path module for path specific functions. This allows resued for other parts of the system not dependent on objcet files or archives. --- rld-cc.cpp | 71 +++++++++++++++++++++--------- rld-cc.h | 46 ++++++++++++++++---- rld-files.cpp | 127 ++++++++--------------------------------------------- rld-files.h | 99 +++++------------------------------------ rld-outputter.cpp | 2 +- rld-path.cpp | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ rld-path.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++ rld-process.cpp | 2 +- rld-resolver.cpp | 2 +- rtems-ld.cpp | 24 ++++------ rtems-ra.cpp | 68 ++++++++++++++--------------- rtems-rapper.cpp | 54 +++++++++++------------ rtems-syms.cpp | 19 +++----- rtems-tld.cpp | 11 ++--- wscript | 1 + 15 files changed, 451 insertions(+), 325 deletions(-) create mode 100644 rld-path.cpp create mode 100644 rld-path.h diff --git a/rld-cc.cpp b/rld-cc.cpp index 38d3093..56dc6ad 100644 --- a/rld-cc.cpp +++ b/rld-cc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, Chris Johns + * Copyright (c) 2011-2014, Chris Johns * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -27,9 +27,12 @@ namespace rld namespace cc { std::string cc; + std::string cc_name = "gcc"; std::string exec_prefix; - std::string march; - std::string mcpu; + std::string cppflags; + std::string cflags; + std::string cxxflags; + std::string ldflags; std::string install_path; std::string programs_path; std::string libraries_path; @@ -41,25 +44,49 @@ namespace rld static const char* std_lib_c = "libgcc.a" RPS "libssp.a" RPS "libc.a"; static const char* std_lib_cplusplus = "libstdc++.a"; - static void + void make_cc_command (rld::process::arg_container& args) { /* - * Use the absolute path to CC is provided. + * Use the absolute path to CC if provided. */ if (!cc.empty ()) args.push_back (cc); else { - std::string cmd = "gcc"; + std::string cmd = cc_name; if (!exec_prefix.empty ()) cmd = exec_prefix + "-rtems" + rld::rtems_version () + '-' + cmd; args.push_back (cmd); } - if (!march.empty ()) - args.push_back ("-march=" + march); - if (!mcpu.empty ()) - args.push_back ("-mcpu=" + mcpu); + } + + void + add_cppflags (rld::process::arg_container& args) + { + if (!cppflags.empty ()) + args.push_back (cppflags); + } + + void + add_cflags (rld::process::arg_container& args) + { + if (!cflags.empty ()) + args.push_back (cflags); + } + + void + add_cxxflags (rld::process::arg_container& args) + { + if (!cxxflags.empty ()) + args.push_back (cxxflags); + } + + void + add_ldflags (rld::process::arg_container& args) + { + if (!ldflags.empty ()) + args.push_back (ldflags); } static bool @@ -82,19 +109,21 @@ namespace rld rld::process::arg_container args; make_cc_command (args); + add_cppflags (args); + add_cflags (args); args.push_back ("-print-search-dirs"); rld::process::tempfile out; rld::process::tempfile err; rld::process::status status; - status = rld::process::execute ("gcc", args, out.name (), err.name ()); + status = rld::process::execute (cc_name, args, out.name (), err.name ()); if ((status.type == rld::process::status::normal) && (status.code == 0)) { if (rld::verbose () >= RLD_VERBOSE_DETAILS) - out.output ("gcc", std::cout, true); + out.output (cc_name, std::cout, true); out.open (); while (true) { @@ -119,7 +148,7 @@ namespace rld } else { - err.output ("gcc", std::cout); + err.output (cc_name, std::cout); } } @@ -129,13 +158,15 @@ namespace rld rld::process::arg_container args; make_cc_command (args); + add_cflags (args); + add_ldflags (args); args.push_back ("-print-file-name=" + name); rld::process::tempfile out; rld::process::tempfile err; rld::process::status status; - status = rld::process::execute ("gcc", args, out.name (), err.name ()); + status = rld::process::execute (cc_name, args, out.name (), err.name ()); if ((status.type == rld::process::status::normal) && (status.code == 0)) @@ -155,22 +186,22 @@ namespace rld } void - get_standard_libpaths (rld::files::paths& libpaths) + get_standard_libpaths (rld::path::paths& libpaths) { search_dirs (); rld::split (libraries_path, libpaths, RLD_PATHSTR_SEPARATOR); } void - get_standard_libs (rld::files::paths& libs, - rld::files::paths& libpaths, - bool cplusplus) + get_standard_libs (rld::path::paths& libs, + rld::path::paths& libpaths, + bool cplusplus) { strings libnames; rld::split (std_lib_c, libnames, RLD_PATHSTR_SEPARATOR); if (cplusplus) - rld::files::path_split (std_lib_cplusplus, libnames); + rld::path::path_split (std_lib_cplusplus, libnames); for (strings::iterator lni = libnames.begin (); lni != libnames.end (); @@ -181,7 +212,7 @@ namespace rld std::string path; - rld::files::find_file (path, *lni, libpaths); + rld::path::find_file (path, *lni, libpaths); if (path.empty ()) throw rld::error ("Library not found: " + *lni, "getting standard libs"); diff --git a/rld-cc.h b/rld-cc.h index a914b2f..db1163e 100644 --- a/rld-cc.h +++ b/rld-cc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, Chris Johns + * Copyright (c) 2011-2014, Chris Johns * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,31 +28,61 @@ #include #include +#include namespace rld { namespace cc { - extern std::string cc; //< The CC executable. + extern std::string cc; //< The CC executable as absolute path. + extern std::string cc_name; //< The CC name, ie gcc, clang. extern std::string exec_prefix; //< The CC executable prefix. - extern std::string march; //< The CC machine architecture. - extern std::string mcpu; //< The CC machine CPU. + + extern std::string cppflags; //< The CPP flags. + extern std::string cflags; //< The CC flags. + extern std::string cxxflags; //< The CXX flags. + extern std::string ldflags; //< The LD flags. extern std::string install_path; //< The CC reported install path. extern std::string programs_path; //< The CC reported programs path. extern std::string libraries_path; //< The CC reported libraries path. + /** + * Make a CC command from the set arguments. + */ + void make_cc_command (rld::process::arg_container& args); + + /** + * If the cppflags has been set append to the arguments. + */ + void add_cppflags (rld::process::arg_container& args); + + /** + * If the cflags has been set append to the arguments. + */ + void add_cflags (rld::process::arg_container& args); + + /** + * If the cxxflags has been set append to the arguments. + */ + void add_cxxflags (rld::process::arg_container& args); + + /** + * If the ldflags has been set append to the arguments. + */ + void add_ldflags (rld::process::arg_container& args); + /** * Get the standard libraries paths from the compiler. */ - void get_standard_libpaths (rld::files::paths& libpaths); + void get_standard_libpaths (rld::path::paths& libpaths); /** * Get the standard libraries. Optionally add the C++ library. */ - void get_standard_libs (rld::files::paths& libs, - rld::files::paths& libpaths, - bool cpp = false); + void get_standard_libs (rld::path::paths& libs, + rld::path::paths& libpaths, + bool cpp = false); } } diff --git a/rld-files.cpp b/rld-files.cpp index 63255b8..03310e8 100644 --- a/rld-files.cpp +++ b/rld-files.cpp @@ -73,97 +73,6 @@ namespace rld memcpy (string, oss.str ().c_str (), l); } - std::string - basename (const std::string& name) - { - size_t b = name.find_last_of (RLD_PATH_SEPARATOR); - if (b != std::string::npos) - return name.substr (b + 1); - return name; - } - - std::string - dirname (const std::string& name) - { - size_t b = name.find_last_of (RLD_PATH_SEPARATOR); - if (b != std::string::npos) - return name.substr (0, b - 1); - return name; - } - - std::string - extension (const std::string& name) - { - size_t b = name.find_last_of ('.'); - if (b != std::string::npos) - return name.substr (b); - return name; - } - - void - path_split (const std::string& path, rld::files::paths& paths) - { - strings ps; - rld::split (path, ps, RLD_PATHSTR_SEPARATOR); - if (ps.size ()) - { - for (strings::iterator psi = ps.begin (); - psi != ps.end (); - ++psi) - { - if (check_directory (*psi)) - paths.push_back (*psi); - } - } - } - - void - path_join (const std::string& path_, const std::string& file_, std::string& joined) - { - if ((path_[path_.size () - 1] != RLD_PATH_SEPARATOR) && - (file_[0] != RLD_PATH_SEPARATOR)) - joined = path_ + RLD_PATH_SEPARATOR + file_; - else if ((path_[path_.size () - 1] == RLD_PATH_SEPARATOR) && - (file_[0] == RLD_PATH_SEPARATOR)) - joined = path_ + &file_[1]; - else - joined = path_ + file_; - } - - bool - check_file (const std::string& path) - { - struct stat sb; - if (::stat (path.c_str (), &sb) == 0) - if (S_ISREG (sb.st_mode)) - return true; - return false; - } - - bool - check_directory (const std::string& path) - { - struct stat sb; - if (::stat (path.c_str (), &sb) == 0) - if (S_ISDIR (sb.st_mode)) - return true; - return false; - } - - void - find_file (std::string& path, const std::string& name, paths& search_paths) - { - for (rld::files::paths::iterator pi = search_paths.begin (); - pi != search_paths.end (); - ++pi) - { - path_join (*pi, name, path); - if (check_file (path)) - return; - } - path.clear (); - } - file::file (const std::string& aname, const std::string& oname, off_t offset, @@ -244,7 +153,7 @@ namespace rld bool file::is_valid () const { - return !aname_.empty () || ~oname_.empty (); + return !aname_.empty () || !oname_.empty (); } bool @@ -256,7 +165,7 @@ namespace rld bool result = false; const std::string p = path (); if (!p.empty ()) - result = check_file (p); + result = path::check_file (p); return result; } @@ -288,7 +197,7 @@ namespace rld const std::string file::basename () const { - return rld::files::basename (full ()); + return rld::path::basename (full ()); } const std::string& @@ -843,7 +752,7 @@ namespace rld ++oi) { object& obj = *(*oi); - const std::string& oname = basename (obj.name ().oname ()); + const std::string& oname = path::basename (obj.name ().oname ()); if (oname.length () >= rld_archive_fname_size) extended_file_names += oname + '\n'; } @@ -868,7 +777,7 @@ namespace rld try { - std::string oname = basename (obj.name ().oname ()); + std::string oname = path::basename (obj.name ().oname ()); /* * Convert the file name to an offset into the extended file name @@ -1391,18 +1300,18 @@ namespace rld } void - cache::add (paths& paths__) + cache::add (path::paths& paths__) { - for (paths::iterator pi = paths__.begin(); + for (path::paths::iterator pi = paths__.begin(); pi != paths__.end(); ++pi) add (*pi); } void - cache::add_libraries (paths& paths__) + cache::add_libraries (path::paths& paths__) { - for (paths::iterator pi = paths__.begin(); + for (path::paths::iterator pi = paths__.begin(); pi != paths__.end(); ++pi) input (*pi); @@ -1459,7 +1368,7 @@ namespace rld void cache::collect_object_files () { - for (paths::iterator ni = paths_.begin (); ni != paths_.end (); ++ni) + for (path::paths::iterator ni = paths_.begin (); ni != paths_.end (); ++ni) collect_object_files (*ni); } @@ -1565,7 +1474,7 @@ namespace rld cache::get_objects (object_list& list) const { list.clear (); - for (paths::const_iterator pi = paths_.begin (); + for (path::paths::const_iterator pi = paths_.begin (); pi != paths_.end (); ++pi) { @@ -1576,7 +1485,7 @@ namespace rld } } - const paths& + const path::paths& cache::get_paths () const { return paths_; @@ -1639,24 +1548,26 @@ namespace rld } void - find_libraries (paths& libraries, paths& libpaths, paths& libs) + find_libraries (path::paths& libraries, + path::paths& libpaths, + path::paths& libs) { if (rld::verbose () >= RLD_VERBOSE_INFO) std::cout << "Finding libraries:." << std::endl; libraries.clear (); - for (paths::size_type l = 0; l < libs.size (); ++l) + for (path::paths::size_type l = 0; l < libs.size (); ++l) { std::string lib = "lib" + libs[l] + ".a"; if (rld::verbose () >= RLD_VERBOSE_DETAILS) std::cout << " searching: " << lib << std::endl; bool found = false; - for (paths::size_type p = 0; p < libpaths.size (); ++p) + for (path::paths::size_type p = 0; p < libpaths.size (); ++p) { std::string plib; - path_join (libpaths[p], lib, plib); + path::path_join (libpaths[p], lib, plib); if (rld::verbose () >= RLD_VERBOSE_DETAILS) std::cout << " checking: " << plib << std::endl; - if (check_file (plib)) + if (path::check_file (plib)) { if (rld::verbose () >= RLD_VERBOSE_INFO) std::cout << " found: " << plib << std::endl; diff --git a/rld-files.h b/rld-files.h index 019357e..0c98cf1 100644 --- a/rld-files.h +++ b/rld-files.h @@ -38,16 +38,12 @@ #include #include +#include namespace rld { namespace files { - /** - * Container of file paths. - */ - typedef std::vector < std::string > paths; - /** * Container of files. */ @@ -68,81 +64,6 @@ namespace rld */ typedef std::list < object* > object_list; - /** - * Return the basename of the file name. - * - * @param name The full file name. - * @return std::string The basename of the file. - */ - std::string basename (const std::string& name); - - /** - * Return the dirname of the file name. - * - * @param name The full file name. - * @return std::string The dirname of the file. - */ - std::string dirname (const std::string& name); - - /** - * Return the extension of the file name. - * - * @param name The full file name. - * @return std::string The extension of the file. - */ - std::string extension (const std::string& name); - - /** - * Split a path from a string with a delimiter to the path container. Add - * only the paths that exist and ignore those that do not. - * - * @param path The paths as a single string delimited by the path - * separator. - * @param paths The split path paths. - */ - void path_split (const std::string& path, - paths& paths); - - /** - * Make a path by joining the parts with required separator. - * - * @param path_ The path component to be joined. - * @param file_ The file name to add to the path. - * @param joined The joined path and file name with a path separator. - */ - void path_join (const std::string& path_, - const std::string& file_, - std::string& joined); - - /** - * Check the path is a file using a stat call. - * - * @param path The path to check. - * @retval true The path is valid. - * @retval false The path is not valid. - */ - bool check_file (const std::string& path); - - /** - * Check if the path is a directory. - * - * @param path The path to check. - * @retval false The path is not a directory. - * @retval true The path is a directory. - */ - bool check_directory (const std::string& path); - - /** - * Find the file given a container of paths and file names. - * - * @param path The path of the file if found else empty. - * @param name The name of the file to search for. - * @param search_paths The container of paths to search. - */ - void find_file (std::string& path, - const std::string& name, - paths& search_paths); - /** * A file is a single object file that is either in an @ref archive or * a separate stand alone @ref object file. @@ -924,12 +845,12 @@ namespace rld /** * Add a container of path to the cache. */ - void add (paths& paths__); + void add (path::paths& paths__); /** * Add a container of path to the cache. */ - void add_libraries (paths& paths__); + void add_libraries (path::paths& paths__); /** * Being a session on an archive. @@ -993,7 +914,7 @@ namespace rld /** * Get the paths. */ - const paths& get_paths () const; + const path::paths& get_paths () const; /** * Get the archive files. @@ -1038,10 +959,10 @@ namespace rld virtual void input (const std::string& path); private: - paths paths_; //< The names of the files to process. - archives archives_; //< The archive files. - objects objects_; //< The object files. - bool opened; //< The cache is open. + path::paths paths_; //< The names of the files to process. + archives archives_; //< The archive files. + objects objects_; //< The object files. + bool opened; //< The cache is open. }; /** @@ -1057,7 +978,9 @@ namespace rld * Find the libraries given the list of libraries as bare name which * have 'lib' and '.a' added. */ - void find_libraries (paths& libraries, paths& libpaths, paths& libs); + void find_libraries (path::paths& libraries, + path::paths& libpaths, + path::paths& libs); } } diff --git a/rld-outputter.cpp b/rld-outputter.cpp index ff9032c..600aedc 100644 --- a/rld-outputter.cpp +++ b/rld-outputter.cpp @@ -188,7 +188,7 @@ namespace rld std::cout << "outputter:archive: " << name << ", dependents: " << dependents.size () << std::endl; - std::string ext = files::extension (name); + std::string ext = path::extension (name); std::string mdname = name.substr (0, name.length () - ext.length ()) + "-metadata.o"; diff --git a/rld-path.cpp b/rld-path.cpp new file mode 100644 index 0000000..50eb992 --- /dev/null +++ b/rld-path.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2011-2014, Chris Johns + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace rld +{ + namespace path + { + std::string + basename (const std::string& name) + { + size_t b = name.find_last_of (RLD_PATH_SEPARATOR); + if (b != std::string::npos) + return name.substr (b + 1); + return name; + } + + std::string + dirname (const std::string& name) + { + size_t b = name.find_last_of (RLD_PATH_SEPARATOR); + if (b != std::string::npos) + return name.substr (0, b - 1); + return name; + } + + std::string + extension (const std::string& name) + { + size_t b = name.find_last_of ('.'); + if (b != std::string::npos) + return name.substr (b); + return name; + } + + void + path_split (const std::string& path, paths& paths) + { + strings ps; + rld::split (path, ps, RLD_PATHSTR_SEPARATOR); + if (ps.size ()) + { + for (strings::iterator psi = ps.begin (); + psi != ps.end (); + ++psi) + { + if (check_directory (*psi)) + paths.push_back (*psi); + } + } + } + + void + path_join (const std::string& path_, const std::string& file_, std::string& joined) + { + if ((path_[path_.size () - 1] != RLD_PATH_SEPARATOR) && + (file_[0] != RLD_PATH_SEPARATOR)) + joined = path_ + RLD_PATH_SEPARATOR + file_; + else if ((path_[path_.size () - 1] == RLD_PATH_SEPARATOR) && + (file_[0] == RLD_PATH_SEPARATOR)) + joined = path_ + &file_[1]; + else + joined = path_ + file_; + } + + bool + check_file (const std::string& path) + { + struct stat sb; + if (::stat (path.c_str (), &sb) == 0) + if (S_ISREG (sb.st_mode)) + return true; + return false; + } + + bool + check_directory (const std::string& path) + { + struct stat sb; + if (::stat (path.c_str (), &sb) == 0) + if (S_ISDIR (sb.st_mode)) + return true; + return false; + } + + void + find_file (std::string& path, const std::string& name, paths& search_paths) + { + for (paths::iterator pi = search_paths.begin (); + pi != search_paths.end (); + ++pi) + { + path_join (*pi, name, path); + if (check_file (path)) + return; + } + path.clear (); + } + + } +} diff --git a/rld-path.h b/rld-path.h new file mode 100644 index 0000000..d9bb991 --- /dev/null +++ b/rld-path.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2011-2014, Chris Johns + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/** + * @file + * + * @ingroup rtems-ld + * + * @brief RTEMS Linker Path to help manage paths. + * + */ + +#if !defined (_RLD_PATH_H_) +#define _RLD_PATH_H_ + +#include +#include +#include +#include + +#include + +namespace rld +{ + namespace path + { + /** + * Container of file paths. + */ + typedef std::vector < std::string > paths; + + /** + * Return the basename of the file name. + * + * @param name The full file name. + * @return std::string The basename of the file. + */ + std::string basename (const std::string& name); + + /** + * Return the dirname of the file name. + * + * @param name The full file name. + * @return std::string The dirname of the file. + */ + std::string dirname (const std::string& name); + + /** + * Return the extension of the file name. + * + * @param name The full file name. + * @return std::string The extension of the file. + */ + std::string extension (const std::string& name); + + /** + * Split a path from a string with a delimiter to the path container. Add + * only the paths that exist and ignore those that do not. + * + * @param path The paths as a single string delimited by the path + * separator. + * @param paths The split path paths. + */ + void path_split (const std::string& path, + paths& paths); + + /** + * Make a path by joining the parts with required separator. + * + * @param path_ The path component to be joined. + * @param file_ The file name to add to the path. + * @param joined The joined path and file name with a path separator. + */ + void path_join (const std::string& path_, + const std::string& file_, + std::string& joined); + + /** + * Check the path is a file using a stat call. + * + * @param path The path to check. + * @retval true The path is valid. + * @retval false The path is not valid. + */ + bool check_file (const std::string& path); + + /** + * Check if the path is a directory. + * + * @param path The path to check. + * @retval false The path is not a directory. + * @retval true The path is a directory. + */ + bool check_directory (const std::string& path); + + /** + * Find the file given a container of paths and file names. + * + * @param path The path of the file if found else empty. + * @param name The name of the file to search for. + * @param search_paths The container of paths to search. + */ + void find_file (std::string& path, + const std::string& name, + paths& search_paths); + + } +} + +#endif diff --git a/rld-process.cpp b/rld-process.cpp index 2032404..bb2f8a4 100644 --- a/rld-process.cpp +++ b/rld-process.cpp @@ -160,7 +160,7 @@ namespace rld void tempfile::open (bool writable) { - if ((fd < 0) && rld::files::check_file (_name)) + if ((fd < 0) && rld::path::check_file (_name)) { level = 0; fd = ::open (_name.c_str (), writable ? O_RDWR : O_RDONLY); diff --git a/rld-resolver.cpp b/rld-resolver.cpp index 31a6779..d2a9f1e 100644 --- a/rld-resolver.cpp +++ b/rld-resolver.cpp @@ -57,7 +57,7 @@ namespace rld symbols::symtab& unresolved, const std::string& fullname) { - const std::string name = files::basename (fullname); + const std::string name = path::basename (fullname); static int nesting = 0; diff --git a/rtems-ld.cpp b/rtems-ld.cpp index 7eabbfe..302dc50 100644 --- a/rtems-ld.cpp +++ b/rtems-ld.cpp @@ -68,8 +68,7 @@ static struct option rld_opts[] = { { "base", required_argument, NULL, 'b' }, { "cc", required_argument, NULL, 'C' }, { "exec-prefix", required_argument, NULL, 'E' }, - { "march", required_argument, NULL, 'a' }, - { "mcpu", required_argument, NULL, 'c' }, + { "cflags", required_argument, NULL, 'c' }, { "rap-strip", no_argument, NULL, 'S' }, { "rpath", required_argument, NULL, 'R' }, { "runtime-lib", required_argument, NULL, 'P' }, @@ -112,8 +111,7 @@ usage (int exit_code) << " image (also --base)" << std::endl << " -C file : execute file as the target C compiler (also --cc)" << std::endl << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl - << " -a march : machine architecture (also --march)" << std::endl - << " -c cpu : machine architecture's CPU (also --mcpu)" << std::endl + << " -c cflags : C compiler flags (also --cflags)" << std::endl << " -S : do not include file details (also --rap-strip)" << std::endl << " -R : include file paths (also --rpath)" << std::endl << " -P : place objects from archives (also --runtime-lib)" << std::endl @@ -173,10 +171,10 @@ main (int argc, char* argv[]) rld::files::cache cache; rld::files::cache base; rld::files::cache cachera; - rld::files::paths libpaths; - rld::files::paths libs; - rld::files::paths objects; - rld::files::paths libraries; + rld::path::paths libpaths; + rld::path::paths libs; + rld::path::paths objects; + rld::path::paths libraries; rld::symbols::bucket defines; rld::symbols::bucket undefines; rld::symbols::table base_symbols; @@ -199,7 +197,7 @@ main (int argc, char* argv[]) while (true) { - int opt = ::getopt_long (argc, argv, "hvwVMnsSb:E:o:O:L:l:a:c:e:d:u:C:W:R:P:", rld_opts, NULL); + int opt = ::getopt_long (argc, argv, "hvwVMnsSb:E:o:O:L:l:c:e:d:u:C:W:R:P:", rld_opts, NULL); if (opt < 0) break; @@ -274,12 +272,8 @@ main (int argc, char* argv[]) rld::cc::exec_prefix = optarg; break; - case 'a': - rld::cc::march = optarg; - break; - case 'c': - rld::cc::mcpu = optarg; + rld::cc::cflags = optarg; break; case 'e': @@ -475,7 +469,7 @@ main (int argc, char* argv[]) one_file); if (!outra.empty ()) { - rld::files::paths ra_libs; + rld::path::paths ra_libs; bool ra_exist = false; /** diff --git a/rtems-ra.cpp b/rtems-ra.cpp index 5edfb12..8d1830c 100644 --- a/rtems-ra.cpp +++ b/rtems-ra.cpp @@ -99,8 +99,7 @@ usage (int exit_code) << " -n : do not search standard libraries (also --no-stdlibs)" << std::endl << " -C file : execute file as the target C compiler (also --cc)" << std::endl << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl - << " -a march : machine architecture (also --march)" << std::endl - << " -c cpu : machine architecture's CPU (also --mcpu)" << std::endl + << " -c cflags : C compiler flags (also --cflags)" << std::endl << " -S : do not include file details (also --rap-strip)" << std::endl << " -R : include file paths (also --rpath)" << std::endl << " -A : Add rap files (also --Add-rap)" << std::endl @@ -155,13 +154,13 @@ main (int argc, char* argv[]) try { - rld::files::paths libpaths; - rld::files::paths libs; - rld::files::paths libraries; - rld::files::paths outra; - rld::files::paths raps_add; - rld::files::paths raps_replace; - rld::files::paths raps_delete; + rld::path::paths libpaths; + rld::path::paths libs; + rld::path::paths libraries; + rld::path::paths outra; + rld::path::paths raps_add; + rld::path::paths raps_replace; + rld::path::paths raps_delete; std::string cc_name; std::string entry; std::string exit; @@ -252,12 +251,8 @@ main (int argc, char* argv[]) rld::cc::exec_prefix = optarg; break; - case 'a': - rld::cc::march = optarg; - break; - case 'c': - rld::cc::mcpu = optarg; + rld::cc::cflags = optarg; break; case 'S': @@ -325,11 +320,11 @@ main (int argc, char* argv[]) /* * Convert ar file to ra file */ - for (rld::files::paths::iterator p = libraries.begin (); p != libraries.end (); ++p) + for (rld::path::paths::iterator p = libraries.begin (); p != libraries.end (); ++p) { - rld::files::paths library; - rld::symbols::table symbols; - rld::files::cache* cache = new rld::files::cache (); + rld::path::paths library; + rld::symbols::table symbols; + rld::files::cache* cache = new rld::files::cache (); library.clear (); library.push_back (*p); @@ -350,7 +345,7 @@ main (int argc, char* argv[]) { rld::files::objects& objs = cache->get_objects (); - rld::files::paths raobjects; + rld::path::paths raobjects; int pos = -1; std::string rap_name; @@ -384,16 +379,16 @@ main (int argc, char* argv[]) } dependents.clear (); - for (rld::files::paths::iterator ni = raobjects.begin (); ni != raobjects.end (); ++ni) + for (rld::path::paths::iterator ni = raobjects.begin (); ni != raobjects.end (); ++ni) { rld::files::object* obj = new rld::files::object (*ni); dependents.push_back (obj); } - bool ra_rap = true; - bool ra_exist = false; + bool ra_rap = true; + bool ra_exist = false; rld::files::cache cachera; - std::string raname = *p; + std::string raname = *p; pos = -1; pos = raname.rfind ('/', raname.length ()); @@ -440,10 +435,10 @@ main (int argc, char* argv[]) /* * Add, replace, delete files from the ra file. */ - for (rld::files::paths::iterator pl = libs.begin (); pl != libs.end (); ++pl) + for (rld::path::paths::iterator pl = libs.begin (); pl != libs.end (); ++pl) { - rld::files::paths library; - rld::files::cache* cache = new rld::files::cache (); + rld::path::paths library; + rld::files::cache* cache = new rld::files::cache (); library.clear (); library.push_back (*pl); @@ -459,10 +454,10 @@ main (int argc, char* argv[]) cache->add_libraries (library); rld::files::objects& objs = cache->get_objects (); - rld::files::paths raobjects; + rld::path::paths raobjects; std::string rap_name; - bool rap_delete = false; + bool rap_delete = false; dependents.clear (); /* @@ -477,7 +472,7 @@ main (int argc, char* argv[]) rap_name = obj->name ().oname (); rap_delete = false; - for (rld::files::paths::iterator pa = raps_delete.begin (); + for (rld::path::paths::iterator pa = raps_delete.begin (); pa != raps_delete.end (); ++pa) { @@ -495,9 +490,10 @@ main (int argc, char* argv[]) /* * Add rap files into ra file, add supports replace. */ - bool rap_exist = false; - rld::files::paths rap_objects; - for (rld::files::paths::iterator pa = raps_add.begin (); + rld::path::paths rap_objects; + bool rap_exist = false; + + for (rld::path::paths::iterator pa = raps_add.begin (); pa != raps_add.end (); ++pa) { @@ -520,7 +516,7 @@ main (int argc, char* argv[]) rap_objects.push_back (*pa); } - for (rld::files::paths::iterator pa = rap_objects.begin (); + for (rld::path::paths::iterator pa = rap_objects.begin (); pa != rap_objects.end (); ++pa) { @@ -536,13 +532,13 @@ main (int argc, char* argv[]) /* * Replace rap files in ra file */ - bool rap_replace = false; rld::files::cache cachera; + bool rap_replace = false; rap_objects.clear (); cachera.open (); - for (rld::files::paths::iterator pa = raps_replace.begin (); + for (rld::path::paths::iterator pa = raps_replace.begin (); pa != raps_replace.end (); ++pa) { @@ -566,7 +562,7 @@ main (int argc, char* argv[]) rap_objects.push_back (*pa); } - for (rld::files::paths::iterator pa = rap_objects.begin (); + for (rld::path::paths::iterator pa = rap_objects.begin (); pa != rap_objects.end (); ++pa) { diff --git a/rtems-rapper.cpp b/rtems-rapper.cpp index f8f2a11..e0d27a0 100644 --- a/rtems-rapper.cpp +++ b/rtems-rapper.cpp @@ -638,7 +638,7 @@ namespace rap file::expand () { std::string name = image.name ().full (); - std::string extension = rld::files::extension (image.name ().full ()); + std::string extension = rld::path::extension (image.name ().full ()); name = name.substr (0, name.size () - extension.size ()) + ".xrap"; @@ -703,17 +703,17 @@ namespace rap } void -rap_show (rld::files::paths& raps, - bool warnings, - bool show_header, - bool show_machine, - bool show_layout, - bool show_strings, - bool show_symbols, - bool show_relocs, - bool show_details) +rap_show (rld::path::paths& raps, + bool warnings, + bool show_header, + bool show_machine, + bool show_layout, + bool show_strings, + bool show_symbols, + bool show_relocs, + bool show_details) { - for (rld::files::paths::iterator pi = raps.begin(); + for (rld::path::paths::iterator pi = raps.begin(); pi != raps.end(); ++pi) { @@ -960,10 +960,10 @@ rap_show (rld::files::paths& raps, } void -rap_overlay (rld::files::paths& raps, bool warnings) +rap_overlay (rld::path::paths& raps, bool warnings) { std::cout << "Overlay .... " << std::endl; - for (rld::files::paths::iterator pi = raps.begin(); + for (rld::path::paths::iterator pi = raps.begin(); pi != raps.end(); ++pi) { @@ -1050,10 +1050,10 @@ rap_overlay (rld::files::paths& raps, bool warnings) } void -rap_expander (rld::files::paths& raps, bool warnings) +rap_expander (rld::path::paths& raps, bool warnings) { std::cout << "Expanding .... " << std::endl; - for (rld::files::paths::iterator pi = raps.begin(); + for (rld::path::paths::iterator pi = raps.begin(); pi != raps.end(); ++pi) { @@ -1149,18 +1149,18 @@ main (int argc, char* argv[]) try { - rld::files::paths raps; - bool warnings = true; - bool show = false; - bool show_header = false; - bool show_machine = false; - bool show_layout = false; - bool show_strings = false; - bool show_symbols = false; - bool show_relocs = false; - bool show_details = false; - bool overlay = false; - bool expand = false; + rld::path::paths raps; + bool warnings = true; + bool show = false; + bool show_header = false; + bool show_machine = false; + bool show_layout = false; + bool show_strings = false; + bool show_symbols = false; + bool show_relocs = false; + bool show_details = false; + bool overlay = false; + bool expand = false; while (true) { diff --git a/rtems-syms.cpp b/rtems-syms.cpp index 437884c..24c7826 100644 --- a/rtems-syms.cpp +++ b/rtems-syms.cpp @@ -82,8 +82,7 @@ usage (int exit_code) << " -S : search standard libraries (also --stdlibs)" << std::endl << " -C file : execute file as the target C compiler (also --cc)" << std::endl << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl - << " -a march : machine architecture (also --march)" << std::endl - << " -c cpu : machine architecture's CPU (also --mcpu)" << std::endl; + << " -c cflags : C compiler flags (also --cflags)" << std::endl; ::exit (exit_code); } @@ -131,10 +130,10 @@ main (int argc, char* argv[]) try { rld::files::cache cache; - rld::files::paths libpaths; - rld::files::paths libs; - rld::files::paths objects; - rld::files::paths libraries; + rld::path::paths libpaths; + rld::path::paths libs; + rld::path::paths objects; + rld::path::paths libraries; rld::symbols::table symbols; std::string base_name; std::string cc_name; @@ -148,7 +147,7 @@ main (int argc, char* argv[]) while (true) { - int opt = ::getopt_long (argc, argv, "hvwVSE:L:l:a:c:C:", rld_opts, NULL); + int opt = ::getopt_long (argc, argv, "hvwVSE:L:l:c:C:", rld_opts, NULL); if (opt < 0) break; @@ -199,12 +198,8 @@ main (int argc, char* argv[]) rld::cc::exec_prefix = optarg; break; - case 'a': - rld::cc::march = optarg; - break; - case 'c': - rld::cc::mcpu = optarg; + rld::cc::cflags = optarg; break; case '?': diff --git a/rtems-tld.cpp b/rtems-tld.cpp index d206da7..2ab292a 100644 --- a/rtems-tld.cpp +++ b/rtems-tld.cpp @@ -755,8 +755,7 @@ usage (int exit_code) << " -w : generate warnings (also --warn)" << std::endl << " -k : keep temporary files (also --keep)" << std::endl << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl - << " -a march : machine architecture (also --march)" << std::endl - << " -c cpu : machine architecture's CPU (also --mcpu)" << std::endl + << " -c cflags : C compiler flags (also --cflags)" << std::endl << " -C ini : user configuration INI file (also --config)" << std::endl; ::exit (exit_code); } @@ -815,7 +814,7 @@ main (int argc, char* argv[]) while (true) { - int opt = ::getopt_long (argc, argv, "hvwkVE:a:c:C:", rld_opts, NULL); + int opt = ::getopt_long (argc, argv, "hvwkVE:c:C:", rld_opts, NULL); if (opt < 0) break; @@ -846,12 +845,8 @@ main (int argc, char* argv[]) rld::cc::exec_prefix = optarg; break; - case 'a': - rld::cc::march = optarg; - break; - case 'c': - rld::cc::mcpu = optarg; + rld::cc::cflags = optarg; break; case 'C': diff --git a/wscript b/wscript index c6d1d31..e6a3fbe 100644 --- a/wscript +++ b/wscript @@ -100,6 +100,7 @@ def build(bld): 'rld-cc.cpp', 'rld-compression.cpp', 'rld-outputter.cpp', + 'rld-path.cpp', 'rld-process.cpp', 'rld-resolver.cpp', 'rld-symbols.cpp', -- cgit v1.2.3