diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-01 13:39:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-01 13:42:10 +0200 |
commit | 7996c2bfc2d7e998e2f9f1236d457ec7bea8ad8a (patch) | |
tree | dca79d3657bec47d4cd5db85899a70d3d49c079e /build/scope.cxx | |
parent | f355a4379f035df61a7702f5ff805eefb004fb20 (diff) |
Implement support for definition target type aliases
For example:
define cli=file
Currently, the semantics is that of a real alias with only name differences
that are used for display. See tests/define/buildfile for more use cases.
Diffstat (limited to 'build/scope.cxx')
-rw-r--r-- | build/scope.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/build/scope.cxx b/build/scope.cxx index 53e3a53..d407ce0 100644 --- a/build/scope.cxx +++ b/build/scope.cxx @@ -44,7 +44,7 @@ namespace build } const target_type* scope:: - find_target_type (const char* tt, const scope** rs) const + find_target_type (const string& tt, const scope** rs) const { // Search scopes outwards, stopping at the project root. // @@ -69,6 +69,9 @@ namespace build return nullptr; } + static const string dir_tt ("dir"); + static const string file_tt ("file"); + const target_type* scope:: find_target_type (name& n, const string*& ext) const { @@ -78,22 +81,22 @@ namespace build // First determine the target type. // - const char* tt; + const string* tt; if (n.untyped ()) { // Empty name or '.' and '..' signify a directory. // if (v.empty () || v == "." || v == "..") - tt = "dir"; + tt = &dir_tt; else //@@ TODO: derive type from extension. // - tt = "file"; + tt = &file_tt; } else - tt = n.type.c_str (); + tt = &n.type; - const target_type* r (find_target_type (tt)); + const target_type* r (find_target_type (*tt)); if (r == nullptr) return r; |