// file : build/config/module.cxx -*- C++ -*- // copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file #include #include #include #include #include #include using namespace std; namespace build { namespace config { static bool trigger (bool pre, scope& base, path& p) { tracer trace ("config::trigger"); if (pre) { level4 ([&]{trace << "intercepted sourcing of " << p;}); return file_exists (p); } else return true; } void init (scope& root, scope& base, const location& l) { //@@ TODO: avoid multiple inits (generally, for modules). // tracer trace ("config::init"); if (&root != &base) fail (l) << "config module must be initialized in project root scope"; const dir_path& out_root (root.path ()); level4 ([&]{trace << "for " << out_root;}); // Register meta-operations. // if (root.meta_operations.insert (configure) != configure_id || root.meta_operations.insert (disfigure) != disfigure_id) fail (l) << "config module must be initialized before other modules"; // Register the build/config.build sourcing trigger. // root.triggers[out_root / path ("build/config.build")] = &trigger; } } }