mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 03:27:12 +01:00
[vcpkg-export-ifw] Separate IFW loop
Separate IFW loop compatible with main export loop Fixed mistakes in templates Set current date to ReleaseDate tag
This commit is contained in:
parent
5199507a58
commit
68b9c2d8b9
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);
|
||||||
|
}
|
@ -5,9 +5,12 @@
|
|||||||
|
|
||||||
namespace vcpkg::Commands::Export::IFW
|
namespace vcpkg::Commands::Export::IFW
|
||||||
{
|
{
|
||||||
fs::path export_real_package(const fs::path &raw_exported_dir_path, const Dependencies::ExportPlanAction& action, Files::Filesystem& fs);
|
struct Options
|
||||||
void export_unique_packages(const fs::path &raw_exported_dir_path, std::map<std::string, const Dependencies::ExportPlanAction*> unique_packages, Files::Filesystem& fs);
|
{
|
||||||
void export_unique_triplets(const fs::path &raw_exported_dir_path, std::set<std::string> unique_triplets, Files::Filesystem& fs);
|
Optional<std::string> maybe_repository_url;
|
||||||
void export_integration(const fs::path &raw_exported_dir_path, Files::Filesystem& fs);
|
Optional<std::string> maybe_packages_dir_path;
|
||||||
void export_config(const fs::path &raw_exported_dir_path, const std::string ifw_repository_url, Files::Filesystem& fs);
|
Optional<std::string> maybe_config_file_path;
|
||||||
|
};
|
||||||
|
|
||||||
|
void do_export(const std::vector<Dependencies::ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths);
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,32 @@ namespace vcpkg::Commands::Export
|
|||||||
return nullopt;
|
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)
|
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_DRY_RUN = "--dry-run";
|
||||||
@ -222,6 +248,8 @@ namespace vcpkg::Commands::Export
|
|||||||
static const std::string OPTION_NUGET_ID = "--nuget-id";
|
static const std::string OPTION_NUGET_ID = "--nuget-id";
|
||||||
static const std::string OPTION_NUGET_VERSION = "--nuget-version";
|
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_REPOSITORY_URL = "--ifw-repository-url";
|
||||||
|
static const std::string OPTION_IFW_PACKAGES_DIR_PATH = "--ifw-packages-directory-path";
|
||||||
|
static const std::string OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path";
|
||||||
|
|
||||||
// input sanitization
|
// input sanitization
|
||||||
static const std::string EXAMPLE =
|
static const std::string EXAMPLE =
|
||||||
@ -247,6 +275,8 @@ namespace vcpkg::Commands::Export
|
|||||||
OPTION_NUGET_ID,
|
OPTION_NUGET_ID,
|
||||||
OPTION_NUGET_VERSION,
|
OPTION_NUGET_VERSION,
|
||||||
OPTION_IFW_REPOSITORY_URL,
|
OPTION_IFW_REPOSITORY_URL,
|
||||||
|
OPTION_IFW_PACKAGES_DIR_PATH,
|
||||||
|
OPTION_IFW_CONFIG_FILE_PATH
|
||||||
});
|
});
|
||||||
const bool dry_run = options.switches.find(OPTION_DRY_RUN) != options.switches.cend();
|
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 raw = options.switches.find(OPTION_RAW) != options.switches.cend();
|
||||||
@ -270,10 +300,19 @@ namespace vcpkg::Commands::Export
|
|||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, !maybe_nuget_version || nuget, "--nuget-version is only valid with --nuget");
|
VCPKG_LINE_INFO, !maybe_nuget_version || nuget, "--nuget-version is only valid with --nuget");
|
||||||
|
|
||||||
auto maybe_ifw_repository_url = maybe_lookup(options.settings, OPTION_IFW_REPOSITORY_URL);
|
IFW::Options ifw_options;
|
||||||
|
|
||||||
|
ifw_options.maybe_repository_url = maybe_lookup(options.settings, OPTION_IFW_REPOSITORY_URL);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, !maybe_ifw_repository_url || ifw, "--ifw-repository-url is only valid with --ifw");
|
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_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");
|
||||||
|
|
||||||
// create the plan
|
// create the plan
|
||||||
const StatusParagraphs status_db = database_load_check(paths);
|
const StatusParagraphs status_db = database_load_check(paths);
|
||||||
@ -318,155 +357,119 @@ namespace vcpkg::Commands::Export
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string export_id = create_export_id();
|
std::string export_id = create_export_id();
|
||||||
if (ifw)
|
|
||||||
{
|
|
||||||
export_id = "vcpkg-export"; // TODO: Remove after debugging
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
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());
|
|
||||||
|
|
||||||
fs::path spec_exported_dir_path = raw_exported_dir_path / "installed";
|
|
||||||
if (ifw)
|
|
||||||
{
|
|
||||||
// Export real package and return data dir for installation
|
|
||||||
spec_exported_dir_path = IFW::export_real_package(raw_exported_dir_path, action, fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
const InstallDir dirs = InstallDir::from_destination_root(spec_exported_dir_path,
|
|
||||||
action.spec.triplet().to_string(),
|
|
||||||
spec_exported_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(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;
|
|
||||||
fs::path destination = raw_exported_dir_path / file;
|
|
||||||
if (ifw)
|
|
||||||
{
|
|
||||||
destination = raw_exported_dir_path / "integration" / "data" / 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifw)
|
|
||||||
{
|
|
||||||
// Unique packages
|
|
||||||
IFW::export_unique_packages(raw_exported_dir_path, unique_packages, fs);
|
|
||||||
// Unique triplets
|
|
||||||
IFW::export_unique_triplets(raw_exported_dir_path, unique_triplets, fs);
|
|
||||||
// Integration
|
|
||||||
IFW::export_integration(raw_exported_dir_path, fs);
|
|
||||||
// Configuration
|
|
||||||
IFW::export_config(raw_exported_dir_path, maybe_ifw_repository_url.value_or(""), fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto print_next_step_info = [](const fs::path& prefix) {
|
const auto print_next_step_info = [](const fs::path& prefix) {
|
||||||
const fs::path cmake_toolchain = prefix / "scripts" / "buildsystems" / "vcpkg.cmake";
|
const fs::path cmake_toolchain = prefix / "scripts" / "buildsystems" / "vcpkg.cmake";
|
||||||
const CMakeVariable cmake_variable =
|
const CMakeVariable cmake_variable =
|
||||||
CMakeVariable(L"CMAKE_TOOLCHAIN_FILE", cmake_toolchain.generic_string());
|
CMakeVariable(L"CMAKE_TOOLCHAIN_FILE", cmake_toolchain.generic_string());
|
||||||
System::println("\n"
|
System::println("\n"
|
||||||
"To use the exported libraries in CMake projects use:"
|
"To use the exported libraries in CMake projects use:"
|
||||||
"\n"
|
"\n"
|
||||||
" %s"
|
" %s"
|
||||||
"\n",
|
"\n",
|
||||||
Strings::to_utf8(cmake_variable.s));
|
Strings::to_utf8(cmake_variable.s));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (raw)
|
// Main loop
|
||||||
|
if (raw || nuget || zip || seven_zip)
|
||||||
{
|
{
|
||||||
System::println(
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
System::Color::success, R"(Files exported at: "%s")", raw_exported_dir_path.generic_string());
|
const fs::path export_to_path = paths.root;
|
||||||
print_next_step_info(export_to_path);
|
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)
|
// execute the plan
|
||||||
{
|
for (const ExportPlanAction& action : export_plan)
|
||||||
System::println("Creating nuget package... ");
|
{
|
||||||
|
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 display_name = action.spec.to_string();
|
||||||
const std::string nuget_version = maybe_nuget_version.value_or("1.0.0");
|
System::println("Exporting package %s... ", display_name);
|
||||||
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"(
|
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:
|
With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste:
|
||||||
Install-Package %s -Source "%s"
|
Install-Package %s -Source "%s"
|
||||||
)"
|
)"
|
||||||
"\n",
|
"\n",
|
||||||
nuget_id,
|
nuget_id,
|
||||||
output_path.parent_path().u8string());
|
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... ");
|
IFW::do_export(export_plan, export_id, ifw_options, paths);
|
||||||
const fs::path output_path =
|
|
||||||
do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::ZIP);
|
// TODO: Download corrected QtIFW tools and automate installer creation
|
||||||
System::println(System::Color::success, "Creating zip archive... done");
|
System::println("Use corrected QtIFW tools (for more info see: https://codereview.qt-project.org/#/c/203958) to create installer...");
|
||||||
System::println(System::Color::success, "Zip archive exported at: %s", output_path.generic_string());
|
|
||||||
print_next_step_info("[...]");
|
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 && !ifw)
|
|
||||||
{
|
|
||||||
fs.remove_all(raw_exported_dir_path, ec);
|
|
||||||
}
|
|
||||||
|
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include "vcpkg_Commands.h"
|
||||||
|
#include "vcpkg_Commands_Export.h"
|
||||||
#include "vcpkg_Commands_Export_IFW.h"
|
#include "vcpkg_Commands_Export_IFW.h"
|
||||||
|
|
||||||
namespace vcpkg::Commands::Export::IFW
|
namespace vcpkg::Commands::Export::IFW
|
||||||
{
|
{
|
||||||
using Dependencies::ExportPlanAction;
|
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 export_real_package(const fs::path& raw_exported_dir_path,
|
fs::path export_real_package(const fs::path& raw_exported_dir_path,
|
||||||
const ExportPlanAction& action,
|
const ExportPlanAction& action,
|
||||||
@ -28,19 +48,19 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
package_xml_file_path.generic_string());
|
package_xml_file_path.generic_string());
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(R"###(
|
Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Version>%s</Version>
|
<Version>%s</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
<AutoDependsOn>packages.%s:,triplets.%s:</AutoDependsOn>
|
<AutoDependOn>packages.%s:,triplets.%s:</AutoDependOn>
|
||||||
<Virtual>true</Virtual>
|
<Virtual>true</Virtual>
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
action.spec.to_string(),
|
action.spec.to_string(),
|
||||||
binary_paragraph.version,
|
binary_paragraph.version,
|
||||||
|
create_release_date(),
|
||||||
action.spec.name(),
|
action.spec.name(),
|
||||||
action.spec.triplet().canonical_name()));
|
action.spec.triplet().canonical_name()));
|
||||||
|
|
||||||
@ -65,15 +85,15 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_string());
|
package_xml_file_path.generic_string());
|
||||||
fs.write_contents(package_xml_file_path, R"###(
|
fs.write_contents(package_xml_file_path, Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Packages</DisplayName>
|
<DisplayName>Packages</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###");
|
)###",
|
||||||
|
create_release_date()));
|
||||||
|
|
||||||
for (auto package = unique_packages.begin(); package != unique_packages.end(); ++package)
|
for (auto package = unique_packages.begin(); package != unique_packages.end(); ++package)
|
||||||
{
|
{
|
||||||
@ -93,22 +113,22 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
auto deps = Strings::join(
|
auto deps = Strings::join(
|
||||||
",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; });
|
",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; });
|
||||||
|
|
||||||
if (!deps.empty()) deps = "\n " + deps;
|
if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>";
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(R"###(
|
Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Description>%s</Description>
|
<Description>%s</Description>
|
||||||
<Version>%s</Version>
|
<Version>%s</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>%s
|
<ReleaseDate>%s</ReleaseDate>%s
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
action.spec.name(),
|
action.spec.name(),
|
||||||
binary_paragraph.description,
|
binary_paragraph.description,
|
||||||
binary_paragraph.version,
|
binary_paragraph.version,
|
||||||
|
create_release_date(),
|
||||||
deps));
|
deps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,15 +148,15 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_string());
|
package_xml_file_path.generic_string());
|
||||||
fs.write_contents(package_xml_file_path, R"###(
|
fs.write_contents(package_xml_file_path, Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Triplets</DisplayName>
|
<DisplayName>Triplets</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###");
|
)###",
|
||||||
|
create_release_date()));
|
||||||
|
|
||||||
for (const std::string& triplet : unique_triplets)
|
for (const std::string& triplet : unique_triplets)
|
||||||
{
|
{
|
||||||
@ -148,15 +168,16 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_string());
|
package_xml_file_path.generic_string());
|
||||||
fs.write_contents(package_xml_file_path, Strings::format(R"###(
|
fs.write_contents(package_xml_file_path, Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###", triplet));
|
)###",
|
||||||
|
triplet,
|
||||||
|
create_release_date()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,52 +194,128 @@ namespace vcpkg::Commands::Export::IFW
|
|||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_string());
|
package_xml_file_path.generic_string());
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path, R"###(
|
fs.write_contents(package_xml_file_path, Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Integration</DisplayName>
|
<DisplayName>Integration</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
<Checkable>true</Checkable>
|
|
||||||
</Package>
|
</Package>
|
||||||
)###");
|
)###",
|
||||||
|
create_release_date()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void export_config(const fs::path& raw_exported_dir_path,
|
void export_config(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||||
const std::string ifw_repository_url,
|
|
||||||
Files::Filesystem& fs)
|
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
|
|
||||||
|
const fs::path config_xml_file_path = 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") / "config.xml";
|
||||||
|
|
||||||
// config.xml
|
|
||||||
fs::path config_xml_file_path = raw_exported_dir_path / "config.xml";
|
|
||||||
fs::path config_xml_dir_path = config_xml_file_path.parent_path();
|
fs::path config_xml_dir_path = config_xml_file_path.parent_path();
|
||||||
fs.create_directories(config_xml_dir_path, ec);
|
fs.create_directories(config_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for configuration file %s",
|
"Could not create directory for configuration file %s",
|
||||||
config_xml_file_path.generic_string());
|
config_xml_file_path.generic_string());
|
||||||
|
|
||||||
std::string formatted_repo_url;
|
std::string formatted_repo_url;
|
||||||
if (!ifw_repository_url.empty())
|
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||||
|
if (!ifw_repo_url.empty())
|
||||||
{
|
{
|
||||||
formatted_repo_url = Strings::format(R"###(
|
formatted_repo_url = Strings::format(R"###(
|
||||||
<RemoteRepositories>
|
<RemoteRepositories>
|
||||||
<Repository>
|
<Repository>
|
||||||
<Url>%s</Url>
|
<Url>%s</Url>
|
||||||
</Repository>
|
</Repository>
|
||||||
</RemoteRepositories>
|
</RemoteRepositories>)###",
|
||||||
)###",
|
ifw_repo_url);
|
||||||
formatted_repo_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.write_contents(config_xml_file_path, Strings::format(R"###(
|
fs.write_contents(config_xml_file_path, Strings::format(
|
||||||
<?xml version=\"1.0\"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Installer>
|
<Installer>
|
||||||
<Name>vcpkg</Name>
|
<Name>vcpkg</Name>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>2017-08-31</ReleaseDate>
|
|
||||||
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
|
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
|
||||||
</Installer>
|
</Installer>
|
||||||
)###", formatted_repo_url));
|
)###",
|
||||||
|
formatted_repo_url));
|
||||||
|
|
||||||
|
System::println("Created ifw configuration file: %s", config_xml_file_path.generic_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_export(const std::vector<ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths)
|
||||||
|
{
|
||||||
|
System::println("Creating ifw packages... ");
|
||||||
|
|
||||||
|
std::error_code ec;
|
||||||
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
|
|
||||||
|
const fs::path ifw_packages_dir_path = 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.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(System::Color::success, "Exporting package %s... done", display_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
System::println("Created ifw packages directory: %s", ifw_packages_dir_path.generic_string());
|
||||||
|
|
||||||
|
// Configuration
|
||||||
|
export_config(export_id, ifw_options, paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,7 @@
|
|||||||
<ClInclude Include="..\include\vcpkg_Checks.h" />
|
<ClInclude Include="..\include\vcpkg_Checks.h" />
|
||||||
<ClInclude Include="..\include\VcpkgCmdArguments.h" />
|
<ClInclude Include="..\include\VcpkgCmdArguments.h" />
|
||||||
<ClInclude Include="..\include\vcpkg_Commands.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_Commands_Export_IFW.h" />
|
||||||
<ClInclude Include="..\include\vcpkg_Dependencies.h" />
|
<ClInclude Include="..\include\vcpkg_Dependencies.h" />
|
||||||
<ClInclude Include="..\include\vcpkg_Enums.h" />
|
<ClInclude Include="..\include\vcpkg_Enums.h" />
|
||||||
|
@ -221,6 +221,9 @@
|
|||||||
<ClInclude Include="..\include\vcpkg_Commands.h">
|
<ClInclude Include="..\include\vcpkg_Commands.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\vcpkg_Commands_Export.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\include\vcpkg_Commands_Export_IFW.h">
|
<ClInclude Include="..\include\vcpkg_Commands_Export_IFW.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user