From e2ff466f65a82dd31584468ddf67955092c79c11 Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Thu, 26 Nov 2020 02:26:33 +0700 Subject: [PATCH] [boost-locale] Replace VCPKG_TARGET_IS_WINDOWS in b2-options (#14502) * [boost-locale] Use CMAKE_SYSTEM_NAME as a fallback where VCPKG_TARGET_IS_WINDOWS is not available * fix this issue in a different way * Remove comments in b2-options.cmake.in Co-authored-by: nicole mazzuca * fix generate-ports.ps1 Co-authored-by: Nicole Mazzuca --- ports/boost-locale/CONTROL | 3 +- .../{b2-options.cmake => b2-options.cmake.in} | 17 ++++----- ports/boost-locale/portfile.cmake | 9 +++-- scripts/boost/generate-ports.ps1 | 36 ++++++++++++++++--- 4 files changed, 49 insertions(+), 16 deletions(-) rename ports/boost-locale/{b2-options.cmake => b2-options.cmake.in} (65%) diff --git a/ports/boost-locale/CONTROL b/ports/boost-locale/CONTROL index 63714c5a75..306cfa32ac 100644 --- a/ports/boost-locale/CONTROL +++ b/ports/boost-locale/CONTROL @@ -1,6 +1,7 @@ -# Automatically generated by boost-vcpkg-helpers/generate-ports.ps1 +# Automatically generated by scripts/boost/generate-ports.ps1 Source: boost-locale Version: 1.74.0 +Port-Version: 1 Build-Depends: boost-assert, boost-build, boost-config, boost-function, boost-integer, boost-iterator, boost-modular-build-helper, boost-smart-ptr, boost-static-assert, boost-system, boost-thread, boost-type-traits, boost-unordered, boost-vcpkg-helpers, libiconv (!uwp&!windows) Homepage: https://github.com/boostorg/locale Description: Boost locale module diff --git a/ports/boost-locale/b2-options.cmake b/ports/boost-locale/b2-options.cmake.in similarity index 65% rename from ports/boost-locale/b2-options.cmake rename to ports/boost-locale/b2-options.cmake.in index 6bd353e1d5..d1df5d6c51 100644 --- a/ports/boost-locale/b2-options.cmake +++ b/ports/boost-locale/b2-options.cmake.in @@ -1,15 +1,16 @@ -if(VCPKG_TARGET_IS_WINDOWS) - if("icu" IN_LIST FEATURES) - set(BOOST_LOCALE_ICU on) - else() - set(BOOST_LOCALE_ICU off) - endif() +set(_B2_OPTIONS_FEATURES "@FEATURES@") +if("icu" IN_LIST _B2_OPTIONS_FEATURES) + set(BOOST_LOCALE_ICU_FEATURE on) +else() + set(BOOST_LOCALE_ICU_FEATURE off) +endif() +if(@VCPKG_TARGET_IS_WINDOWS@) list(APPEND B2_OPTIONS boost.locale.iconv=off boost.locale.posix=off /boost/locale//boost_locale - boost.locale.icu=${BOOST_LOCALE_ICU} + boost.locale.icu=${BOOST_LOCALE_ICU_FEATURE} ) else() find_library(LIBICONV_LIBRARY iconv) @@ -19,7 +20,7 @@ else() boost.locale.iconv=on boost.locale.posix=on /boost/locale//boost_locale - boost.locale.icu=off + boost.locale.icu=${BOOST_LOCALE_ICU_FEATURE} -sICONV_PATH=${LIBICONV_DIR} ) if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "wasm32") diff --git a/ports/boost-locale/portfile.cmake b/ports/boost-locale/portfile.cmake index fa62041db3..445569a41f 100644 --- a/ports/boost-locale/portfile.cmake +++ b/ports/boost-locale/portfile.cmake @@ -1,4 +1,4 @@ -# Automatically generated by boost-vcpkg-helpers/generate-ports.ps1 +# Automatically generated by scripts/boost/generate-ports.ps1 vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -12,9 +12,14 @@ vcpkg_from_github( ) include(${CURRENT_INSTALLED_DIR}/share/boost-build/boost-modular-build.cmake) +configure_file( + "${CMAKE_CURRENT_LIST_DIR}/b2-options.cmake.in" + "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake" + @ONLY +) boost_modular_build( SOURCE_PATH ${SOURCE_PATH} - BOOST_CMAKE_FRAGMENT "${CMAKE_CURRENT_LIST_DIR}/b2-options.cmake" + BOOST_CMAKE_FRAGMENT "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake" ) include(${CURRENT_INSTALLED_DIR}/share/boost-vcpkg-helpers/boost-modular-headers.cmake) boost_modular_headers(SOURCE_PATH ${SOURCE_PATH}) diff --git a/scripts/boost/generate-ports.ps1 b/scripts/boost/generate-ports.ps1 index d92ab8adfa..29ab213dad 100644 --- a/scripts/boost/generate-ports.ps1 +++ b/scripts/boost/generate-ports.ps1 @@ -5,15 +5,27 @@ param ( $portsDir = $null ) +$ErrorActionPreference = 'Stop' + $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition if ($null -eq $portsDir) { $portsDir = "$scriptsDir/../../ports" } +if ($IsWindows) +{ + $vcpkg = "$scriptsDir/../../vcpkg.exe" +} +else +{ + $vcpkg = "$scriptsDir/../../vcpkg" +} + # Optionally clear this array when moving to a new boost version $port_versions = @{ #e.g. "asio" = 1; + "locale" = 1; } $per_port_data = @{ @@ -82,7 +94,7 @@ function Generate() mkdir "$portsDir/boost-$PortName" -erroraction SilentlyContinue | out-null $controlLines = @( - "# Automatically generated by boost-vcpkg-helpers/generate-ports.ps1" + "# Automatically generated by scripts/boost/generate-ports.ps1" "Source: boost-$PortName" "Version: $version" ) @@ -106,7 +118,7 @@ function Generate() $controlLines | out-file -enc ascii "$portsDir/boost-$PortName/CONTROL" $portfileLines = @( - "# Automatically generated by boost-vcpkg-helpers/generate-ports.ps1" + "# Automatically generated by scripts/boost/generate-ports.ps1" "" ) @@ -167,6 +179,20 @@ function Generate() ")" ) } + elseif (Test-Path "$portsDir/boost-$PortName/b2-options.cmake.in") + { + $portfileLines += @( + 'configure_file(' + ' "${CMAKE_CURRENT_LIST_DIR}/b2-options.cmake.in"' + ' "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake"' + ' @ONLY' + ')' + 'boost_modular_build(' + ' SOURCE_PATH ${SOURCE_PATH}' + ' BOOST_CMAKE_FRAGMENT "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake"' + ')' + ) + } else { $portfileLines += @( @@ -249,9 +275,9 @@ foreach ($library in $libraries) if (!(Test-Path $archive)) { "Downloading boost/$library..." - & @(vcpkg fetch aria2)[-1] "https://github.com/boostorg/$library/archive/boost-$version.tar.gz" -d "$scriptsDir/downloads" -o "$library-boost-$version.tar.gz" + & @(& $vcpkg fetch aria2)[-1] "https://github.com/boostorg/$library/archive/boost-$version.tar.gz" -d "$scriptsDir/downloads" -o "$library-boost-$version.tar.gz" } - $hash = vcpkg hash $archive + $hash = & $vcpkg hash $archive $unpacked = "$scriptsDir/libs/$library-boost-$version" if (!(Test-Path $unpacked)) { @@ -408,7 +434,7 @@ if ($libraries_in_boost_port.length -gt 1) { $boostDependsList = @($libraries_in_boost_port | % { "boost-$_" } | ? { $_ -notmatch "boost-mpi" }) -join ", " @( - "# Automatically generated by boost-vcpkg-helpers/generate-ports.ps1" + "# Automatically generated by scripts/boost/generate-ports.ps1" "Source: boost" "Version: $version" "Port-Version: $($port_versions.boost)"