diff options
Diffstat (limited to 'bpkg/package-skeleton.hxx')
-rw-r--r-- | bpkg/package-skeleton.hxx | 87 |
1 files changed, 74 insertions, 13 deletions
diff --git a/bpkg/package-skeleton.hxx b/bpkg/package-skeleton.hxx index 7224d1d..947522e 100644 --- a/bpkg/package-skeleton.hxx +++ b/bpkg/package-skeleton.hxx @@ -27,14 +27,27 @@ namespace bpkg // is NULL, then the skeleton can only be used to print and collect the // configuration information. // - // If the package is external, then the existing package source root + // If the package is being reconfigured (rather than up/downgraded), then + // the existing package source and output root directories (src_root and + // out_root) need to be specified (as absolute and normalized). Otherwise, + // if the package is external, then the existing package source root // directory needs to be specified (as absolute and normalized). In this // case, if output root is specified (as absolute and normalized; normally // <config-dir>/<package-name>), then it's used as is. Otherwise, an empty // skeleton directory is used as output root. // - // If the package is not external, then none of the root directories - // should be specified. + // If the package is neither being reconfigured nor is external, then none + // of the root directories should be specified. + // + // If the package is configured as source and the user and/or dependent + // configuration is requested to be loaded from config.build, then the + // existing package old source and output root directories (old_src_root + // and old_out_root) need to be specified (as absolute and normalized). If + // specified, they are used instead of package source and output root + // directories to load the current user and/or dependent configuration. + // The idea here is that during package upgrade/downgrade, we want to load + // the old configuration from the old version's src/out but then continue + // evaluating clauses using the new version's src/out. // // The disfigure argument should indicate whether the package is being // reconfigured from scratch (--disfigure). @@ -68,13 +81,22 @@ namespace bpkg bool disfigure, const vector<config_variable>* config_srcs, optional<dir_path> src_root, - optional<dir_path> out_root); - + optional<dir_path> out_root, + optional<dir_path> old_src_root, + optional<dir_path> old_out_root, + uint16_t load_config_flags); package_key package; bool system; shared_ptr<const available_package> available; + // Load package (old) configuration flags. + // + uint16_t load_config_flags; + + static const uint16_t load_config_user = 0x1; + static const uint16_t load_config_dependent = 0x2; + // The following functions should be called in the following sequence // (* -- zero or more, ? -- zero or one): // @@ -82,8 +104,13 @@ namespace bpkg // ? dependent_config() // * evaluate_*() // * empty() | print_config() + // * config_checksum() // collect_config() // + // Note that the load_old_config() function can be called at eny point + // before collect_config() (and is called implicitly by most other + // functions). + // // Note that a copy of the skeleton is expected to continue with the // sequence rather than starting from scratch, unless reset() is called. // @@ -141,11 +168,13 @@ namespace bpkg bool evaluate_prefer_accept (const dependency_configurations&, - const string&, const string&, pair<size_t, size_t>); + const string&, const string&, pair<size_t, size_t>, + bool has_alternative); bool evaluate_require (const dependency_configurations&, - const string&, pair<size_t, size_t>); + const string&, pair<size_t, size_t>, + bool has_alternative); // Reset the skeleton to the start of the call sequence. // @@ -166,6 +195,11 @@ namespace bpkg void print_config (ostream&, const char* indent); + // Load the package's old configuration, unless it is already loaded. + // + void + load_old_config (); + // Return the accumulated configuration variables (first) and project // configuration variable sources (second). Note that the arrays are not // necessarily parallel (config_vars may contain non-project variables). @@ -179,6 +213,12 @@ namespace bpkg pair<strings, vector<config_variable>> collect_config () &&; + // Return the checksum of the project configuration variables that will be + // returned by the collect_config() function call. + // + string + config_checksum (); + // Implementation details. // public: @@ -186,16 +226,17 @@ namespace bpkg // constructor has some special logic. // ~package_skeleton (); - package_skeleton (package_skeleton&&); - package_skeleton& operator= (package_skeleton&&); + package_skeleton (package_skeleton&&) noexcept; + package_skeleton& operator= (package_skeleton&&) noexcept; package_skeleton (const package_skeleton&); package_skeleton& operator= (const package_skeleton&) = delete; private: - // Load old user configuration variables from config.build (or equivalent) - // and merge them into config_vars_. Also verify new user configuration - // already in config_vars_ makes sense. + // Load old user and/or dependent configuration variables from + // config.build (or equivalent) and merge them into config_vars_ and + // config_var_srcs_. Also verify new user configuration already in + // config_vars_ makes sense. // // This should be done before any attempt to load the configuration with // config.config.disfigure and, if this did not happen, inside @@ -203,7 +244,7 @@ namespace bpkg // config.config.disfigure). // void - load_old_config (); + load_old_config_impl (); // (Re)load the build system state. // @@ -244,6 +285,13 @@ namespace bpkg string var_prefix_; // config.<project> strings config_vars_; + + // Configuration sources for variables in config_vars_ (parallel). Can + // only contain config_source::{user,dependent} entries (see + // load_old_config_impl() for details). + // + vector<config_source> config_var_srcs_; + bool disfigure_; const vector<config_variable>* config_srcs_; // NULL if nothing to do or // already done. @@ -251,6 +299,19 @@ namespace bpkg dir_path src_root_; // Must be absolute and normalized. dir_path out_root_; // If empty, the same as src_root_. + // True if the existing source root directory has been specified. + // + // Note that if that's the case, we can use the manifest file this + // directory contains for diagnostics. + // + bool src_root_specified_ = false; + + // If specified, are used instead of {src,out}_root_ for loading of the + // project configuration variables. + // + dir_path old_src_root_; + dir_path old_out_root_; + bool created_ = false; bool verified_ = false; bool loaded_old_config_; |