aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2020-12-30 12:12:17 -0800
committerGitHub <noreply@github.com>2020-12-30 12:12:17 -0800
commit6772fdd145f2b69da18cdf14a5f93bc935aaf7e9 (patch)
treecccc445d310b1da351fbd9e2c398d1b223e8675d /toolsrc/src
parentf55a5d91d965ec3aa7c5ce63872fcd5d90cc635e (diff)
downloadvcpkg-6772fdd145f2b69da18cdf14a5f93bc935aaf7e9.tar.gz
vcpkg-6772fdd145f2b69da18cdf14a5f93bc935aaf7e9.zip
[vcpkg] Teach `vcpkg install` `--no-build-missing` (#15139)
* [vcpkg] Teach `vcpkg install` `--no-build-missing` This switch causes failure to restore from cache to abort the build instead of performing a just-in-time build. This is useful in complex CI systems where the build was expected to have been performed previously, such as via another pipeline. * [vcpkg] Rename flag to require binary caching
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/build.cpp6
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp2
-rw-r--r--toolsrc/src/vcpkg/install.cpp11
3 files changed, 15 insertions, 4 deletions
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index b01162b4f..eb2a338b2 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -1164,6 +1164,10 @@ namespace vcpkg::Build
// missing package, proceed to build.
}
}
+ if (action.build_options.build_missing == BuildMissing::NO)
+ {
+ return BuildResult::CACHE_MISSING;
+ }
ExtendedBuildResult result = do_build_package_and_clean_buildtrees(args, paths, action);
@@ -1190,6 +1194,7 @@ namespace vcpkg::Build
static const std::string POST_BUILD_CHECKS_FAILED_STRING = "POST_BUILD_CHECKS_FAILED";
static const std::string CASCADED_DUE_TO_MISSING_DEPENDENCIES_STRING = "CASCADED_DUE_TO_MISSING_DEPENDENCIES";
static const std::string EXCLUDED_STRING = "EXCLUDED";
+ static const std::string CACHE_MISSING_STRING = "CACHE_MISSING";
static const std::string DOWNLOADED_STRING = "DOWNLOADED";
switch (build_result)
@@ -1201,6 +1206,7 @@ namespace vcpkg::Build
case BuildResult::FILE_CONFLICTS: return FILE_CONFLICTS_STRING;
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: return CASCADED_DUE_TO_MISSING_DEPENDENCIES_STRING;
case BuildResult::EXCLUDED: return EXCLUDED_STRING;
+ case BuildResult::CACHE_MISSING: return CACHE_MISSING_STRING;
case BuildResult::DOWNLOADED: return DOWNLOADED_STRING;
default: Checks::unreachable(VCPKG_LINE_INFO);
}
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp
index e7768f2bf..e811efd2f 100644
--- a/toolsrc/src/vcpkg/dependencies.cpp
+++ b/toolsrc/src/vcpkg/dependencies.cpp
@@ -356,7 +356,7 @@ namespace vcpkg::Dependencies
std::string to_output_string(RequestType request_type, const CStringView s)
{
- return to_output_string(request_type, s, {Build::UseHeadVersion::NO}, {}, {}, {});
+ return to_output_string(request_type, s, {}, {}, {}, {});
}
InstallPlanAction::InstallPlanAction() noexcept
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index 50f07c732..cac0e0e69 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -511,6 +511,7 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_DRY_RUN = "dry-run";
static constexpr StringLiteral OPTION_USE_HEAD_VERSION = "head";
static constexpr StringLiteral OPTION_NO_DOWNLOADS = "no-downloads";
+ static constexpr StringLiteral OPTION_ONLY_BINARYCACHING = "only-binarycaching";
static constexpr StringLiteral OPTION_ONLY_DOWNLOADS = "only-downloads";
static constexpr StringLiteral OPTION_RECURSE = "recurse";
static constexpr StringLiteral OPTION_KEEP_GOING = "keep-going";
@@ -523,11 +524,12 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_MANIFEST_FEATURE = "x-feature";
static constexpr StringLiteral OPTION_PROHIBIT_BACKCOMPAT_FEATURES = "x-prohibit-backcompat-features";
- static constexpr std::array<CommandSwitch, 10> INSTALL_SWITCHES = {{
+ static constexpr std::array<CommandSwitch, 11> INSTALL_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually build or install"},
{OPTION_USE_HEAD_VERSION, "Install the libraries on the command line using the latest upstream sources"},
{OPTION_NO_DOWNLOADS, "Do not download new sources"},
{OPTION_ONLY_DOWNLOADS, "Download sources but don't build packages"},
+ {OPTION_ONLY_BINARYCACHING, "Fail if cached binaries are not available"},
{OPTION_RECURSE, "Allow removal of packages as part of installation"},
{OPTION_KEEP_GOING, "Continue installing packages on failure"},
{OPTION_EDITABLE, "Disable source re-extraction and binary caching for libraries on the command line"},
@@ -537,12 +539,12 @@ namespace vcpkg::Install
{OPTION_PROHIBIT_BACKCOMPAT_FEATURES,
"(experimental) Fail install if a package attempts to use a deprecated feature"},
}};
-
- static constexpr std::array<CommandSwitch, 10> MANIFEST_INSTALL_SWITCHES = {{
+ static constexpr std::array<CommandSwitch, 11> MANIFEST_INSTALL_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually build or install"},
{OPTION_USE_HEAD_VERSION, "Install the libraries on the command line using the latest upstream sources"},
{OPTION_NO_DOWNLOADS, "Do not download new sources"},
{OPTION_ONLY_DOWNLOADS, "Download sources but don't build packages"},
+ {OPTION_ONLY_BINARYCACHING, "Fail if cached binaries are not available"},
{OPTION_RECURSE, "Allow removal of packages as part of installation"},
{OPTION_KEEP_GOING, "Continue installing packages on failure"},
{OPTION_EDITABLE, "Disable source re-extraction and binary caching for libraries on the command line"},
@@ -765,6 +767,7 @@ namespace vcpkg::Install
const bool use_head_version = Util::Sets::contains(options.switches, (OPTION_USE_HEAD_VERSION));
const bool no_downloads = Util::Sets::contains(options.switches, (OPTION_NO_DOWNLOADS));
const bool only_downloads = Util::Sets::contains(options.switches, (OPTION_ONLY_DOWNLOADS));
+ const bool no_build_missing = Util::Sets::contains(options.switches, OPTION_ONLY_BINARYCACHING);
const bool is_recursive = Util::Sets::contains(options.switches, (OPTION_RECURSE));
const bool is_editable = Util::Sets::contains(options.switches, (OPTION_EDITABLE)) || !args.cmake_args.empty();
const bool use_aria2 = Util::Sets::contains(options.switches, (OPTION_USE_ARIA2));
@@ -780,6 +783,7 @@ namespace vcpkg::Install
if (use_aria2) download_tool = Build::DownloadTool::ARIA2;
const Build::BuildPackageOptions install_plan_options = {
+ Util::Enum::to_enum<Build::BuildMissing>(!no_build_missing),
Util::Enum::to_enum<Build::UseHeadVersion>(use_head_version),
Util::Enum::to_enum<Build::AllowDownloads>(!no_downloads),
Util::Enum::to_enum<Build::OnlyDownloads>(only_downloads),
@@ -1070,6 +1074,7 @@ namespace vcpkg::Install
case BuildResult::POST_BUILD_CHECKS_FAILED:
case BuildResult::FILE_CONFLICTS:
case BuildResult::BUILD_FAILED:
+ case BuildResult::CACHE_MISSING:
result_string = "Fail";
message_block =
Strings::format("<failure><message><![CDATA[%s]]></message></failure>", to_string(code));