From 70317569c6dcd9809ed4a8c425777e653ec6ca08 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 May 2017 18:24:31 +0300 Subject: Add hxx extension for headers --- build2/config/init | 31 --------- build2/config/init.cxx | 24 +++---- build2/config/init.hxx | 31 +++++++++ build2/config/module | 94 --------------------------- build2/config/module.cxx | 2 +- build2/config/module.hxx | 94 +++++++++++++++++++++++++++ build2/config/operation | 29 --------- build2/config/operation.cxx | 24 +++---- build2/config/operation.hxx | 29 +++++++++ build2/config/utility | 152 -------------------------------------------- build2/config/utility.cxx | 6 +- build2/config/utility.hxx | 152 ++++++++++++++++++++++++++++++++++++++++++++ build2/config/utility.txx | 4 +- 13 files changed, 336 insertions(+), 336 deletions(-) delete mode 100644 build2/config/init create mode 100644 build2/config/init.hxx delete mode 100644 build2/config/module create mode 100644 build2/config/module.hxx delete mode 100644 build2/config/operation create mode 100644 build2/config/operation.hxx delete mode 100644 build2/config/utility create mode 100644 build2/config/utility.hxx (limited to 'build2/config') diff --git a/build2/config/init b/build2/config/init deleted file mode 100644 index 7100ab2..0000000 --- a/build2/config/init +++ /dev/null @@ -1,31 +0,0 @@ -// file : build2/config/init -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CONFIG_INIT -#define BUILD2_CONFIG_INIT - -#include -#include - -#include - -namespace build2 -{ - namespace config - { - void - boot (scope&, const location&, unique_ptr&); - - bool - init (scope&, - scope&, - const location&, - unique_ptr&, - bool, - bool, - const variable_map&); - } -} - -#endif // BUILD2_CONFIG_INIT diff --git a/build2/config/init.cxx b/build2/config/init.cxx index 65aa7bb..889285d 100644 --- a/build2/config/init.cxx +++ b/build2/config/init.cxx @@ -2,18 +2,18 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include - -#include -#include -#include -#include -#include // exists() -#include - -#include -#include -#include +#include + +#include +#include +#include +#include +#include // exists() +#include + +#include +#include +#include using namespace std; using namespace butl; diff --git a/build2/config/init.hxx b/build2/config/init.hxx new file mode 100644 index 0000000..45c288b --- /dev/null +++ b/build2/config/init.hxx @@ -0,0 +1,31 @@ +// file : build2/config/init.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CONFIG_INIT_HXX +#define BUILD2_CONFIG_INIT_HXX + +#include +#include + +#include + +namespace build2 +{ + namespace config + { + void + boot (scope&, const location&, unique_ptr&); + + bool + init (scope&, + scope&, + const location&, + unique_ptr&, + bool, + bool, + const variable_map&); + } +} + +#endif // BUILD2_CONFIG_INIT_HXX diff --git a/build2/config/module b/build2/config/module deleted file mode 100644 index 3b58aa0..0000000 --- a/build2/config/module +++ /dev/null @@ -1,94 +0,0 @@ -// file : build2/config/module -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CONFIG_MODULE -#define BUILD2_CONFIG_MODULE - -#include -#include // find_if() - -#include - -#include -#include - -#include -#include - -namespace build2 -{ - namespace config - { - // An ordered list of modules each with an ordered list of list of - // config.* variables and their "save flags" (see save_variable()) that - // are used (as opposed to just being specified) in this configuration. - // Populated by the config utility functions (required(), optional()) - // and saved in the order populated. - // - struct saved_variable - { - reference_wrapper var; - uint64_t flags; - }; - - struct saved_variables: vector - { - // Normally each module only have a handful of config variables and we - // only do this during configuration so for now we do linear search - // instead of adding a map. - // - const_iterator - find (const variable& var) const - { - return std::find_if ( - begin (), - end (), - [&var] (const saved_variable& v) {return var == v.var;}); - } - }; - - struct saved_modules: butl::prefix_map - { - // Priority order with INT32_MIN being the highest. Modules with the - // same priority are saved in the order inserted. - // - // Generally, the idea is that we want higher-level modules at the top - // of the file since that's the configuration that we usualy want to - // change. So we have the following priority bands/defaults: - // - // 101-200/150 - code generators (e.g., yacc, bison) - // 201-300/250 - compilers (e.g., C, C++), - // 301-400/350 - binutils (ar, ld) - // - std::multimap order; - - iterator - insert (string name, int prio = 0) - { - auto p (emplace (move (name), saved_variables ())); - - if (p.second) - order.emplace (prio, p.first); - - return p.first; - } - }; - - struct module: module_base - { - config::saved_modules saved_modules; - - void - save_variable (const variable&, uint64_t flags = 0); - - void - save_module (const char* name, int prio = 0); - - static const string name; - static const uint64_t version; - }; - } -} - -#endif // BUILD2_CONFIG_MODULE diff --git a/build2/config/module.cxx b/build2/config/module.cxx index 6d54e46..19b5125 100644 --- a/build2/config/module.cxx +++ b/build2/config/module.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include using namespace std; diff --git a/build2/config/module.hxx b/build2/config/module.hxx new file mode 100644 index 0000000..d997802 --- /dev/null +++ b/build2/config/module.hxx @@ -0,0 +1,94 @@ +// file : build2/config/module.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CONFIG_MODULE_HXX +#define BUILD2_CONFIG_MODULE_HXX + +#include +#include // find_if() + +#include + +#include +#include + +#include +#include + +namespace build2 +{ + namespace config + { + // An ordered list of modules each with an ordered list of list of + // config.* variables and their "save flags" (see save_variable()) that + // are used (as opposed to just being specified) in this configuration. + // Populated by the config utility functions (required(), optional()) + // and saved in the order populated. + // + struct saved_variable + { + reference_wrapper var; + uint64_t flags; + }; + + struct saved_variables: vector + { + // Normally each module only have a handful of config variables and we + // only do this during configuration so for now we do linear search + // instead of adding a map. + // + const_iterator + find (const variable& var) const + { + return std::find_if ( + begin (), + end (), + [&var] (const saved_variable& v) {return var == v.var;}); + } + }; + + struct saved_modules: butl::prefix_map + { + // Priority order with INT32_MIN being the highest. Modules with the + // same priority are saved in the order inserted. + // + // Generally, the idea is that we want higher-level modules at the top + // of the file since that's the configuration that we usualy want to + // change. So we have the following priority bands/defaults: + // + // 101-200/150 - code generators (e.g., yacc, bison) + // 201-300/250 - compilers (e.g., C, C++), + // 301-400/350 - binutils (ar, ld) + // + std::multimap order; + + iterator + insert (string name, int prio = 0) + { + auto p (emplace (move (name), saved_variables ())); + + if (p.second) + order.emplace (prio, p.first); + + return p.first; + } + }; + + struct module: module_base + { + config::saved_modules saved_modules; + + void + save_variable (const variable&, uint64_t flags = 0); + + void + save_module (const char* name, int prio = 0); + + static const string name; + static const uint64_t version; + }; + } +} + +#endif // BUILD2_CONFIG_MODULE_HXX diff --git a/build2/config/operation b/build2/config/operation deleted file mode 100644 index 425869c..0000000 --- a/build2/config/operation +++ /dev/null @@ -1,29 +0,0 @@ -// file : build2/config/operation -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CONFIG_OPERATION -#define BUILD2_CONFIG_OPERATION - -#include -#include - -#include - -namespace build2 -{ - namespace config - { - extern const meta_operation_info configure; - extern const meta_operation_info disfigure; - - const string& - preprocess_create (const variable_overrides&, - values&, - vector_view&, - bool, - const location&); - } -} - -#endif // BUILD2_CONFIG_OPERATION diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index cf53292..bffc45b 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -2,21 +2,21 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace std; using namespace butl; diff --git a/build2/config/operation.hxx b/build2/config/operation.hxx new file mode 100644 index 0000000..bf9403f --- /dev/null +++ b/build2/config/operation.hxx @@ -0,0 +1,29 @@ +// file : build2/config/operation.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CONFIG_OPERATION_HXX +#define BUILD2_CONFIG_OPERATION_HXX + +#include +#include + +#include + +namespace build2 +{ + namespace config + { + extern const meta_operation_info configure; + extern const meta_operation_info disfigure; + + const string& + preprocess_create (const variable_overrides&, + values&, + vector_view&, + bool, + const location&); + } +} + +#endif // BUILD2_CONFIG_OPERATION_HXX diff --git a/build2/config/utility b/build2/config/utility deleted file mode 100644 index 041277a..0000000 --- a/build2/config/utility +++ /dev/null @@ -1,152 +0,0 @@ -// file : build2/config/utility -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD2_CONFIG_UTILITY -#define BUILD2_CONFIG_UTILITY - -#include -#include - -#include -#include - -namespace build2 -{ - class scope; - - namespace config - { - // Set, if necessary, a required config.* variable. - // - // If override is true and the variable doesn't come from this root scope - // or from the command line (i.e., it is inherited from the amalgamtion), - // then its value is "overridden" to the default value on this root scope. - // See save_variable() for more information on save_flags. - // - // Return the reference to the value as well as the indication of whether - // the value is "new", that is, it was set to the default value (inherited - // or not, including overrides). We also treat command line overrides - // (inherited or not) as new. This flag is usually used to test that the - // new value is valid, print report, etc. We return the value as lookup - // (always defined) to pass alone its location (could be used to detect - // inheritance, etc). - // - // Note also that if save_flags has save_commented, then a default value - // is never considered "new" since for such variables absence of a value - // means the default value. - // - template - pair - required (scope& root, - const variable&, - const T& default_value, - bool override = false, - uint64_t save_flags = 0); - - // Note that the variable is expected to have already been registered. - // - template - inline pair - required (scope& root, - const string& name, - const T& default_value, - bool override = false, - uint64_t save_flags = 0) - { - return required ( - root, var_pool[name], default_value, override, save_flags); - } - - inline pair - required (scope& root, - const string& name, - const char* default_value, - bool override = false, - uint64_t save_flags = 0) - { - return required ( - root, name, string (default_value), override, save_flags); - } - - // As above, but leave the unspecified value as undefined rather than - // setting it to the default value. - // - // This can be useful when we don't have a default value but may figure - // out some fallback. See config.bin.target for an example. - // - pair - omitted (scope& root, const variable&); - - // Note that the variable is expected to have already been registered. - // - inline pair - omitted (scope& root, const string& name) - { - return omitted (root, var_pool[name]); - } - - // Set, if necessary, an optional config.* variable. In particular, an - // unspecified variable is set to NULL which is used to distinguish - // between the "configured as unspecified" and "not yet configured" cases. - // - // Return the value (as always defined lookup), which can be NULL. - // - lookup - optional (scope& root, const variable&); - - // Note that the variable is expected to have already been registered. - // - inline lookup - optional (scope& root, const string& name) - { - return optional (root, var_pool[name]); - } - - // Check whether there are any variables specified from the config - // namespace. The idea is that we can check if there are any, say, - // config.install.* values. If there are none, then we can assume - // this functionality is not (yet) used and omit writing a whole - // bunch of NULL config.install.* values to the config.build file. - // We call it omitted/delayed configuration. - // - // Note that this function detects and ignores the special - // config.*.configured variable which may be used by a module to - // "remember" that it is unconfigured (e.g., in order to avoid re- - // running the tests, etc). - // - bool - specified (scope& root, const string& name); - - // Check if there is a false config.*.configured value. This mechanism can - // be used to "remember" that the module is left unconfigured in order to - // avoid re-running the tests, etc. - // - bool - unconfigured (scope& root, const string& name); - - // Set the config.*.configured value. Note that you only need to set it to - // false. It will be automatically ignored if there are any other config.* - // values for this module. Return true if this sets a new value. - // - bool - unconfigured (scope& root, const string& name, bool); - - // Enter the variable so that it is saved during configuration. See - // config::module for details. - // - const uint64_t save_commented = 0x01; // Save default value as commented. - - void - save_variable (scope& root, const variable&, uint64_t flags = 0); - - // Establish module order/priority. See config::module for details. - // - void - save_module (scope& root, const char* name, int prio = 0); - } -} - -#include - -#endif // BUILD2_CONFIG_UTILITY diff --git a/build2/config/utility.cxx b/build2/config/utility.cxx index ea66e92..c195e0b 100644 --- a/build2/config/utility.cxx +++ b/build2/config/utility.cxx @@ -2,11 +2,11 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include +#include -#include +#include using namespace std; diff --git a/build2/config/utility.hxx b/build2/config/utility.hxx new file mode 100644 index 0000000..33a3985 --- /dev/null +++ b/build2/config/utility.hxx @@ -0,0 +1,152 @@ +// file : build2/config/utility.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CONFIG_UTILITY_HXX +#define BUILD2_CONFIG_UTILITY_HXX + +#include +#include + +#include +#include + +namespace build2 +{ + class scope; + + namespace config + { + // Set, if necessary, a required config.* variable. + // + // If override is true and the variable doesn't come from this root scope + // or from the command line (i.e., it is inherited from the amalgamtion), + // then its value is "overridden" to the default value on this root scope. + // See save_variable() for more information on save_flags. + // + // Return the reference to the value as well as the indication of whether + // the value is "new", that is, it was set to the default value (inherited + // or not, including overrides). We also treat command line overrides + // (inherited or not) as new. This flag is usually used to test that the + // new value is valid, print report, etc. We return the value as lookup + // (always defined) to pass alone its location (could be used to detect + // inheritance, etc). + // + // Note also that if save_flags has save_commented, then a default value + // is never considered "new" since for such variables absence of a value + // means the default value. + // + template + pair + required (scope& root, + const variable&, + const T& default_value, + bool override = false, + uint64_t save_flags = 0); + + // Note that the variable is expected to have already been registered. + // + template + inline pair + required (scope& root, + const string& name, + const T& default_value, + bool override = false, + uint64_t save_flags = 0) + { + return required ( + root, var_pool[name], default_value, override, save_flags); + } + + inline pair + required (scope& root, + const string& name, + const char* default_value, + bool override = false, + uint64_t save_flags = 0) + { + return required ( + root, name, string (default_value), override, save_flags); + } + + // As above, but leave the unspecified value as undefined rather than + // setting it to the default value. + // + // This can be useful when we don't have a default value but may figure + // out some fallback. See config.bin.target for an example. + // + pair + omitted (scope& root, const variable&); + + // Note that the variable is expected to have already been registered. + // + inline pair + omitted (scope& root, const string& name) + { + return omitted (root, var_pool[name]); + } + + // Set, if necessary, an optional config.* variable. In particular, an + // unspecified variable is set to NULL which is used to distinguish + // between the "configured as unspecified" and "not yet configured" cases. + // + // Return the value (as always defined lookup), which can be NULL. + // + lookup + optional (scope& root, const variable&); + + // Note that the variable is expected to have already been registered. + // + inline lookup + optional (scope& root, const string& name) + { + return optional (root, var_pool[name]); + } + + // Check whether there are any variables specified from the config + // namespace. The idea is that we can check if there are any, say, + // config.install.* values. If there are none, then we can assume + // this functionality is not (yet) used and omit writing a whole + // bunch of NULL config.install.* values to the config.build file. + // We call it omitted/delayed configuration. + // + // Note that this function detects and ignores the special + // config.*.configured variable which may be used by a module to + // "remember" that it is unconfigured (e.g., in order to avoid re- + // running the tests, etc). + // + bool + specified (scope& root, const string& name); + + // Check if there is a false config.*.configured value. This mechanism can + // be used to "remember" that the module is left unconfigured in order to + // avoid re-running the tests, etc. + // + bool + unconfigured (scope& root, const string& name); + + // Set the config.*.configured value. Note that you only need to set it to + // false. It will be automatically ignored if there are any other config.* + // values for this module. Return true if this sets a new value. + // + bool + unconfigured (scope& root, const string& name, bool); + + // Enter the variable so that it is saved during configuration. See + // config::module for details. + // + const uint64_t save_commented = 0x01; // Save default value as commented. + + void + save_variable (scope& root, const variable&, uint64_t flags = 0); + + // Establish module order/priority. See config::module for details. + // + void + save_module (scope& root, const char* name, int prio = 0); + } +} + +#include + +#endif // BUILD2_CONFIG_UTILITY_HXX diff --git a/build2/config/utility.txx b/build2/config/utility.txx index 1434406..fc21710 100644 --- a/build2/config/utility.txx +++ b/build2/config/utility.txx @@ -2,8 +2,8 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include -#include +#include +#include namespace build2 { -- cgit v1.1