aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-02-13 14:01:56 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-02-15 18:06:06 -0800
commitc432b66034a4efe304d79926bf81f92cb6e96ad6 (patch)
tree7e48673a16f8807e9395ac6cb7ba3d5bc8a47aca
parentc60c9de6e2371b31a79c58719df1d344b564111c (diff)
downloadvcpkg-c432b66034a4efe304d79926bf81f92cb6e96ad6.tar.gz
vcpkg-c432b66034a4efe304d79926bf81f92cb6e96ad6.zip
Introduce ci command: builds all packages of a triplet
-rw-r--r--toolsrc/include/vcpkg_Commands.h6
-rw-r--r--toolsrc/src/commands_available_commands.cpp1
-rw-r--r--toolsrc/src/commands_ci.cpp92
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj1
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj.filters3
5 files changed, 103 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h
index c3cda3d87..976e66c18 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -35,6 +35,12 @@ namespace vcpkg::Commands
namespace Install
{
+ void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs* status_db);
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace CI
+ {
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
}
diff --git a/toolsrc/src/commands_available_commands.cpp b/toolsrc/src/commands_available_commands.cpp
index 56056218b..4c7e0df2c 100644
--- a/toolsrc/src/commands_available_commands.cpp
+++ b/toolsrc/src/commands_available_commands.cpp
@@ -7,6 +7,7 @@ namespace vcpkg::Commands
{
static std::vector<package_name_and_function<command_type_a>> t = {
{"install", &Install::perform_and_exit},
+ { "ci", &CI::perform_and_exit },
{"remove", &Remove::perform_and_exit},
{"build", &Build::perform_and_exit},
{"build_external", &BuildExternal::perform_and_exit}
diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp
new file mode 100644
index 000000000..189a801da
--- /dev/null
+++ b/toolsrc/src/commands_ci.cpp
@@ -0,0 +1,92 @@
+#include "pch.h"
+#include "vcpkg_Commands.h"
+#include "vcpkglib.h"
+#include "vcpkg_Environment.h"
+#include "vcpkg_Files.h"
+#include "vcpkg_System.h"
+#include "vcpkg_Dependencies.h"
+#include "vcpkg_Input.h"
+#include "Stopwatch.h"
+
+namespace vcpkg::Commands::CI
+{
+ using Dependencies::package_spec_with_install_plan;
+ using Dependencies::install_plan_type;
+
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
+ {
+ static const std::string example = Commands::Help::create_example_string("ci x64-windows");
+ args.check_max_arg_count(1, example);
+ const triplet target_triplet = args.command_arguments.size() == 1 ? triplet::from_canonical_name(args.command_arguments.at(0)) : default_target_triplet;
+ Input::check_triplet(target_triplet, paths);
+
+ StatusParagraphs status_db = database_load_check(paths);
+
+ std::vector<fs::path> port_folders;
+ Files::non_recursive_find_matching_paths_in_dir(paths.ports, [](const fs::path& current)
+ {
+ return fs::is_directory(current);
+ }, &port_folders);
+
+ std::vector<package_spec> specs;
+ for (const fs::path& p : port_folders)
+ {
+ specs.push_back(package_spec::from_name_and_triplet(p.filename().generic_string(), target_triplet).get_or_throw());
+ }
+
+ std::vector<package_spec_with_install_plan> install_plan = Dependencies::create_install_plan(paths, specs, status_db);
+ Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty");
+
+ std::vector<Build::BuildResult> results;
+
+ Environment::ensure_utilities_on_path(paths);
+
+ Stopwatch stopwatch = Stopwatch::createStarted();
+ for (const package_spec_with_install_plan& action : install_plan)
+ {
+ System::println(stopwatch.toString());
+ try
+ {
+ if (action.plan.plan_type == install_plan_type::ALREADY_INSTALLED)
+ {
+ results.push_back(Build::BuildResult::SUCCEEDED);
+ System::println(System::color::success, "Package %s is already installed", action.spec);
+ }
+ else if (action.plan.plan_type == install_plan_type::BUILD_AND_INSTALL)
+ {
+ const Build::BuildResult result = Commands::Build::build_package(*action.plan.source_pgh, action.spec, paths, paths.port_dir(action.spec), status_db);
+ results.push_back(result);
+ if (result != Build::BuildResult::SUCCEEDED)
+ {
+ System::println(System::color::error, Build::create_error_message(action.spec.toString(), result));
+ continue;
+ }
+ const BinaryParagraph bpgh = try_load_cached_package(paths, action.spec).get_or_throw();
+ Install::install_package(paths, bpgh, &status_db);
+ System::println(System::color::success, "Package %s is installed", action.spec);
+ }
+ else if (action.plan.plan_type == install_plan_type::INSTALL)
+ {
+ results.push_back(Build::BuildResult::SUCCEEDED);
+ Install::install_package(paths, *action.plan.binary_pgh, &status_db);
+ System::println(System::color::success, "Package %s is installed", action.spec);
+ }
+ else
+ Checks::unreachable();
+ }
+ catch (const std::exception& e)
+ {
+ System::println(System::color::error, "Error: Could not install package %s: %s", action.spec, e.what());
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ for (int i = 0; i < results.size(); i++)
+ {
+ System::println("%s: %s", install_plan[i].spec.toString(), Build::to_string(results[i]));
+ }
+
+ System::println(stopwatch.toString());
+ exit(EXIT_SUCCESS);
+ }
+}
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj
index 537b2fb0f..7ca8158dd 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj
@@ -180,6 +180,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\BinaryParagraph.cpp" />
+ <ClCompile Include="..\src\commands_ci.cpp" />
<ClCompile Include="..\src\PostBuildLint_BuildInfo.cpp" />
<ClCompile Include="..\src\PostBuildLint_BuildPolicies.cpp" />
<ClCompile Include="..\src\coff_file_reader.cpp" />
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
index 519331b49..622544e3d 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
@@ -171,6 +171,9 @@
<ClCompile Include="..\src\vcpkg_Enums.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\commands_ci.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\package_spec.h">