From 89a9f8174ec858bf6df8515a84f061f211dec551 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Jul 2016 17:10:51 +0200 Subject: Add import library target libi{}, make libs{} the DLL In the end, having libs{} be the DLL with import library being its member is more natural than making libs{} the import library and having dll{} as its member. --- build2/bin/module.cxx | 92 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 36 deletions(-) (limited to 'build2/bin/module.cxx') diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index 334384a..194b409 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -348,19 +348,59 @@ namespace build2 // const string& tclass (cast (r["bin.target.class"])); - // Register target types. + // Register target types and configure their default "installability". // + using namespace install; + { auto& t (b.target_types); + t.insert (); t.insert (); t.insert (); t.insert (); - t.insert (); + t.insert (); + install_path (b, dir_path ("bin")); // Install into install.bin. + + t.insert (); t.insert (); t.insert (); - t.insert (); + + install_path (b, dir_path ("lib")); // Install into install.lib. + install_mode (b, "644"); + + // Should shared libraries have the executable bit? That depends on + // who you ask. In Debian, for example, it should not unless, it + // really is executable (i.e., has main()). On the other hand, on + // some systems, this may be required in order for the dynamic + // linker to be able to load the library. So, by default, we will + // keep it executable, especially seeing that this is also the + // behavior of autotools. At the same time, it is easy to override + // this, for example: + // + // config.install.lib.mode=644 + // + // And a library that wants to override any such overrides (e.g., + // because it does have main()) can do: + // + // libs{foo}: install.mode=755 + // + // Everyone is happy then? On Windows libs{} is the DLL and goes to + // bin/, not lib/. + // + install_path (b, dir_path (tclass == "windows" ? "bin" : "lib")); + + // Create additional target types for certain targets. + // + if (tclass == "windows") + { + // Import library. + // + t.insert (); + install_path (b, dir_path ("lib")); + install_mode (b, "644"); + } } // Register rules. @@ -388,39 +428,6 @@ namespace build2 r.insert (perform_install_id, "bin.lib", lib_); } - // Configure "installability" of our target types. - // - using namespace install; - - install_path (b, dir_path ("bin")); // Install into install.bin. - - // Should shared libraries have executable bit? That depends on - // who you ask. In Debian, for example, it should not unless, it - // really is executable (i.e., has main()). On the other hand, on - // some systems, this may be required in order for the dynamic - // linker to be able to load the library. So, by default, we will - // keep it executable, especially seeing that this is also the - // behavior of autotools. At the same time, it is easy to override - // this, for example: - // - // config.install.lib.mode=644 - // - // And a library that wants to override any such overrides (e.g., - // because it does have main()) can do: - // - // libs{foo}: install.mode=755 - // - // Everyone is happy then? Not Windows users. When targeting Windows - // libs{} is an import library and shouldn't be exec. - // - install_path (b, dir_path ("lib")); // Install into install.lib. - - if (tclass == "windows") - install_mode (b, "644"); - - install_path (b, dir_path ("lib")); // Install into install.lib. - install_mode (b, "644"); - return true; } @@ -485,6 +492,19 @@ namespace build2 r.assign ("bin.ld.checksum") = move (ldi.checksum); } + const string& lid (cast (r["bin.ld.id"])); + + // Register the pdb{} target if using the VC toolchain. + // + using namespace install; + + if (lid == "msvc") + { + const target_type& pdb (b.derive_target_type ("pdb").first); + install_path (pdb, b, dir_path ("bin")); // Goes to install.bin + install_mode (pdb, b, "644"); // But not executable. + } + return true; } -- cgit v1.1