diff options
Diffstat (limited to 'build/bin')
-rw-r--r-- | build/bin/module | 26 | ||||
-rw-r--r-- | build/bin/module.cxx | 58 | ||||
-rw-r--r-- | build/bin/rule.cxx | 26 | ||||
-rw-r--r-- | build/bin/target.cxx | 7 |
4 files changed, 97 insertions, 20 deletions
diff --git a/build/bin/module b/build/bin/module new file mode 100644 index 0000000..f2d9502 --- /dev/null +++ b/build/bin/module @@ -0,0 +1,26 @@ +// file : build/bin/module -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD_BIN_MODULE +#define BUILD_BIN_MODULE + +#include <build/path> +#include <build/module> + +namespace build +{ + namespace bin + { + void + init (scope&, scope&, const location&); + + // Init the 'lib' part of the module because a lib{} target + // has been created in the specified directory. + // + void + init_lib (const dir_path&); + } +} + +#endif // BUILD_BIN_MODULE diff --git a/build/bin/module.cxx b/build/bin/module.cxx new file mode 100644 index 0000000..89ea9fe --- /dev/null +++ b/build/bin/module.cxx @@ -0,0 +1,58 @@ +// file : build/bin/module.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <build/bin/module> + +#include <build/scope> +#include <build/variable> +#include <build/diagnostics> + +#include <build/config/utility> + +using namespace std; + +namespace build +{ + namespace bin + { + void + init (scope& root, scope& base, const location& l) + { + //@@ TODO: avoid multiple inits (generally, for modules). + // + tracer trace ("bin::init"); + + //@@ Should it be this way? + // + if (&root != &base) + fail (l) << "bin module must be initialized in project root scope"; + + //@@ TODO: need to register target types, rules here instead of main(). + + const dir_path& out_root (root.path ()); + level4 ([&]{trace << "for " << out_root;}); + + // Configure. + // + } + + void + init_lib (const dir_path& d) + { + scope* root (scopes.find (d).root_scope ()); + + if (root == nullptr) + return; + + // config.bin.lib + // + { + auto v (root->vars.assign ("bin.lib")); + + if (!v) + v = config::required (*root, "config.bin.lib", "shared").first; + } + } + } +} diff --git a/build/bin/rule.cxx b/build/bin/rule.cxx index 1b887bf..d84af25 100644 --- a/build/bin/rule.cxx +++ b/build/bin/rule.cxx @@ -9,8 +9,6 @@ #include <build/algorithm> #include <build/diagnostics> -#include <build/config/utility> - #include <build/bin/target> using namespace std; @@ -47,28 +45,16 @@ namespace build { lib& t (static_cast<lib&> (xt)); - // Configure. - // - // The logic is as follows: if this library somehow knowns what - // it wants to be (i.e., the bin.lib is defined), then don't - // bother configuring the project-wide value. + // Get the library type to build. If not set for a target, this + // should be configured at the project scope by init_lib(). // - const string* type (nullptr); - - if (auto v = t["bin.lib"]) - type = &v.as<const string&> (); - else - { - scope& root (*t.root_scope ()); - type = &config::required (root, "config.bin.lib", "shared").first; - root.assign ("bin.lib") = *type; - } + const string& type (t["bin.lib"].as<const string&> ()); - bool ar (*type == "static" || *type == "both"); - bool so (*type == "shared" || *type == "both"); + bool ar (type == "static" || type == "both"); + bool so (type == "shared" || type == "both"); if (!ar && !so) - fail << "unknown library type: " << *type << + fail << "unknown library type: " << type << info << "'static', 'shared', or 'both' expected"; if (ar) diff --git a/build/bin/target.cxx b/build/bin/target.cxx index 1849533..ca198d7d 100644 --- a/build/bin/target.cxx +++ b/build/bin/target.cxx @@ -4,6 +4,8 @@ #include <build/bin/target> +#include <build/bin/module> + using namespace std; namespace build @@ -131,6 +133,11 @@ namespace build static target* lib_factory (dir_path d, string n, const string* e) { + // If there is a target of type lib{} in this project, then + // initialized the lib part of the module. + // + init_lib (d); + liba* a (targets.find<liba> (d, n)); libso* so (targets.find<libso> (d, n)); lib* l (new lib (move (d), move (n), e)); |