// file : mod/build-config-module.hxx -*- C++ -*- // license : MIT; see accompanying LICENSE file #ifndef MOD_BUILD_CONFIG_MODULE_HXX #define MOD_BUILD_CONFIG_MODULE_HXX #include #include // compare_c_string #include #include #include #include #include #include // Base class for modules that utilize the build controller configuration. // // Specifically, it loads build controller configuration and provides various // build configuration-related utilities. Note that the configuration is // shared across multiple modules once loaded. // // Note that the build database is in the database_module. // namespace brep { class build_config_module { protected: // Parse build configuration file and establish mapping of build bot agent // public keys fingerprints to their paths. Throw tab_parsing on parsing // error, system_error on the underlying OS error. // void init (const options::build&); bool exclude (const small_vector& exprs, const vector& constrs, const bbot::build_config& cfg, string* reason = nullptr, bool default_all_ucs = false) const { return brep::exclude (exprs, constrs, cfg, build_conf_->class_inheritance_map, reason, default_all_ucs); } // Check if the configuration belongs to the specified class. // bool belongs (const bbot::build_config&, const char*) const; bool belongs (const bbot::build_config& cfg, const string& cls) const { return belongs (cfg, cls.c_str ()); } // Configuration/toolchain combination that, in particular, can be used as // a set value. // // Note: contains shallow references to the configuration, toolchain name, // and version. // struct config_toolchain { const string& configuration; const string& toolchain_name; const bpkg::version& toolchain_version; bool operator< (const config_toolchain& ct) const { if (int r = toolchain_name.compare (ct.toolchain_name)) return r < 0; if (toolchain_version != ct.toolchain_version) return toolchain_version > ct.toolchain_version; return configuration.compare (ct.configuration) < 0; } }; protected: // Build configurations. // shared_ptr build_conf_; shared_ptr build_conf_names_; shared_ptr> build_conf_map_; // Map of build bot agent public keys fingerprints to the key file paths. // shared_ptr> bot_agent_key_map_; }; } #endif // MOD_BUILD_CONFIG_MODULE_HXX