aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-05-02 20:34:11 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-05-03 04:12:28 -0700
commit4633c5e0ea8560ac17c14aa56e50bf3693017f51 (patch)
tree543c1994c5b9b244bb3a9517fd4dfbde389afffc /toolsrc/src
parentf10861fa7af9bd675cb4e80ea31d85d7e5c6d906 (diff)
downloadvcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.tar.gz
vcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.zip
[vcpkg] Add support for installing from HEAD
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/commands_install.cpp34
-rw-r--r--toolsrc/src/vcpkg_Build.cpp15
2 files changed, 45 insertions, 4 deletions
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index bfbefe1c1..2260b067e 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -265,6 +265,8 @@ namespace vcpkg::Commands::Install
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
static const std::string OPTION_DRY_RUN = "--dry-run";
+ static const std::string OPTION_USE_HEAD_VERSION = "--head";
+ static const std::string OPTION_NO_DOWNLOADS = "--no-downloads";
// input sanitization
static const std::string example =
@@ -277,8 +279,11 @@ namespace vcpkg::Commands::Install
for (auto&& spec : specs)
Input::check_triplet(spec.triplet(), paths);
- const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_DRY_RUN});
+ const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments(
+ {OPTION_DRY_RUN, OPTION_USE_HEAD_VERSION, OPTION_NO_DOWNLOADS});
const bool dryRun = options.find(OPTION_DRY_RUN) != options.cend();
+ const bool use_head_version = options.find(OPTION_USE_HEAD_VERSION) != options.cend();
+ const bool no_downloads = options.find(OPTION_NO_DOWNLOADS) != options.cend();
// create the plan
StatusParagraphs status_db = database_load_check(paths);
@@ -319,17 +324,34 @@ namespace vcpkg::Commands::Install
switch (action.plan_type)
{
case InstallPlanType::ALREADY_INSTALLED:
- System::println(System::Color::success, "Package %s is already installed", display_name);
+ if (use_head_version && action.request_type == RequestType::USER_REQUESTED)
+ {
+ System::println(System::Color::warning,
+ "Package %s is already installed -- not building from HEAD",
+ display_name);
+ }
+ else
+ {
+ System::println(System::Color::success, "Package %s is already installed", display_name);
+ }
break;
case InstallPlanType::BUILD_AND_INSTALL:
{
- System::println("Building package %s... ", display_name);
Build::BuildPackageConfig build_config{
action.any_paragraph.source_paragraph.value_or_exit(VCPKG_LINE_INFO),
action.spec.triplet(),
paths.port_dir(action.spec),
};
+ build_config.use_head_version =
+ use_head_version && action.request_type == RequestType::USER_REQUESTED;
+ build_config.no_downloads = no_downloads;
+
+ if (build_config.use_head_version)
+ System::println("Building package %s from HEAD... ", display_name);
+ else
+ System::println("Building package %s... ", display_name);
+
const auto result = Build::build_package(paths, build_config, status_db);
if (result.code != Build::BuildResult::SUCCEEDED)
{
@@ -348,6 +370,12 @@ namespace vcpkg::Commands::Install
break;
}
case InstallPlanType::INSTALL:
+ if (use_head_version && action.request_type == RequestType::USER_REQUESTED)
+ {
+ System::println(System::Color::warning,
+ "Package %s is already built -- not building from HEAD",
+ display_name);
+ }
System::println("Installing package %s... ", display_name);
install_package(
paths, action.any_paragraph.binary_paragraph.value_or_exit(VCPKG_LINE_INFO), &status_db);
diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp
index 2573feb68..c29f61468 100644
--- a/toolsrc/src/vcpkg_Build.cpp
+++ b/toolsrc/src/vcpkg_Build.cpp
@@ -43,7 +43,11 @@ namespace vcpkg::Build
const Triplet& triplet,
const BuildInfo& build_info)
{
- const BinaryParagraph bpgh = BinaryParagraph(source_paragraph, triplet);
+ BinaryParagraph bpgh = BinaryParagraph(source_paragraph, triplet);
+ if (auto p_ver = build_info.version.get())
+ {
+ bpgh.version = *p_ver;
+ }
const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL";
paths.get_filesystem().write_contents(binary_control_file, Strings::serialize(bpgh));
}
@@ -88,6 +92,8 @@ namespace vcpkg::Build
{L"CURRENT_PORT_DIR", config.port_dir / "/."},
{L"TARGET_TRIPLET", triplet.canonical_name()},
{L"VCPKG_PLATFORM_TOOLSET", toolset.version},
+ {L"VCPKG_USE_HEAD_VERSION", config.use_head_version ? L"1" : L"0"},
+ {L"_VCPKG_NO_DOWNLOADS", config.no_downloads ? L"1" : L"0"},
{L"GIT", git_exe_path}});
const std::wstring command = Strings::wformat(LR"(%s && %s)", cmd_set_environment, cmd_launch_cmake);
@@ -177,6 +183,13 @@ namespace vcpkg::Build
"Invalid library linkage type: [%s]",
library_linkage_as_string);
+ auto it_version = pgh.find("Version");
+ if (it_version != pgh.end())
+ {
+ build_info.version = it_version->second;
+ pgh.erase(it_version);
+ }
+
// The remaining entries are policies
for (const std::unordered_map<std::string, std::string>::value_type& p : pgh)
{