diff --git a/include/vcpkg/base/contractual-constants.h b/include/vcpkg/base/contractual-constants.h index b6e45a37e2..202b09bada 100644 --- a/include/vcpkg/base/contractual-constants.h +++ b/include/vcpkg/base/contractual-constants.h @@ -331,17 +331,31 @@ namespace vcpkg inline constexpr StringLiteral FileBaselineDotJson = "baseline.json"; inline constexpr StringLiteral FileBin = "bin"; inline constexpr StringLiteral FileControl = "CONTROL"; + inline constexpr StringLiteral FileCopying = "COPYING"; + inline constexpr StringLiteral FileCopyright = "copyright"; inline constexpr StringLiteral FileDebug = "debug"; inline constexpr StringLiteral FileDetectCompiler = "detect_compiler"; inline constexpr StringLiteral FileDotDsStore = ".DS_Store"; inline constexpr StringLiteral FileInclude = "include"; + inline constexpr StringLiteral FileIncomplete = "incomplete"; + inline constexpr StringLiteral FileInfo = "info"; + inline constexpr StringLiteral FileLicense = "LICENSE"; + inline constexpr StringLiteral FileLicenseDotTxt = "LICENSE.txt"; inline constexpr StringLiteral FilePortfileDotCMake = "portfile.cmake"; + inline constexpr StringLiteral FileShare = "share"; + inline constexpr StringLiteral FileStatus = "status"; inline constexpr StringLiteral FileTools = "tools"; + inline constexpr StringLiteral FileUpdates = "updates"; + inline constexpr StringLiteral FileUsage = "usage"; + inline constexpr StringLiteral FileVcpkg = "vcpkg"; inline constexpr StringLiteral FileVcpkgAbiInfo = "vcpkg_abi_info.txt"; inline constexpr StringLiteral FileVcpkgBundleDotJson = "vcpkg-bundle.json"; inline constexpr StringLiteral FileVcpkgConfigurationDotJson = "vcpkg-configuration.json"; inline constexpr StringLiteral FileVcpkgDotJson = "vcpkg.json"; + inline constexpr StringLiteral FileVcpkgLock = "vcpkg-lock.json"; inline constexpr StringLiteral FileVcpkgPathTxt = "vcpkg.path.txt"; + inline constexpr StringLiteral FileVcpkgPortConfig = "vcpkg-port-config.cmake"; + inline constexpr StringLiteral FileVcpkgSpdxJson = "vcpkg.spdx.json"; inline constexpr StringLiteral FileVcpkgUserProps = "vcpkg.user.props"; inline constexpr StringLiteral FileVcpkgUserTargets = "vcpkg.user.targets"; inline constexpr StringLiteral FileVersions = "versions"; diff --git a/include/vcpkg/installedpaths.h b/include/vcpkg/installedpaths.h index 101d8793d0..08349eb24f 100644 --- a/include/vcpkg/installedpaths.h +++ b/include/vcpkg/installedpaths.h @@ -2,6 +2,7 @@ #include +#include #include #include @@ -16,15 +17,16 @@ namespace vcpkg const Path& root() const { return m_root; } Path listfile_path(const BinaryParagraph& pgh) const; - Path vcpkg_dir() const { return m_root / "vcpkg"; } - Path vcpkg_dir_status_file() const { return vcpkg_dir() / "status"; } - Path vcpkg_dir_info() const { return vcpkg_dir() / "info"; } - Path vcpkg_dir_updates() const { return vcpkg_dir() / "updates"; } - Path lockfile_path() const { return vcpkg_dir() / "vcpkg-lock.json"; } + Path vcpkg_dir() const { return m_root / FileVcpkg; } + Path vcpkg_dir_status_file() const { return vcpkg_dir() / FileStatus; } + Path vcpkg_dir_info() const { return vcpkg_dir() / FileInfo; } + Path vcpkg_dir_updates() const { return vcpkg_dir() / FileUpdates; } + Path lockfile_path() const { return vcpkg_dir() / FileVcpkgLock; } Path triplet_dir(Triplet t) const { return m_root / t.canonical_name(); } - Path share_dir(const PackageSpec& p) const { return triplet_dir(p.triplet()) / "share" / p.name(); } - Path usage_file(const PackageSpec& p) const { return share_dir(p) / "usage"; } - Path vcpkg_port_config_cmake(const PackageSpec& p) const { return share_dir(p) / "vcpkg-port-config.cmake"; } + Path share_dir(const PackageSpec& p) const { return triplet_dir(p.triplet()) / FileShare / p.name(); } + Path usage_file(const PackageSpec& p) const { return share_dir(p) / FileUsage; } + Path spdx_file(const PackageSpec& p) const { return share_dir(p) / FileVcpkgSpdxJson; } + Path vcpkg_port_config_cmake(const PackageSpec& p) const { return share_dir(p) / FileVcpkgPortConfig; } private: Path m_root; diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 26d949ea58..408140d2e3 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -941,7 +941,7 @@ namespace vcpkg const auto& abi = action.abi_info.value_or_exit(VCPKG_LINE_INFO); const auto json_path = - action.package_dir.value_or_exit(VCPKG_LINE_INFO) / "share" / action.spec.name() / "vcpkg.spdx.json"; + action.package_dir.value_or_exit(VCPKG_LINE_INFO) / FileShare / action.spec.name() / FileVcpkgSpdxJson; fs.write_contents_and_dirs( json_path, create_spdx_sbom( @@ -1446,7 +1446,7 @@ namespace vcpkg if (abi_info.abi_tag_file) { auto& abi_file = *abi_info.abi_tag_file.get(); - const auto abi_package_dir = action.package_dir.value_or_exit(VCPKG_LINE_INFO) / "share" / spec.name(); + const auto abi_package_dir = action.package_dir.value_or_exit(VCPKG_LINE_INFO) / FileShare / spec.name(); const auto abi_file_in_package = abi_package_dir / FileVcpkgAbiInfo; build_logs_recorder.record_build_result(paths, spec, result.code); filesystem.create_directories(abi_package_dir, VCPKG_LINE_INFO); diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 22f9fcad01..64fe9998a7 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -433,8 +433,8 @@ namespace vcpkg::Prefab const auto share_root = paths.packages() / fmt::format("{}_{}", name, action.spec.triplet()); - fs.copy_file(share_root / "share" / name / "copyright", - meta_dir / "LICENSE", + fs.copy_file(share_root / FileShare / name / FileCopyright, + meta_dir / FileLicense, CopyOptions::overwrite_existing, IgnoreErrors{}); diff --git a/src/vcpkg/postbuildlint.cpp b/src/vcpkg/postbuildlint.cpp index 968e7c96b3..a11e6131e7 100644 --- a/src/vcpkg/postbuildlint.cpp +++ b/src/vcpkg/postbuildlint.cpp @@ -282,7 +282,7 @@ namespace vcpkg const Path& portfile_cmake, MessageSink& msg_sink) { - const auto debug_share = package_dir / "debug" VCPKG_PREFERRED_SEPARATOR "share"; + const auto debug_share = package_dir / FileDebug / FileShare; if (fs.exists(debug_share, IgnoreErrors{})) { msg_sink.print(Color::warning, @@ -303,7 +303,7 @@ namespace vcpkg const Path& portfile_cmake, MessageSink& msg_sink) { - if (!fs.exists(package_dir / "share" / package_name / "vcpkg-port-config.cmake", IgnoreErrors{})) + if (!fs.exists(package_dir / FileShare / package_name / FileVcpkgPortConfig, IgnoreErrors{})) { msg_sink.print(Color::warning, LocalizedString::from_raw(portfile_cmake) @@ -327,8 +327,8 @@ namespace vcpkg static constexpr StringLiteral STANDARD_INSTALL_USAGE = R"###(file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"))###"; - auto usage_path_from = port_dir / "usage"; - auto usage_path_to = package_dir / "share" / package_name / "usage"; + auto usage_path_from = port_dir / FileUsage; + auto usage_path_to = package_dir / FileShare / package_name / FileUsage; if (fs.is_regular_file(usage_path_from) && !fs.is_regular_file(usage_path_to)) { @@ -467,8 +467,8 @@ namespace vcpkg const Path& portfile_cmake, MessageSink& msg_sink) { - static constexpr StringLiteral copyright_filenames[] = {"COPYING", "LICENSE", "LICENSE.txt"}; - const auto copyright_file = package_dir / "share" / spec_name / "copyright"; + static constexpr StringLiteral copyright_filenames[] = {FileCopying, FileLicense, FileLicenseDotTxt}; + const auto copyright_file = package_dir / FileShare / spec_name / FileCopyright; switch (fs.status(copyright_file, IgnoreErrors{})) {