mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-31 05:03:22 +08:00
Merge branch 'export-ifw' of https://github.com/podsvirov/vcpkg into podsvirov-export-ifw
This commit is contained in:
commit
a34b6ee16e
@ -137,6 +137,17 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
|
||||
$extractionType = $ExtractionType_ZIP
|
||||
$extractionFolder = "$downloadsDir\MinGit-2.14.1-32-bit"
|
||||
}
|
||||
elseif($Dependency -eq "installerbase")
|
||||
{
|
||||
$requiredVersion = "3.1.81"
|
||||
$downloadVersion = "3.1.81"
|
||||
$url = "https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip"
|
||||
$downloadPath = "$downloadsDir\QtInstallerFramework-win-x86.zip"
|
||||
$expectedDownloadedFileHash = "f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8"
|
||||
$executableFromDownload = "$downloadsDir\QtInstallerFramework-win-x86\bin\installerbase.exe"
|
||||
$extractionType = $ExtractionType_ZIP
|
||||
$extractionFolder = $downloadsDir
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Unknown program requested"
|
||||
|
@ -58,6 +58,9 @@ namespace vcpkg
|
||||
const fs::path& get_cmake_exe() const;
|
||||
const fs::path& get_git_exe() const;
|
||||
const fs::path& get_nuget_exe() const;
|
||||
const fs::path& get_ifw_installerbase_exe() const;
|
||||
const fs::path& get_ifw_binarycreator_exe() const;
|
||||
const fs::path& get_ifw_repogen_exe() const;
|
||||
|
||||
/// <summary>Retrieve a toolset matching a VS version</summary>
|
||||
/// <remarks>
|
||||
@ -71,6 +74,9 @@ namespace vcpkg
|
||||
Lazy<fs::path> cmake_exe;
|
||||
Lazy<fs::path> git_exe;
|
||||
Lazy<fs::path> nuget_exe;
|
||||
Lazy<fs::path> ifw_installerbase_exe;
|
||||
Lazy<fs::path> ifw_binarycreator_exe;
|
||||
Lazy<fs::path> ifw_repogen_exe;
|
||||
Lazy<std::vector<Toolset>> toolsets;
|
||||
Lazy<std::vector<Toolset>> toolsets_vs2017_v140;
|
||||
};
|
||||
|
14
toolsrc/include/vcpkg_Commands_Export.h
Normal file
14
toolsrc/include/vcpkg_Commands_Export.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "StatusParagraphs.h"
|
||||
#include "VcpkgCmdArguments.h"
|
||||
#include "VcpkgPaths.h"
|
||||
#include "VersionT.h"
|
||||
#include "vcpkg_Build.h"
|
||||
#include "vcpkg_Dependencies.h"
|
||||
#include <array>
|
||||
|
||||
namespace vcpkg::Commands::Export
|
||||
{
|
||||
void export_integration_files(const fs::path &raw_exported_dir_path, const VcpkgPaths& paths);
|
||||
}
|
18
toolsrc/include/vcpkg_Commands_Export_IFW.h
Normal file
18
toolsrc/include/vcpkg_Commands_Export_IFW.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "vcpkg_Files.h"
|
||||
#include "vcpkg_Dependencies.h"
|
||||
|
||||
namespace vcpkg::Commands::Export::IFW
|
||||
{
|
||||
struct Options
|
||||
{
|
||||
Optional<std::string> maybe_repository_url;
|
||||
Optional<std::string> maybe_packages_dir_path;
|
||||
Optional<std::string> maybe_repository_dir_path;
|
||||
Optional<std::string> maybe_config_file_path;
|
||||
Optional<std::string> maybe_installer_file_path;
|
||||
};
|
||||
|
||||
void do_export(const std::vector<Dependencies::ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths);
|
||||
}
|
@ -173,6 +173,31 @@ namespace vcpkg
|
||||
return fetch_dependency(scripts_folder, L"git", downloaded_copy, EXPECTED_VERSION);
|
||||
}
|
||||
|
||||
static fs::path get_ifw_installerbase_path(const fs::path& downloads_folder, const fs::path& scripts_folder)
|
||||
{
|
||||
static constexpr std::array<int, 3> EXPECTED_VERSION = { 3, 1, 81 };
|
||||
static const std::wstring VERSION_CHECK_ARGUMENTS = L"--framework-version";
|
||||
|
||||
const fs::path downloaded_copy = downloads_folder / "QtInstallerFramework-win-x86" / "bin" / "installerbase.exe";
|
||||
|
||||
std::vector<fs::path> candidate_paths;
|
||||
candidate_paths.push_back(downloaded_copy);
|
||||
// TODO: Uncomment later
|
||||
//const std::vector<fs::path> from_path = Files::find_from_PATH(L"installerbase");
|
||||
//candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
|
||||
//candidate_paths.push_back(fs::path(System::get_environment_variable(L"HOMEDRIVE").value_or("C:")) / "Qt" / "Tools" / "QtInstallerFramework" / "3.1" / "bin" / "installerbase.exe");
|
||||
//candidate_paths.push_back(fs::path(System::get_environment_variable(L"HOMEDRIVE").value_or("C:")) / "Qt" / "QtIFW-3.1.0" / "bin" / "installerbase.exe");
|
||||
|
||||
const Optional<fs::path> path =
|
||||
find_if_has_equal_or_greater_version(candidate_paths, VERSION_CHECK_ARGUMENTS, EXPECTED_VERSION);
|
||||
if (const auto p = path.get())
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
return fetch_dependency(scripts_folder, L"installerbase", downloaded_copy, EXPECTED_VERSION);
|
||||
}
|
||||
|
||||
Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir)
|
||||
{
|
||||
std::error_code ec;
|
||||
@ -256,6 +281,21 @@ namespace vcpkg
|
||||
return this->nuget_exe.get_lazy([this]() { return get_nuget_path(this->downloads, this->scripts); });
|
||||
}
|
||||
|
||||
const fs::path& VcpkgPaths::get_ifw_installerbase_exe() const
|
||||
{
|
||||
return this->ifw_installerbase_exe.get_lazy([this]() { return get_ifw_installerbase_path(this->downloads, this->scripts); });
|
||||
}
|
||||
|
||||
const fs::path& VcpkgPaths::get_ifw_binarycreator_exe() const
|
||||
{
|
||||
return this->ifw_binarycreator_exe.get_lazy([this]() { return get_ifw_installerbase_exe().parent_path() / "binarycreator.exe"; });
|
||||
}
|
||||
|
||||
const fs::path& VcpkgPaths::get_ifw_repogen_exe() const
|
||||
{
|
||||
return this->ifw_repogen_exe.get_lazy([this]() { return get_ifw_installerbase_exe().parent_path() / "repogen.exe"; });
|
||||
}
|
||||
|
||||
static std::vector<std::string> get_vs2017_installation_instances(const VcpkgPaths& paths)
|
||||
{
|
||||
const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1";
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "Paragraphs.h"
|
||||
#include "vcpkg_Commands.h"
|
||||
#include "vcpkg_Commands_Export_IFW.h"
|
||||
#include "vcpkg_Dependencies.h"
|
||||
#include "vcpkg_Input.h"
|
||||
#include "vcpkg_System.h"
|
||||
@ -210,15 +211,47 @@ namespace vcpkg::Commands::Export
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
void export_integration_files(const fs::path &raw_exported_dir_path, const VcpkgPaths& paths)
|
||||
{
|
||||
const std::vector<fs::path> integration_files_relative_to_root = {
|
||||
{ ".vcpkg-root" },
|
||||
{ fs::path{ "scripts" } / "buildsystems" / "msbuild" / "applocal.ps1" },
|
||||
{ fs::path{ "scripts" } / "buildsystems" / "msbuild" / "vcpkg.targets" },
|
||||
{ fs::path{ "scripts" } / "buildsystems" / "vcpkg.cmake" },
|
||||
{ fs::path{ "scripts" } / "cmake" / "vcpkg_get_windows_sdk.cmake" },
|
||||
{ fs::path{ "scripts" } / "getWindowsSDK.ps1" },
|
||||
{ fs::path{ "scripts" } / "getProgramFilesPlatformBitness.ps1" },
|
||||
{ fs::path{ "scripts" } / "getProgramFiles32bit.ps1" },
|
||||
};
|
||||
|
||||
for (const fs::path& file : integration_files_relative_to_root)
|
||||
{
|
||||
const fs::path source = paths.root / file;
|
||||
fs::path destination = raw_exported_dir_path / file;
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
std::error_code ec;
|
||||
fs.create_directories(destination.parent_path(), ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
fs.copy_file(source, destination, fs::copy_options::overwrite_existing, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
}
|
||||
}
|
||||
|
||||
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_RAW = "--raw";
|
||||
static const std::string OPTION_NUGET = "--nuget";
|
||||
static const std::string OPTION_IFW = "--ifw";
|
||||
static const std::string OPTION_ZIP = "--zip";
|
||||
static const std::string OPTION_SEVEN_ZIP = "--7zip";
|
||||
static const std::string OPTION_NUGET_ID = "--nuget-id";
|
||||
static const std::string OPTION_NUGET_VERSION = "--nuget-version";
|
||||
static const std::string OPTION_IFW_REPOSITORY_URL = "--ifw-repository-url";
|
||||
static const std::string OPTION_IFW_PACKAGES_DIR_PATH = "--ifw-packages-directory-path";
|
||||
static const std::string OPTION_IFW_REPOSITORY_DIR_PATH = "--ifw-repository-directory-path";
|
||||
static const std::string OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path";
|
||||
static const std::string OPTION_IFW_INSTALLER_FILE_PATH = "--ifw-installer-file-path";
|
||||
|
||||
// input sanitization
|
||||
static const std::string EXAMPLE =
|
||||
@ -236,22 +269,30 @@ namespace vcpkg::Commands::Export
|
||||
OPTION_DRY_RUN,
|
||||
OPTION_RAW,
|
||||
OPTION_NUGET,
|
||||
OPTION_IFW,
|
||||
OPTION_ZIP,
|
||||
OPTION_SEVEN_ZIP,
|
||||
},
|
||||
{
|
||||
OPTION_NUGET_ID,
|
||||
OPTION_NUGET_VERSION,
|
||||
OPTION_IFW_REPOSITORY_URL,
|
||||
OPTION_IFW_PACKAGES_DIR_PATH,
|
||||
OPTION_IFW_REPOSITORY_DIR_PATH,
|
||||
OPTION_IFW_CONFIG_FILE_PATH,
|
||||
OPTION_IFW_INSTALLER_FILE_PATH
|
||||
});
|
||||
const bool dry_run = options.switches.find(OPTION_DRY_RUN) != options.switches.cend();
|
||||
const bool raw = options.switches.find(OPTION_RAW) != options.switches.cend();
|
||||
const bool nuget = options.switches.find(OPTION_NUGET) != options.switches.cend();
|
||||
const bool ifw = options.switches.find(OPTION_IFW) != options.switches.cend();
|
||||
const bool zip = options.switches.find(OPTION_ZIP) != options.switches.cend();
|
||||
const bool seven_zip = options.switches.find(OPTION_SEVEN_ZIP) != options.switches.cend();
|
||||
|
||||
if (!raw && !nuget && !zip && !seven_zip && !dry_run)
|
||||
if (!raw && !nuget && !ifw && !zip && !seven_zip && !dry_run)
|
||||
{
|
||||
System::println(System::Color::error, "Must provide at least one export type: --raw --nuget --zip --7zip");
|
||||
System::println(System::Color::error,
|
||||
"Must provide at least one export type: --raw --nuget --ifw --zip --7zip");
|
||||
System::print(EXAMPLE);
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
@ -263,6 +304,28 @@ namespace vcpkg::Commands::Export
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !maybe_nuget_version || nuget, "--nuget-version is only valid with --nuget");
|
||||
|
||||
IFW::Options ifw_options;
|
||||
|
||||
ifw_options.maybe_repository_url = maybe_lookup(options.settings, OPTION_IFW_REPOSITORY_URL);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !ifw_options.maybe_repository_url || ifw, "--ifw-repository-url is only valid with --ifw");
|
||||
|
||||
ifw_options.maybe_packages_dir_path = maybe_lookup(options.settings, OPTION_IFW_PACKAGES_DIR_PATH);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !ifw_options.maybe_packages_dir_path || ifw, "--ifw-packages-directory-path is only valid with --ifw");
|
||||
|
||||
ifw_options.maybe_repository_dir_path = maybe_lookup(options.settings, OPTION_IFW_REPOSITORY_DIR_PATH);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !ifw_options.maybe_repository_dir_path || ifw, "--ifw-repository-directory-path is only valid with --ifw");
|
||||
|
||||
ifw_options.maybe_config_file_path = maybe_lookup(options.settings, OPTION_IFW_CONFIG_FILE_PATH);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !ifw_options.maybe_config_file_path || ifw, "--ifw-configuration-file-path is only valid with --ifw");
|
||||
|
||||
ifw_options.maybe_installer_file_path = maybe_lookup(options.settings, OPTION_IFW_INSTALLER_FILE_PATH);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !ifw_options.maybe_installer_file_path || ifw, "--ifw-installer-file-path is only valid with --ifw");
|
||||
|
||||
// create the plan
|
||||
const StatusParagraphs status_db = database_load_check(paths);
|
||||
std::vector<ExportPlanAction> export_plan = Dependencies::create_export_plan(paths, specs, status_db);
|
||||
@ -305,121 +368,115 @@ namespace vcpkg::Commands::Export
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const std::string export_id = create_export_id();
|
||||
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
const fs::path export_to_path = paths.root;
|
||||
const fs::path raw_exported_dir_path = export_to_path / export_id;
|
||||
std::error_code ec;
|
||||
fs.remove_all(raw_exported_dir_path, ec);
|
||||
fs.create_directory(raw_exported_dir_path, ec);
|
||||
|
||||
// execute the plan
|
||||
for (const ExportPlanAction& action : export_plan)
|
||||
{
|
||||
if (action.plan_type != ExportPlanType::ALREADY_BUILT)
|
||||
{
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const std::string display_name = action.spec.to_string();
|
||||
System::println("Exporting package %s... ", display_name);
|
||||
|
||||
const BinaryParagraph& binary_paragraph =
|
||||
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
|
||||
const InstallDir dirs = InstallDir::from_destination_root(
|
||||
raw_exported_dir_path / "installed",
|
||||
action.spec.triplet().to_string(),
|
||||
raw_exported_dir_path / "installed" / "vcpkg" / "info" / (binary_paragraph.fullstem() + ".list"));
|
||||
|
||||
Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs);
|
||||
System::println(System::Color::success, "Exporting package %s... done", display_name);
|
||||
}
|
||||
|
||||
// Copy files needed for integration
|
||||
const std::vector<fs::path> integration_files_relative_to_root = {
|
||||
{".vcpkg-root"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "vcpkg.cmake"},
|
||||
{fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"},
|
||||
{fs::path{"scripts"} / "getWindowsSDK.ps1"},
|
||||
{fs::path{"scripts"} / "getProgramFilesPlatformBitness.ps1"},
|
||||
{fs::path{"scripts"} / "getProgramFiles32bit.ps1"},
|
||||
};
|
||||
|
||||
for (const fs::path& file : integration_files_relative_to_root)
|
||||
{
|
||||
const fs::path source = paths.root / file;
|
||||
const fs::path destination = raw_exported_dir_path / file;
|
||||
fs.create_directories(destination.parent_path(), ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
fs.copy_file(source, destination, fs::copy_options::overwrite_existing, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
}
|
||||
std::string export_id = create_export_id();
|
||||
|
||||
const auto print_next_step_info = [](const fs::path& prefix) {
|
||||
const fs::path cmake_toolchain = prefix / "scripts" / "buildsystems" / "vcpkg.cmake";
|
||||
const CMakeVariable cmake_variable =
|
||||
CMakeVariable(L"CMAKE_TOOLCHAIN_FILE", cmake_toolchain.generic_string());
|
||||
System::println("\n"
|
||||
"To use the exported libraries in CMake projects use:"
|
||||
"\n"
|
||||
" %s"
|
||||
"\n",
|
||||
Strings::to_utf8(cmake_variable.s));
|
||||
"To use the exported libraries in CMake projects use:"
|
||||
"\n"
|
||||
" %s"
|
||||
"\n",
|
||||
Strings::to_utf8(cmake_variable.s));
|
||||
};
|
||||
|
||||
if (raw)
|
||||
// Main loop
|
||||
if (raw || nuget || zip || seven_zip)
|
||||
{
|
||||
System::println(
|
||||
System::Color::success, R"(Files exported at: "%s")", raw_exported_dir_path.generic_string());
|
||||
print_next_step_info(export_to_path);
|
||||
}
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
const fs::path export_to_path = paths.root;
|
||||
const fs::path raw_exported_dir_path = export_to_path / export_id;
|
||||
std::error_code ec;
|
||||
fs.remove_all(raw_exported_dir_path, ec);
|
||||
fs.create_directory(raw_exported_dir_path, ec);
|
||||
|
||||
if (nuget)
|
||||
{
|
||||
System::println("Creating nuget package... ");
|
||||
// execute the plan
|
||||
for (const ExportPlanAction& action : export_plan)
|
||||
{
|
||||
if (action.plan_type != ExportPlanType::ALREADY_BUILT)
|
||||
{
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const std::string nuget_id = maybe_nuget_id.value_or(raw_exported_dir_path.filename().string());
|
||||
const std::string nuget_version = maybe_nuget_version.value_or("1.0.0");
|
||||
const fs::path output_path =
|
||||
do_nuget_export(paths, nuget_id, nuget_version, raw_exported_dir_path, export_to_path);
|
||||
System::println(System::Color::success, "Creating nuget package... done");
|
||||
System::println(System::Color::success, "NuGet package exported at: %s", output_path.generic_string());
|
||||
const std::string display_name = action.spec.to_string();
|
||||
System::println("Exporting package %s... ", display_name);
|
||||
|
||||
System::println(R"(
|
||||
const BinaryParagraph& binary_paragraph =
|
||||
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
|
||||
|
||||
const InstallDir dirs = InstallDir::from_destination_root(
|
||||
raw_exported_dir_path / "installed",
|
||||
action.spec.triplet().to_string(),
|
||||
raw_exported_dir_path / "installed" / "vcpkg" / "info" / (binary_paragraph.fullstem() + ".list"));
|
||||
|
||||
Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs);
|
||||
System::println(System::Color::success, "Exporting package %s... done", display_name);
|
||||
}
|
||||
|
||||
// Copy files needed for integration
|
||||
export_integration_files(raw_exported_dir_path, paths);
|
||||
|
||||
if (raw)
|
||||
{
|
||||
System::println(
|
||||
System::Color::success, R"(Files exported at: "%s")", raw_exported_dir_path.generic_string());
|
||||
print_next_step_info(export_to_path);
|
||||
}
|
||||
|
||||
if (nuget)
|
||||
{
|
||||
System::println("Creating nuget package... ");
|
||||
|
||||
const std::string nuget_id = maybe_nuget_id.value_or(raw_exported_dir_path.filename().string());
|
||||
const std::string nuget_version = maybe_nuget_version.value_or("1.0.0");
|
||||
const fs::path output_path =
|
||||
do_nuget_export(paths, nuget_id, nuget_version, raw_exported_dir_path, export_to_path);
|
||||
System::println(System::Color::success, "Creating nuget package... done");
|
||||
System::println(System::Color::success, "NuGet package exported at: %s", output_path.generic_string());
|
||||
|
||||
System::println(R"(
|
||||
With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:
|
||||
Install-Package %s -Source "%s"
|
||||
)"
|
||||
"\n",
|
||||
nuget_id,
|
||||
output_path.parent_path().u8string());
|
||||
"\n",
|
||||
nuget_id,
|
||||
output_path.parent_path().u8string());
|
||||
}
|
||||
|
||||
if (zip)
|
||||
{
|
||||
System::println("Creating zip archive... ");
|
||||
const fs::path output_path =
|
||||
do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::ZIP);
|
||||
System::println(System::Color::success, "Creating zip archive... done");
|
||||
System::println(System::Color::success, "Zip archive exported at: %s", output_path.generic_string());
|
||||
print_next_step_info("[...]");
|
||||
}
|
||||
|
||||
if (seven_zip)
|
||||
{
|
||||
System::println("Creating 7zip archive... ");
|
||||
const fs::path output_path =
|
||||
do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::SEVEN_ZIP);
|
||||
System::println(System::Color::success, "Creating 7zip archive... done");
|
||||
System::println(System::Color::success, "7zip archive exported at: %s", output_path.generic_string());
|
||||
print_next_step_info("[...]");
|
||||
}
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
fs.remove_all(raw_exported_dir_path, ec);
|
||||
}
|
||||
}
|
||||
|
||||
if (zip)
|
||||
// IFW loop
|
||||
if (ifw)
|
||||
{
|
||||
System::println("Creating zip archive... ");
|
||||
const fs::path output_path =
|
||||
do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::ZIP);
|
||||
System::println(System::Color::success, "Creating zip archive... done");
|
||||
System::println(System::Color::success, "Zip archive exported at: %s", output_path.generic_string());
|
||||
print_next_step_info("[...]");
|
||||
}
|
||||
IFW::do_export(export_plan, export_id, ifw_options, paths);
|
||||
|
||||
if (seven_zip)
|
||||
{
|
||||
System::println("Creating 7zip archive... ");
|
||||
const fs::path output_path =
|
||||
do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::SEVEN_ZIP);
|
||||
System::println(System::Color::success, "Creating 7zip archive... done");
|
||||
System::println(System::Color::success, "7zip archive exported at: %s", output_path.generic_string());
|
||||
print_next_step_info("[...]");
|
||||
}
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
fs.remove_all(raw_exported_dir_path, ec);
|
||||
print_next_step_info("@RootDir@/src/vcpkg");
|
||||
}
|
||||
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
|
425
toolsrc/src/commands_export_ifw.cpp
Normal file
425
toolsrc/src/commands_export_ifw.cpp
Normal file
@ -0,0 +1,425 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "vcpkg_Commands.h"
|
||||
#include "vcpkg_Commands_Export.h"
|
||||
#include "vcpkg_Commands_Export_IFW.h"
|
||||
|
||||
namespace vcpkg::Commands::Export::IFW
|
||||
{
|
||||
using Dependencies::ExportPlanAction;
|
||||
using Dependencies::ExportPlanType;
|
||||
using Install::InstallDir;
|
||||
|
||||
static std::string create_release_date()
|
||||
{
|
||||
const tm date_time = System::get_current_date_time();
|
||||
|
||||
// Format is: YYYY-mm-dd
|
||||
// 10 characters + 1 null terminating character will be written for a total of 11 chars
|
||||
char mbstr[11];
|
||||
const size_t bytes_written = std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d", &date_time);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
bytes_written == 10,
|
||||
"Expected 10 bytes to be written, but %u were written",
|
||||
bytes_written);
|
||||
const std::string date_time_as_string(mbstr);
|
||||
return date_time_as_string;
|
||||
}
|
||||
|
||||
fs::path get_packages_dir_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
return ifw_options.maybe_packages_dir_path.has_value() ?
|
||||
fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
||||
: paths.root / (export_id + "-ifw-packages");
|
||||
}
|
||||
|
||||
fs::path get_repository_dir_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
return ifw_options.maybe_repository_dir_path.has_value() ?
|
||||
fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
||||
: paths.root / (export_id + "-ifw-repository");
|
||||
}
|
||||
|
||||
fs::path get_config_file_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
return ifw_options.maybe_config_file_path.has_value() ?
|
||||
fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO))
|
||||
: paths.root / (export_id + "-ifw-configuration.xml");
|
||||
}
|
||||
|
||||
fs::path get_installer_file_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
return ifw_options.maybe_installer_file_path.has_value() ?
|
||||
fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO))
|
||||
: paths.root / (export_id + "-ifw-installer.exe");
|
||||
}
|
||||
|
||||
fs::path export_real_package(const fs::path& ifw_packages_dir_path,
|
||||
const ExportPlanAction& action,
|
||||
Files::Filesystem& fs)
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
const BinaryParagraph& binary_paragraph =
|
||||
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
|
||||
|
||||
// Prepare meta dir
|
||||
const fs::path package_xml_file_path =
|
||||
ifw_packages_dir_path /
|
||||
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" /
|
||||
"package.xml";
|
||||
const fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
|
||||
auto deps = Strings::join(
|
||||
",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; });
|
||||
|
||||
if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>";
|
||||
|
||||
fs.write_contents(package_xml_file_path,
|
||||
Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>%s</DisplayName>
|
||||
<Version>%s</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
<AutoDependOn>packages.%s:,triplets.%s:</AutoDependOn>%s
|
||||
<Virtual>true</Virtual>
|
||||
</Package>
|
||||
)###",
|
||||
action.spec.to_string(),
|
||||
binary_paragraph.version,
|
||||
create_release_date(),
|
||||
action.spec.name(),
|
||||
action.spec.triplet().canonical_name(),
|
||||
deps));
|
||||
|
||||
// Return dir path for export package data
|
||||
return ifw_packages_dir_path /
|
||||
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "data" /
|
||||
"installed";
|
||||
}
|
||||
|
||||
void export_unique_packages(const fs::path& raw_exported_dir_path,
|
||||
std::map<std::string, const ExportPlanAction*> unique_packages,
|
||||
Files::Filesystem& fs)
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
// packages
|
||||
|
||||
fs::path package_xml_file_path = raw_exported_dir_path / "packages" / "meta" / "package.xml";
|
||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
fs.write_contents(package_xml_file_path, Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>Packages</DisplayName>
|
||||
<Version>1.0.0</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
</Package>
|
||||
)###",
|
||||
create_release_date()));
|
||||
|
||||
for (auto package = unique_packages.begin(); package != unique_packages.end(); ++package)
|
||||
{
|
||||
const ExportPlanAction& action = *(package->second);
|
||||
const BinaryParagraph& binary_paragraph =
|
||||
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
|
||||
|
||||
package_xml_file_path =
|
||||
raw_exported_dir_path / Strings::format("packages.%s", package->first) / "meta" / "package.xml";
|
||||
package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
|
||||
fs.write_contents(package_xml_file_path,
|
||||
Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>%s</DisplayName>
|
||||
<Description>%s</Description>
|
||||
<Version>%s</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
</Package>
|
||||
)###",
|
||||
action.spec.name(),
|
||||
binary_paragraph.description,
|
||||
binary_paragraph.version,
|
||||
create_release_date()));
|
||||
}
|
||||
}
|
||||
|
||||
void export_unique_triplets(const fs::path& raw_exported_dir_path,
|
||||
std::set<std::string> unique_triplets,
|
||||
Files::Filesystem& fs)
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
// triplets
|
||||
|
||||
fs::path package_xml_file_path = raw_exported_dir_path / "triplets" / "meta" / "package.xml";
|
||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
fs.write_contents(package_xml_file_path, Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>Triplets</DisplayName>
|
||||
<Version>1.0.0</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
</Package>
|
||||
)###",
|
||||
create_release_date()));
|
||||
|
||||
for (const std::string& triplet : unique_triplets)
|
||||
{
|
||||
package_xml_file_path =
|
||||
raw_exported_dir_path / Strings::format("triplets.%s", triplet) / "meta" / "package.xml";
|
||||
package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
fs.write_contents(package_xml_file_path, Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>%s</DisplayName>
|
||||
<Version>1.0.0</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
</Package>
|
||||
)###",
|
||||
triplet,
|
||||
create_release_date()));
|
||||
}
|
||||
}
|
||||
|
||||
void export_integration(const fs::path& raw_exported_dir_path, Files::Filesystem& fs)
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
// integration
|
||||
fs::path package_xml_file_path = raw_exported_dir_path / "integration" / "meta" / "package.xml";
|
||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||
fs.create_directories(package_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for package file %s",
|
||||
package_xml_file_path.generic_string());
|
||||
|
||||
fs.write_contents(package_xml_file_path, Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Package>
|
||||
<DisplayName>Integration</DisplayName>
|
||||
<Version>1.0.0</Version>
|
||||
<ReleaseDate>%s</ReleaseDate>
|
||||
</Package>
|
||||
)###",
|
||||
create_release_date()));
|
||||
}
|
||||
|
||||
void export_config(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
std::error_code ec;
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
|
||||
const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths);
|
||||
|
||||
fs::path config_xml_dir_path = config_xml_file_path.parent_path();
|
||||
fs.create_directories(config_xml_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create directory for configuration file %s",
|
||||
config_xml_file_path.generic_string());
|
||||
|
||||
std::string formatted_repo_url;
|
||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||
if (!ifw_repo_url.empty())
|
||||
{
|
||||
formatted_repo_url = Strings::format(R"###(
|
||||
<RemoteRepositories>
|
||||
<Repository>
|
||||
<Url>%s</Url>
|
||||
</Repository>
|
||||
</RemoteRepositories>)###",
|
||||
ifw_repo_url);
|
||||
}
|
||||
|
||||
fs.write_contents(config_xml_file_path, Strings::format(
|
||||
R"###(<?xml version="1.0"?>
|
||||
<Installer>
|
||||
<Name>vcpkg</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
|
||||
</Installer>
|
||||
)###",
|
||||
formatted_repo_url));
|
||||
}
|
||||
|
||||
void do_repository(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
const fs::path& repogen_exe = paths.get_ifw_repogen_exe();
|
||||
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
||||
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
||||
|
||||
System::println("Generating repository %s...", repository_dir.generic_string());
|
||||
|
||||
std::error_code ec;
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
|
||||
fs.remove_all(repository_dir, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not remove outdated repository directory %s",
|
||||
repository_dir.generic_string());
|
||||
|
||||
const std::wstring cmd_line =
|
||||
Strings::wformat(LR"("%s" --packages "%s" "%s" > nul)",
|
||||
repogen_exe.native(),
|
||||
packages_dir.native(),
|
||||
repository_dir.native());
|
||||
|
||||
const int exit_code = System::cmd_execute_clean(cmd_line);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed");
|
||||
|
||||
System::println(System::Color::success, "Generating repository %s... done.", repository_dir.generic_string());
|
||||
}
|
||||
|
||||
void do_installer(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
const fs::path& binarycreator_exe = paths.get_ifw_binarycreator_exe();
|
||||
const fs::path config_file = get_config_file_path(export_id, ifw_options, paths);
|
||||
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
||||
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
||||
const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths);
|
||||
|
||||
System::println("Generating installer %s...", installer_file.generic_string());
|
||||
|
||||
std::wstring cmd_line;
|
||||
|
||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||
if (!ifw_repo_url.empty())
|
||||
{
|
||||
cmd_line =
|
||||
Strings::wformat(LR"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)",
|
||||
binarycreator_exe.native(),
|
||||
config_file.native(),
|
||||
repository_dir.native(),
|
||||
installer_file.native());
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd_line =
|
||||
Strings::wformat(LR"("%s" --config "%s" --packages "%s" "%s" > nul)",
|
||||
binarycreator_exe.native(),
|
||||
config_file.native(),
|
||||
packages_dir.native(),
|
||||
installer_file.native());
|
||||
}
|
||||
|
||||
const int exit_code = System::cmd_execute_clean(cmd_line);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed");
|
||||
|
||||
System::println(System::Color::success, "Generating installer %s... done.", installer_file.generic_string());
|
||||
}
|
||||
|
||||
void do_export(const std::vector<ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||
{
|
||||
const fs::path ifw_packages_dir_path = get_packages_dir_path(export_id, ifw_options, paths);
|
||||
const fs::path config_file = get_config_file_path(export_id, ifw_options, paths);
|
||||
|
||||
System::println("Exporting packages %s... ", ifw_packages_dir_path.generic_string());
|
||||
|
||||
std::error_code ec;
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
|
||||
fs.remove_all(ifw_packages_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not remove outdated packages directory %s",
|
||||
ifw_packages_dir_path.generic_string());
|
||||
|
||||
fs.create_directory(ifw_packages_dir_path, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!ec,
|
||||
"Could not create packages directory %s",
|
||||
ifw_packages_dir_path.generic_string());
|
||||
|
||||
// execute the plan
|
||||
std::map<std::string, const ExportPlanAction*> unique_packages;
|
||||
std::set<std::string> unique_triplets;
|
||||
for (const ExportPlanAction& action : export_plan)
|
||||
{
|
||||
if (action.plan_type != ExportPlanType::ALREADY_BUILT)
|
||||
{
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
const std::string display_name = action.spec.to_string();
|
||||
System::println("Exporting package %s... ", display_name);
|
||||
|
||||
const BinaryParagraph& binary_paragraph =
|
||||
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
|
||||
|
||||
unique_packages[action.spec.name()] = &action;
|
||||
unique_triplets.insert(action.spec.triplet().canonical_name());
|
||||
|
||||
// Export real package and return data dir for installation
|
||||
fs::path ifw_package_dir_path = export_real_package(ifw_packages_dir_path, action, fs);
|
||||
|
||||
// Copy package data
|
||||
const InstallDir dirs = InstallDir::from_destination_root(ifw_package_dir_path,
|
||||
action.spec.triplet().to_string(),
|
||||
ifw_package_dir_path / "vcpkg" / "info" /
|
||||
(binary_paragraph.fullstem() + ".list"));
|
||||
|
||||
Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs);
|
||||
System::println("Exporting package %s... done", display_name);
|
||||
}
|
||||
|
||||
System::println("Exporting packages %s... done", ifw_packages_dir_path.generic_string());
|
||||
|
||||
System::println("Generating configuration %s...", config_file.generic_string());
|
||||
|
||||
// Unique packages
|
||||
export_unique_packages(ifw_packages_dir_path, unique_packages, fs);
|
||||
|
||||
// Unique triplets
|
||||
export_unique_triplets(ifw_packages_dir_path, unique_triplets, fs);
|
||||
|
||||
// Copy files needed for integration
|
||||
export_integration_files(ifw_packages_dir_path / "integration" / "data", paths);
|
||||
// Integration
|
||||
export_integration(ifw_packages_dir_path, fs);
|
||||
|
||||
// Configuration
|
||||
export_config(export_id, ifw_options, paths);
|
||||
|
||||
System::println("Generating configuration %s... done.", config_file.generic_string());
|
||||
|
||||
// Do repository (optional)
|
||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||
if (!ifw_repo_url.empty())
|
||||
{
|
||||
do_repository(export_id, ifw_options, paths);
|
||||
}
|
||||
|
||||
// Do installer
|
||||
do_installer(export_id, ifw_options, paths);
|
||||
}
|
||||
}
|
@ -166,6 +166,8 @@
|
||||
<ClInclude Include="..\include\vcpkg_Checks.h" />
|
||||
<ClInclude Include="..\include\VcpkgCmdArguments.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Commands.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Commands_Export.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Commands_Export_IFW.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Dependencies.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Enums.h" />
|
||||
<ClInclude Include="..\include\vcpkg_Files.h" />
|
||||
@ -185,6 +187,7 @@
|
||||
<ClCompile Include="..\src\commands_depends.cpp" />
|
||||
<ClCompile Include="..\src\commands_env.cpp" />
|
||||
<ClCompile Include="..\src\commands_export.cpp" />
|
||||
<ClCompile Include="..\src\commands_export_ifw.cpp" />
|
||||
<ClCompile Include="..\src\LineInfo.cpp" />
|
||||
<ClCompile Include="..\src\ParagraphParseResult.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg_Build.cpp" />
|
||||
|
@ -165,6 +165,9 @@
|
||||
<ClCompile Include="..\src\commands_export.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\commands_export_ifw.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\VersionT.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -218,6 +221,12 @@
|
||||
<ClInclude Include="..\include\vcpkg_Commands.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\vcpkg_Commands_Export.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\vcpkg_Commands_Export_IFW.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\vcpkg_Dependencies.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
x
Reference in New Issue
Block a user