Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract more contractual constants. #1529

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/vcpkg/base/contractual-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 10 additions & 8 deletions include/vcpkg/installedpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <vcpkg/fwd/binaryparagraph.h>

#include <vcpkg/base/contractual-constants.h>
#include <vcpkg/base/path.h>

#include <vcpkg/packagespec.h>
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/export.prefab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{});

Expand Down
12 changes: 6 additions & 6 deletions src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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))
{
Expand Down Expand Up @@ -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{}))
{
Expand Down
Loading