aboutsummaryrefslogtreecommitdiff
path: root/build2/bin
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-19 17:10:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-19 17:10:51 +0200
commit89a9f8174ec858bf6df8515a84f061f211dec551 (patch)
tree030daad1364ea38a4f2ec22c57b41aeeb8b1b6e8 /build2/bin
parent3ec07c196c9ab86db09c77bff7eb11cd5a5a9b1e (diff)
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.
Diffstat (limited to 'build2/bin')
-rw-r--r--build2/bin/module.cxx92
-rw-r--r--build2/bin/target12
-rw-r--r--build2/bin/target.cxx13
3 files changed, 81 insertions, 36 deletions
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<string> (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<obj> ();
t.insert<obje> ();
t.insert<obja> ();
t.insert<objs> ();
- t.insert<obj> ();
+
t.insert<exe> ();
+ install_path<exe> (b, dir_path ("bin")); // Install into install.bin.
+
+ t.insert<lib> ();
t.insert<liba> ();
t.insert<libs> ();
- t.insert<lib> ();
+
+ install_path<liba> (b, dir_path ("lib")); // Install into install.lib.
+ install_mode<liba> (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<libs> (b, dir_path (tclass == "windows" ? "bin" : "lib"));
+
+ // Create additional target types for certain targets.
+ //
+ if (tclass == "windows")
+ {
+ // Import library.
+ //
+ t.insert<libi> ();
+ install_path<libi> (b, dir_path ("lib"));
+ install_mode<libi> (b, "644");
+ }
}
// Register rules.
@@ -388,39 +428,6 @@ namespace build2
r.insert<lib> (perform_install_id, "bin.lib", lib_);
}
- // Configure "installability" of our target types.
- //
- using namespace install;
-
- install_path<exe> (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<libs> (b, dir_path ("lib")); // Install into install.lib.
-
- if (tclass == "windows")
- install_mode<libs> (b, "644");
-
- install_path<liba> (b, dir_path ("lib")); // Install into install.lib.
- install_mode<liba> (b, "644");
-
return true;
}
@@ -485,6 +492,19 @@ namespace build2
r.assign<string> ("bin.ld.checksum") = move (ldi.checksum);
}
+ const string& lid (cast<string> (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<file> ("pdb").first);
+ install_path (pdb, b, dir_path ("bin")); // Goes to install.bin
+ install_mode (pdb, b, "644"); // But not executable.
+ }
+
return true;
}
diff --git a/build2/bin/target b/build2/bin/target
index 8c32e84..849316e 100644
--- a/build2/bin/target
+++ b/build2/bin/target
@@ -107,6 +107,18 @@ namespace build2
static const target_type static_type;
virtual const target_type& dynamic_type () const {return static_type;}
};
+
+ // Windows import library.
+ //
+ class libi: public file
+ {
+ public:
+ using file::file;
+
+ public:
+ static const target_type static_type;
+ virtual const target_type& dynamic_type () const {return static_type;}
+ };
}
}
diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx
index 3f16467..d78d34c 100644
--- a/build2/bin/target.cxx
+++ b/build2/bin/target.cxx
@@ -261,5 +261,18 @@ namespace build2
&search_target,
false
};
+
+ // libi
+ //
+ const target_type libi::static_type
+ {
+ "libi",
+ &file::static_type,
+ &target_factory<libi>,
+ &target_extension_var<ext_var, nullptr>,
+ nullptr,
+ &search_file,
+ false
+ };
}
}