From eacabe5c4641c2f95507a4c513fa35552937f6ab Mon Sep 17 00:00:00 2001 From: Mateusz Loskot Date: Tue, 26 Sep 2017 22:29:24 +0200 Subject: [PATCH 1/5] [geos] Update port to latest GEOS 3.6.2 * Bump GEOS version wherever necessary * Update download package and checksum. * Replace download from SVN with official release source package. * Remove generating of geos_svn_revision.h as unnecessary - released source package includes the header. * Explain status of the missing CMake modules. * Remove CMake option -DBUILD_TESTING as unused. GEOS is important dependency of GDAL (updated in #1879; GDAL 2.2.2 can still work with GEOS earlier than 3.6.2). --- ports/geos/CONTROL | 2 +- ports/geos/portfile.cmake | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ports/geos/CONTROL b/ports/geos/CONTROL index 3e9d4d7c61f..fbf31661fc0 100644 --- a/ports/geos/CONTROL +++ b/ports/geos/CONTROL @@ -1,3 +1,3 @@ Source: geos -Version: 3.5.0-1 +Version: 3.6.2 Description: Geometry Engine Open Source diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index 7cd50db58c9..b391a9fcef9 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -7,25 +7,26 @@ # include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/3.5) -#downloading 3.5 from their SVN repo and not the release tarball -#because the 3.5 release did not build on windows, and fixes were backported -#without generating a new release tarball (I don't think very many GIS people use win) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/geos-3.6.2) + vcpkg_download_distfile(ARCHIVE - URLS "https://trac.osgeo.org/geos/browser/branches/3.5?rev=4261&format=zip" - FILENAME "geos-3.5.0.zip" - SHA512 3b91e8992f60b99a3f01069d955b71bce425ae5e5c599252fa26a337494e1a5a8ea796be124766d054710d6c03806f56dc1c63539b4660e2bb894d7ef779d4b9 + URLS "http://download.osgeo.org/geos/geos-3.6.2.tar.bz2" + FILENAME "geos-3.6.2.tar.bz2" + SHA512 515d8700b8a28282678e481faee355e3a43d7b70160472a63335b8d7225d9ba10437be782378f18f31a15288118126d411a2d862f01ce35d27c96f6bc0a73016 ) vcpkg_extract_source_archive(${ARCHIVE}) -#we need to do this because GEOS deploy process is totally broken for cmake -#file(DOWNLOAD http://svn.osgeo.org/geos/tags/3.5.0/cmake/modules/GenerateSourceGroups.cmake -# ${SOURCE_PATH}/cmake/modules/GenerateSourceGroups.cmake) -file(WRITE ${SOURCE_PATH}/geos_svn_revision.h "#define GEOS_SVN_REVISION 4261") +# NOTE: GEOS provides CMake as optional build configuration, it might not be actively +# maintained, so CMake build issues may happen between releases. + +# Pull modules referred in the main CMakeLists.txt but missing from the released package. +# TODO: GEOS 3.6.3 or later will include the missing script in release package. +file(DOWNLOAD http://svn.osgeo.org/geos/branches/3.6/cmake/modules/GenerateSourceGroups.cmake + ${SOURCE_PATH}/cmake/modules/GenerateSourceGroups.cmake) + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} OPTIONS -DGEOS_ENABLE_TESTS=False - -DBUILD_TESTING=False ) vcpkg_build_cmake() From eca068e4c5673b888d6470b42d6b5b44b21c4007 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 27 Sep 2017 17:22:40 -0700 Subject: [PATCH 2/5] Extract function for duplicated code --- toolsrc/src/VcpkgPaths.cpp | 51 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 02e238b3f30..00f4691cd84 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -269,10 +269,29 @@ namespace vcpkg return nullopt; } - static std::vector find_toolset_instances(const VcpkgPaths& paths) + static std::vector detect_supported_architectures(const Files::Filesystem& fs, + const fs::path& vcvarsall_dir) { using CPU = System::CPUArchitecture; + std::vector supported_architectures; + if (fs.exists(vcvarsall_dir / "vcvars32.bat")) supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); + if (fs.exists(vcvarsall_dir / "vcvars64.bat")) + supported_architectures.push_back({L"amd64", CPU::X64, CPU::X64}); + if (fs.exists(vcvarsall_dir / "vcvarsx86_amd64.bat")) + supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); + if (fs.exists(vcvarsall_dir / "vcvarsx86_arm.bat")) + supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); + if (fs.exists(vcvarsall_dir / "vcvarsamd64_x86.bat")) + supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); + if (fs.exists(vcvarsall_dir / "vcvarsamd64_arm.bat")) + supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + + return supported_architectures; + } + + static std::vector find_toolset_instances(const VcpkgPaths& paths) + { const auto& fs = paths.get_filesystem(); const std::vector vs2017_installation_instances = get_vs2017_installation_instances(paths); @@ -294,19 +313,8 @@ namespace vcpkg paths_examined.push_back(vs2015_dumpbin_exe); const fs::path vs2015_bin_dir = vs2015_vcvarsall_bat.parent_path() / "bin"; - std::vector supported_architectures; - if (fs.exists(vs2015_bin_dir / "vcvars32.bat")) - supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); - if (fs.exists(vs2015_bin_dir / "amd64\\vcvars64.bat")) - supported_architectures.push_back({L"x64", CPU::X64, CPU::X64}); - if (fs.exists(vs2015_bin_dir / "x86_amd64\\vcvarsx86_amd64.bat")) - supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); - if (fs.exists(vs2015_bin_dir / "x86_arm\\vcvarsx86_arm.bat")) - supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); - if (fs.exists(vs2015_bin_dir / "amd64_x86\\vcvarsamd64_x86.bat")) - supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); - if (fs.exists(vs2015_bin_dir / "amd64_arm\\vcvarsamd64_arm.bat")) - supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + const std::vector supported_architectures = + detect_supported_architectures(fs, vs2015_bin_dir); if (fs.exists(vs2015_dumpbin_exe)) { @@ -329,19 +337,8 @@ namespace vcpkg if (!fs.exists(vcvarsall_bat)) continue; // Get all supported architectures - std::vector supported_architectures; - if (fs.exists(vcvarsall_dir / "vcvars32.bat")) - supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); - if (fs.exists(vcvarsall_dir / "vcvars64.bat")) - supported_architectures.push_back({L"amd64", CPU::X64, CPU::X64}); - if (fs.exists(vcvarsall_dir / "vcvarsx86_amd64.bat")) - supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); - if (fs.exists(vcvarsall_dir / "vcvarsx86_arm.bat")) - supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); - if (fs.exists(vcvarsall_dir / "vcvarsamd64_x86.bat")) - supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); - if (fs.exists(vcvarsall_dir / "vcvarsamd64_arm.bat")) - supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + const std::vector supported_architectures = + detect_supported_architectures(fs, vcvarsall_dir); // Locate the "best" MSVC toolchain version const fs::path msvc_path = vc_dir / "Tools" / "MSVC"; From 712491c8223616803220b7f8b807ecb5a3e64ece Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 27 Sep 2017 17:48:51 -0700 Subject: [PATCH 3/5] Place line closer to usage --- toolsrc/src/VcpkgPaths.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 00f4691cd84..b831b6f46a1 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -294,7 +294,6 @@ namespace vcpkg { const auto& fs = paths.get_filesystem(); - const std::vector vs2017_installation_instances = get_vs2017_installation_instances(paths); // Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations. std::vector paths_examined; @@ -324,6 +323,8 @@ namespace vcpkg } } + const std::vector vs2017_installation_instances = get_vs2017_installation_instances(paths); + // VS2017 Optional vs2017_toolset; for (const std::string& instance : vs2017_installation_instances) From f617a711ec4c3d5527911c32340238053901269d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 27 Sep 2017 18:41:28 -0700 Subject: [PATCH 4/5] Fix: Don't break before finding all VS2017 instances --- toolsrc/src/VcpkgPaths.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index b831b6f46a1..8ce4df3dfcf 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -364,7 +364,6 @@ namespace vcpkg if (const auto value = vs2017_toolset.get()) { found_toolsets.push_back(*value); - break; } } From 0ccea4f3677d92a20935e03c2cb301d8300b43d1 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 27 Sep 2017 18:55:09 -0700 Subject: [PATCH 5/5] [Toolset selection] Use VS2017 vcvarsall for v140 if available --- toolsrc/include/VcpkgPaths.h | 2 ++ toolsrc/src/VcpkgPaths.cpp | 61 +++++++++++++++++++++++++++++++----- toolsrc/src/vcpkg_Build.cpp | 7 ++++- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/toolsrc/include/VcpkgPaths.h b/toolsrc/include/VcpkgPaths.h index d55c95fe149..3c1955204bb 100644 --- a/toolsrc/include/VcpkgPaths.h +++ b/toolsrc/include/VcpkgPaths.h @@ -19,6 +19,7 @@ namespace vcpkg { fs::path dumpbin; fs::path vcvarsall; + std::vector vcvarsall_options; CWStringView version; std::vector supported_architectures; }; @@ -71,5 +72,6 @@ namespace vcpkg Lazy git_exe; Lazy nuget_exe; Lazy> toolsets; + Lazy> toolsets_vs2017_v140; }; } diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 8ce4df3dfcf..8892207bd83 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -10,6 +10,10 @@ namespace vcpkg { + // Intentionally wstring so we can easily use operator== with CWStringView. + static const std::wstring V_140 = L"v140"; + static const std::wstring V_141 = L"v141"; + static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd, const std::array& expected_version) { @@ -318,7 +322,7 @@ namespace vcpkg if (fs.exists(vs2015_dumpbin_exe)) { found_toolsets.push_back( - {vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140", supported_architectures}); + {vs2015_dumpbin_exe, vs2015_vcvarsall_bat, {}, V_140, supported_architectures}); } } } @@ -357,7 +361,7 @@ namespace vcpkg paths_examined.push_back(dumpbin_path); if (fs.exists(dumpbin_path)) { - vs2017_toolset = Toolset{dumpbin_path, vcvarsall_bat, L"v141", supported_architectures}; + vs2017_toolset = Toolset{dumpbin_path, vcvarsall_bat, {}, V_141, supported_architectures}; break; } } @@ -381,20 +385,63 @@ namespace vcpkg return found_toolsets; } + static std::vector create_vs2017_v140_toolset_instances(const std::vector& vs_toolsets) + { + std::vector vs2017_v140_toolsets; + + // In constrast to v141 and above, there can only be a single instance of v140 (VS2017 vs VS2015). + const auto it = Util::find_if(vs_toolsets, [&](const Toolset& t) { return t.version == V_140; }); + + // If v140 is not available, then VS2017 cant use them. Return empty. + if (it == vs_toolsets.cend()) + { + return vs2017_v140_toolsets; + } + + // If it does exist, then create a matching v140 toolset for each v141 toolset + const Toolset v140_toolset = *it; + for (const Toolset& toolset : vs_toolsets) + { + if (toolset.version != V_141) + { + continue; + } + + Toolset t = Toolset{ + toolset.dumpbin, toolset.vcvarsall, {L"-vcvars_ver=14.0"}, V_140, toolset.supported_architectures}; + vs2017_v140_toolsets.push_back(std::move(t)); + } + + return vs2017_v140_toolsets; + } + const Toolset& VcpkgPaths::get_toolset(const std::string& toolset_version) const { - // Invariant: toolsets are non-empty and sorted with newest at back() - const auto& vs_toolsets = this->toolsets.get_lazy([this]() { return find_toolset_instances(*this); }); + const std::wstring& w_toolset_version = Strings::to_utf16(toolset_version); - if (toolset_version.empty()) + // Invariant: toolsets are non-empty and sorted with newest at back() + const std::vector& vs_toolsets = + this->toolsets.get_lazy([this]() { return find_toolset_instances(*this); }); + + if (w_toolset_version.empty()) { return vs_toolsets.back(); } - const auto toolset = Util::find_if( - vs_toolsets, [&](const Toolset& t) { return toolset_version == Strings::to_utf8(t.version); }); + const auto toolset = + Util::find_if(vs_toolsets, [&](const Toolset& t) { return w_toolset_version == t.version; }); Checks::check_exit( VCPKG_LINE_INFO, toolset != vs_toolsets.end(), "Could not find toolset '%s'", toolset_version); + + // If v140 is the selected toolset and VS2017 is available, then use VS2017's vcvarsall with the + // -vcvars_ver=14.0 option + const std::vector& vs2017_v140_toolsets = this->toolsets_vs2017_v140.get_lazy( + [&vs_toolsets]() { return create_vs2017_v140_toolset_instances(vs_toolsets); }); + if (w_toolset_version == V_140 && !vs2017_v140_toolsets.empty()) + { + return vs2017_v140_toolsets.back(); + } + return *toolset; } diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp index d40140aca4d..5ac13c6c67b 100644 --- a/toolsrc/src/vcpkg_Build.cpp +++ b/toolsrc/src/vcpkg_Build.cpp @@ -67,7 +67,12 @@ namespace vcpkg::Build const auto arch = to_vcvarsall_toolchain(pre_build_info.target_architecture, toolset); const 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); + return Strings::wformat(LR"("%s" %s %s %s %s 2>&1)", + toolset.vcvarsall.native(), + Strings::join(L" ", toolset.vcvarsall_options), + arch, + target, + tonull); } static void create_binary_feature_control_file(const SourceParagraph& source_paragraph,