From e5a6c7a7a61a14e546c7c2f51bbe8595d6624ff0 Mon Sep 17 00:00:00 2001 From: seanyen Date: Tue, 11 Jun 2019 18:09:55 -0700 Subject: first check-in. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 82 +++++++++++++++++++++++++++++++++ toolsrc/src/vcpkg/export.cpp | 16 +++++-- 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 toolsrc/src/vcpkg/export.chocolatey.cpp (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp new file mode 100644 index 000000000..88fb15c23 --- /dev/null +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -0,0 +1,82 @@ +#include "pch.h" + +#include +#include +#include +#include +#include +#include + +namespace vcpkg::Export::Chocolatey +{ + using Dependencies::ExportPlanAction; + using Dependencies::ExportPlanType; + using Install::InstallDir; + + static std::string create_nuspec_file_contents(const std::string& exported_root_dir, + const BinaryParagraph& binary_paragraph) + { + static constexpr auto CONTENT_TEMPLATE = R"( + + + @PACKAGE_ID@ + @PACKAGE_VERSION@ + + + + + + +)"; + + std::string nuspec_file_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name()); + nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", binary_paragraph.version); + nuspec_file_content = + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DESCRIPTION@", binary_paragraph.description); + nuspec_file_content = + Strings::replace_all(std::move(nuspec_file_content), "@EXPORTED_ROOT_DIR@", exported_root_dir); + return nuspec_file_content; + } + + void do_export(const std::vector& export_plan, + const VcpkgPaths& paths) + { + Files::Filesystem& fs = paths.get_filesystem(); + const fs::path export_to_path = paths.root; + const fs::path raw_exported_dir_path = export_to_path / "test-chocolatey"; + + 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::print2("Exporting package ", display_name, "...\n"); + + const fs::path per_package_dir_path = raw_exported_dir_path / action.spec.name(); + + const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); + + const InstallDir dirs = InstallDir::from_destination_root( + per_package_dir_path / "installed", + action.spec.triplet().to_string(), + per_package_dir_path / "installed" / "vcpkg" / "info" / (binary_paragraph.fullstem() + ".list")); + + Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); + + const std::string nuspec_file_content = + create_nuspec_file_contents(raw_exported_dir_path.string(), binary_paragraph); + const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); + fs.write_contents(nuspec_file_path, nuspec_file_content); + } + } +} diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 23fc7441a..3a40befc7 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -256,6 +257,7 @@ namespace vcpkg::Export bool ifw = false; bool zip = false; bool seven_zip = false; + bool chocolatey = false; Optional maybe_output; @@ -280,14 +282,16 @@ namespace vcpkg::Export static constexpr StringLiteral OPTION_IFW_REPOSITORY_DIR_PATH = "--ifw-repository-directory-path"; static constexpr StringLiteral OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path"; static constexpr StringLiteral OPTION_IFW_INSTALLER_FILE_PATH = "--ifw-installer-file-path"; + static constexpr StringLiteral OPTION_CHOCOLATEY = "--chocolatey"; - static constexpr std::array EXPORT_SWITCHES = {{ + static constexpr std::array EXPORT_SWITCHES = {{ {OPTION_DRY_RUN, "Do not actually export"}, {OPTION_RAW, "Export to an uncompressed directory"}, {OPTION_NUGET, "Export a NuGet package"}, {OPTION_IFW, "Export to an IFW-based installer"}, {OPTION_ZIP, "Export to a zip file"}, {OPTION_SEVEN_ZIP, "Export to a 7zip (.7z) file"}, + {OPTION_CHOCOLATEY, "Export a Chocolatey package"}, }}; static constexpr std::array EXPORT_SETTINGS = {{ @@ -326,13 +330,14 @@ namespace vcpkg::Export ret.ifw = options.switches.find(OPTION_IFW) != options.switches.cend(); ret.zip = options.switches.find(OPTION_ZIP) != options.switches.cend(); ret.seven_zip = options.switches.find(OPTION_SEVEN_ZIP) != options.switches.cend(); + ret.chocolatey = options.switches.find(OPTION_CHOCOLATEY) != options.switches.cend(); ret.maybe_output = maybe_lookup(options.settings, OPTION_OUTPUT); - if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run) + if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey) { System::print2(System::Color::error, - "Must provide at least one export type: --raw --nuget --ifw --zip --7zip\n"); + "Must provide at least one export type: --raw --nuget --ifw --zip --7zip --chocolatey\n"); System::print2(COMMAND_STRUCTURE.example_text); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -544,6 +549,11 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console print_next_step_info("@RootDir@/src/vcpkg"); } + if (opts.chocolatey) + { + Chocolatey::do_export(export_plan, paths); + } + Checks::exit_success(VCPKG_LINE_INFO); } } -- cgit v1.2.3 From 31482e4d09bce785dbe2e999c3c009d854734224 Mon Sep 17 00:00:00 2001 From: seanyen Date: Tue, 11 Jun 2019 23:54:54 -0700 Subject: add nuget packaging logic. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index 88fb15c23..aa10ec71d 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -21,6 +21,7 @@ namespace vcpkg::Export::Chocolatey @PACKAGE_ID@ @PACKAGE_VERSION@ + @PACKAGE_MAINTAINER@ @@ -30,9 +31,16 @@ namespace vcpkg::Export::Chocolatey )"; - + std::string maintainer = binary_paragraph.maintainer; + if (maintainer.empty()) + { + maintainer = binary_paragraph.spec.name(); + } std::string nuspec_file_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name()); - nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", binary_paragraph.version); + nuspec_file_content = + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", binary_paragraph.version); + nuspec_file_content = + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_MAINTAINER@", maintainer); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DESCRIPTION@", binary_paragraph.description); nuspec_file_content = @@ -45,7 +53,8 @@ namespace vcpkg::Export::Chocolatey { Files::Filesystem& fs = paths.get_filesystem(); const fs::path export_to_path = paths.root; - const fs::path raw_exported_dir_path = export_to_path / "test-chocolatey"; + const fs::path raw_exported_dir_path = export_to_path / "chocolatey"; + const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET); std::error_code ec; fs.remove_all(raw_exported_dir_path, ec); @@ -74,9 +83,17 @@ namespace vcpkg::Export::Chocolatey Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); const std::string nuspec_file_content = - create_nuspec_file_contents(raw_exported_dir_path.string(), binary_paragraph); + create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph); const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); fs.write_contents(nuspec_file_path, nuspec_file_content); + + const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)", + nuget_exe.u8string(), + raw_exported_dir_path.u8string(), + nuspec_file_path.u8string()); + + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: NuGet package creation failed"); } } } -- cgit v1.2.3 From 9a3999d8e29c535ed7fd304a1db5eb2805313416 Mon Sep 17 00:00:00 2001 From: seanyen Date: Wed, 12 Jun 2019 00:29:51 -0700 Subject: add dependencies. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index aa10ec71d..3e6acd34e 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -13,6 +13,19 @@ namespace vcpkg::Export::Chocolatey using Dependencies::ExportPlanType; using Install::InstallDir; + static std::string create_nuspec_dependencies(const BinaryParagraph& binary_paragraph) + { + static constexpr auto CONTENT_TEMPLATE = + R"()"; + + std::string nuspec_dependencies; + for (const std::string& depend: binary_paragraph.depends) + { + nuspec_dependencies += Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", depend); + } + return nuspec_dependencies; + } + static std::string create_nuspec_file_contents(const std::string& exported_root_dir, const BinaryParagraph& binary_paragraph) { @@ -25,6 +38,9 @@ namespace vcpkg::Export::Chocolatey + + @PACKAGE_DEPENDENCIES@ + @@ -45,6 +61,8 @@ namespace vcpkg::Export::Chocolatey Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DESCRIPTION@", binary_paragraph.description); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@EXPORTED_ROOT_DIR@", exported_root_dir); + nuspec_file_content = + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph)); return nuspec_file_content; } -- cgit v1.2.3 From c63af255e39c8303b07014456d97985a71ef3174 Mon Sep 17 00:00:00 2001 From: seanyen Date: Wed, 12 Jun 2019 18:20:02 -0700 Subject: add chocolatey install scripts. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 86 +++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index 3e6acd34e..b2bfffd41 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -44,6 +44,7 @@ namespace vcpkg::Export::Chocolatey + )"; @@ -66,12 +67,81 @@ namespace vcpkg::Export::Chocolatey return nuspec_file_content; } + static std::string create_chocolatey_install_contents() + { + static constexpr auto CONTENT_TEMPLATE = R"###( +$ErrorActionPreference = 'Stop'; + +$packageName= $env:ChocolateyPackageName +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$rootDir = "$(Split-Path -parent $toolsDir)" +$installedDir = Join-Path $rootDir 'installed' + +$whereToInstall = (pwd).path +$whereToInstallCache = Join-Path $rootDir 'install.txt' +Set-Content -Path $whereToInstallCache -Value $whereToInstall +Copy-Item $installedDir -destination $whereToInstall -recurse -force +)###"; + return CONTENT_TEMPLATE; + } + + static std::string create_chocolatey_uninstall_contents(const BinaryParagraph& binary_paragraph) + { + static constexpr auto CONTENT_TEMPLATE = R"###( +$ErrorActionPreference = 'Stop'; + +$packageName= $env:ChocolateyPackageName +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$rootDir = "$(Split-Path -parent $toolsDir)" +$listFile = Join-Path $rootDir 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list' + +$whereToInstall = $null +$whereToInstallCache = Join-Path $rootDir 'install.txt' +Get-Content $whereToInstallCache | Foreach-Object { + $whereToInstall = $_ +} + +$installedDir = Join-Path $whereToInstall 'installed' +Get-Content $listFile | Foreach-Object { + $fileToRemove = Join-Path $installedDir $_ + if (Test-Path $fileToRemove -PathType Leaf) { + Remove-Item $fileToRemove + } +} + +Get-Content $listFile | Foreach-Object { + $fileToRemove = Join-Path $installedDir $_ + if (Test-Path $fileToRemove -PathType Container) { + $folderToDelete = Join-Path $fileToRemove * + if (-Not (Test-Path $folderToDelete)) + { + Remove-Item $fileToRemove + } + } +} + +$listFileToRemove = Join-Path $whereToInstall 'installed\vcpkg\info\@PACKAGE_FULLSTEM@.list' +Remove-Item $listFileToRemove + +if (Test-Path $installedDir) +{ + while ( + $empties = Get-ChildItem $installedDir -recurse -Directory | Where-Object { + $_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0 + } + ) { $empties | Remove-Item } +} +)###"; + std::string chocolatey_uninstall_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_FULLSTEM@", binary_paragraph.fullstem()); + return chocolatey_uninstall_content; + } + void do_export(const std::vector& export_plan, const VcpkgPaths& paths) { Files::Filesystem& fs = paths.get_filesystem(); - const fs::path export_to_path = paths.root; - const fs::path raw_exported_dir_path = export_to_path / "chocolatey"; + const fs::path vcpkg_root_path = paths.root; + const fs::path raw_exported_dir_path = vcpkg_root_path / "chocolatey"; const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET); std::error_code ec; @@ -105,9 +175,19 @@ namespace vcpkg::Export::Chocolatey const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); fs.write_contents(nuspec_file_path, nuspec_file_content); + fs.create_directory(per_package_dir_path / "tools", ec); + + const std::string chocolatey_install_content = create_chocolatey_install_contents(); + const fs::path chocolatey_install_file_path = per_package_dir_path / "tools" / "chocolateyInstall.ps1"; + fs.write_contents(chocolatey_install_file_path, chocolatey_install_content); + + const std::string chocolatey_uninstall_content = create_chocolatey_uninstall_contents(binary_paragraph); + const fs::path chocolatey_uninstall_file_path = per_package_dir_path / "tools" / "chocolateyUninstall.ps1"; + fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content); + const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)", nuget_exe.u8string(), - raw_exported_dir_path.u8string(), + vcpkg_root_path.u8string(), nuspec_file_path.u8string()); const int exit_code = System::cmd_execute_clean(cmd_line); -- cgit v1.2.3 From 11d2fc9f81065cc883a59ea29931d8e1030a3731 Mon Sep 17 00:00:00 2001 From: seanyen Date: Thu, 13 Jun 2019 01:04:19 -0700 Subject: add depends version restrictions. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index b2bfffd41..2c1d1e657 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -13,21 +13,30 @@ namespace vcpkg::Export::Chocolatey using Dependencies::ExportPlanType; using Install::InstallDir; - static std::string create_nuspec_dependencies(const BinaryParagraph& binary_paragraph) + static std::string create_nuspec_dependencies(const BinaryParagraph& binary_paragraph, + const std::map& dependsVersion) { static constexpr auto CONTENT_TEMPLATE = - R"()"; + R"()"; std::string nuspec_dependencies; for (const std::string& depend: binary_paragraph.depends) { - nuspec_dependencies += Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", depend); + auto found = dependsVersion.find(depend); + if (found == dependsVersion.end()) + { + Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired dependency version."); + } + std::string nuspec_dependency = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", depend); + nuspec_dependency = Strings::replace_all(std::move(nuspec_dependency), "@PACKAGE_VERSION@", found->second); + nuspec_dependencies += nuspec_dependency; } return nuspec_dependencies; } static std::string create_nuspec_file_contents(const std::string& exported_root_dir, - const BinaryParagraph& binary_paragraph) + const BinaryParagraph& binary_paragraph, + const std::map& dependsVersion) { static constexpr auto CONTENT_TEMPLATE = R"( @@ -63,7 +72,7 @@ namespace vcpkg::Export::Chocolatey nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@EXPORTED_ROOT_DIR@", exported_root_dir); nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph)); + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph, dependsVersion)); return nuspec_file_content; } @@ -149,6 +158,7 @@ if (Test-Path $installedDir) fs.create_directory(raw_exported_dir_path, ec); // execute the plan + std::map dependsVersion; for (const ExportPlanAction& action : export_plan) { if (action.plan_type != ExportPlanType::ALREADY_BUILT) @@ -156,6 +166,12 @@ if (Test-Path $installedDir) Checks::unreachable(VCPKG_LINE_INFO); } + const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); + dependsVersion.insert(std::make_pair(binary_paragraph.spec.name(), binary_paragraph.version)); + } + + for (const ExportPlanAction& action : export_plan) + { const std::string display_name = action.spec.to_string(); System::print2("Exporting package ", display_name, "...\n"); @@ -171,7 +187,7 @@ if (Test-Path $installedDir) Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); const std::string nuspec_file_content = - create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph); + create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph, dependsVersion); const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); fs.write_contents(nuspec_file_path, nuspec_file_content); -- cgit v1.2.3 From 4c7188919a63dd0f3cdbd559f25571ca079596b7 Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Mon, 17 Jun 2019 17:50:48 -0700 Subject: Add version-suffix and maintainer options. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 45 ++++++++++++++++++++------------- toolsrc/src/vcpkg/export.cpp | 16 ++++++++++-- 2 files changed, 42 insertions(+), 19 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index 2c1d1e657..cf9db6f4c 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Export::Chocolatey using Install::InstallDir; static std::string create_nuspec_dependencies(const BinaryParagraph& binary_paragraph, - const std::map& dependsVersion) + const std::map& packages_version) { static constexpr auto CONTENT_TEMPLATE = R"()"; @@ -22,8 +22,8 @@ namespace vcpkg::Export::Chocolatey std::string nuspec_dependencies; for (const std::string& depend: binary_paragraph.depends) { - auto found = dependsVersion.find(depend); - if (found == dependsVersion.end()) + auto found = packages_version.find(depend); + if (found == packages_version.end()) { Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired dependency version."); } @@ -36,10 +36,11 @@ namespace vcpkg::Export::Chocolatey static std::string create_nuspec_file_contents(const std::string& exported_root_dir, const BinaryParagraph& binary_paragraph, - const std::map& dependsVersion) + const std::map& packages_version, + const Options& chocolatey_options) { - static constexpr auto CONTENT_TEMPLATE = R"( - + static constexpr auto CONTENT_TEMPLATE = R"( + @PACKAGE_ID@ @PACKAGE_VERSION@ @@ -57,22 +58,22 @@ namespace vcpkg::Export::Chocolatey )"; - std::string maintainer = binary_paragraph.maintainer; - if (maintainer.empty()) + auto package_version = packages_version.find(binary_paragraph.spec.name()); + if (package_version == packages_version.end()) { - maintainer = binary_paragraph.spec.name(); + Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired package version."); } std::string nuspec_file_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name()); nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", binary_paragraph.version); + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", package_version->second); nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_MAINTAINER@", maintainer); + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_MAINTAINER@", chocolatey_options.maybe_maintainer.value_or("")); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DESCRIPTION@", binary_paragraph.description); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@EXPORTED_ROOT_DIR@", exported_root_dir); nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph, dependsVersion)); + Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph, packages_version)); return nuspec_file_content; } @@ -146,19 +147,23 @@ if (Test-Path $installedDir) } void do_export(const std::vector& export_plan, - const VcpkgPaths& paths) + const VcpkgPaths& paths, + const Options& chocolatey_options) { Files::Filesystem& fs = paths.get_filesystem(); const fs::path vcpkg_root_path = paths.root; const fs::path raw_exported_dir_path = vcpkg_root_path / "chocolatey"; + const fs::path exported_dir_path = vcpkg_root_path / "chocolatey_exports"; const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET); std::error_code ec; fs.remove_all(raw_exported_dir_path, ec); fs.create_directory(raw_exported_dir_path, ec); + fs.remove_all(exported_dir_path, ec); + fs.create_directory(exported_dir_path, ec); // execute the plan - std::map dependsVersion; + std::map packages_version; for (const ExportPlanAction& action : export_plan) { if (action.plan_type != ExportPlanType::ALREADY_BUILT) @@ -167,7 +172,13 @@ if (Test-Path $installedDir) } const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); - dependsVersion.insert(std::make_pair(binary_paragraph.spec.name(), binary_paragraph.version)); + auto norm_version = binary_paragraph.version; + + // normalize the version string to be separated by dots to be compliant with Nusepc. + norm_version = Strings::replace_all(std::move(norm_version), "-", "."); + norm_version = Strings::replace_all(std::move(norm_version), "_", "."); + norm_version = norm_version + chocolatey_options.maybe_version_suffix.value_or(""); + packages_version.insert(std::make_pair(binary_paragraph.spec.name(), norm_version)); } for (const ExportPlanAction& action : export_plan) @@ -187,7 +198,7 @@ if (Test-Path $installedDir) Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); const std::string nuspec_file_content = - create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph, dependsVersion); + create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph, packages_version, chocolatey_options); const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); fs.write_contents(nuspec_file_path, nuspec_file_content); @@ -203,7 +214,7 @@ if (Test-Path $installedDir) const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)", nuget_exe.u8string(), - vcpkg_root_path.u8string(), + exported_dir_path.u8string(), nuspec_file_path.u8string()); const int exit_code = System::cmd_execute_clean(cmd_line); diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 3a40befc7..06f4b1868 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -265,6 +265,7 @@ namespace vcpkg::Export Optional maybe_nuget_version; IFW::Options ifw_options; + Chocolatey::Options chocolatey_options; std::vector specs; }; @@ -283,6 +284,8 @@ namespace vcpkg::Export static constexpr StringLiteral OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path"; static constexpr StringLiteral OPTION_IFW_INSTALLER_FILE_PATH = "--ifw-installer-file-path"; static constexpr StringLiteral OPTION_CHOCOLATEY = "--chocolatey"; + static constexpr StringLiteral OPTION_CHOCOLATEY_MAINTAINER = "--maintainer"; + static constexpr StringLiteral OPTION_CHOCOLATEY_VERSION_SUFFIX = "--version-suffix"; static constexpr std::array EXPORT_SWITCHES = {{ {OPTION_DRY_RUN, "Do not actually export"}, @@ -294,7 +297,7 @@ namespace vcpkg::Export {OPTION_CHOCOLATEY, "Export a Chocolatey package"}, }}; - static constexpr std::array EXPORT_SETTINGS = {{ + static constexpr std::array EXPORT_SETTINGS = {{ {OPTION_OUTPUT, "Specify the output name (used to construct filename)"}, {OPTION_NUGET_ID, "Specify the id for the exported NuGet package (overrides --output)"}, {OPTION_NUGET_VERSION, "Specify the version for the exported NuGet package"}, @@ -303,6 +306,8 @@ namespace vcpkg::Export {OPTION_IFW_REPOSITORY_DIR_PATH, "Specify the directory path for the exported repository"}, {OPTION_IFW_CONFIG_FILE_PATH, "Specify the temporary file path for the installer configuration"}, {OPTION_IFW_INSTALLER_FILE_PATH, "Specify the file path for the exported installer"}, + {OPTION_CHOCOLATEY_MAINTAINER, "Specify the maintainer for the exported Chocolatey package"}, + {OPTION_CHOCOLATEY_VERSION_SUFFIX, "Specify the version suffix to add for the exported Chocolatey package"}, }}; const CommandStructure COMMAND_STRUCTURE = { @@ -381,6 +386,13 @@ namespace vcpkg::Export {OPTION_IFW_CONFIG_FILE_PATH, ret.ifw_options.maybe_config_file_path}, {OPTION_IFW_INSTALLER_FILE_PATH, ret.ifw_options.maybe_installer_file_path}, }); + + options_implies(OPTION_CHOCOLATEY, + ret.chocolatey, + { + {OPTION_CHOCOLATEY_MAINTAINER, ret.chocolatey_options.maybe_maintainer}, + {OPTION_CHOCOLATEY_VERSION_SUFFIX, ret.chocolatey_options.maybe_version_suffix}, + }); return ret; } @@ -551,7 +563,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console if (opts.chocolatey) { - Chocolatey::do_export(export_plan, paths); + Chocolatey::do_export(export_plan, paths, opts.chocolatey_options); } Checks::exit_success(VCPKG_LINE_INFO); -- cgit v1.2.3 From f54151fff6ce32b24ef18be0a55113132345c859 Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Wed, 19 Jun 2019 16:25:21 -0700 Subject: make options to be experimental. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 2 ++ toolsrc/src/vcpkg/export.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index cf9db6f4c..a433cc84b 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -150,6 +150,8 @@ if (Test-Path $installedDir) const VcpkgPaths& paths, const Options& chocolatey_options) { + Checks::check_exit(VCPKG_LINE_INFO, chocolatey_options.maybe_maintainer.has_value(), "--x-maintainer option is required."); + Files::Filesystem& fs = paths.get_filesystem(); const fs::path vcpkg_root_path = paths.root; const fs::path raw_exported_dir_path = vcpkg_root_path / "chocolatey"; diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 06f4b1868..607066164 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -283,9 +283,9 @@ namespace vcpkg::Export static constexpr StringLiteral OPTION_IFW_REPOSITORY_DIR_PATH = "--ifw-repository-directory-path"; static constexpr StringLiteral OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path"; static constexpr StringLiteral OPTION_IFW_INSTALLER_FILE_PATH = "--ifw-installer-file-path"; - static constexpr StringLiteral OPTION_CHOCOLATEY = "--chocolatey"; - static constexpr StringLiteral OPTION_CHOCOLATEY_MAINTAINER = "--maintainer"; - static constexpr StringLiteral OPTION_CHOCOLATEY_VERSION_SUFFIX = "--version-suffix"; + static constexpr StringLiteral OPTION_CHOCOLATEY = "--x-chocolatey"; + static constexpr StringLiteral OPTION_CHOCOLATEY_MAINTAINER = "--x-maintainer"; + static constexpr StringLiteral OPTION_CHOCOLATEY_VERSION_SUFFIX = "--x-version-suffix"; static constexpr std::array EXPORT_SWITCHES = {{ {OPTION_DRY_RUN, "Do not actually export"}, @@ -294,7 +294,7 @@ namespace vcpkg::Export {OPTION_IFW, "Export to an IFW-based installer"}, {OPTION_ZIP, "Export to a zip file"}, {OPTION_SEVEN_ZIP, "Export to a 7zip (.7z) file"}, - {OPTION_CHOCOLATEY, "Export a Chocolatey package"}, + {OPTION_CHOCOLATEY, "Export a Chocolatey package (experimental feature)"}, }}; static constexpr std::array EXPORT_SETTINGS = {{ @@ -306,8 +306,8 @@ namespace vcpkg::Export {OPTION_IFW_REPOSITORY_DIR_PATH, "Specify the directory path for the exported repository"}, {OPTION_IFW_CONFIG_FILE_PATH, "Specify the temporary file path for the installer configuration"}, {OPTION_IFW_INSTALLER_FILE_PATH, "Specify the file path for the exported installer"}, - {OPTION_CHOCOLATEY_MAINTAINER, "Specify the maintainer for the exported Chocolatey package"}, - {OPTION_CHOCOLATEY_VERSION_SUFFIX, "Specify the version suffix to add for the exported Chocolatey package"}, + {OPTION_CHOCOLATEY_MAINTAINER, "Specify the maintainer for the exported Chocolatey package (experimental feature)"}, + {OPTION_CHOCOLATEY_VERSION_SUFFIX, "Specify the version suffix to add for the exported Chocolatey package (experimental feature)"}, }}; const CommandStructure COMMAND_STRUCTURE = { -- cgit v1.2.3 From 62d67d3bf8eeff1afa8009041fd08b8822676b7b Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Wed, 19 Jun 2019 16:39:04 -0700 Subject: rebase and fix build breaks. --- toolsrc/src/vcpkg/export.chocolatey.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index a433cc84b..ef9952bc4 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -202,17 +202,17 @@ if (Test-Path $installedDir) const std::string nuspec_file_content = create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph, packages_version, chocolatey_options); const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); - fs.write_contents(nuspec_file_path, nuspec_file_content); + fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO); fs.create_directory(per_package_dir_path / "tools", ec); const std::string chocolatey_install_content = create_chocolatey_install_contents(); const fs::path chocolatey_install_file_path = per_package_dir_path / "tools" / "chocolateyInstall.ps1"; - fs.write_contents(chocolatey_install_file_path, chocolatey_install_content); + fs.write_contents(chocolatey_install_file_path, chocolatey_install_content, VCPKG_LINE_INFO); const std::string chocolatey_uninstall_content = create_chocolatey_uninstall_contents(binary_paragraph); const fs::path chocolatey_uninstall_file_path = per_package_dir_path / "tools" / "chocolateyUninstall.ps1"; - fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content); + fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content, VCPKG_LINE_INFO); const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)", nuget_exe.u8string(), -- cgit v1.2.3 From 552296a74113a7f56babe232e7f554f1279484c5 Mon Sep 17 00:00:00 2001 From: dan-shaw <51385773+dan-shaw@users.noreply.github.com> Date: Thu, 14 Nov 2019 13:12:36 -0800 Subject: [vcpkg] update telemetry --- toolsrc/src/vcpkg.cpp | 4 ---- toolsrc/src/vcpkg/build.cpp | 10 +++++++++- toolsrc/src/vcpkg/install.cpp | 5 +++-- toolsrc/src/vcpkg/metrics.cpp | 12 +++++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 9cd0ddf19..c336d2f63 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -304,7 +304,6 @@ int main(const int argc, const char* const* const argv) SetConsoleCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8); - const std::string trimmed_command_line = trim_path_from_command_line(Strings::to_utf8(GetCommandLineW())); #endif Checks::register_global_shutdown_handler([]() { @@ -335,9 +334,6 @@ int main(const int argc, const char* const* const argv) { auto locked_metrics = Metrics::g_metrics.lock(); locked_metrics->track_property("version", Commands::Version::version()); -#if defined(_WIN32) - locked_metrics->track_property("cmdline", trimmed_command_line); -#endif } System::register_console_ctrl_handler(); diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 618e4126b..c606594af 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -580,7 +580,15 @@ namespace vcpkg::Build { auto locked_metrics = Metrics::g_metrics.lock(); - locked_metrics->track_buildtime(spec.to_string() + ":[" + Strings::join(",", config.feature_list) + "]", + + locked_metrics->track_buildtime(Hash::get_string_hash(spec.to_string(), Hash::Algorithm::Sha256) + ":[" + + Strings::join(",", + config.feature_list, + [](std::string feature) { + return Hash::get_string_hash(feature, + Hash::Algorithm::Sha256); + }) + + "]", buildtimeus); if (return_code != 0) { diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 21be2d7b0..d1c4a4b2d 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include +#include #include #include #include @@ -690,9 +691,9 @@ namespace vcpkg::Install // log the plan const std::string specs_string = Strings::join(",", action_plan, [](const AnyAction& action) { if (auto iaction = action.install_action.get()) - return iaction->spec.to_string(); + return Hash::get_string_hash(iaction->spec.to_string(), Hash::Algorithm::Sha256); else if (auto raction = action.remove_action.get()) - return "R$" + raction->spec.to_string(); + return "R$" + Hash::get_string_hash(raction->spec.to_string(), Hash::Algorithm::Sha256); Checks::unreachable(VCPKG_LINE_INFO); }); diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index b8c55919e..7aaa852c3 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -184,9 +184,15 @@ namespace vcpkg::Metrics if (buildtime_names.size() > 0) { if (props_plus_buildtimes.size() > 0) props_plus_buildtimes.push_back(','); - props_plus_buildtimes.append(Strings::format(R"("buildnames": [%s], "buildtimes": [%s])", - Strings::join(",", buildtime_names, to_json_string), - Strings::join(",", buildtime_times))); + props_plus_buildtimes.append( + Strings::format(R"("buildnames": [%s], "buildtimes": [%s])", + Strings::join(",", + buildtime_names, + [](std::string buildname) { + return to_json_string(vcpkg::Hash::get_string_hash( + buildname, Hash::Algorithm::Sha256)); + }), + Strings::join(",", buildtime_times))); } const std::string& session_id = get_session_id(); -- cgit v1.2.3 From 018c265d71a40b316f1fe6d68411bc1804fd401e Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Fri, 22 Nov 2019 10:33:45 -0800 Subject: [vcpkg] Fix build breaks and run clang-format --- toolsrc/src/vcpkg/export.chocolatey.cpp | 44 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/export.chocolatey.cpp b/toolsrc/src/vcpkg/export.chocolatey.cpp index ef9952bc4..492e5d371 100644 --- a/toolsrc/src/vcpkg/export.chocolatey.cpp +++ b/toolsrc/src/vcpkg/export.chocolatey.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include namespace vcpkg::Export::Chocolatey @@ -16,11 +16,10 @@ namespace vcpkg::Export::Chocolatey static std::string create_nuspec_dependencies(const BinaryParagraph& binary_paragraph, const std::map& packages_version) { - static constexpr auto CONTENT_TEMPLATE = - R"()"; - + static constexpr auto CONTENT_TEMPLATE = R"()"; + std::string nuspec_dependencies; - for (const std::string& depend: binary_paragraph.depends) + for (const std::string& depend : binary_paragraph.depends) { auto found = packages_version.find(depend); if (found == packages_version.end()) @@ -63,17 +62,19 @@ namespace vcpkg::Export::Chocolatey { Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired package version."); } - std::string nuspec_file_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name()); + std::string nuspec_file_content = + Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name()); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_VERSION@", package_version->second); - nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_MAINTAINER@", chocolatey_options.maybe_maintainer.value_or("")); + nuspec_file_content = Strings::replace_all( + std::move(nuspec_file_content), "@PACKAGE_MAINTAINER@", chocolatey_options.maybe_maintainer.value_or("")); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DESCRIPTION@", binary_paragraph.description); nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), "@EXPORTED_ROOT_DIR@", exported_root_dir); - nuspec_file_content = - Strings::replace_all(std::move(nuspec_file_content), "@PACKAGE_DEPENDENCIES@", create_nuspec_dependencies(binary_paragraph, packages_version)); + nuspec_file_content = Strings::replace_all(std::move(nuspec_file_content), + "@PACKAGE_DEPENDENCIES@", + create_nuspec_dependencies(binary_paragraph, packages_version)); return nuspec_file_content; } @@ -142,7 +143,8 @@ if (Test-Path $installedDir) ) { $empties | Remove-Item } } )###"; - std::string chocolatey_uninstall_content = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_FULLSTEM@", binary_paragraph.fullstem()); + std::string chocolatey_uninstall_content = + Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_FULLSTEM@", binary_paragraph.fullstem()); return chocolatey_uninstall_content; } @@ -150,7 +152,8 @@ if (Test-Path $installedDir) const VcpkgPaths& paths, const Options& chocolatey_options) { - Checks::check_exit(VCPKG_LINE_INFO, chocolatey_options.maybe_maintainer.has_value(), "--x-maintainer option is required."); + Checks::check_exit( + VCPKG_LINE_INFO, chocolatey_options.maybe_maintainer.has_value(), "--x-maintainer option is required."); Files::Filesystem& fs = paths.get_filesystem(); const fs::path vcpkg_root_path = paths.root; @@ -159,9 +162,9 @@ if (Test-Path $installedDir) const fs::path& nuget_exe = paths.get_tool_exe(Tools::NUGET); std::error_code ec; - fs.remove_all(raw_exported_dir_path, ec); + fs.remove_all(raw_exported_dir_path, VCPKG_LINE_INFO); fs.create_directory(raw_exported_dir_path, ec); - fs.remove_all(exported_dir_path, ec); + fs.remove_all(exported_dir_path, VCPKG_LINE_INFO); fs.create_directory(exported_dir_path, ec); // execute the plan @@ -199,9 +202,10 @@ if (Test-Path $installedDir) Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); - const std::string nuspec_file_content = - create_nuspec_file_contents(per_package_dir_path.string(), binary_paragraph, packages_version, chocolatey_options); - const fs::path nuspec_file_path = per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); + const std::string nuspec_file_content = create_nuspec_file_contents( + per_package_dir_path.string(), binary_paragraph, packages_version, chocolatey_options); + const fs::path nuspec_file_path = + per_package_dir_path / Strings::concat(binary_paragraph.spec.name(), ".nuspec"); fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO); fs.create_directory(per_package_dir_path / "tools", ec); @@ -215,9 +219,9 @@ if (Test-Path $installedDir) fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content, VCPKG_LINE_INFO); const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes > nul)", - nuget_exe.u8string(), - exported_dir_path.u8string(), - nuspec_file_path.u8string()); + nuget_exe.u8string(), + exported_dir_path.u8string(), + nuspec_file_path.u8string()); const int exit_code = System::cmd_execute_clean(cmd_line); Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: NuGet package creation failed"); -- cgit v1.2.3 From 0a0440c1a89037866f091dae33a3859f40f41fa2 Mon Sep 17 00:00:00 2001 From: dan-shaw <51385773+dan-shaw@users.noreply.github.com> Date: Fri, 22 Nov 2019 15:07:00 -0800 Subject: update telemetry --- toolsrc/src/vcpkg/build.cpp | 2 +- toolsrc/src/vcpkg/install.cpp | 2 +- toolsrc/src/vcpkg/metrics.cpp | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index c606594af..2037e8d26 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -584,7 +584,7 @@ namespace vcpkg::Build locked_metrics->track_buildtime(Hash::get_string_hash(spec.to_string(), Hash::Algorithm::Sha256) + ":[" + Strings::join(",", config.feature_list, - [](std::string feature) { + [](const std::string& feature) { return Hash::get_string_hash(feature, Hash::Algorithm::Sha256); }) + diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index d1c4a4b2d..a082f1b95 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -697,7 +697,7 @@ namespace vcpkg::Install Checks::unreachable(VCPKG_LINE_INFO); }); - Metrics::g_metrics.lock()->track_property("installplan", specs_string); + Metrics::g_metrics.lock()->track_property("installplan_1", specs_string); Dependencies::print_plan(action_plan, is_recursive, paths.ports); diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index 7aaa852c3..b971d96da 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/src/vcpkg/metrics.cpp @@ -184,15 +184,9 @@ namespace vcpkg::Metrics if (buildtime_names.size() > 0) { if (props_plus_buildtimes.size() > 0) props_plus_buildtimes.push_back(','); - props_plus_buildtimes.append( - Strings::format(R"("buildnames": [%s], "buildtimes": [%s])", - Strings::join(",", - buildtime_names, - [](std::string buildname) { - return to_json_string(vcpkg::Hash::get_string_hash( - buildname, Hash::Algorithm::Sha256)); - }), - Strings::join(",", buildtime_times))); + props_plus_buildtimes.append(Strings::format(R"("buildnames_1": [%s], "buildtimes": [%s])", + Strings::join(",", buildtime_names, to_json_string), + Strings::join(",", buildtime_times))); } const std::string& session_id = get_session_id(); -- cgit v1.2.3 From 7b61b7b515cc077e2ce76505cad94c4268ef2bb4 Mon Sep 17 00:00:00 2001 From: Curtis J Bezault Date: Thu, 9 Jan 2020 14:27:03 -0800 Subject: Allow ARM64 to build x86 things (#9578) --- toolsrc/src/vcpkg/base/system.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index d9c6349be..c84b7f8be 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -157,11 +157,24 @@ namespace vcpkg std::vector supported_architectures; supported_architectures.push_back(get_host_processor()); - // AMD64 machines support to run x86 applications + // AMD64 machines support running x86 applications and ARM64 machines support running ARM applications if (supported_architectures.back() == CPUArchitecture::X64) { supported_architectures.push_back(CPUArchitecture::X86); } + else if (supported_architectures.back() == CPUArchitecture::ARM64) + { + supported_architectures.push_back(CPUArchitecture::ARM); + } + +#if defined(_WIN32) + // On ARM32/64 Windows we can rely on x86 emulation + if (supported_architectures.front() == CPUArchitecture::ARM || + supported_architectures.front() == CPUArchitecture::ARM64) + { + supported_architectures.push_back(CPUArchitecture::X86); + } +#endif return supported_architectures; } -- cgit v1.2.3 From 891a840ffa22d7d2631a0c67ec4f0b001e1c19ed Mon Sep 17 00:00:00 2001 From: Maher Jendoubi Date: Thu, 9 Jan 2020 23:31:48 +0100 Subject: Contributing: Fix a typo (#9566) --- toolsrc/src/vcpkg/build.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 2037e8d26..451f72445 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -662,7 +662,7 @@ namespace vcpkg::Build std::vector abi_tag_entries(dependency_abis.begin(), dependency_abis.end()); // Sorted here as the order of dependency_abis is the only - // non-deterministicly ordered set of AbiEntries + // non-deterministically ordered set of AbiEntries Util::sort(abi_tag_entries); // If there is an unusually large number of files in the port then -- cgit v1.2.3 From 299c7c730ca759ef3dee365a2ecd7c3dd39db8a6 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 14 Jan 2020 00:31:58 +0000 Subject: Introduce new policy to skip post verification of dll exports (#9642) * - Introduce new policy to skip post verification of dll exports (see issue #9641). * - Fixed line endings. --- toolsrc/src/vcpkg/build.cpp | 3 +++ toolsrc/src/vcpkg/postbuildlint.cpp | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 451f72445..f13dd2a25 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -129,6 +129,7 @@ namespace vcpkg::Build { static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage"; static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs"; + static const std::string NAME_DLLS_WITHOUT_EXPORTS = "PolicyDLLsWithoutExports"; static const std::string NAME_ONLY_RELEASE_CRT = "PolicyOnlyReleaseCRT"; static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder"; static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt"; @@ -139,6 +140,7 @@ namespace vcpkg::Build { case BuildPolicy::EMPTY_PACKAGE: return NAME_EMPTY_PACKAGE; case BuildPolicy::DLLS_WITHOUT_LIBS: return NAME_DLLS_WITHOUT_LIBS; + case BuildPolicy::DLLS_WITHOUT_EXPORTS: return NAME_DLLS_WITHOUT_EXPORTS; case BuildPolicy::ONLY_RELEASE_CRT: return NAME_ONLY_RELEASE_CRT; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT; @@ -152,6 +154,7 @@ namespace vcpkg::Build { case BuildPolicy::EMPTY_PACKAGE: return "VCPKG_POLICY_EMPTY_PACKAGE"; case BuildPolicy::DLLS_WITHOUT_LIBS: return "VCPKG_POLICY_DLLS_WITHOUT_LIBS"; + case BuildPolicy::DLLS_WITHOUT_EXPORTS: return "VCPKG_POLICY_DLLS_WITHOUT_EXPORTS"; case BuildPolicy::ONLY_RELEASE_CRT: return "VCPKG_POLICY_ONLY_RELEASE_CRT"; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER"; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT"; diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index a85d879fe..2a13d2786 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -295,8 +295,10 @@ namespace vcpkg::PostBuildLint return LintStatus::SUCCESS; } - static LintStatus check_exports_of_dlls(const std::vector& dlls, const fs::path& dumpbin_exe) + static LintStatus check_exports_of_dlls(const Build::BuildPolicies& policies, const std::vector& dlls, const fs::path& dumpbin_exe) { + if (policies.is_enabled(BuildPolicy::DLLS_WITHOUT_EXPORTS)) return LintStatus::SUCCESS; + std::vector dlls_with_no_exports; for (const fs::path& dll : dlls) { @@ -316,6 +318,10 @@ namespace vcpkg::PostBuildLint System::print2(System::Color::warning, "The following DLLs have no exports:\n"); Files::print_paths(dlls_with_no_exports); System::print2(System::Color::warning, "DLLs without any exports are likely a bug in the build script.\n"); + System::printf(System::Color::warning, + "If this is intended, add the following line in the portfile:\n" + " SET(%s enabled)\n", + to_cmake_variable(BuildPolicy::DLLS_WITHOUT_EXPORTS)); return LintStatus::ERROR_DETECTED; } @@ -809,7 +815,7 @@ namespace vcpkg::PostBuildLint if (!toolset.dumpbin.empty()) { - error_count += check_exports_of_dlls(dlls, toolset.dumpbin); + error_count += check_exports_of_dlls(build_info.policies, dlls, toolset.dumpbin); error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin); error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info, pre_build_info); -- cgit v1.2.3 From 28eee51adb36f2165be846e77ef7b3ee5b3f8789 Mon Sep 17 00:00:00 2001 From: Darrell Date: Mon, 13 Jan 2020 16:57:03 -0800 Subject: Minor edit to help message for cli depend-info option. Fix for #9534. (#9536) --- toolsrc/src/vcpkg/help.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index 0c53536fb..a4908e02e 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -105,7 +105,7 @@ namespace vcpkg::Help " vcpkg create \n" " [archivename] Create a new package\n" " vcpkg owns Search for files in installed packages\n" - " vcpkg depend-info [pkg]... Display a list of dependencies for packages\n" + " vcpkg depend-info ... Display a list of dependencies for packages\n" " vcpkg env Creates a clean shell environment for development or " "compiling.\n" " vcpkg version Display version information\n" -- cgit v1.2.3