diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-09 15:06:27 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-09 15:06:27 +0200 |
commit | d304762e4338b4a055e2be018205a00c2ca9ee2f (patch) | |
tree | 252a4aa70118135e589095442fb4df3879c96eb0 /bdep/project.hxx | |
parent | df5e58e6e5eb2727a185bf9a98a462c18fa3a83d (diff) |
Support for resolving and adding configurations
Diffstat (limited to 'bdep/project.hxx')
-rw-r--r-- | bdep/project.hxx | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/bdep/project.hxx b/bdep/project.hxx index 274455c..42f520a 100644 --- a/bdep/project.hxx +++ b/bdep/project.hxx @@ -26,9 +26,16 @@ void assert (int); namespace bdep { + using optional_string = optional<string>; + using optional_dir_path = optional<dir_path>; + #pragma db map type(dir_path) as(string) \ to((?).string ()) from(bdep::dir_path (?)) + #pragma db map type(optional_dir_path) as(bdep::optional_string) \ + to((?) ? (?)->string () : bdep::optional_string ()) \ + from((?) ? bdep::dir_path (*(?)) : bdep::optional_dir_path ()) + //@@ TODO: do we need session/shared_ptr? #pragma db object pointer(shared_ptr) session @@ -36,23 +43,72 @@ namespace bdep { public: - dir_path path; // @@ TODO: relative or absolute? - string name; + // The configuration stores an absolute and normalized path to the bpkg + // configuration. It may also have a name. A configuration can be moved or + // renamed so we also have the id (it is NULL'able so that we can assign + // fixed configuration ids, for example, in configurations.manifest). + // + // We also store a version of the configuration path relative to the + // project directory so that we can automatically handle moving of the + // project and its configurations as a bundle (note that the dir: + // repository path in the configuration will have to be adjust as well). + // Since it is not always possible to derive a relative path, it is + // optional. + // + optional<uint64_t> id; + optional<string> name; + dir_path path; + optional<dir_path> relative_path; + + bool default_; // Database mapping. // - #pragma db member(name) id - //#pragma db member(name) index + #pragma db member(id) id auto + #pragma db member(name) unique + #pragma db member(path) unique + + // Make path comparison case-insensitive for certain platforms. + // + // It would have been nice to do something like this but we can't: the + // options are stored in the changelog and this will render changelog + // platform-specific. So instead we tweak the scheme at runtime after + // creating the database. + // + // #ifdef _WIN32 + // #pragma db member(path) options("COLLATE NOCASE") + // #pragma db member(relative_path) options("COLLATE NOCASE") + // #endif private: friend class odb::access; configuration () = default; }; - // Given project_options (and CWD) locate the packages and their project. - // The result is the absolute and normalized project directory and a vector - // of relative (to the project directory) package directories (which will be - // empty if ignore_packages is true). + #pragma db view object(configuration) + struct configuration_count + { + #pragma db column("COUNT(*)") + size_t result; + + operator size_t () const {return result;} + }; + + // Given the project directory, database, and options resolve all the + // mentioned configurations or find the default configuration if none were + // mentioned. + // + using configurations = vector<shared_ptr<configuration>>; + + configurations + find_configurations (const dir_path& prj, + transaction&, + const project_options&); + + // Given the project options (and CWD) locate the packages and their + // project. The result is the absolute and normalized project directory and + // a vector of relative (to the project directory) package directories + // (which will be empty if ignore_packages is true). // // Note that if the package directory is the same as project, then the // package directory will be empty (and not ./). |