From db3534da1bcbf286df7ac4c8736f5c5157399ced Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 17 Jul 2016 08:18:45 +0200 Subject: Redesign obj to exe/lib mapping Specifically: * objso{} and libso{} target types have been renamed to objs{} and libs{} * obje{} has been added (so now we have obje{}, obja{}, and objs{}) * obje{} is now used for building exe{} * object file extensions have been changed to use "hierarchical extensions" that reflect the extension of the corresponding exe/lib target (instead of the -so suffix we used), specifically: obje{}: foo.o, (UNIX), foo.exe.o (MinGW), foo.exe.obj (Windows) obja{}: foo.a.o (UNIX, MinGW), foo.lib.obj (Windows) objs{}: foo.so.o (UNIX), foo.dylib.o (Darwin), foo.dll.o (MinGW), foo.dll.obj (Windows) --- build2/cxx/common | 60 ++++++++++++ build2/cxx/common.cxx | 70 ++++++++++++++ build2/cxx/compile.cxx | 80 +++++++++++---- build2/cxx/install.cxx | 14 ++- build2/cxx/link | 20 ---- build2/cxx/link.cxx | 226 +++++++++++++++++++------------------------ build2/cxx/module.cxx | 30 +++--- build2/cxx/utility.cxx | 4 +- build2/cxx/windows-rpath.cxx | 4 +- 9 files changed, 320 insertions(+), 188 deletions(-) create mode 100644 build2/cxx/common create mode 100644 build2/cxx/common.cxx (limited to 'build2/cxx') diff --git a/build2/cxx/common b/build2/cxx/common new file mode 100644 index 00000000..77f11495 --- /dev/null +++ b/build2/cxx/common @@ -0,0 +1,60 @@ +// file : build2/cxx/common -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CXX_COMMON +#define BUILD2_CXX_COMMON + +#include +#include + +#include + +namespace build2 +{ + namespace cxx + { + // Compile/link output type (executable, static, or shared). + // + enum class otype {e, a, s}; + + inline otype + compile_type (target& t) + { + return + t.is_a () ? otype::e : + t.is_a () ? otype::a : + otype::s; + } + + inline otype + link_type (target& t) + { + return + t.is_a () ? otype::e : + t.is_a () ? otype::a : + otype::s; + } + + // Library link order. + // + enum class lorder {a, s, a_s, s_a}; + + // The reason we pass scope and not the target is because this function is + // called not only for exe/lib but also for obj as part of the library + // meta-information protocol implementation. Normally the bin.*.lib values + // will be project-wide. With this scheme they can be customized on the + // per-directory basis but not per-target which means all exe/lib in the + // same directory have to have the same link order. + // + lorder + link_order (scope& base, otype); + + // Given the link order return the library member (liba or libs) to link. + // + target& + link_member (bin::lib&, lorder); + } +} + +#endif // BUILD2_CXX_COMMON diff --git a/build2/cxx/common.cxx b/build2/cxx/common.cxx new file mode 100644 index 00000000..0b66eb58 --- /dev/null +++ b/build2/cxx/common.cxx @@ -0,0 +1,70 @@ +// file : build2/cxx/common.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include + +using namespace std; + +namespace build2 +{ + namespace cxx + { + using namespace bin; + + lorder + link_order (scope& bs, otype ot) + { + const char* var; + + switch (ot) + { + case otype::e: var = "bin.exe.lib"; break; + case otype::a: var = "bin.liba.lib"; break; + case otype::s: var = "bin.libs.lib"; break; + } + + const auto& v (cast (bs[var])); + return v[0] == "shared" + ? v.size () > 1 && v[1] == "static" ? lorder::s_a : lorder::s + : v.size () > 1 && v[1] == "shared" ? lorder::a_s : lorder::a; + } + + target& + link_member (bin::lib& l, lorder lo) + { + bool ls (true); + const string& at (cast (l["bin.lib"])); // Available members. + + switch (lo) + { + case lorder::a: + case lorder::a_s: + ls = false; // Fall through. + case lorder::s: + case lorder::s_a: + { + if (ls ? at == "static" : at == "shared") + { + if (lo == lorder::a_s || lo == lorder::s_a) + ls = !ls; + else + fail << (ls ? "shared" : "static") << " variant of " << l + << " is not available"; + } + } + } + + target* r (ls ? static_cast (l.s) : l.a); + + if (r == nullptr) + r = &search (ls ? libs::static_type : liba::static_type, + prerequisite_key {nullptr, l.key (), nullptr}); + + return *r; + } + } +} diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index 504df7f1..645e8181 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -21,6 +21,7 @@ #include #include +#include #include @@ -69,15 +70,57 @@ namespace build2 path_target& t (static_cast (xt)); scope& rs (t.root_scope ()); + const string& cid (cast (rs["cxx.id"])); + const string& tsys (cast (rs["cxx.target.system"])); const string& tclass (cast (rs["cxx.target.class"])); + otype ct (compile_type (t)); + // Derive file name from target name. // if (t.path ().empty ()) { - const char* ext (cid == "msvc" ? "obj" : "o"); - t.derive_path (ext, nullptr, (t.is_a () ? "-so" : nullptr)); + const char* e (nullptr); + + if (tsys == "win32-msvc") + { + switch (ct) + { + case otype::e: e = "exe.obj"; break; + case otype::a: e = "lib.obj"; break; + case otype::s: e = "dll.obj"; break; + } + } + else if (tsys == "mingw32") + { + switch (ct) + { + case otype::e: e = "exe.o"; break; + case otype::a: e = "a.o"; break; + case otype::s: e = "dll.o"; break; + } + } + else if (tsys == "darwin") + { + switch (ct) + { + case otype::e: e = "o"; break; + case otype::a: e = "a.o"; break; + case otype::s: e = "dylib.o"; break; + } + } + else + { + switch (ct) + { + case otype::e: e = "o"; break; + case otype::a: e = "a.o"; break; + case otype::s: e = "so.o"; break; + } + } + + t.derive_path (e); } // Inject dependency on the output directory. @@ -102,7 +145,7 @@ namespace build2 // meta-information protocol". See also append_lib_options() // above. // - if (p.is_a () || p.is_a () || p.is_a ()) + if (p.is_a () || p.is_a () || p.is_a ()) { if (a.operation () == update_id) { @@ -184,7 +227,7 @@ namespace build2 { target& pt (*p.target); // Already searched and matched. - if (pt.is_a () || pt.is_a () || pt.is_a ()) + if (pt.is_a () || pt.is_a () || pt.is_a ()) hash_lib_options (cs, pt, "cxx.export.poptions"); } @@ -192,7 +235,7 @@ namespace build2 hash_options (cs, t, "cxx.coptions"); hash_std (cs, rs, cid, t); - if (t.is_a ()) + if (ct == otype::s) { // On Darwin, Win32 -fPIC is the default. // @@ -369,7 +412,7 @@ namespace build2 if (t == nullptr) continue; - if (t->is_a () || t->is_a () || t->is_a ()) + if (t->is_a () || t->is_a () || t->is_a ()) append_lib_prefixes (m, *t); } @@ -389,7 +432,7 @@ namespace build2 { target& pt (*p.target); // Already searched and matched. - if (pt.is_a () || pt.is_a () || pt.is_a ()) + if (pt.is_a () || pt.is_a () || pt.is_a ()) append_lib_prefixes (m, pt); } @@ -617,7 +660,7 @@ namespace build2 { target& pt (*p.target); // Already searched and matched. - if (pt.is_a () || pt.is_a () || pt.is_a ()) + if (pt.is_a () || pt.is_a () || pt.is_a ()) append_lib_options (args, pt, "cxx.export.poptions"); } @@ -628,7 +671,7 @@ namespace build2 append_options (args, t, "cxx.coptions"); append_std (args, rs, cid, t, cxx_std); - if (t.is_a ()) + if (t.is_a ()) { // On Darwin, Win32 -fPIC is the default. // @@ -1181,19 +1224,22 @@ namespace build2 if (s == nullptr) return target_state::unchanged; - // Translate paths to relative (to working directory) ones. This - // results in easier to read diagnostics. - // - path relo (relative (t.path ())); - path rels (relative (s->path ())); - scope& rs (t.root_scope ()); + const path& cxx (cast (rs["config.cxx"])); const string& cid (cast (rs["cxx.id"])); const string& tclass (cast (rs["cxx.target.class"])); + otype ct (compile_type (t)); + cstrings args {cxx.string ().c_str ()}; + // Translate paths to relative (to working directory) ones. This + // results in easier to read diagnostics. + // + path relo (relative (t.path ())); + path rels (relative (s->path ())); + // Add cxx.export.poptions from prerequisite libraries. Note that // here we don't need to see group members (see apply()). // @@ -1201,7 +1247,7 @@ namespace build2 { target& pt (*p.target); // Already searched and matched. - if (pt.is_a () || pt.is_a () || pt.is_a ()) + if (pt.is_a () || pt.is_a () || pt.is_a ()) append_lib_options (args, pt, "cxx.export.poptions"); } @@ -1268,7 +1314,7 @@ namespace build2 } else { - if (t.is_a ()) + if (ct == otype::s) { // On Darwin, Win32 -fPIC is the default. // diff --git a/build2/cxx/install.cxx b/build2/cxx/install.cxx index f6f502a0..e07d1156 100644 --- a/build2/cxx/install.cxx +++ b/build2/cxx/install.cxx @@ -6,8 +6,9 @@ #include -#include #include +#include +#include using namespace std; @@ -31,17 +32,20 @@ namespace build2 // If this is a shared library prerequisite, install it as long as it // is in the same amalgamation as we are. // - if ((t.is_a () || t.is_a ()) && - (p.is_a () || p.is_a ())) + // @@ Shouldn't we also install a static library prerequisite of a + // static library? + // + if ((t.is_a () || t.is_a ()) && + (p.is_a () || p.is_a ())) { target* pt (&p.search ()); // If this is the lib{} group, pick a member which we would link. // if (lib* l = pt->is_a ()) - pt = &link::link_member (*l, link::link_order (t)); + pt = &link_member (*l, link_order (t.base_scope (), link_type (t))); - if (pt->is_a ()) // Can be liba{}. + if (pt->is_a ()) // Can be liba{}. return pt->in (t.weak_scope ()) ? pt : nullptr; } diff --git a/build2/cxx/link b/build2/cxx/link index ca45e176..4f00ea0b 100644 --- a/build2/cxx/link +++ b/build2/cxx/link @@ -33,26 +33,6 @@ namespace build2 static link instance; - public: - enum class type {e, a, so}; - enum class order {a, so, a_so, so_a}; - - static type - link_type (target& t) - { - return t.is_a () - ? type::e - : (t.is_a () ? type::a : type::so); - } - - static order - link_order (target&); - - // Determine the library member (liba or libso) to link. - // - static target& - link_member (bin::lib&, order); - private: friend class compile; diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index 181c2b88..002cd427 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -19,6 +19,7 @@ #include #include +#include #include using namespace std; @@ -30,58 +31,6 @@ namespace build2 { using namespace bin; - link::order link:: - link_order (target& t) - { - const char* var; - - switch (link_type (t)) - { - case type::e: var = "bin.exe.lib"; break; - case type::a: var = "bin.liba.lib"; break; - case type::so: var = "bin.libso.lib"; break; - } - - const auto& v (cast (t[var])); - return v[0] == "shared" - ? v.size () > 1 && v[1] == "static" ? order::so_a : order::so - : v.size () > 1 && v[1] == "shared" ? order::a_so : order::a; - } - - target& link:: - link_member (bin::lib& l, order lo) - { - bool lso (true); - const string& at (cast (l["bin.lib"])); // Available types. - - switch (lo) - { - case order::a: - case order::a_so: - lso = false; // Fall through. - case order::so: - case order::so_a: - { - if (lso ? at == "static" : at == "shared") - { - if (lo == order::a_so || lo == order::so_a) - lso = !lso; - else - fail << (lso ? "shared" : "static") << " build of " << l - << " is not available"; - } - } - } - - target* r (lso ? static_cast (l.so) : l.a); - - if (r == nullptr) - r = &search (lso ? libso::static_type : liba::static_type, - prerequisite_key {nullptr, l.key (), nullptr}); - - return *r; - } - // Extract system library search paths from GCC or compatible (Clang, // Intel C++) using the -print-search-dirs option. // @@ -261,7 +210,7 @@ namespace build2 const string& tsys (cast (rs["cxx.target.system"])); bool l (p.is_a ()); - const string* ext (l ? nullptr : p.ext); // Only for liba/libso. + const string* ext (l ? nullptr : p.ext); // Only for liba/libs. // Then figure out what we need to search for. // @@ -302,12 +251,12 @@ namespace build2 } } - // libso + // libs // path sn; const string* se (nullptr); - if (l || p.is_a ()) + if (l || p.is_a ()) { const char* e (""); @@ -358,7 +307,7 @@ namespace build2 spc = extract_library_paths (p.scope); liba* a (nullptr); - libso* s (nullptr); + libs* s (nullptr); path f; // Reuse the buffer. const dir_path* pd; @@ -390,7 +339,7 @@ namespace build2 } } - // libso + // libs // if (!sn.empty ()) { @@ -403,7 +352,7 @@ namespace build2 // Above we searched for the import library (.dll.a) but if it's // not found, then we also search for the .dll (unless the // extension was specified explicitly) since we can link to it - // directly. Note also that the resulting libso{} would end up + // directly. Note also that the resulting libs{} would end up // being the .dll. // if (mt == timestamp_nonexistent && ext == nullptr) @@ -416,7 +365,7 @@ namespace build2 if (mt != timestamp_nonexistent) { - s = &targets.insert (d, dir_path (), p.name, se, trace); + s = &targets.insert (d, dir_path (), p.name, se, trace); if (s->path ().empty ()) s->path (move (f)); @@ -444,7 +393,7 @@ namespace build2 // It should automatically link-up to the members we have found. // assert (l.a == a); - assert (l.so == s); + assert (l.s == s); // Set the bin.lib variable to indicate what's available. // @@ -474,11 +423,11 @@ namespace build2 // // - if there is no .o, are we going to check if the one derived // from target exist or can be built? A: No. - // What if there is a library. Probably ok if .a, not if .so. + // What if there is a library. Probably ok if static, not if shared, // (i.e., a utility library). // - type lt (link_type (t)); + otype lt (link_type (t)); // Scan prerequisites and see if we can work with what we've got. // @@ -495,22 +444,34 @@ namespace build2 { seen_c = seen_c || true; } + else if (p.is_a ()) + { + seen_obj = seen_obj || true; + } + else if (p.is_a ()) + { + if (lt != otype::e) + fail << "obje{} as prerequisite of " << t; + + seen_obj = seen_obj || true; + } else if (p.is_a ()) { - if (lt == type::so) - fail << "shared library " << t << " prerequisite " << p - << " is static object"; + if (lt != otype::a) + fail << "obja{} as prerequisite of " << t; seen_obj = seen_obj || true; } - else if (p.is_a () || - p.is_a ()) + else if (p.is_a ()) { + if (lt != otype::s) + fail << "objs{} as prerequisite of " << t; + seen_obj = seen_obj || true; } - else if (p.is_a () || - p.is_a () || - p.is_a ()) + else if (p.is_a () || + p.is_a () || + p.is_a ()) { seen_lib = seen_lib || true; } @@ -530,7 +491,7 @@ namespace build2 // "library meta-information protocol". Don't do this if we are // called from the install rule just to check if we would match. // - if (seen_lib && lt != type::e && + if (seen_lib && lt != otype::e && a.operation () != install_id && a.outer_operation () != install_id) { if (t.group != nullptr) @@ -540,7 +501,7 @@ namespace build2 for (prerequisite_member p: group_prerequisite_members (a, t)) { - if (p.is_a () || p.is_a () || p.is_a ()) + if (p.is_a () || p.is_a () || p.is_a ()) { target* pt (nullptr); @@ -583,9 +544,8 @@ namespace build2 const string& tsys (cast (rs["cxx.target.system"])); const string& tclass (cast (rs["cxx.target.class"])); - type lt (link_type (t)); - order lo (link_order (t)); - bool so (lt == type::so); + otype lt (link_type (t)); + lorder lo (link_order (bs, lt)); // Derive file name from target name. // @@ -596,7 +556,7 @@ namespace build2 switch (lt) { - case type::e: + case otype::e: { if (tclass == "windows") e = "exe"; @@ -605,7 +565,7 @@ namespace build2 break; } - case type::a: + case otype::a: { // To be anally precise, let's use the ar id to decide how to name // the library in case, for example, someone wants to archive @@ -626,7 +586,7 @@ namespace build2 break; } - case type::so: + case otype::s: { //@@ VC: DLL name. @@ -637,9 +597,9 @@ namespace build2 } else if (tclass == "windows") { - // On Windows libso{} is an ad hoc group. The libso{} itself is + // On Windows libs{} is an ad hoc group. The libs{} itself is // the import library and we add dll{} as a member (see below). - // While at first it may seem strange that libso{} is the import + // While at first it may seem strange that libs{} is the import // library and not the DLL, if you meditate on it, you will see // it makes a lot of sense: our main task here is building and // for that we need the import library, not the DLL. @@ -697,7 +657,7 @@ namespace build2 { // DLL // - if (so) + if (lt == otype::s) { file& dll (add_adhoc (t, "dll")); @@ -707,7 +667,7 @@ namespace build2 // PDB // - if (lt != type::a && + if (lt != otype::a && cid == "msvc" && find_option ("/DEBUG", t, "cxx.loptions", true)) { @@ -734,6 +694,10 @@ namespace build2 // When cleaning, ignore prerequisites that are not in the same // or a subdirectory of our project root. // + const target_type& ott (lt == otype::e ? obje::static_type : + lt == otype::a ? obja::static_type : + objs::static_type); + for (prerequisite_member p: group_prerequisite_members (a, t)) { target* pt (nullptr); @@ -758,11 +722,15 @@ namespace build2 // if (obj* o = pt->is_a ()) { - pt = so ? static_cast (o->so) : o->a; + switch (lt) + { + case otype::e: pt = o->e; break; + case otype::a: pt = o->a; break; + case otype::s: pt = o->s; break; + } if (pt == nullptr) - pt = &search (so ? objso::static_type : obja::static_type, - p.key ()); + pt = &search (ott, p.key ()); } else if (lib* l = pt->is_a ()) { @@ -785,10 +753,7 @@ namespace build2 bool group (!p.prerequisite.belongs (t)); // Group's prerequisite. const prerequisite_key& cp (p.key ()); // c(xx){} prerequisite key. - const target_type& otype ( - group - ? obj::static_type - : (so ? objso::static_type : obja::static_type)); + const target_type& tt (group ? obj::static_type : ott); // Come up with the obj*{} target. The c(xx){} prerequisite directory // can be relative (to the scope) or absolute. If it is relative, then @@ -807,7 +772,7 @@ namespace build2 { if (!cpd.sub (rs.src_path ())) fail << "out of project prerequisite " << cp << - info << "specify corresponding " << otype.name << "{} " + info << "specify corresponding " << tt.name << "{} " << "target explicitly"; d = rs.out_path () / cpd.leaf (rs.src_path ()); @@ -817,7 +782,7 @@ namespace build2 // obj*{} is always in the out tree. // target& ot ( - search (otype, d, dir_path (), *cp.tk.name, nullptr, cp.scope)); + search (tt, d, dir_path (), *cp.tk.name, nullptr, cp.scope)); // If we are cleaning, check that this target is in the same or // a subdirectory of our project root. @@ -838,11 +803,16 @@ namespace build2 if (group) { obj& o (static_cast (ot)); - pt = so ? static_cast (o.so) : o.a; + + switch (lt) + { + case otype::e: pt = o.e; break; + case otype::a: pt = o.a; break; + case otype::s: pt = o.s; break; + } if (pt == nullptr) - pt = &search (so ? objso::static_type : obja::static_type, - o.dir, o.out, o.name, o.ext, nullptr); + pt = &search (ott, o.dir, o.out, o.name, o.ext, nullptr); } else pt = &ot; @@ -869,9 +839,9 @@ namespace build2 (p.is_a () && (p1.is_a () || p1.is_a () || p1.is_a ())) || - p1.is_a () || + p1.is_a () || p1.is_a () || - p1.is_a ()) + p1.is_a ()) { continue; } @@ -893,7 +863,7 @@ namespace build2 << "be incompatible with existing target " << *pt << info << "existing prerequisite " << p1 << " does not match " << cp << - info << "specify corresponding " << otype.name << "{} target " + info << "specify corresponding " << tt.name << "{} target " << "explicitly"; found = true; @@ -918,7 +888,7 @@ namespace build2 // for (prerequisite& p: group_prerequisites (t)) { - if (p.is_a () || p.is_a () || p.is_a ()) + if (p.is_a () || p.is_a () || p.is_a ()) ot.prerequisites.emplace_back (p); } @@ -948,7 +918,7 @@ namespace build2 args.push_back (relative (pa->path ()).string ()); // string()&& append_libraries (args, *pa); } - else if (libso* ps = pt->is_a ()) + else if (libs* ps = pt->is_a ()) args.push_back (relative (ps->path ()).string ()); // string()&& } } @@ -963,17 +933,17 @@ namespace build2 cs.append (pa->path ().string ()); hash_libraries (cs, *pa); } - else if (libso* ps = pt->is_a ()) + else if (libs* ps = pt->is_a ()) cs.append (ps->path ().string ()); } } static void - append_rpath_link (strings& args, libso& t) + append_rpath_link (strings& args, libs& t) { for (target* pt: t.prerequisite_targets) { - if (libso* ls = pt->is_a ()) + if (libs* ls = pt->is_a ()) { args.push_back ("-Wl,-rpath-link," + ls->path ().directory ().string ()); @@ -1002,8 +972,7 @@ namespace build2 file& t (static_cast (xt)); - type lt (link_type (t)); - bool so (lt == type::so); + otype lt (link_type (t)); // Update prerequisites. // @@ -1020,7 +989,7 @@ namespace build2 path manifest; // Manifest itself (msvc) or compiled object file. timestamp rpath_timestamp (timestamp_nonexistent); // DLLs timestamp. - if (lt == type::e && tclass == "windows") + if (lt == otype::e && tclass == "windows") { // First determine if we need to add our rpath emulating assembly. The // assembly itself is generated later, after updating the target. Omit @@ -1130,7 +1099,7 @@ namespace build2 // Then the linker checksum (ar/ranlib or C++ compiler). // - if (lt == type::a) + if (lt == otype::a) { ranlib = rs["config.bin.ranlib"]; @@ -1195,7 +1164,7 @@ namespace build2 args.push_back (m); } - if (lt == type::a) + if (lt == otype::a) { if (cid == "msvc") ; else @@ -1238,7 +1207,7 @@ namespace build2 { // Set soname. // - if (so) + if (lt == otype::s) { const string& leaf (t.path ().leaf ().string ()); @@ -1277,7 +1246,7 @@ namespace build2 // for (target* pt: t.prerequisite_targets) { - if (libso* ls = pt->is_a ()) + if (libs* ls = pt->is_a ()) { if (a.outer_operation () != install_id) { @@ -1330,11 +1299,12 @@ namespace build2 path_target* ppt; liba* a (nullptr); - if ((ppt = pt->is_a ()) || - (ppt = pt->is_a ()) || - (lt != type::a && + if ((ppt = pt->is_a ()) || + (ppt = pt->is_a ()) || + (ppt = pt->is_a ()) || + (lt != otype::a && ((ppt = a = pt->is_a ()) || - (ppt = pt->is_a ())))) + (ppt = pt->is_a ())))) { cs.append (ppt->path ().string ()); @@ -1353,7 +1323,7 @@ namespace build2 // Treat them as inputs, not options. // - if (lt != type::a) + if (lt != otype::a) hash_options (cs, t, "cxx.libs"); if (dd.expect (cs.string ()) != nullptr) @@ -1387,7 +1357,7 @@ namespace build2 switch (lt) { - case type::e: + case otype::e: { if (cid == "msvc") { @@ -1449,7 +1419,7 @@ namespace build2 break; } - case type::a: + case otype::a: { args[0] = cast (rs["config.bin.ar"]).string ().c_str (); @@ -1470,7 +1440,7 @@ namespace build2 break; } - case type::so: + case otype::s: { if (cid == "msvc") { @@ -1489,7 +1459,7 @@ namespace build2 if (tsys == "mingw32") { - // On Windows libso{} is the import stub and its first ad hoc + // On Windows libs{} is the import stub and its first ad hoc // group member is dll{}. // out = "-Wl,--out-implib=" + relt.string (); @@ -1514,13 +1484,13 @@ namespace build2 { path_target* ppt; liba* a (nullptr); - libso* so (nullptr); - if ((ppt = pt->is_a ()) || - (ppt = pt->is_a ()) || - (lt != type::a && + if ((ppt = pt->is_a ()) || + (ppt = pt->is_a ()) || + (ppt = pt->is_a ()) || + (lt != otype::a && ((ppt = a = pt->is_a ()) || - (ppt = so = pt->is_a ())))) + (ppt = pt->is_a ())))) { sargs.push_back (relative (ppt->path ()).string ()); // string()&& @@ -1543,7 +1513,7 @@ namespace build2 for (size_t i (0); i != sargs.size (); ++i) args.push_back (sargs[i].c_str ()); - if (lt != type::a) + if (lt != otype::a) append_options (args, t, "cxx.libs"); args.push_back (nullptr); @@ -1615,7 +1585,7 @@ namespace build2 // For Windows generate rpath-emulating assembly (unless updaing for // install). // - if (lt == type::e && tclass == "windows") + if (lt == otype::e && tclass == "windows") { if (a.outer_operation () != install_id) windows_rpath_assembly (t, rpath_timestamp, scratch); @@ -1644,12 +1614,12 @@ namespace build2 switch (link_type (t)) { - case type::a: + case otype::a: { e = {"+.d"}; break; } - case type::e: + case otype::e: { if (tclass == "windows") { @@ -1671,7 +1641,7 @@ namespace build2 break; } - case type::so: + case otype::s: { e = {"+.d"}; break; diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index 6a5469ca..69e76a32 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -316,38 +316,40 @@ namespace build2 auto& r (b.rules); - r.insert (perform_update_id, "cxx.compile", compile::instance); + r.insert (perform_update_id, "cxx.compile", compile::instance); + r.insert (perform_clean_id, "cxx.compile", compile::instance); r.insert (perform_update_id, "cxx.compile", compile::instance); r.insert (perform_clean_id, "cxx.compile", compile::instance); - r.insert (perform_update_id, "cxx.compile", compile::instance); - r.insert (perform_clean_id, "cxx.compile", compile::instance); + r.insert (perform_update_id, "cxx.compile", compile::instance); + r.insert (perform_clean_id, "cxx.compile", compile::instance); - r.insert (perform_update_id, "cxx.link", link::instance); - r.insert (perform_clean_id, "cxx.link", link::instance); + r.insert (perform_update_id, "cxx.link", link::instance); + r.insert (perform_clean_id, "cxx.link", link::instance); r.insert (perform_update_id, "cxx.link", link::instance); r.insert (perform_clean_id, "cxx.link", link::instance); - r.insert (perform_update_id, "cxx.link", link::instance); - r.insert (perform_clean_id, "cxx.link", link::instance); + r.insert (perform_update_id, "cxx.link", link::instance); + r.insert (perform_clean_id, "cxx.link", link::instance); - // Register for configure so that we detect unresolved imports - // during configuration rather that later, e.g., during update. + // Register for configure so that we detect unresolved imports during + // configuration rather that later, e.g., during update. // + r.insert (configure_update_id, "cxx.compile", compile::instance); r.insert (configure_update_id, "cxx.compile", compile::instance); - r.insert (configure_update_id, "cxx.compile", compile::instance); + r.insert (configure_update_id, "cxx.compile", compile::instance); - r.insert (configure_update_id, "cxx.link", link::instance); + r.insert (configure_update_id, "cxx.link", link::instance); r.insert (configure_update_id, "cxx.link", link::instance); - r.insert (configure_update_id, "cxx.link", link::instance); + r.insert (configure_update_id, "cxx.link", link::instance); //@@ Should we check if install module was loaded (see bin)? // - r.insert (perform_install_id, "cxx.install", install::instance); + r.insert (perform_install_id, "cxx.install", install::instance); r.insert (perform_install_id, "cxx.install", install::instance); - r.insert (perform_install_id, "cxx.install", install::instance); + r.insert (perform_install_id, "cxx.install", install::instance); } // Configure "installability" of our target types. diff --git a/build2/cxx/utility.cxx b/build2/cxx/utility.cxx index ed57fd2b..cf9c4d07 100644 --- a/build2/cxx/utility.cxx +++ b/build2/cxx/utility.cxx @@ -79,7 +79,7 @@ namespace build2 for (target* t: l.prerequisite_targets) { - if (t->is_a () || t->is_a () || t->is_a ()) + if (t->is_a () || t->is_a () || t->is_a ()) append_lib_options (args, *t, var); } @@ -93,7 +93,7 @@ namespace build2 for (target* t: l.prerequisite_targets) { - if (t->is_a () || t->is_a () || t->is_a ()) + if (t->is_a () || t->is_a () || t->is_a ()) hash_lib_options (csum, *t, var); } diff --git a/build2/cxx/windows-rpath.cxx b/build2/cxx/windows-rpath.cxx index 8f19f790..0bd4bc52 100644 --- a/build2/cxx/windows-rpath.cxx +++ b/build2/cxx/windows-rpath.cxx @@ -49,7 +49,7 @@ namespace build2 for (target* pt: t.prerequisite_targets) { - if (libso* ls = pt->is_a ()) + if (libs* ls = pt->is_a ()) { // This can be an installed library in which case we will have just // the import stub but may also have just the DLL. For now we don't @@ -84,7 +84,7 @@ namespace build2 { for (target* pt: t.prerequisite_targets) { - if (libso* ls = pt->is_a ()) + if (libs* ls = pt->is_a ()) { if (ls->member == nullptr) continue; -- cgit