// file : bpkg/manifest-utility.hxx -*- C++ -*- // copyright : Copyright (c) 2014-2019 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #ifndef BPKG_MANIFEST_UTILITY_HXX #define BPKG_MANIFEST_UTILITY_HXX #include #include #include #include namespace bpkg { extern const path repositories_file; // repositories.manifest extern const path packages_file; // packages.manifest extern const path signature_file; // signature.manifest extern const path manifest_file; // manifest // Package naming schemes. // enum class package_scheme { none, sys }; // Extract scheme from [:]. Position the pointer right after // the scheme end if present, otherwise leave unchanged. // package_scheme parse_package_scheme (const char*&); // Extract the package name and version components from [/]. // Diagnose invalid components and throw failed. // package_name parse_package_name (const char*, bool allow_version = true); inline package_name parse_package_name (const string& s, bool allow_version = true) { return parse_package_name (s.c_str (), allow_version); } // Return empty version if none is specified. // version parse_package_version (const char*); inline version parse_package_version (const string& s) { return parse_package_version (s.c_str ()); } // If the passed location is a relative local path, then assume this is a // relative path to the repository directory and complete it based on the // current working directory. Diagnose invalid locations and throw failed. // repository_location parse_location (const string&, optional); // Return the repository state subdirectory for the specified location as it // appears under .bpkg/repos/ in the bpkg configuration. Return empty // directory if the repository type doesn't have any state. // // Note that the semantics used to produce this name is repository type- // specific and can base on the repository canonical name or (potentially a // subset of) the location URL. In particular, a state directory could be // shared by multiple repository locations of the same type. // dir_path repository_state (const repository_location&); // Return true if the argument is a valid repository canonical name. // bool repository_name (const string&); // Return the version of a package as provided by the build2 version module. // Return nullopt if the version module is disabled for the package (or the // build2 project directory doesn't contain the manifest file). Fail if the // directory is not a build2 project. // // Note that if the package directory is under the version control, then the // resulting version may be populated with the snapshot information (see // libbutl/standard-version.mxx for more details). Thus, this function can // be used for fixing up the package manifest version. // class common_options; optional package_version (const common_options&, const dir_path&); } #endif // BPKG_MANIFEST_UTILITY_HXX