mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 14:29:06 +08:00
Merge branch 'master' of https://github.com/microsoft/vcpkg
This commit is contained in:
commit
17786b865a
@ -21,20 +21,20 @@ if(NOT VCPKG_TOOLCHAIN)
|
||||
set(_VCPKG_TARGET_TRIPLET_PLAT windows)
|
||||
endif()
|
||||
|
||||
set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT})
|
||||
set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)")
|
||||
set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed)
|
||||
set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}/debug
|
||||
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug
|
||||
)
|
||||
endif()
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}
|
||||
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
|
||||
)
|
||||
|
||||
include_directories(${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}/include)
|
||||
include_directories(${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include)
|
||||
|
||||
option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON)
|
||||
if(OVERRIDE_ADD_EXECUTABLE)
|
||||
@ -43,7 +43,7 @@ if(NOT VCPKG_TOOLCHAIN)
|
||||
add_custom_command(TARGET ${name} POST_BUILD
|
||||
COMMAND powershell -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1
|
||||
-targetBinary $<TARGET_FILE:${name}>
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${_VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
||||
-OutVariable out
|
||||
)
|
||||
endfunction()
|
||||
|
@ -16,11 +16,11 @@ set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
|
||||
string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET})
|
||||
string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET})
|
||||
|
||||
if(NOT EXISTS ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
|
||||
message(FATAL_ERROR "Unsupported target triplet. Toolchain file does not exist: ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake")
|
||||
set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
|
||||
if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
|
||||
message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
|
||||
list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake)
|
||||
set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
|
||||
set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct vcpkg_paths;
|
||||
|
||||
struct triplet
|
||||
{
|
||||
static const triplet X86_WINDOWS;
|
||||
@ -19,8 +17,6 @@ namespace vcpkg
|
||||
std::string architecture() const;
|
||||
|
||||
std::string system() const;
|
||||
|
||||
bool validate(const vcpkg_paths& paths) const;
|
||||
};
|
||||
|
||||
bool operator==(const triplet& left, const triplet& right);
|
||||
|
@ -31,7 +31,7 @@ namespace vcpkg {namespace Strings {namespace details
|
||||
return s;
|
||||
}
|
||||
|
||||
std::wstring format_internal(const wchar_t* fmtstr, ...);
|
||||
std::wstring wformat_internal(const wchar_t* fmtstr, ...);
|
||||
}}}
|
||||
|
||||
namespace vcpkg {namespace Strings
|
||||
@ -44,10 +44,10 @@ namespace vcpkg {namespace Strings
|
||||
}
|
||||
|
||||
template <class...Args>
|
||||
std::wstring format(const wchar_t* fmtstr, const Args&...args)
|
||||
std::wstring wformat(const wchar_t* fmtstr, const Args&...args)
|
||||
{
|
||||
using vcpkg::Strings::details::to_wprintf_arg;
|
||||
return details::format_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
|
||||
return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...);
|
||||
}
|
||||
|
||||
std::wstring utf8_to_utf16(const std::string& s);
|
||||
|
@ -13,6 +13,7 @@ namespace vcpkg
|
||||
|
||||
fs::path package_dir(const package_spec& spec) const;
|
||||
fs::path port_dir(const package_spec& spec) const;
|
||||
bool is_valid_triplet(const triplet& t) const;
|
||||
|
||||
std::tr2::sys::path root;
|
||||
std::tr2::sys::path packages;
|
||||
|
@ -28,10 +28,10 @@ namespace vcpkg
|
||||
Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name),
|
||||
R"(Filename cannot contain invalid chars %s, but was %s)",
|
||||
Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name);
|
||||
custom_filename = Strings::format(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
|
||||
custom_filename = Strings::wformat(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
|
||||
}
|
||||
|
||||
const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
|
||||
const std::wstring cmdline = Strings::wformat(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
|
||||
Strings::utf8_to_utf16(spec->name),
|
||||
Strings::utf8_to_utf16(spec->target_triplet.value),
|
||||
Strings::utf8_to_utf16(args.command_arguments.at(1)),
|
||||
|
@ -15,7 +15,7 @@ namespace vcpkg
|
||||
env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)";
|
||||
|
||||
auto portpath = paths.ports / spec.name;
|
||||
std::wstring cmdLine = Strings::format(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
|
||||
std::wstring cmdLine = Strings::wformat(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
|
||||
exit(System::cmd_execute(cmdLine));
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace vcpkg
|
||||
static void build_internal(const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
|
||||
{
|
||||
const fs::path ports_cmake_script_path = paths.ports_cmake;
|
||||
const std::wstring command = Strings::format(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
|
||||
const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
|
||||
Strings::utf8_to_utf16(spec.target_triplet.architecture()),
|
||||
Strings::utf8_to_utf16(spec.name),
|
||||
Strings::utf8_to_utf16(spec.target_triplet.value),
|
||||
|
@ -238,7 +238,7 @@ namespace vcpkg
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
const std::wstring cmd_line = Strings::format(LR"(DEL "%s")", get_appdata_targets_path().native());
|
||||
const std::wstring cmd_line = Strings::wformat(LR"(DEL "%s")", get_appdata_targets_path().native());
|
||||
const int exit_code = System::cmd_execute(cmd_line);
|
||||
if (exit_code)
|
||||
{
|
||||
@ -269,7 +269,7 @@ namespace vcpkg
|
||||
std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version);
|
||||
|
||||
// Using all forward slashes for the command line
|
||||
const std::wstring cmd_line = Strings::format(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native());
|
||||
const std::wstring cmd_line = Strings::wformat(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native());
|
||||
|
||||
const int exit_code = System::cmd_execute(cmd_line);
|
||||
|
||||
|
@ -70,14 +70,14 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
}
|
||||
|
||||
triplet default_target_triplet;
|
||||
if(args.target_triplet != nullptr)
|
||||
if (args.target_triplet != nullptr)
|
||||
{
|
||||
default_target_triplet = {*args.target_triplet};
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET");
|
||||
if(!vcpkg_default_triplet_env.empty())
|
||||
if (!vcpkg_default_triplet_env.empty())
|
||||
{
|
||||
default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)};
|
||||
}
|
||||
@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
}
|
||||
}
|
||||
|
||||
if(!default_target_triplet.validate(paths))
|
||||
if (!paths.is_valid_triplet(default_target_triplet))
|
||||
{
|
||||
System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value);
|
||||
TrackProperty("error", "invalid triplet: " + default_target_triplet.value);
|
||||
|
@ -419,7 +419,7 @@ true
|
||||
const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt");
|
||||
std::ofstream(vcpkg_metrics_txt_path) << payload;
|
||||
|
||||
const std::wstring cmdLine = Strings::format(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native());
|
||||
const std::wstring cmdLine = Strings::wformat(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native());
|
||||
System::cmd_execute(cmdLine);
|
||||
}
|
||||
}
|
||||
|
@ -71,12 +71,10 @@ namespace vcpkg
|
||||
System::println(System::color::warning, "Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use\n"
|
||||
" file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)"
|
||||
);
|
||||
return
|
||||
lint_status::ERROR;
|
||||
return lint_status::ERROR;
|
||||
}
|
||||
|
||||
return
|
||||
lint_status::SUCCESS;
|
||||
return lint_status::SUCCESS;
|
||||
}
|
||||
|
||||
static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths)
|
||||
@ -221,7 +219,7 @@ namespace vcpkg
|
||||
std::vector<fs::path> dlls_with_no_exports;
|
||||
for (const fs::path& dll : dlls)
|
||||
{
|
||||
const std::wstring cmd_line = Strings::format(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native());
|
||||
const std::wstring cmd_line = Strings::wformat(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native());
|
||||
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
|
||||
|
||||
@ -252,7 +250,7 @@ namespace vcpkg
|
||||
std::vector<fs::path> dlls_with_improper_uwp_bit;
|
||||
for (const fs::path& dll : dlls)
|
||||
{
|
||||
const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native());
|
||||
const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native());
|
||||
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
|
||||
|
||||
@ -284,7 +282,7 @@ namespace vcpkg
|
||||
std::vector<file_and_arch> binaries_with_invalid_architecture;
|
||||
for (const fs::path& f : files)
|
||||
{
|
||||
const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
|
||||
const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
|
||||
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
|
||||
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "triplet.h"
|
||||
#include "vcpkg.h"
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
|
||||
namespace vcpkg
|
||||
@ -38,38 +36,15 @@ namespace vcpkg
|
||||
|
||||
std::string triplet::architecture() const
|
||||
{
|
||||
if (*this == X86_WINDOWS || *this == X86_UWP)
|
||||
return "x86";
|
||||
if (*this == X64_WINDOWS || *this == X64_UWP)
|
||||
return "x64";
|
||||
if (*this == ARM_UWP)
|
||||
return "arm";
|
||||
|
||||
Checks::exit_with_message("Unknown architecture: %s", value);
|
||||
auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
|
||||
Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
|
||||
return std::string(this->value.cbegin(), it);
|
||||
}
|
||||
|
||||
std::string triplet::system() const
|
||||
{
|
||||
if (*this == X86_WINDOWS || *this == X64_WINDOWS)
|
||||
return "windows";
|
||||
if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP)
|
||||
return "uwp";
|
||||
|
||||
Checks::exit_with_message("Unknown system: %s", value);
|
||||
}
|
||||
|
||||
bool triplet::validate(const vcpkg_paths& paths) const
|
||||
{
|
||||
auto it = fs::directory_iterator(paths.triplets);
|
||||
for (; it != fs::directory_iterator(); ++it)
|
||||
{
|
||||
std::string triplet_file_name = it->path().stem().generic_u8string();
|
||||
if (value == triplet_file_name) // TODO: fuzzy compare
|
||||
{
|
||||
//value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
|
||||
Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
|
||||
return std::string(it + 1, this->value.cend());
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace vcpkg {namespace Environment
|
||||
void ensure_git_on_path(const vcpkg_paths& paths)
|
||||
{
|
||||
const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd";
|
||||
const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s",
|
||||
const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
|
||||
downloaded_git.native(),
|
||||
System::wdupenv_str(L"PATH"),
|
||||
default_git_installation_dir.native(),
|
||||
@ -63,7 +63,7 @@ namespace vcpkg {namespace Environment
|
||||
void ensure_cmake_on_path(const vcpkg_paths& paths)
|
||||
{
|
||||
const fs::path downloaded_cmake = paths.downloads / "cmake-3.5.2-win32-x86" / "bin";
|
||||
const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s",
|
||||
const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
|
||||
downloaded_cmake.native(),
|
||||
System::wdupenv_str(L"PATH"),
|
||||
default_cmake_installation_dir.native(),
|
||||
@ -77,7 +77,7 @@ namespace vcpkg {namespace Environment
|
||||
|
||||
void ensure_nuget_on_path(const vcpkg_paths& paths)
|
||||
{
|
||||
const std::wstring path_buf = Strings::format(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH"));
|
||||
const std::wstring path_buf = Strings::wformat(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH"));
|
||||
_wputenv_s(L"PATH", path_buf.c_str());
|
||||
|
||||
static constexpr std::array<int, 3> nuget_version = {1,0,0};
|
||||
|
@ -20,7 +20,7 @@ namespace vcpkg {namespace Strings {namespace details
|
||||
return output;
|
||||
}
|
||||
|
||||
std::wstring format_internal(const wchar_t* fmtstr, ...)
|
||||
std::wstring wformat_internal(const wchar_t* fmtstr, ...)
|
||||
{
|
||||
va_list lst;
|
||||
va_start(lst, fmtstr);
|
||||
|
@ -19,14 +19,14 @@ namespace vcpkg {namespace System
|
||||
int cmd_execute(const wchar_t* cmd_line)
|
||||
{
|
||||
// Basically we are wrapping it in quotes
|
||||
const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line);
|
||||
const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
|
||||
int exit_code = _wsystem(actual_cmd_line.c_str());
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line)
|
||||
{
|
||||
const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line);
|
||||
const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
|
||||
|
||||
std::string output;
|
||||
char buf[1024];
|
||||
|
@ -56,4 +56,19 @@ namespace vcpkg
|
||||
{
|
||||
return this->ports / spec.name;
|
||||
}
|
||||
|
||||
bool vcpkg_paths::is_valid_triplet(const triplet& t) const
|
||||
{
|
||||
auto it = fs::directory_iterator(this->triplets);
|
||||
for (; it != fs::directory_iterator(); ++it)
|
||||
{
|
||||
std::string triplet_file_name = it->path().stem().generic_u8string();
|
||||
if (t.value == triplet_file_name) // TODO: fuzzy compare
|
||||
{
|
||||
//t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user