aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-05-05 00:26:51 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-05-05 00:26:51 -0700
commitfcb60f72593275a5727c93edc31f0a35d420d069 (patch)
tree4ffb3ccec34ddb347925c2cb874063f274aae61f
parentdc2bdbd4adb27ac81b5e7e91d8275913838bc4a1 (diff)
parente4c5ef656607a1165566b338f5a85f907a627f86 (diff)
downloadvcpkg-fcb60f72593275a5727c93edc31f0a35d420d069.tar.gz
vcpkg-fcb60f72593275a5727c93edc31f0a35d420d069.zip
Merge branch 'master' into KindDragon-snappy
-rw-r--r--ports/pango/0001-fix-static-symbols-export.diff16
-rw-r--r--ports/pango/CMakeLists.txt3
-rw-r--r--ports/pango/CONTROL2
-rw-r--r--scripts/get_triplet_environment.cmake8
-rw-r--r--toolsrc/include/PostBuildLint.h5
-rw-r--r--toolsrc/include/triplet.h2
-rw-r--r--toolsrc/include/vcpkg_Build.h13
-rw-r--r--toolsrc/include/vcpkg_Strings.h6
-rw-r--r--toolsrc/include/vcpkg_System.h14
-rw-r--r--toolsrc/src/PostBuildLint.cpp28
-rw-r--r--toolsrc/src/VcpkgCmdArguments.cpp2
-rw-r--r--toolsrc/src/VcpkgPaths.cpp2
-rw-r--r--toolsrc/src/commands_build.cpp6
-rw-r--r--toolsrc/src/commands_edit.cpp2
-rw-r--r--toolsrc/src/commands_env.cpp3
-rw-r--r--toolsrc/src/commands_export.cpp2
-rw-r--r--toolsrc/src/commands_hash.cpp12
-rw-r--r--toolsrc/src/commands_install.cpp3
-rw-r--r--toolsrc/src/commands_integrate.cpp2
-rw-r--r--toolsrc/src/commands_portsdiff.cpp6
-rw-r--r--toolsrc/src/commands_update.cpp4
-rw-r--r--toolsrc/src/tests_paragraph.cpp4
-rw-r--r--toolsrc/src/triplet.cpp12
-rw-r--r--toolsrc/src/vcpkg.cpp12
-rw-r--r--toolsrc/src/vcpkg_Build.cpp130
-rw-r--r--toolsrc/src/vcpkg_Strings.cpp9
-rw-r--r--toolsrc/src/vcpkg_System.cpp36
-rw-r--r--toolsrc/src/vcpkglib.cpp2
28 files changed, 251 insertions, 95 deletions
diff --git a/ports/pango/0001-fix-static-symbols-export.diff b/ports/pango/0001-fix-static-symbols-export.diff
index c09544f5d..a7ab60901 100644
--- a/ports/pango/0001-fix-static-symbols-export.diff
+++ b/ports/pango/0001-fix-static-symbols-export.diff
@@ -1,21 +1,12 @@
-From 9e7d3a6ea06e1fb661e0aa4b60c6efa9a5684d9d Mon Sep 17 00:00:00 2001
-From: Mikhail Paulyshka <me@mixaill.tk>
-Date: Sat, 29 Apr 2017 21:28:12 +0300
-Subject: [PATCH] do not use dllexport for static build
-
----
- config.h.win32 | 4 ++++
- 1 file changed, 4 insertions(+)
-
diff --git a/config.h.win32 b/config.h.win32
-index 31b330f..e25b5d8 100644
+index 31b330f..e5ed86c 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -147,7 +147,11 @@
/* defines how to decorate public symbols while building */
#ifdef _MSC_VER
-+#ifdef _WINDLL
++#ifdef PANGO_EXPORTS
#define _PANGO_EXTERN __declspec(dllexport) extern
#else
+#define _PANGO_EXTERN extern
@@ -23,6 +14,3 @@ index 31b330f..e25b5d8 100644
+#else
#define _PANGO_EXTERN __attribute__((visibility("default"))) __declspec(dllexport) extern
#endif
---
-2.11.0.windows.1
-
diff --git a/ports/pango/CMakeLists.txt b/ports/pango/CMakeLists.txt
index f6145dc4c..7dad7dbcf 100644
--- a/ports/pango/CMakeLists.txt
+++ b/ports/pango/CMakeLists.txt
@@ -58,7 +58,8 @@ macro(pango_add_module MODULE_NAME)
G_LOG_DOMAIN="Pango" PANGO_ENABLE_BACKEND PANGO_ENABLE_ENGINE
G_DISABLE_SINGLE_INCLUDES SYSCONFDIR="/dummy/etc" LIBDIR="/dummy/lib")
target_compile_definitions(${MODULE_NAME} PRIVATE HAVE_CAIRO_FREETYPE=1)
- set_target_properties(${MODULE_NAME} PROPERTIES
+ set_target_properties(${MODULE_NAME} PROPERTIES
+ DEFINE_SYMBOL PANGO_EXPORTS
OUTPUT_NAME ${MODULE_NAME}-${PANGO_DLL_SUFFIX}
ARCHIVE_OUTPUT_NAME ${MODULE_NAME}-${PANGO_LIB_SUFFIX})
install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
diff --git a/ports/pango/CONTROL b/ports/pango/CONTROL
index 89a742b79..430243537 100644
--- a/ports/pango/CONTROL
+++ b/ports/pango/CONTROL
@@ -1,4 +1,4 @@
Source: pango
-Version: 1.40.5-1
+Version: 1.40.5-2
Description: Text and font handling library.
Build-Depends: glib, gettext, cairo, fontconfig, freetype, harfbuzz
diff --git a/scripts/get_triplet_environment.cmake b/scripts/get_triplet_environment.cmake
new file mode 100644
index 000000000..69e06bf97
--- /dev/null
+++ b/scripts/get_triplet_environment.cmake
@@ -0,0 +1,8 @@
+include(${CMAKE_TRIPLET_FILE})
+
+# GUID used as a flag - "cut here line"
+message("c35112b6-d1ba-415b-aa5d-81de856ef8eb")
+message("VCPKG_TARGET_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}")
+message("VCPKG_CMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}")
+message("VCPKG_CMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}")
+message("VCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}") \ No newline at end of file
diff --git a/toolsrc/include/PostBuildLint.h b/toolsrc/include/PostBuildLint.h
index 0ee47d0c1..69fafc9f7 100644
--- a/toolsrc/include/PostBuildLint.h
+++ b/toolsrc/include/PostBuildLint.h
@@ -5,5 +5,8 @@
namespace vcpkg::PostBuildLint
{
- size_t perform_all_checks(const PackageSpec& spec, const VcpkgPaths& paths, const Build::BuildInfo& build_info);
+ size_t perform_all_checks(const PackageSpec& spec,
+ const VcpkgPaths& paths,
+ const Build::PreBuildInfo& pre_build_info,
+ const Build::BuildInfo& build_info);
}
diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h
index 4d837bc47..e634afd3f 100644
--- a/toolsrc/include/triplet.h
+++ b/toolsrc/include/triplet.h
@@ -15,8 +15,6 @@ namespace vcpkg
static const Triplet ARM_UWP;
const std::string& canonical_name() const;
- std::string architecture() const;
- std::string system() const;
const std::string& to_string() const;
private:
diff --git a/toolsrc/include/vcpkg_Build.h b/toolsrc/include/vcpkg_Build.h
index 28ddb0d16..4deb81900 100644
--- a/toolsrc/include/vcpkg_Build.h
+++ b/toolsrc/include/vcpkg_Build.h
@@ -8,7 +8,6 @@
#include "vcpkg_Files.h"
#include "vcpkg_optional.h"
#include <map>
-#include <string>
#include <unordered_map>
#include <vector>
@@ -33,7 +32,17 @@ namespace vcpkg::Build
std::string create_error_message(const BuildResult build_result, const PackageSpec& spec);
std::string create_user_troubleshooting_message(const PackageSpec& spec);
- std::wstring make_build_env_cmd(const Triplet& triplet, const Toolset& toolset);
+ struct PreBuildInfo
+ {
+ static PreBuildInfo from_triplet_file(const VcpkgPaths& paths, const Triplet& triplet);
+
+ std::string target_architecture;
+ std::string cmake_system_name;
+ std::string cmake_system_version;
+ std::string platform_toolset;
+ };
+
+ std::wstring make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
struct ExtendedBuildResult
{
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h
index 11c8b5a6a..3f8f4562e 100644
--- a/toolsrc/include/vcpkg_Strings.h
+++ b/toolsrc/include/vcpkg_Strings.h
@@ -48,12 +48,14 @@ namespace vcpkg::Strings
return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
}
- std::wstring utf8_to_utf16(const CStringView s);
+ std::wstring to_utf16(const CStringView s);
- std::string utf16_to_utf8(const CWStringView w);
+ std::string to_utf8(const CWStringView w);
std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern);
+ int case_insensitive_ascii_compare(const CStringView left, const CStringView right);
+
std::string ascii_to_lowercase(const std::string& input);
template<class T, class Transformer, class CharType>
diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h
index c8deac38e..71033a642 100644
--- a/toolsrc/include/vcpkg_System.h
+++ b/toolsrc/include/vcpkg_System.h
@@ -61,10 +61,22 @@ namespace vcpkg::System
return println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
}
- Optional<std::wstring> get_environmental_variable(const CWStringView varname) noexcept;
+ Optional<std::wstring> get_environment_variable(const CWStringView varname) noexcept;
Optional<std::wstring> get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename);
+ enum class CPUArchitecture
+ {
+ X86,
+ X64,
+ ARM,
+ ARM64,
+ };
+
+ Optional<CPUArchitecture> to_cpu_architecture(CStringView arch);
+
+ CPUArchitecture get_host_processor();
+
const fs::path& get_ProgramFiles_32_bit();
const fs::path& get_ProgramFiles_platform_bitness();
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp
index 295a8a3b4..294645e82 100644
--- a/toolsrc/src/PostBuildLint.cpp
+++ b/toolsrc/src/PostBuildLint.cpp
@@ -10,6 +10,7 @@
#include "vcpkg_System.h"
#include "vcpkg_Util.h"
+using vcpkg::Build::PreBuildInfo;
using vcpkg::Build::BuildInfo;
namespace vcpkg::PostBuildLint
@@ -297,7 +298,7 @@ namespace vcpkg::PostBuildLint
Checks::check_exit(VCPKG_LINE_INFO,
ec_data.exit_code == 0,
"Running command:\n %s\n failed",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
if (ec_data.output.find("ordinal hint RVA name") == std::string::npos)
{
@@ -320,7 +321,7 @@ namespace vcpkg::PostBuildLint
const std::vector<fs::path>& dlls,
const fs::path dumpbin_exe)
{
- if (expected_system_name != "uwp")
+ if (expected_system_name != "WindowsStore")
{
return LintStatus::SUCCESS;
}
@@ -334,7 +335,7 @@ namespace vcpkg::PostBuildLint
Checks::check_exit(VCPKG_LINE_INFO,
ec_data.exit_code == 0,
"Running command:\n %s\n failed",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
if (ec_data.output.find("App Container") == std::string::npos)
{
@@ -610,7 +611,7 @@ namespace vcpkg::PostBuildLint
Checks::check_exit(VCPKG_LINE_INFO,
ec_data.exit_code == 0,
"Running command:\n %s\n failed",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
for (const BuildType& bad_build_type : bad_build_types)
{
@@ -664,7 +665,7 @@ namespace vcpkg::PostBuildLint
Checks::check_exit(VCPKG_LINE_INFO,
ec_data.exit_code == 0,
"Running command:\n %s\n failed",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
for (const OutdatedDynamicCrt& outdated_crt : outdated_crts)
{
@@ -699,7 +700,8 @@ namespace vcpkg::PostBuildLint
std::vector<fs::path> misplaced_files = fs.get_files_non_recursive(dir);
Util::unstable_keep_if(misplaced_files, [&fs](const fs::path& path) {
const std::string filename = path.filename().generic_string();
- if (_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0)
+ if (Strings::case_insensitive_ascii_compare(filename.c_str(), "CONTROL") == 0 ||
+ Strings::case_insensitive_ascii_compare(filename.c_str(), "BUILD_INFO") == 0)
return false;
return !fs.is_directory(path);
});
@@ -719,6 +721,7 @@ namespace vcpkg::PostBuildLint
static size_t perform_all_checks_and_return_error_count(const PackageSpec& spec,
const VcpkgPaths& paths,
+ const PreBuildInfo& pre_build_info,
const BuildInfo& build_info)
{
const auto& fs = paths.get_filesystem();
@@ -763,7 +766,7 @@ namespace vcpkg::PostBuildLint
libs.insert(libs.cend(), debug_libs.cbegin(), debug_libs.cend());
libs.insert(libs.cend(), release_libs.cbegin(), release_libs.cend());
- error_count += check_lib_architecture(spec.triplet().architecture(), libs);
+ error_count += check_lib_architecture(pre_build_info.target_architecture, libs);
}
switch (build_info.library_linkage)
@@ -787,8 +790,8 @@ namespace vcpkg::PostBuildLint
dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend());
error_count += check_exports_of_dlls(dlls, toolset.dumpbin);
- error_count += check_uwp_bit_of_dlls(spec.triplet().system(), dlls, toolset.dumpbin);
- error_count += check_dll_architecture(spec.triplet().architecture(), dlls);
+ error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin);
+ error_count += check_dll_architecture(pre_build_info.target_architecture, dlls);
error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin);
break;
@@ -825,10 +828,13 @@ namespace vcpkg::PostBuildLint
return error_count;
}
- size_t perform_all_checks(const PackageSpec& spec, const VcpkgPaths& paths, const BuildInfo& build_info)
+ size_t perform_all_checks(const PackageSpec& spec,
+ const VcpkgPaths& paths,
+ const PreBuildInfo& pre_build_info,
+ const BuildInfo& build_info)
{
System::println("-- Performing post-build validation");
- const size_t error_count = perform_all_checks_and_return_error_count(spec, paths, build_info);
+ const size_t error_count = perform_all_checks_and_return_error_count(spec, paths, pre_build_info, build_info);
if (error_count != 0)
{
diff --git a/toolsrc/src/VcpkgCmdArguments.cpp b/toolsrc/src/VcpkgCmdArguments.cpp
index 25f4c5582..733308cb0 100644
--- a/toolsrc/src/VcpkgCmdArguments.cpp
+++ b/toolsrc/src/VcpkgCmdArguments.cpp
@@ -48,7 +48,7 @@ namespace vcpkg
std::vector<std::string> v;
for (int i = 1; i < argc; ++i)
{
- v.push_back(Strings::utf16_to_utf8(argv[i]));
+ v.push_back(Strings::to_utf8(argv[i]));
}
return VcpkgCmdArguments::create_from_arg_sequence(v.data(), v.data() + v.size());
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp
index 008827c62..eabdcd410 100644
--- a/toolsrc/src/VcpkgPaths.cpp
+++ b/toolsrc/src/VcpkgPaths.cpp
@@ -256,7 +256,7 @@ namespace vcpkg
static Optional<fs::path> get_VS2015_installation_instance()
{
- const Optional<std::wstring> vs2015_cmntools_optional = System::get_environmental_variable(L"VS140COMNTOOLS");
+ const Optional<std::wstring> vs2015_cmntools_optional = System::get_environment_variable(L"VS140COMNTOOLS");
if (auto v = vs2015_cmntools_optional.get())
{
const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index fe84f4b13..ec6586fa3 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -3,14 +3,11 @@
#include "Paragraphs.h"
#include "PostBuildLint.h"
#include "StatusParagraphs.h"
-#include "metrics.h"
-#include "vcpkg_Chrono.h"
#include "vcpkg_Commands.h"
#include "vcpkg_Dependencies.h"
#include "vcpkg_Enums.h"
#include "vcpkg_Input.h"
#include "vcpkg_System.h"
-#include "vcpkg_Util.h"
#include "vcpkglib.h"
using vcpkg::Build::BuildResult;
@@ -29,8 +26,9 @@ namespace vcpkg::Commands::BuildCommand
{
if (options.find(OPTION_CHECKS_ONLY) != options.end())
{
+ auto pre_build_info = Build::PreBuildInfo::from_triplet_file(paths, spec.triplet());
auto build_info = Build::read_build_info(paths.get_filesystem(), paths.build_info_file_path(spec));
- const size_t error_count = PostBuildLint::perform_all_checks(spec, paths, build_info);
+ const size_t error_count = PostBuildLint::perform_all_checks(spec, paths, pre_build_info, build_info);
Checks::check_exit(VCPKG_LINE_INFO, error_count == 0);
Checks::exit_success(VCPKG_LINE_INFO);
}
diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp
index bd23489ff..4e83fcca8 100644
--- a/toolsrc/src/commands_edit.cpp
+++ b/toolsrc/src/commands_edit.cpp
@@ -23,7 +23,7 @@ namespace vcpkg::Commands::Edit
if (env_EDITOR.empty())
{
- const Optional<std::wstring> env_EDITOR_optional = System::get_environmental_variable(L"EDITOR");
+ const Optional<std::wstring> env_EDITOR_optional = System::get_environment_variable(L"EDITOR");
if (auto e = env_EDITOR_optional.get())
{
env_EDITOR = *e;
diff --git a/toolsrc/src/commands_env.cpp b/toolsrc/src/commands_env.cpp
index 017d3c8f7..5e1ecc5e7 100644
--- a/toolsrc/src/commands_env.cpp
+++ b/toolsrc/src/commands_env.cpp
@@ -12,7 +12,8 @@ namespace vcpkg::Commands::Env
args.check_exact_arg_count(0, example);
args.check_and_get_optional_command_arguments({});
- System::cmd_execute_clean(Build::make_build_env_cmd(default_triplet, paths.get_toolset()) + L" && cmd");
+ auto pre_build_info = Build::PreBuildInfo::from_triplet_file(paths, default_triplet);
+ System::cmd_execute_clean(Build::make_build_env_cmd(pre_build_info, paths.get_toolset()) + L" && cmd");
Checks::exit_success(VCPKG_LINE_INFO);
}
diff --git a/toolsrc/src/commands_export.cpp b/toolsrc/src/commands_export.cpp
index 98bf00777..e46001b06 100644
--- a/toolsrc/src/commands_export.cpp
+++ b/toolsrc/src/commands_export.cpp
@@ -334,7 +334,7 @@ namespace vcpkg::Commands::Export
"\n"
" %s"
"\n",
- Strings::utf16_to_utf8(cmake_variable.s));
+ Strings::to_utf8(cmake_variable.s));
};
if (raw)
diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp
index 349c0e58f..0da2b031f 100644
--- a/toolsrc/src/commands_hash.cpp
+++ b/toolsrc/src/commands_hash.cpp
@@ -10,10 +10,8 @@ namespace vcpkg::Commands::Hash
{
auto cmd_line = Strings::wformat(LR"(CertUtil.exe -hashfile "%s" %s)", path.c_str(), hashType);
auto ec_data = System::cmd_execute_and_capture_output(cmd_line);
- Checks::check_exit(VCPKG_LINE_INFO,
- ec_data.exit_code == 0,
- "Running command:\n %s\n failed",
- Strings::utf16_to_utf8(cmd_line));
+ Checks::check_exit(
+ VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::to_utf8(cmd_line));
std::string const& output = ec_data.output;
@@ -21,13 +19,13 @@ namespace vcpkg::Commands::Hash
Checks::check_exit(VCPKG_LINE_INFO,
start != std::string::npos,
"Unexpected output format from command: %s",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
auto end = output.find_first_of("\r\n", start + 1);
Checks::check_exit(VCPKG_LINE_INFO,
end != std::string::npos,
"Unexpected output format from command: %s",
- Strings::utf16_to_utf8(cmd_line));
+ Strings::to_utf8(cmd_line));
auto hash = output.substr(start, end - start);
Util::erase_remove_if(hash, isspace);
@@ -49,7 +47,7 @@ namespace vcpkg::Commands::Hash
}
if (args.command_arguments.size() == 2)
{
- do_file_hash(args.command_arguments[0], Strings::utf8_to_utf16(args.command_arguments[1]));
+ do_file_hash(args.command_arguments[0], Strings::to_utf16(args.command_arguments[1]));
}
Checks::exit_success(VCPKG_LINE_INFO);
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index 2260b067e..bebe6a3a2 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -69,7 +69,8 @@ namespace vcpkg::Commands::Install
const std::string filename = file.filename().generic_string();
if (fs::is_regular_file(status) &&
- (_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0))
+ (Strings::case_insensitive_ascii_compare(filename.c_str(), "CONTROL") == 0 ||
+ Strings::case_insensitive_ascii_compare(filename.c_str(), "BUILD_INFO") == 0))
{
// Do not copy the control file
continue;
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp
index 89f18c664..c5942f9fc 100644
--- a/toolsrc/src/commands_integrate.cpp
+++ b/toolsrc/src/commands_integrate.cpp
@@ -141,7 +141,7 @@ namespace vcpkg::Commands::Integrate
static fs::path get_appdata_targets_path()
{
static const fs::path local_app_data =
- fs::path(System::get_environmental_variable(L"LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO));
+ fs::path(System::get_environment_variable(L"LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO));
return local_app_data / "vcpkg" / "vcpkg.user.targets";
}
diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp
index 996d41f92..a614d654e 100644
--- a/toolsrc/src/commands_portsdiff.cpp
+++ b/toolsrc/src/commands_portsdiff.cpp
@@ -114,7 +114,7 @@ namespace vcpkg::Commands::PortsDiff
Checks::check_exit(VCPKG_LINE_INFO,
output.output == VALID_COMMIT_OUTPUT,
"Invalid commit id %s",
- Strings::utf16_to_utf8(git_commit_id));
+ Strings::to_utf8(git_commit_id));
}
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
@@ -128,9 +128,9 @@ namespace vcpkg::Commands::PortsDiff
const fs::path& git_exe = paths.get_git_exe();
- const std::wstring git_commit_id_for_previous_snapshot = Strings::utf8_to_utf16(args.command_arguments.at(0));
+ const std::wstring git_commit_id_for_previous_snapshot = Strings::to_utf16(args.command_arguments.at(0));
const std::wstring git_commit_id_for_current_snapshot =
- args.command_arguments.size() < 2 ? L"HEAD" : Strings::utf8_to_utf16(args.command_arguments.at(1));
+ args.command_arguments.size() < 2 ? L"HEAD" : Strings::to_utf16(args.command_arguments.at(1));
check_commit_exists(git_exe, git_commit_id_for_current_snapshot);
check_commit_exists(git_exe, git_commit_id_for_previous_snapshot);
diff --git a/toolsrc/src/commands_update.cpp b/toolsrc/src/commands_update.cpp
index 1873c280c..e39c7dd35 100644
--- a/toolsrc/src/commands_update.cpp
+++ b/toolsrc/src/commands_update.cpp
@@ -63,8 +63,8 @@ namespace vcpkg::Commands::Update
}
System::println("\n"
"To update these packages, run\n"
- " vcpkg remove --outdated\n"
- " vcpkg install <pkgs>...");
+ " .\\vcpkg remove --outdated\n"
+ " .\\vcpkg install <pkgs>...");
}
auto version_file = paths.get_filesystem().read_contents(paths.root / "toolsrc" / "VERSION.txt");
diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp
index de7a6d190..b66adc816 100644
--- a/toolsrc/src/tests_paragraph.cpp
+++ b/toolsrc/src/tests_paragraph.cpp
@@ -353,13 +353,13 @@ namespace UnitTest1
TEST_METHOD(utf8_to_utf16)
{
- auto str = vcpkg::Strings::utf8_to_utf16("abc");
+ auto str = vcpkg::Strings::to_utf16("abc");
Assert::AreEqual(L"abc", str.c_str());
}
TEST_METHOD(utf8_to_utf16_with_whitespace)
{
- auto str = vcpkg::Strings::utf8_to_utf16("abc -x86-windows");
+ auto str = vcpkg::Strings::to_utf16("abc -x86-windows");
Assert::AreEqual(L"abc -x86-windows", str.c_str());
}
};
diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp
index 411c6c28a..ff41ce77d 100644
--- a/toolsrc/src/triplet.cpp
+++ b/toolsrc/src/triplet.cpp
@@ -32,17 +32,5 @@ namespace vcpkg
const std::string& Triplet::canonical_name() const { return this->m_canonical_name; }
- std::string Triplet::architecture() const
- {
- auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
- return std::string(this->m_canonical_name.cbegin(), it);
- }
-
- std::string Triplet::system() const
- {
- auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
- return std::string(it + 1, this->m_canonical_name.cend());
- }
-
const std::string& Triplet::to_string() const { return this->m_canonical_name; }
}
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index d24fad0e6..154aefd0a 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -41,11 +41,11 @@ static void inner(const VcpkgCmdArguments& args)
fs::path vcpkg_root_dir;
if (args.vcpkg_root_dir != nullptr)
{
- vcpkg_root_dir = fs::stdfs::absolute(Strings::utf8_to_utf16(*args.vcpkg_root_dir));
+ vcpkg_root_dir = fs::stdfs::absolute(Strings::to_utf16(*args.vcpkg_root_dir));
}
else
{
- const Optional<std::wstring> vcpkg_root_dir_env = System::get_environmental_variable(L"VCPKG_ROOT");
+ const Optional<std::wstring> vcpkg_root_dir_env = System::get_environment_variable(L"VCPKG_ROOT");
if (auto v = vcpkg_root_dir_env.get())
{
vcpkg_root_dir = fs::stdfs::absolute(*v);
@@ -82,10 +82,10 @@ static void inner(const VcpkgCmdArguments& args)
else
{
const Optional<std::wstring> vcpkg_default_triplet_env =
- System::get_environmental_variable(L"VCPKG_DEFAULT_TRIPLET");
+ System::get_environment_variable(L"VCPKG_DEFAULT_TRIPLET");
if (auto v = vcpkg_default_triplet_env.get())
{
- default_triplet = Triplet::from_canonical_name(Strings::utf16_to_utf8(*v));
+ default_triplet = Triplet::from_canonical_name(Strings::to_utf8(*v));
}
else
{
@@ -200,7 +200,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
Metrics::track_property("version", Commands::Version::version());
- const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW()));
+ const std::string trimmed_command_line = trim_path_from_command_line(Strings::to_utf8(GetCommandLineW()));
Metrics::track_property("cmdline", trimmed_command_line);
loadConfig();
Metrics::track_property("sqmuser", Metrics::get_SQM_user());
@@ -247,6 +247,6 @@ int wmain(const int argc, const wchar_t* const* const argv)
exc_msg);
fflush(stdout);
for (int x = 0; x < argc; ++x)
- System::println("%s|", Strings::utf16_to_utf8(argv[x]));
+ System::println("%s|", Strings::to_utf8(argv[x]));
fflush(stdout);
}
diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp
index c29f61468..ccc0ff95e 100644
--- a/toolsrc/src/vcpkg_Build.cpp
+++ b/toolsrc/src/vcpkg_Build.cpp
@@ -26,7 +26,54 @@ namespace vcpkg::Build
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
}
- std::wstring make_build_env_cmd(const Triplet& triplet, const Toolset& toolset)
+ CWStringView to_vcvarsall_target(const std::string& cmake_system_name)
+ {
+ if (cmake_system_name == "") return L"";
+ if (cmake_system_name == "Windows") return L"";
+ if (cmake_system_name == "WindowsStore") return L"store";
+
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
+ }
+
+ CWStringView to_vcvarsall_toolchain(const std::string& target_architecture)
+ {
+ using CPU = System::CPUArchitecture;
+
+ struct ArchOption
+ {
+ CWStringView name;
+ CPU host_arch;
+ CPU target_arch;
+ };
+
+ static constexpr ArchOption X86 = {L"x86", CPU::X86, CPU::X86};
+ static constexpr ArchOption X86_X64 = {L"x86_x64", CPU::X86, CPU::X64};
+ static constexpr ArchOption X86_ARM = {L"x86_arm", CPU::X86, CPU::ARM};
+ static constexpr ArchOption X86_ARM64 = {L"x86_arm64", CPU::X86, CPU::ARM64};
+
+ static constexpr ArchOption X64 = {L"x64", CPU::X64, CPU::X64};
+ static constexpr ArchOption X64_X86 = {L"x64_x86", CPU::X64, CPU::X86};
+ static constexpr ArchOption X64_ARM = {L"x64_arm", CPU::X64, CPU::ARM};
+ static constexpr ArchOption X64_ARM64 = {L"x64_arm64", CPU::X64, CPU::ARM64};
+
+ static constexpr std::array<ArchOption, 8> VALUES = {
+ X86, X86_X64, X86_ARM, X86_ARM64, X64, X64_X86, X64_ARM, X64_ARM64};
+
+ auto target_arch = System::to_cpu_architecture(target_architecture);
+ auto host_arch = System::get_host_processor();
+
+ for (auto&& value : VALUES)
+ {
+ if (target_arch == value.target_arch && host_arch == value.host_arch)
+ {
+ return value.name;
+ }
+ }
+
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported toolchain combination %s", target_architecture);
+ }
+
+ std::wstring make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset)
{
const wchar_t* tonull = L" >nul";
if (g_debugging)
@@ -34,8 +81,10 @@ namespace vcpkg::Build
tonull = L"";
}
- return Strings::wformat(
- LR"("%s" %s %s 2>&1)", toolset.vcvarsall.native(), Strings::utf8_to_utf16(triplet.architecture()), tonull);
+ auto arch = to_vcvarsall_toolchain(pre_build_info.target_architecture);
+ auto target = to_vcvarsall_target(pre_build_info.cmake_system_name);
+
+ return Strings::wformat(LR"("%s" %s %s %s 2>&1)", toolset.vcvarsall.native(), arch, target, tonull);
}
static void create_binary_control_file(const VcpkgPaths& paths,
@@ -82,7 +131,8 @@ namespace vcpkg::Build
const fs::path ports_cmake_script_path = paths.ports_cmake;
const Toolset& toolset = paths.get_toolset();
- const auto cmd_set_environment = make_build_env_cmd(triplet, toolset);
+ auto pre_build_info = PreBuildInfo::from_triplet_file(paths, triplet);
+ const auto cmd_set_environment = make_build_env_cmd(pre_build_info, toolset);
const std::wstring cmd_launch_cmake =
make_cmake_cmd(cmake_exe_path,
@@ -113,7 +163,7 @@ namespace vcpkg::Build
}
auto build_info = read_build_info(paths.get_filesystem(), paths.build_info_file_path(spec));
- const size_t error_count = PostBuildLint::perform_all_checks(spec, paths, build_info);
+ const size_t error_count = PostBuildLint::perform_all_checks(spec, paths, pre_build_info, build_info);
if (error_count != 0)
{
@@ -214,4 +264,74 @@ namespace vcpkg::Build
Checks::check_exit(VCPKG_LINE_INFO, pghs.get() != nullptr, "Invalid BUILD_INFO file for package");
return BuildInfo::create(*pghs.get());
}
+
+ PreBuildInfo PreBuildInfo::from_triplet_file(const VcpkgPaths& paths, const Triplet& triplet)
+ {
+ static constexpr CStringView FLAG_GUID = "c35112b6-d1ba-415b-aa5d-81de856ef8eb";
+
+ const fs::path& cmake_exe_path = paths.get_cmake_exe();
+ const fs::path ports_cmake_script_path = paths.scripts / "get_triplet_environment.cmake";
+ const fs::path triplet_file_path = paths.triplets / (triplet.canonical_name() + ".cmake");
+
+ const std::wstring cmd_launch_cmake = make_cmake_cmd(cmake_exe_path,
+ ports_cmake_script_path,
+ {
+ {L"CMAKE_TRIPLET_FILE", triplet_file_path},
+ });
+
+ const std::wstring command = Strings::wformat(LR"(%s)", cmd_launch_cmake);
+ auto ec_data = System::cmd_execute_and_capture_output(command);
+ Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0);
+
+ const std::vector<std::string> lines = Strings::split(ec_data.output, "\n");
+
+ PreBuildInfo pre_build_info;
+
+ auto e = lines.cend();
+ auto cur = std::find(lines.cbegin(), e, FLAG_GUID);
+ if (cur != e) ++cur;
+
+ for (; cur != e; ++cur)
+ {
+ auto&& line = *cur;
+
+ const std::vector<std::string> s = Strings::split(line, "=");
+ Checks::check_exit(VCPKG_LINE_INFO,
+ s.size() == 1 || s.size() == 2,
+ "Expected format is [VARIABLE_NAME=VARIABLE_VALUE], but was [%s]",
+ line);
+
+ const bool variable_with_no_value = s.size() == 1;
+ const std::string variable_name = s.at(0);
+ const std::string variable_value = variable_with_no_value ? "" : s.at(1);
+
+ if (variable_name == "VCPKG_TARGET_ARCHITECTURE")
+ {
+ pre_build_info.target_architecture = variable_value;
+ continue;
+ }
+
+ if (variable_name == "VCPKG_CMAKE_SYSTEM_NAME")
+ {
+ pre_build_info.cmake_system_name = variable_value;
+ continue;
+ }
+
+ if (variable_name == "VCPKG_CMAKE_SYSTEM_VERSION")
+ {
+ pre_build_info.cmake_system_version = variable_value;
+ continue;
+ }
+
+ if (variable_name == "VCPKG_PLATFORM_TOOLSET")
+ {
+ pre_build_info.platform_toolset = variable_value;
+ continue;
+ }
+
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown variable name %s", line);
+ }
+
+ return pre_build_info;
+ }
}
diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp
index 97f56e746..9ba9eb700 100644
--- a/toolsrc/src/vcpkg_Strings.cpp
+++ b/toolsrc/src/vcpkg_Strings.cpp
@@ -46,13 +46,13 @@ namespace vcpkg::Strings::details
namespace vcpkg::Strings
{
- std::wstring utf8_to_utf16(const CStringView s)
+ std::wstring to_utf16(const CStringView s)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> conversion;
return conversion.from_bytes(s);
}
- std::string utf16_to_utf8(const CWStringView w)
+ std::string to_utf8(const CWStringView w)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> conversion;
return conversion.to_bytes(w);
@@ -68,6 +68,11 @@ namespace vcpkg::Strings
[](const char a, const char b) { return details::tolower_char(a) == b; });
}
+ int case_insensitive_ascii_compare(const CStringView left, const CStringView right)
+ {
+ return _stricmp(left, right);
+ }
+
std::string ascii_to_lowercase(const std::string& input)
{
std::string output(input);
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp
index abbed587c..00f4a091b 100644
--- a/toolsrc/src/vcpkg_System.cpp
+++ b/toolsrc/src/vcpkg_System.cpp
@@ -23,10 +23,28 @@ namespace vcpkg::System
return fs::path(buf, buf + bytes);
}
+ Optional<CPUArchitecture> to_cpu_architecture(CStringView arch)
+ {
+ if (Strings::case_insensitive_ascii_compare(arch, "x86") == 0) return CPUArchitecture::X86;
+ if (Strings::case_insensitive_ascii_compare(arch, "x64") == 0) return CPUArchitecture::X64;
+ if (Strings::case_insensitive_ascii_compare(arch, "amd64") == 0) return CPUArchitecture::X64;
+ if (Strings::case_insensitive_ascii_compare(arch, "arm") == 0) return CPUArchitecture::ARM;
+ if (Strings::case_insensitive_ascii_compare(arch, "arm64") == 0) return CPUArchitecture::ARM64;
+ return nullopt;
+ }
+
+ CPUArchitecture get_host_processor()
+ {
+ auto w6432 = get_environment_variable(L"PROCESSOR_ARCHITEW6432");
+ if (auto p = w6432.get()) return to_cpu_architecture(Strings::to_utf8(*p)).value_or_exit(VCPKG_LINE_INFO);
+
+ auto procarch = get_environment_variable(L"PROCESSOR_ARCHITECTURE").value_or_exit(VCPKG_LINE_INFO);
+ return to_cpu_architecture(Strings::to_utf8(procarch)).value_or_exit(VCPKG_LINE_INFO);
+ }
+
int cmd_execute_clean(const CWStringView cmd_line)
{
- static const std::wstring system_root =
- get_environmental_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO);
+ static const std::wstring system_root = get_environment_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO);
static const std::wstring system_32 = system_root + LR"(\system32)";
static const std::wstring new_PATH = Strings::wformat(
LR"(Path=%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", system_32, system_root, system_32, system_32);
@@ -83,7 +101,7 @@ namespace vcpkg::System
for (auto&& env_wstring : env_wstrings)
{
- const Optional<std::wstring> value = System::get_environmental_variable(env_wstring);
+ const Optional<std::wstring> value = System::get_environment_variable(env_wstring);
auto v = value.get();
if (!v || v->empty()) continue;
@@ -97,7 +115,7 @@ namespace vcpkg::System
// Basically we are wrapping it in quotes
const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
- if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::utf16_to_utf8(actual_cmd_line));
+ if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::to_utf8(actual_cmd_line));
auto exit_code =
_wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data());
if (g_debugging) System::println("[DEBUG] _wspawnlpe() returned %d", exit_code);
@@ -111,7 +129,7 @@ namespace vcpkg::System
// Basically we are wrapping it in quotes
const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
- if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::utf16_to_utf8(actual_cmd_line));
+ if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::to_utf8(actual_cmd_line));
int exit_code = _wsystem(actual_cmd_line.c_str());
if (g_debugging) System::println("[DEBUG] _wsystem() returned %d", exit_code);
return exit_code;
@@ -177,7 +195,7 @@ namespace vcpkg::System
putchar('\n');
}
- Optional<std::wstring> get_environmental_variable(const CWStringView varname) noexcept
+ Optional<std::wstring> get_environment_variable(const CWStringView varname) noexcept
{
auto sz = GetEnvironmentVariableW(varname, nullptr, 0);
if (sz == 0) return nullopt;
@@ -221,14 +239,14 @@ namespace vcpkg::System
static const fs::path& get_ProgramFiles()
{
- static const fs::path p = System::get_environmental_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO);
+ static const fs::path p = System::get_environment_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO);
return p;
}
const fs::path& get_ProgramFiles_32_bit()
{
static const fs::path p = []() -> fs::path {
- auto value = System::get_environmental_variable(L"ProgramFiles(x86)");
+ auto value = System::get_environment_variable(L"ProgramFiles(x86)");
if (auto v = value.get())
{
return std::move(*v);
@@ -241,7 +259,7 @@ namespace vcpkg::System
const fs::path& get_ProgramFiles_platform_bitness()
{
static const fs::path p = []() -> fs::path {
- auto value = System::get_environmental_variable(L"ProgramW6432");
+ auto value = System::get_environment_variable(L"ProgramW6432");
if (auto v = value.get())
{
return std::move(*v);
diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp
index 001ce839e..15130f77e 100644
--- a/toolsrc/src/vcpkglib.cpp
+++ b/toolsrc/src/vcpkglib.cpp
@@ -219,7 +219,7 @@ namespace vcpkg
{
}
CMakeVariable::CMakeVariable(const CWStringView varname, const std::string& varvalue)
- : CMakeVariable(varname, Strings::utf8_to_utf16(varvalue).c_str())
+ : CMakeVariable(varname, Strings::to_utf16(varvalue).c_str())
{
}
CMakeVariable::CMakeVariable(const CWStringView varname, const std::wstring& varvalue)