diff options
Diffstat (limited to 'libbuild2/cc/compile-rule.hxx')
-rw-r--r-- | libbuild2/cc/compile-rule.hxx | 136 |
1 files changed, 72 insertions, 64 deletions
diff --git a/libbuild2/cc/compile-rule.hxx b/libbuild2/cc/compile-rule.hxx index d6cb002..0886b4b 100644 --- a/libbuild2/cc/compile-rule.hxx +++ b/libbuild2/cc/compile-rule.hxx @@ -8,7 +8,8 @@ #include <libbuild2/utility.hxx> #include <libbuild2/rule.hxx> -#include <libbuild2/filesystem.hxx> // auto_rmfile +#include <libbuild2/dyndep.hxx> +#include <libbuild2/file-cache.hxx> #include <libbuild2/cc/types.hxx> #include <libbuild2/cc/common.hxx> @@ -21,6 +22,8 @@ namespace build2 namespace cc { + class config_module; + // The order is arranged so that their integral values indicate whether // one is a "stronger" than another. // @@ -36,106 +39,108 @@ namespace build2 size_t copied; // First copied-over bmi*{}, 0 if none. }; - class LIBBUILD2_CC_SYMEXPORT compile_rule: public simple_rule, virtual common + class LIBBUILD2_CC_SYMEXPORT compile_rule: public simple_rule, + virtual common, + dyndep_rule { public: - compile_rule (data&&); + struct match_data; + + compile_rule (data&&, const scope&); virtual bool - match (action, target&, const string&) const override; + match (action, target&) const override; virtual recipe apply (action, target&) const override; target_state - perform_update (action, const target&) const; + perform_update (action, const target&, match_data&) const; target_state - perform_clean (action, const target&) const; + perform_clean (action, const target&, const target_type&) const; + + public: + using appended_libraries = small_vector<const target*, 256>; + + void + append_library_options (appended_libraries&, strings&, + const scope&, + action, const file&, bool, linfo, + bool, bool) const; + + optional<path> + find_system_header (const path&) const; + + protected: + static void + functions (function_family&, const char*); // functions.cxx private: - struct match_data; using environment = small_vector<const char*, 2>; template <typename T> void - append_sys_inc_options (T&) const; + append_sys_hdr_options (T&) const; template <typename T> void - append_lib_options (const scope&, - T&, - action, - const target&, - linfo) const; - - // Mapping of include prefixes (e.g., foo in <foo/bar>) for auto- - // generated headers to directories where they will be generated. - // - // We are using a prefix map of directories (dir_path_map) instead of - // just a map in order to also cover sub-paths (e.g., <foo/more/bar> if - // we continue with the example). Specifically, we need to make sure we - // don't treat foobar as a sub-directory of foo. - // - // The priority is used to decide who should override whom. Lesser - // values are considered higher priority. See append_prefixes() for - // details. - // - // @@ The keys should be normalized. - // - struct prefix_value - { - dir_path directory; - size_t priority; - }; - using prefix_map = dir_path_map<prefix_value>; + append_library_options (appended_libraries&, T&, + const scope&, + const scope*, + action, const file&, bool, linfo, bool, + library_cache*) const; + template <typename T> void - append_prefixes (prefix_map&, const target&, const variable&) const; + append_library_options (T&, + const scope&, + action, const target&, linfo) const; - void - append_lib_prefixes (const scope&, - prefix_map&, - action, - target&, - linfo) const; + using prefix_map = dyndep_rule::prefix_map; + using srcout_map = dyndep_rule::srcout_map; - prefix_map - build_prefix_map (const scope&, action, target&, linfo) const; + void + append_prefixes (prefix_map&, + const scope&, const target&, + const variable&) const; - small_vector<const target_type*, 2> - map_extension (const scope&, const string&, const string&) const; + void + append_library_prefixes (appended_libraries&, prefix_map&, + const scope&, + action, const target&, linfo) const; - // Src-to-out re-mapping. See extract_headers() for details. - // - using srcout_map = path_map<dir_path>; + prefix_map + build_prefix_map (const scope&, action, const target&, linfo) const; - struct module_mapper_state; + struct gcc_module_mapper_state; - void - gcc_module_mapper (module_mapper_state&, + optional<bool> + gcc_module_mapper (gcc_module_mapper_state&, action, const scope&, file&, linfo, - ifdstream&, ofdstream&, + const string&, ofdstream&, depdb&, bool&, bool&, optional<prefix_map>&, srcout_map&) const; pair<const file*, bool> enter_header (action, const scope&, file&, linfo, - path&&, bool, - optional<prefix_map>&, srcout_map&) const; + path&&, bool, bool, + optional<prefix_map>&, const srcout_map&) const; optional<bool> inject_header (action, file&, const file&, timestamp, bool) const; - pair<auto_rmfile, bool> + void extract_headers (action, const scope&, file&, linfo, const file&, match_data&, - depdb&, bool&, timestamp) const; + depdb&, bool&, timestamp, module_imports&, + pair<file_cache::entry, bool>&) const; - pair<unit, string> + string parse_unit (action, file&, linfo, - const file&, auto_rmfile&, - const match_data&, const path&) const; + const file&, file_cache::entry&, + const match_data&, const path&, + unit&) const; void extract_modules (action, const scope&, file&, linfo, @@ -148,15 +153,17 @@ namespace build2 const target_type&, const file&, module_imports&, sha256&) const; - dir_path + pair<dir_path, const scope&> find_modules_sidebuild (const scope&) const; - const file& - make_module_sidebuild (action, const scope&, const target&, + pair<target&, ulock> + make_module_sidebuild (action, const scope&, + const file*, otype, const target&, const string&) const; const file& - make_header_sidebuild (action, const scope&, linfo, const file&) const; + make_header_sidebuild (action, const scope&, const file&, + linfo, const file&) const; void append_header_options (environment&, cstrings&, small_vector<string, 2>&, @@ -168,7 +175,7 @@ namespace build2 action, const file&, const match_data&, const path&) const; - // Compiler-specific language selection option. Return the number of + // Compiler-specific language selection options. Return the number of // options (arguments, really) appended. // size_t @@ -179,6 +186,7 @@ namespace build2 private: const string rule_id; + const config_module* header_cache_; }; } } |