Changeset b28e8b3 in rtems-tools
- Timestamp:
- Sep 7, 2014, 4:31:18 AM (6 years ago)
- Branches:
- 4.10, 4.11, 5, master
- Children:
- 6506aa1
- Parents:
- 32cd4fc
- Location:
- linkers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
linkers/rld-cc.cpp
r32cd4fc rb28e8b3 22 22 #include <rld-cc.h> 23 23 #include <rld-process.h> 24 #include <rld-rtems.h> 24 25 25 26 namespace rld … … 424 425 std::string cmd = cc_name; 425 426 if (!exec_prefix.empty ()) 426 cmd = exec_prefix + "-rtems" + rld::rtems _version () + '-' + cmd;427 cmd = exec_prefix + "-rtems" + rld::rtems::version () + '-' + cmd; 427 428 args.push_back (cmd); 428 429 } -
linkers/rld-rtems.cpp
r32cd4fc rb28e8b3 17 17 #include <rld.h> 18 18 #include <rld-cc.h> 19 #include <rld-rtems.h> 19 20 20 21 #include <pkgconfig.h> … … 24 25 namespace rtems 25 26 { 26 std::string version = "4.11"; 27 std::string path; 28 bool installed; 29 std::string arch_bsp; 30 31 const std::string 32 arch (const std::string& ab) 33 { 34 std::string::size_type slash = ab.find_first_of ('/'); 35 if (slash == std::string::npos) 36 throw rld::error ("Invalid BSP name", ab); 37 return ab.substr (0, slash); 38 std::string bsp = ab.substr (slash + 1); 39 } 40 41 const std::string 42 bsp (const std::string& ab) 43 { 44 std::string::size_type slash = ab.find_first_of ('/'); 45 if (slash == std::string::npos) 46 throw rld::error ("Invalid BSP name", ab); 47 return ab.substr (slash + 1); 48 } 49 50 const std::string 51 rtems_arch_prefix (const std::string& ab) 52 { 53 return arch (ab) + "-rtems" + version; 54 } 55 56 const std::string 57 rtems_arch_bsp (const std::string& ab) 58 { 59 return rtems_arch_prefix (ab) + '-' + bsp (ab); 60 } 61 62 void 27 static std::string _version = "4.11"; 28 static std::string _path; 29 static std::string _arch_bsp; 30 31 static void 63 32 load_cc () 64 33 { … … 67 36 std::string bsp; 68 37 69 if ( path.empty ())70 throw rld::error ("Not set ; see -r", "RTEMS path");71 72 bsp = rtems_arch_bsp ( arch_bsp);38 if (_path.empty ()) 39 throw rld::error ("Not set", "RTEMS path"); 40 41 bsp = rtems_arch_bsp (); 73 42 74 43 parts.push_back ("lib"); 75 44 parts.push_back ("pkgconfig"); 76 45 77 rld::path::path_join (path , parts, rtems_pkgconfig);46 rld::path::path_join (path (), parts, rtems_pkgconfig); 78 47 79 48 if (!path::check_directory (rtems_pkgconfig)) 80 throw rld::error ("Invalid RTEMS path", path );49 throw rld::error ("Invalid RTEMS path", path ()); 81 50 82 51 rld::path::path_join (rtems_pkgconfig, bsp + ".pc", rtems_pkgconfig); 83 52 84 53 if (!path::check_file (rtems_pkgconfig)) 85 throw rld::error ("RTEMS BSP not found", arch_bsp );54 throw rld::error ("RTEMS BSP not found", arch_bsp ()); 86 55 87 56 if (rld::verbose () >= RLD_VERBOSE_INFO) 88 std::cout << " rtems: " << arch_bsp << ": "57 std::cout << " rtems: " << _arch_bsp << ": " 89 58 << rtems_pkgconfig << std::endl; 90 59 … … 96 65 std::string name; 97 66 if (!pkg.get ("name", name)) 98 throw rld::error ("RTEMS BSP no name in pkgconfig file", arch_bsp);67 throw rld::error ("RTEMS BSP no name in pkgconfig file", _arch_bsp); 99 68 100 69 if (name != bsp) 101 throw rld::error ("RTEMS BSP does not match the name in pkgconfig file", arch_bsp); 70 throw rld::error ("RTEMS BSP does not match the name in pkgconfig file", 71 _arch_bsp); 102 72 103 73 std::string flags; … … 105 75 if (pkg.get ("CPPFLAGS", flags)) 106 76 { 107 rld::cc::append_flags (flags, arch ( arch_bsp), path, rld::cc::ft_cppflags);108 if (rld::verbose () >= RLD_VERBOSE_INFO) 109 std::cout << " rtems: " << arch_bsp 77 rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cppflags); 78 if (rld::verbose () >= RLD_VERBOSE_INFO) 79 std::cout << " rtems: " << arch_bsp () 110 80 << ": CPPFLAGS=" 111 81 << rld::cc::get_flags (rld::cc::ft_cppflags) … … 115 85 if (pkg.get ("CFLAGS", flags)) 116 86 { 117 rld::cc::append_flags (flags, arch ( arch_bsp), path, rld::cc::ft_cflags);87 rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cflags); 118 88 if (rld::verbose () >= RLD_VERBOSE_INFO) 119 89 { 120 std::cout << " rtems: " << arch_bsp 90 std::cout << " rtems: " << arch_bsp () 121 91 << ": CFLAGS=" << rld::cc::get_flags (rld::cc::ft_cflags) 122 92 << std::endl; 123 std::cout << " rtems: " << arch_bsp93 std::cout << " rtems: " << _arch_bsp 124 94 << ": WARNINGS=" << rld::cc::get_flags (rld::cc::fg_warning_flags) 125 95 << std::endl; 126 std::cout << " rtems: " << arch_bsp 96 std::cout << " rtems: " << arch_bsp () 127 97 << ": INCLUDES=" << rld::cc::get_flags (rld::cc::fg_include_flags) 128 98 << std::endl; 129 std::cout << " rtems: " << arch_bsp 99 std::cout << " rtems: " << arch_bsp () 130 100 << ": MACHINES=" << rld::cc::get_flags (rld::cc::fg_machine_flags) 131 101 << std::endl; 132 std::cout << " rtems: " << arch_bsp 102 std::cout << " rtems: " << arch_bsp () 133 103 << ": SPECS=" << rld::cc::get_flags (rld::cc::fg_spec_flags) 134 104 << std::endl; … … 138 108 if (pkg.get ("CXXFLAGS", flags)) 139 109 { 140 rld::cc::append_flags (flags, arch ( arch_bsp), path, rld::cc::ft_cxxflags);141 if (rld::verbose () >= RLD_VERBOSE_INFO) 142 std::cout << " rtems: " << arch_bsp 110 rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_cxxflags); 111 if (rld::verbose () >= RLD_VERBOSE_INFO) 112 std::cout << " rtems: " << arch_bsp () 143 113 << ": CXXFLAGS=" << rld::cc::get_flags (rld::cc::ft_cxxflags) 144 114 << std::endl; … … 147 117 if (pkg.get ("LDFLAGS", flags)) 148 118 { 149 rld::cc::append_flags (flags, arch ( arch_bsp), path, rld::cc::ft_ldflags);150 if (rld::verbose () >= RLD_VERBOSE_INFO) 151 std::cout << " rtems: " << arch_bsp 119 rld::cc::append_flags (flags, arch (), path (), rld::cc::ft_ldflags); 120 if (rld::verbose () >= RLD_VERBOSE_INFO) 121 std::cout << " rtems: " << arch_bsp () 152 122 << ": LDFLAGS=" << rld::cc::get_flags (rld::cc::ft_ldflags) 153 123 << std::endl; 154 124 } 155 125 156 rld::cc::set_exec_prefix (arch (arch_bsp)); 157 } 126 rld::cc::set_exec_prefix (arch ()); 127 } 128 129 void 130 set_version (const std::string& version_) 131 { 132 _version = version_; 133 } 134 135 void 136 set_arch_bsp (const std::string& arch_bsp_) 137 { 138 _arch_bsp = arch_bsp_; 139 if (!_path.empty ()) 140 load_cc (); 141 } 142 143 void 144 set_path (const std::string& path_) 145 { 146 _path = path_; 147 if (!_arch_bsp.empty ()) 148 load_cc (); 149 } 150 151 const std::string 152 version () 153 { 154 return _version; 155 } 156 157 const std::string 158 arch_bsp () 159 { 160 return _arch_bsp; 161 } 162 163 const std::string 164 arch () 165 { 166 if (_arch_bsp.empty ()) 167 throw rld::error ("No arch/bsp name", "rtems: arch"); 168 std::string::size_type slash = _arch_bsp.find_first_of ('/'); 169 if (slash == std::string::npos) 170 throw rld::error ("Invalid BSP name", _arch_bsp); 171 return _arch_bsp.substr (0, slash); 172 std::string bsp = _arch_bsp.substr (slash + 1); 173 } 174 175 const std::string 176 bsp () 177 { 178 if (_arch_bsp.empty ()) 179 throw rld::error ("No arch/bsp name", "rtems: bsp"); 180 std::string::size_type slash = _arch_bsp.find_first_of ('/'); 181 if (slash == std::string::npos) 182 throw rld::error ("Invalid BSP name", _arch_bsp); 183 return _arch_bsp.substr (slash + 1); 184 } 185 186 const std::string 187 path () 188 { 189 return _path; 190 } 191 192 const std::string 193 rtems_arch_prefix () 194 { 195 return arch () + "-rtems" + version (); 196 } 197 198 const std::string 199 rtems_arch_bsp () 200 { 201 return rtems_arch_prefix () + '-' + bsp (); 202 } 203 158 204 } 159 205 } -
linkers/rld-rtems.h
r32cd4fc rb28e8b3 33 33 { 34 34 /** 35 * The RTEMS defaultversion.35 * Set the RTEMS version. 36 36 */ 37 extern std::string version;37 void set_version (const std::string& version); 38 38 39 39 /** 40 * The path to RTEMS.40 * Set the arch/bsp string. 41 41 */ 42 extern std::string path;42 void set_arch_bsp (const std::string& arch_bsp); 43 43 44 44 /** 45 * Is the RTEMS installed.45 * Set the path to RTEMS. 46 46 */ 47 extern bool installed;47 void set_path (const std::string& path); 48 48 49 49 /** 50 * The BSP name.50 * Get the RTEMS version. 51 51 */ 52 extern std::string arch_bsp; 52 const std::string version (); 53 54 /** 55 * Return the arch/bsp string. 56 */ 57 const std::string arch_bsp (); 53 58 54 59 /** 55 60 * Return the architecture given an arch/bsp string. 56 61 */ 57 const std::string arch ( const std::string& ab);62 const std::string arch (); 58 63 59 64 /** 60 65 * Return the bsp given an arch/bsp string. 61 66 */ 62 const std::string bsp ( const std::string& ab);67 const std::string bsp (); 63 68 64 69 /** 65 * Return the RTEMS bsp string given an arch/bsp string.70 * Get the RTEMS path. 66 71 */ 67 const std::string rtems_bsp (const std::string& ab);72 const std::string path (); 68 73 69 74 /** 70 * Load the configuration. Set the various values via the command or a 71 * configuration file then check the configuration. 75 * Return the RTEMS BSP prefix. 72 76 */ 73 void load_cc();77 const std::string rtems_arch_prefix (); 74 78 75 79 /** 76 * Process the BSP name updating the various CC flags.80 * Return the arch/bsp as an RTEMS prefix and BSP string. 77 81 */ 78 void set_cc (void);82 const std::string rtems_arch_bsp (); 79 83 } 80 84 } -
linkers/rld.h
r32cd4fc rb28e8b3 273 273 274 274 /** 275 * The RTEMS version string. @todo move to rld-rtems.276 */277 const std::string rtems_version ();278 279 /**280 275 * Container of strings to hold the results of a split. 281 276 */ -
linkers/rtems-ld.cpp
r32cd4fc rb28e8b3 186 186 rld::symbols::table symbols; 187 187 rld::symbols::symtab undefined; 188 std::string rtems_path; 189 std::string rtems_arch_bsp; 188 190 std::string entry = "rtems"; 189 191 std::string exit; … … 196 198 bool warnings = false; 197 199 bool one_file = false; 198 bool arch_bsp_load = false;199 200 200 201 libpaths.push_back ("."); … … 312 313 313 314 case 'r': 314 r ld::rtems::path = optarg;315 rtems_path = optarg; 315 316 break; 316 317 317 318 case 'B': 318 rld::rtems::arch_bsp = optarg; 319 arch_bsp_load = true; 319 rtems_arch_bsp = optarg; 320 320 break; 321 321 … … 354 354 * Load the arch/bsp value if provided. 355 355 */ 356 if (arch_bsp_load) 357 rld::rtems::load_cc (); 356 if (!rtems_arch_bsp.empty ()) 357 { 358 if (rtems_path.empty ()) 359 throw rld::error ("arch/bsp provide and no RTEMS path", "options"); 360 rld::rtems::set_path (rtems_path); 361 rld::rtems::set_arch_bsp (rtems_arch_bsp); 362 } 358 363 359 364 /* -
linkers/rtems-tld.cpp
r32cd4fc rb28e8b3 234 234 235 235 /** 236 * Link the application. 237 */ 238 void link (rld::process::tempfile& o, 239 const std::string& ld_cmds); 240 241 /** 236 242 * Dump the linker. 237 243 */ … … 753 759 754 760 void 761 linker::link (rld::process::tempfile& o, 762 const std::string& ld_cmds) 763 { 764 765 } 766 767 void 755 768 linker::dump (std::ostream& out) const 756 769 { … … 780 793 { "warn", no_argument, NULL, 'w' }, 781 794 { "keep", no_argument, NULL, 'k' }, 795 { "linker", required_argument, NULL, 'l' }, 782 796 { "exec-prefix", required_argument, NULL, 'E' }, 783 797 { "cflags", required_argument, NULL, 'c' }, … … 800 814 << " -w : generate warnings (also --warn)" << std::endl 801 815 << " -k : keep temporary files (also --keep)" << std::endl 816 << " -l linker : target linker is not standard (also --linker)" << std::endl 802 817 << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl 803 818 << " -c cflags : C compiler flags (also --cflags)" << std::endl 804 819 << " -r path : RTEMS path (also --rtems)" << std::endl 805 820 << " -B bsp : RTEMS arch/bsp (also --rtems-bsp)" << std::endl 806 << " -W wrapper : Wrapper file name without ext (also --wrapper)" << std::endl821 << " -W wrapper : wrapper file name without ext (also --wrapper)" << std::endl 807 822 << " -C ini : user configuration INI file (also --config)" << std::endl; 808 823 ::exit (exit_code); … … 853 868 { 854 869 rld::trace::linker linker; 870 std::string ld; 855 871 std::string ld_cmd; 856 872 std::string configuration; 857 873 std::string trace = "tracer"; 858 874 std::string wrapper; 859 bool arch_bsp_load = false; 875 std::string rtems_path; 876 std::string rtems_arch_bsp; 860 877 861 878 while (true) 862 879 { 863 int opt = ::getopt_long (argc, argv, "hvwkV E:c:C:r:B:W:", rld_opts, NULL);880 int opt = ::getopt_long (argc, argv, "hvwkVl:E:c:C:r:B:W:", rld_opts, NULL); 864 881 if (opt < 0) 865 882 break; … … 887 904 break; 888 905 906 case 'l': 907 ld = optarg; 908 break; 909 889 910 case 'E': 890 911 rld::cc::set_exec_prefix (optarg); … … 896 917 897 918 case 'r': 898 r ld::rtems::path = optarg;919 rtems_path = optarg; 899 920 break; 900 921 901 922 case 'B': 902 rld::rtems::arch_bsp = optarg; 903 arch_bsp_load = true; 923 rtems_arch_bsp = optarg; 904 924 break; 905 925 … … 931 951 * Load the arch/bsp value if provided. 932 952 */ 933 if (arch_bsp_load) 934 rld::rtems::load_cc (); 953 if (!rtems_arch_bsp.empty ()) 954 { 955 if (rtems_path.empty ()) 956 throw rld::error ("arch/bsp provide and no RTEMS path", "options"); 957 rld::rtems::set_path (rtems_path); 958 rld::rtems::set_arch_bsp (rtems_arch_bsp); 959 } 935 960 936 961 /* … … 938 963 */ 939 964 while (argc--) 940 { 941 if (ld_cmd.length () != 0) 942 ld_cmd += " "; 943 ld_cmd += *argv++; 944 } 965 ld_cmd += ' ' + *argv++; 966 ld_cmd = rld::trim (ld_cmd); 945 967 946 968 /* … … 970 992 linker.generate_wrapper (c); 971 993 linker.compile_wrapper (c, o); 994 linker.link (o, ld_cmd); 972 995 973 996 if (rld::verbose ())
Note: See TracChangeset
for help on using the changeset viewer.