diff options
author | Chris Johns <chrisj@rtems.org> | 2014-09-01 13:26:47 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2014-09-01 13:26:47 +1000 |
commit | 8c841a582f45d8a6cc1b3c439d4f660099e34d1b (patch) | |
tree | 6d5099a2bc67b72cbb43c0b3c3af0e8db39ce2cf /rld-cc.cpp | |
parent | 02ccf12ec62e7894786b6fff059f92fdcd7acaa1 (diff) |
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.
Diffstat (limited to 'rld-cc.cpp')
-rw-r--r-- | rld-cc.cpp | 71 |
1 files changed, 51 insertions, 20 deletions
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org> + * Copyright (c) 2011-2014, Chris Johns <chrisj@rtems.org> * * 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"); |