aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-07-07 13:53:19 -0700
committerGitHub <noreply@github.com>2020-07-07 13:53:19 -0700
commitf9bdf139535f25dd0847fecff22a1c8c606da613 (patch)
tree9ffe023676b93d7f4bd4400dced790d96b3ac906 /toolsrc/src
parent12333a6b96848445fd04b19a8f7e00cdaf2ad0b6 (diff)
downloadvcpkg-f9bdf139535f25dd0847fecff22a1c8c606da613.tar.gz
vcpkg-f9bdf139535f25dd0847fecff22a1c8c606da613.zip
[vcpkg] Implement --editable (#12200)
--editable suppresses binary caching and source re-extraction for packages listed on the command line (similar to --head). This fundamentally changes the port maintenance loop, so several example documents were updated. To avoid users having substantial changes suddenly destroyed by forgetting to pass --editable, "clean" sources have different extract locations. The undocumented command `build` implies `--editable`. Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/binarycaching.cpp7
-rw-r--r--toolsrc/src/vcpkg/build.cpp31
-rw-r--r--toolsrc/src/vcpkg/install.cpp16
3 files changed, 36 insertions, 18 deletions
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp
index fbff12833..2b8a1dd98 100644
--- a/toolsrc/src/vcpkg/binarycaching.cpp
+++ b/toolsrc/src/vcpkg/binarycaching.cpp
@@ -198,7 +198,6 @@ namespace
void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) override
{
if (m_read_sources.empty() && m_read_configs.empty()) return;
- if (plan.install_actions.empty()) return;
auto& fs = paths.get_filesystem();
@@ -206,13 +205,17 @@ namespace
for (auto&& action : plan.install_actions)
{
+ if (action.build_options.editable == Build::Editable::YES) continue;
+
auto& spec = action.spec;
fs.remove_all(paths.package_dir(spec), VCPKG_LINE_INFO);
nuget_refs.emplace_back(spec, NugetReference(action));
}
- System::print2("Attempting to fetch ", plan.install_actions.size(), " packages from nuget.\n");
+ if (nuget_refs.empty()) return;
+
+ System::print2("Attempting to fetch ", nuget_refs.size(), " packages from nuget.\n");
auto packages_config = paths.buildtrees / fs::u8path("packages.config");
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index 8ae4531cc..e7e25d738 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -125,6 +125,7 @@ namespace vcpkg::Build
Checks::check_exit(VCPKG_LINE_INFO, action != nullptr);
ASSUME(action != nullptr);
action->build_options = default_build_package_options;
+ action->build_options.editable = Editable::YES;
action->build_options.clean_buildtrees = CleanBuildtrees::NO;
action->build_options.clean_packages = CleanPackages::NO;
@@ -531,6 +532,7 @@ namespace vcpkg::Build
{"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(action.build_options.use_head_version) ? "1" : "0"},
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(action.build_options.allow_downloads) ? "1" : "0"},
{"_VCPKG_DOWNLOAD_TOOL", to_string(action.build_options.download_tool)},
+ {"_VCPKG_EDITABLE", Util::Enum::to_bool(action.build_options.editable) ? "1" : "0"},
{"FEATURES", Strings::join(";", action.feature_list)},
{"ALL_FEATURES", all_features},
};
@@ -981,18 +983,23 @@ namespace vcpkg::Build
std::error_code ec;
const fs::path abi_package_dir = paths.package_dir(spec) / "share" / spec.name();
const fs::path abi_file_in_package = paths.package_dir(spec) / "share" / spec.name() / "vcpkg_abi_info.txt";
- auto restore = binaries_provider.try_restore(paths, action);
- if (restore == RestoreResult::build_failed)
- return BuildResult::BUILD_FAILED;
- else if (restore == RestoreResult::success)
+ if (action.build_options.editable == Build::Editable::NO)
{
- auto maybe_bcf = Paragraphs::try_load_cached_package(paths, spec);
- auto bcf = std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
- return {BuildResult::SUCCEEDED, std::move(bcf)};
- }
- else
- {
- // missing package, proceed to build.
+ auto restore = binaries_provider.try_restore(paths, action);
+ if (restore == RestoreResult::build_failed)
+ {
+ return BuildResult::BUILD_FAILED;
+ }
+ else if (restore == RestoreResult::success)
+ {
+ auto maybe_bcf = Paragraphs::try_load_cached_package(paths, spec);
+ auto bcf = std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
+ return {BuildResult::SUCCEEDED, std::move(bcf)};
+ }
+ else
+ {
+ // missing package, proceed to build.
+ }
}
ExtendedBuildResult result = do_build_package_and_clean_buildtrees(paths, action);
@@ -1001,7 +1008,7 @@ namespace vcpkg::Build
fs.copy_file(abi_file, abi_file_in_package, fs::copy_options::none, ec);
Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not copy into file: %s", abi_file_in_package.u8string());
- if (result.code == BuildResult::SUCCEEDED)
+ if (action.build_options.editable == Build::Editable::NO && result.code == BuildResult::SUCCEEDED)
{
binaries_provider.push_success(paths, action);
}
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index b5024e0a5..3be938215 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -506,18 +506,20 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_ONLY_DOWNLOADS = "--only-downloads";
static constexpr StringLiteral OPTION_RECURSE = "--recurse";
static constexpr StringLiteral OPTION_KEEP_GOING = "--keep-going";
+ static constexpr StringLiteral OPTION_EDITABLE = "--editable";
static constexpr StringLiteral OPTION_XUNIT = "--x-xunit";
static constexpr StringLiteral OPTION_USE_ARIA2 = "--x-use-aria2";
static constexpr StringLiteral OPTION_CLEAN_AFTER_BUILD = "--clean-after-build";
static constexpr StringLiteral OPTION_WRITE_PACKAGES_CONFIG = "--x-write-nuget-packages-config";
- static constexpr std::array<CommandSwitch, 8> INSTALL_SWITCHES = {{
+ static constexpr std::array<CommandSwitch, 9> 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_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"},
{OPTION_USE_ARIA2, "Use aria2 to perform download tasks"},
{OPTION_CLEAN_AFTER_BUILD, "Clean buildtrees, packages and downloads after building each package"},
}};
@@ -678,6 +680,7 @@ namespace vcpkg::Install
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 is_recursive = Util::Sets::contains(options.switches, (OPTION_RECURSE));
+ const bool is_editable = Util::Sets::contains(options.switches, (OPTION_EDITABLE));
const bool use_aria2 = Util::Sets::contains(options.switches, (OPTION_USE_ARIA2));
const bool clean_after_build = Util::Sets::contains(options.switches, (OPTION_CLEAN_AFTER_BUILD));
const KeepGoing keep_going =
@@ -692,10 +695,12 @@ namespace vcpkg::Install
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),
- clean_after_build ? Build::CleanBuildtrees::YES : Build::CleanBuildtrees::NO,
- clean_after_build ? Build::CleanPackages::YES : Build::CleanPackages::NO,
- clean_after_build ? Build::CleanDownloads::YES : Build::CleanDownloads::NO,
+ Util::Enum::to_enum<Build::CleanBuildtrees>(clean_after_build),
+ Util::Enum::to_enum<Build::CleanPackages>(clean_after_build),
+ Util::Enum::to_enum<Build::CleanDownloads>(clean_after_build),
download_tool,
+ Build::PurgeDecompressFailure::NO,
+ Util::Enum::to_enum<Build::Editable>(is_editable),
};
PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports);
@@ -769,7 +774,10 @@ namespace vcpkg::Install
{
action.build_options = install_plan_options;
if (action.request_type != RequestType::USER_REQUESTED)
+ {
action.build_options.use_head_version = Build::UseHeadVersion::NO;
+ action.build_options.editable = Build::Editable::NO;
+ }
}
var_provider.load_tag_vars(action_plan, provider);