diff options
Diffstat (limited to 'libbuild2/cc/module.hxx')
-rw-r--r-- | libbuild2/cc/module.hxx | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/libbuild2/cc/module.hxx b/libbuild2/cc/module.hxx index 85b7158..4213516 100644 --- a/libbuild2/cc/module.hxx +++ b/libbuild2/cc/module.hxx @@ -4,6 +4,8 @@ #ifndef LIBBUILD2_CC_MODULE_HXX #define LIBBUILD2_CC_MODULE_HXX +#include <unordered_map> + #include <libbuild2/types.hxx> #include <libbuild2/utility.hxx> @@ -15,6 +17,7 @@ #include <libbuild2/cc/compile-rule.hxx> #include <libbuild2/cc/link-rule.hxx> #include <libbuild2/cc/install-rule.hxx> +#include <libbuild2/cc/predefs-rule.hxx> #include <libbuild2/cc/export.hxx> @@ -45,8 +48,10 @@ namespace build2 // Translate the x.std value (if any) to the standard-selecting // option(s) (if any) and fold them (normally by pre-pending) into the - // compiler mode options. This function may also check/set x.features.* - // variables on the root scope. + // compiler mode options. + // + // This function may also check/set [config.]x.features.* variables on + // the root scope. // virtual void translate_std (const compiler_info&, @@ -57,33 +62,72 @@ namespace build2 const compiler_info* x_info; + string env_checksum; // Environment checksum (also in x.path). + + // Cached x.internal.scope value. + // + using internal_scope = data::internal_scope; + optional<internal_scope> iscope; + const scope* iscope_current = nullptr; + // Temporary storage for data::sys_*_dirs_*. // size_t sys_lib_dirs_mode; - size_t sys_inc_dirs_mode; + size_t sys_hdr_dirs_mode; size_t sys_mod_dirs_mode; size_t sys_lib_dirs_extra; - size_t sys_inc_dirs_extra; + size_t sys_hdr_dirs_extra; bool new_config = false; // See guess() and init() for details. + // Header cache (see compile_rule::enter_header()). + // + // We place it into the config module so that we have an option of + // sharing it for the entire weak amalgamation. + // + public: + // Keep the hash in the key. This way we can compute it outside of the + // lock. + // + struct header_key + { + path file; + size_t hash; + + friend bool + operator== (const header_key& x, const header_key& y) + { + return x.file == y.file; // Note: hash was already compared. + } + }; + + struct header_key_hasher + { + size_t operator() (const header_key& k) const {return k.hash;} + }; + + mutable shared_mutex header_map_mutex; + mutable std::unordered_map<header_key, + const file*, + header_key_hasher> header_map; + private: // Defined in gcc.cxx. // pair<dir_paths, size_t> - gcc_header_search_dirs (const process_path&, scope&) const; + gcc_header_search_dirs (const compiler_info&, scope&) const; pair<dir_paths, size_t> - gcc_library_search_dirs (const process_path&, scope&) const; + gcc_library_search_dirs (const compiler_info&, scope&) const; // Defined in msvc.cxx. // pair<dir_paths, size_t> - msvc_header_search_dirs (const process_path&, scope&) const; + msvc_header_search_dirs (const compiler_info&, scope&) const; pair<dir_paths, size_t> - msvc_library_search_dirs (const process_path&, scope&) const; + msvc_library_search_dirs (const compiler_info&, scope&) const; }; class LIBBUILD2_CC_SYMEXPORT module: public build2::module, @@ -91,19 +135,24 @@ namespace build2 public link_rule, public compile_rule, public install_rule, - public libux_install_rule + public libux_install_rule, + public predefs_rule { public: explicit - module (data&& d) + module (data&& d, const scope& rs) : common (move (d)), link_rule (move (d)), - compile_rule (move (d)), + compile_rule (move (d), rs), install_rule (move (d), *this), - libux_install_rule (move (d), *this) {} + libux_install_rule (move (d), *this), + predefs_rule (move (d)) {} void - init (scope&, const location&, const variable_map&); + init (scope&, + const location&, + const variable_map&, + const compiler_info&); }; } } |