aboutsummaryrefslogtreecommitdiff
path: root/build2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:22:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:22:28 +0200
commit75152526696fc024628796f0633ed695d5ebc49c (patch)
treefaeef54a6b4d7e9a816b8d541500c48484e4ed39 /build2/target.cxx
parentcc12ed4245a2b61f4c4eb2a970398c920fbc1d37 (diff)
Move exe{} to build2 core, add fallback extensions (existing files)
Diffstat (limited to 'build2/target.cxx')
-rw-r--r--build2/target.cxx39
1 files changed, 34 insertions, 5 deletions
diff --git a/build2/target.cxx b/build2/target.cxx
index 126159c..385cebd 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -332,7 +332,7 @@ namespace build2
// path_target
//
const string& path_target::
- derive_extension (const char* de)
+ derive_extension (const char* de, bool search)
{
// See also search_existing_file() if updating anything here.
//
@@ -346,7 +346,7 @@ namespace build2
// the user can use to override extensions.
//
if (auto f = type ().extension)
- ext = f (key (), base_scope ()); // Already from the pool.
+ ext = f (key (), base_scope (), search); // Already from the pool.
if (ext == nullptr)
{
@@ -453,13 +453,13 @@ namespace build2
}
const string*
- target_extension_null (const target_key&, scope&)
+ target_extension_null (const target_key&, scope&, bool)
{
return nullptr;
}
const string*
- target_extension_assert (const target_key&, scope&)
+ target_extension_assert (const target_key&, scope&, bool)
{
assert (false); // Attempt to obtain the default extension.
throw failed ();
@@ -585,6 +585,35 @@ namespace build2
false
};
+ static const string*
+ exe_extension (const target_key&, scope&, bool search)
+ {
+ // If we are searching for an executable that is not a target, then
+ // use the build machine executable extension. Otherwise, if this is
+ // a target, then we expect the rule to use target machine extension.
+ //
+ return search
+ ? &extension_pool.find (
+#ifdef _WIN32
+ "exe"
+#else
+ ""
+#endif
+ )
+ : nullptr;
+ }
+
+ const target_type exe::static_type
+ {
+ "exe",
+ &file::static_type,
+ &target_factory<exe>,
+ &exe_extension,
+ nullptr,
+ &search_file,
+ false
+ };
+
static target*
buildfile_factory (const target_type&,
dir_path d,
@@ -599,7 +628,7 @@ namespace build2
}
static const string*
- buildfile_target_extension (const target_key& tk, scope&)
+ buildfile_target_extension (const target_key& tk, scope&, bool)
{
// If the name is special 'buildfile', then there is no extension,
// otherwise it is .build.