2017-12-05 13:00:50 -08:00
[ CmdletBinding ( ) ]
param (
$libraries = @ ( ) ,
2020-11-06 22:30:37 +01:00
$version = " 1.74.0 " ,
2020-03-10 10:15:27 -07:00
$portsDir = $null
2017-12-05 13:00:50 -08:00
)
$scriptsDir = split-path -parent $MyInvocation . MyCommand . Definition
2020-03-10 10:15:27 -07:00
if ( $null -eq $portsDir )
{
$portsDir = " $scriptsDir /../../ports "
}
2017-12-05 13:00:50 -08:00
2020-08-07 11:41:21 -07:00
# Optionally clear this array when moving to a new boost version
$port_versions = @ {
2020-11-06 22:30:37 +01:00
#e.g. "asio" = 1;
2020-08-07 11:41:21 -07:00
}
$per_port_data = @ {
2020-10-28 22:22:51 +01:00
" asio " = @ { " supports " = " !emscripten " } ;
" beast " = @ { " supports " = " !emscripten " } ;
" fiber " = @ { " supports " = " !osx&!uwp&!arm&!emscripten " } ;
2020-08-07 11:41:21 -07:00
" filesystem " = @ { " supports " = " !uwp " } ;
" iostreams " = @ { " supports " = " !uwp " } ;
2020-10-28 22:22:51 +01:00
" context " = @ { " supports " = " !uwp&!emscripten " } ;
2020-08-07 11:41:21 -07:00
" stacktrace " = @ { " supports " = " !uwp " } ;
2020-10-28 22:22:51 +01:00
" coroutine " = @ { " supports " = " !arm&!uwp&!emscripten " } ;
" coroutine2 " = @ { " supports " = " !emscripten " } ;
2020-08-07 11:41:21 -07:00
" test " = @ { " supports " = " !uwp " } ;
" wave " = @ { " supports " = " !uwp " } ;
2020-10-28 22:22:51 +01:00
" log " = @ { " supports " = " !uwp&!emscripten " } ;
2020-08-07 11:41:21 -07:00
" locale " = @ {
" supports " = " !uwp " ;
" features " = @ (
" Feature: icu "
" Build-Depends: icu "
" Description: ICU backend for Boost.Locale "
) } ;
2020-10-28 22:22:51 +01:00
" parameter-python " = @ { " supports " = " !emscripten " } ;
" process " = @ { " supports " = " !emscripten " } ;
2020-08-07 11:41:21 -07:00
" python " = @ {
2020-10-28 22:22:51 +01:00
" supports " = " !uwp&!(arm&windows)&!emscripten " ;
2020-08-07 11:41:21 -07:00
" features " = @ (
" Feature: python2 "
" Build-Depends: python2 (windows) "
" Description: Build with Python2 support "
) } ;
" regex " = @ { " features " = @ (
" Feature: icu "
" Build-Depends: icu "
" Description: ICU backend for Boost.Regex "
) }
}
2018-08-09 22:56:09 -07:00
function TransformReference ( )
{
param (
[ string ] $library
)
2020-08-07 11:41:21 -07:00
if ( $per_port_data [ $library ] . supports )
2018-08-09 22:56:09 -07:00
{
2020-08-07 11:41:21 -07:00
" $library ( $( $per_port_data [ $library ] . supports ) ) "
2018-08-09 22:56:09 -07:00
}
else
{
" $library "
}
}
2017-12-05 13:00:50 -08:00
function Generate ( )
{
param (
[ string ] $Name ,
2020-01-17 02:10:15 +03:00
[ string ] $PortName ,
2017-12-05 13:00:50 -08:00
[ string ] $Hash ,
[ bool ] $NeedsBuild ,
$Depends = @ ( )
)
$controlDeps = ( $Depends | sort ) -join " , "
2020-01-17 02:10:15 +03:00
mkdir " $portsDir /boost- $PortName " -erroraction SilentlyContinue | out-null
2017-12-05 13:00:50 -08:00
$controlLines = @ (
" # Automatically generated by boost-vcpkg-helpers/generate-ports.ps1 "
2020-01-17 02:10:15 +03:00
" Source: boost- $PortName "
2020-08-07 11:41:21 -07:00
" Version: $version "
)
if ( $port_versions [ $PortName ] )
{
$controlLines + = @ ( " Port-Version: $( $port_versions [ $PortName ] ) " )
}
$controlLines + = @ (
2017-12-05 13:00:50 -08:00
" Build-Depends: $controlDeps "
2020-01-17 02:10:15 +03:00
" Homepage: https://github.com/boostorg/ $Name "
2017-12-05 13:00:50 -08:00
" Description: Boost $Name module "
)
2020-08-07 11:41:21 -07:00
if ( $per_port_data [ $PortName ] . supports )
2017-12-05 13:00:50 -08:00
{
2020-08-07 11:41:21 -07:00
$controlLines + = @ ( " Supports: $( $per_port_data [ $PortName ] . supports ) " )
2017-12-05 13:00:50 -08:00
}
2020-08-07 11:41:21 -07:00
if ( $per_port_data [ $PortName ] . features )
2017-12-05 13:00:50 -08:00
{
2020-08-07 11:41:21 -07:00
$controlLines + = @ ( " " ) + $per_port_data [ $PortName ] . features
2017-12-05 13:00:50 -08:00
}
2020-01-17 02:10:15 +03:00
$controlLines | out-file -enc ascii " $portsDir /boost- $PortName /CONTROL "
2017-12-05 13:00:50 -08:00
$portfileLines = @ (
" # Automatically generated by boost-vcpkg-helpers/generate-ports.ps1 "
" "
2020-01-17 02:10:15 +03:00
)
if ( $PortName -eq " system " )
{
$portfileLines + = @ (
" vcpkg_buildpath_length_warning(37) "
" "
)
}
$portfileLines + = @ (
2017-12-05 13:00:50 -08:00
" vcpkg_from_github( "
" OUT_SOURCE_PATH SOURCE_PATH "
" REPO boostorg/ $Name "
" REF boost- $version "
" SHA512 $Hash "
" HEAD_REF master "
2019-01-31 10:04:17 +10:00
)
2020-08-07 11:41:21 -07:00
$patches = ls $portsDir / boost - $PortName / * . patch
if ( $patches . Count -eq 0 )
2019-01-31 10:04:17 +10:00
{
2019-09-27 10:41:02 -07:00
}
2020-08-07 11:41:21 -07:00
elseif ( $patches . Count -eq 1 )
2019-09-27 10:41:02 -07:00
{
2020-08-07 11:41:21 -07:00
$portfileLines + = @ ( " PATCHES $( $patches . name ) " )
2019-01-31 10:04:17 +10:00
}
2020-08-07 11:41:21 -07:00
else
2020-03-24 13:01:25 -07:00
{
2020-08-07 11:41:21 -07:00
$portfileLines + = @ ( " PATCHES " )
foreach ( $patch in $patches )
{
2020-11-06 22:30:37 +01:00
$portfileLines + = @ ( " $( $patch . name ) " )
2020-08-07 11:41:21 -07:00
}
2020-03-24 13:01:25 -07:00
}
2019-01-31 10:04:17 +10:00
$portfileLines + = @ (
2017-12-05 13:00:50 -08:00
" ) "
" "
)
2020-01-17 02:10:15 +03:00
if ( Test-Path " $scriptsDir /post-source-stubs/ $PortName .cmake " )
2017-12-05 13:00:50 -08:00
{
2020-01-17 02:10:15 +03:00
$portfileLines + = @ ( get-content " $scriptsDir /post-source-stubs/ $PortName .cmake " )
2017-12-05 13:00:50 -08:00
}
if ( $NeedsBuild )
{
2020-05-13 20:26:05 +03:00
$portfileLines + = @ (
" include( `$ {CURRENT_INSTALLED_DIR}/share/boost-build/boost-modular-build.cmake) "
)
# b2-options.cmake contains port-specific build options
if ( Test-Path " $portsDir /boost- $PortName /b2-options.cmake " )
2017-12-05 13:00:50 -08:00
{
$portfileLines + = @ (
2019-01-31 10:04:17 +10:00
" boost_modular_build( "
" SOURCE_PATH `$ {SOURCE_PATH} "
2020-05-13 20:26:05 +03:00
" BOOST_CMAKE_FRAGMENT `" `$ {CMAKE_CURRENT_LIST_DIR}/b2-options.cmake `" "
2019-01-31 10:04:17 +10:00
" ) "
2017-12-05 13:00:50 -08:00
)
}
else
{
$portfileLines + = @ (
" boost_modular_build(SOURCE_PATH `$ {SOURCE_PATH}) "
2020-05-13 20:26:05 +03:00
)
2017-12-05 13:00:50 -08:00
}
}
2020-01-17 12:56:22 +03:00
$portfileLines + = @ (
" include( `$ {CURRENT_INSTALLED_DIR}/share/boost-vcpkg-helpers/boost-modular-headers.cmake) "
" boost_modular_headers(SOURCE_PATH `$ {SOURCE_PATH}) "
)
2017-12-05 13:00:50 -08:00
2020-01-17 02:10:15 +03:00
if ( Test-Path " $scriptsDir /post-build-stubs/ $PortName .cmake " )
2017-12-05 13:00:50 -08:00
{
2020-01-17 02:10:15 +03:00
$portfileLines + = @ ( get-content " $scriptsDir /post-build-stubs/ $PortName .cmake " )
2018-01-03 17:44:55 -08:00
}
2017-12-05 13:00:50 -08:00
2020-01-17 02:10:15 +03:00
$portfileLines | out-file -enc ascii " $portsDir /boost- $PortName /portfile.cmake "
2017-12-05 13:00:50 -08:00
}
if ( ! ( Test-Path " $scriptsDir /boost " ) )
{
" Cloning boost... "
pushd $scriptsDir
try
{
git clone https : / / github . com / boostorg / boost - -branch boost - $version
}
finally
{
popd
}
}
2018-04-17 15:18:09 -07:00
else
{
pushd $scriptsDir / boost
try
{
git fetch
git checkout -f boost - $version
}
finally
{
popd
}
}
2017-12-05 13:00:50 -08:00
$libraries_found = ls $scriptsDir / boost / libs -directory | % name | % {
if ( $_ -match " numeric " )
{
" numeric_conversion "
" interval "
" odeint "
" ublas "
2019-01-31 10:04:17 +10:00
" safe_numerics "
2017-12-05 13:00:50 -08:00
}
2019-05-16 18:33:32 -07:00
elseif ( $_ -eq " headers " )
{
}
2017-12-05 13:00:50 -08:00
else
{
$_
}
}
mkdir $scriptsDir / downloads -erroraction SilentlyContinue | out-null
if ( $libraries . Length -eq 0 )
{
$libraries = $libraries_found
}
$libraries_in_boost_port = @ ( )
foreach ( $library in $libraries )
{
" Handling boost/ $library ... "
$archive = " $scriptsDir /downloads/ $library -boost- $version .tar.gz "
if ( ! ( Test-Path $archive ) )
{
" Downloading boost/ $library ... "
2018-08-09 22:56:09 -07:00
& @ ( vcpkg fetch aria2 ) [ -1 ] " https://github.com/boostorg/ $library /archive/boost- $version .tar.gz " -d " $scriptsDir /downloads " -o " $library -boost- $version .tar.gz "
2017-12-05 13:00:50 -08:00
}
$hash = vcpkg hash $archive
$unpacked = " $scriptsDir /libs/ $library -boost- $version "
if ( ! ( Test-Path $unpacked ) )
{
" Unpacking boost/ $library ... "
mkdir $scriptsDir / libs -erroraction SilentlyContinue | out-null
pushd $scriptsDir / libs
try
{
cmake -E tar xf $archive
}
finally
{
popd
}
}
pushd $unpacked
try
{
$groups = $ (
2018-08-09 22:56:09 -07:00
findstr / si / C: " include <boost/ " include / *
findstr / si / C: " include <boost/ " src / *
2017-12-05 13:00:50 -08:00
) |
2018-08-09 22:56:09 -07:00
% { $_ `
-replace " ^[^:]*: " , " " `
-replace " boost/numeric/conversion/ " , " boost/numeric_conversion/ " `
-replace " boost/functional/hash.hpp " , " boost/container_hash/hash.hpp " `
-replace " boost/detail/([^/]+)/ " , " boost/ `$ 1/ " `
2019-01-31 10:04:17 +10:00
-replace " *# *include *<boost/([a-zA-Z0-9\._]*)(/|>).* " , " `$ 1 " `
2018-08-09 22:56:09 -07:00
-replace " /|\.hp?p?| " , " " } | group | % name | % {
2017-12-05 13:00:50 -08:00
# mappings
Write-Verbose " ${library} : $_ "
if ( $_ -match " aligned_storage " ) { " type_traits " }
elseif ( $_ -match " noncopyable|ref|swap|get_pointer|checked_delete|visit_each " ) { " core " }
elseif ( $_ -eq " type " ) { " core " }
2020-08-07 11:41:21 -07:00
elseif ( $_ -eq " concept " ) { " concept_check " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -match " unordered_ " ) { " unordered " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " cstdint|integer_fwd|integer_traits " ) { " integer " }
2019-01-31 10:04:17 +10:00
elseif ( $_ -match " call_traits|operators|current_function|cstdlib|next_prior|compressed_pair " ) { " utility " }
elseif ( $_ -match " ^version|^workaround " ) { " config " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " enable_shared_from_this|shared_ptr|make_shared|make_unique|intrusive_ptr|scoped_ptr|pointer_cast|pointer_to_other|weak_ptr|shared_array|scoped_array " ) { " smart_ptr " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -match " iterator_adaptors|generator_iterator|pointee " ) { " iterator " }
elseif ( $_ -eq " regex_fwd " ) { " regex " }
elseif ( $_ -eq " make_default " ) { " convert " }
elseif ( $_ -eq " foreach_fwd " ) { " foreach " }
elseif ( $_ -eq " cerrno " ) { " system " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -eq " circular_buffer_fwd " ) { " circular_buffer " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -eq " archive " ) { " serialization " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " none|none_t " ) { " optional " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -eq " limits " ) { " compatibility " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " cstdfloat|math_fwd " ) { " math " }
elseif ( $_ -eq " cast " ) { " conversion " ; " numeric_conversion " } # DEPRECATED header file, includes <boost/polymorphic_cast.hpp> and <boost/numeric/conversion/cast.hpp>
2017-12-05 13:00:50 -08:00
elseif ( $_ -match " polymorphic_cast|implicit_cast " ) { " conversion " }
elseif ( $_ -eq " nondet_random " ) { " random " }
elseif ( $_ -eq " memory_order " ) { " atomic " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " blank|blank_fwd|numeric_traits " ) { " detail " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -match " is_placeholder|mem_fn " ) { " bind " }
elseif ( $_ -eq " exception_ptr " ) { " exception " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -match " multi_index_container|multi_index_container_fwd " ) { " multi_index " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -eq " lexical_cast " ) { " lexical_cast " ; " math " }
2019-01-31 10:04:17 +10:00
elseif ( $_ -match " token_iterator|token_functions " ) { " tokenizer " }
2017-12-05 13:00:50 -08:00
elseif ( $_ -eq " numeric " -and $library -notmatch " numeric_conversion|interval|odeint|ublas " ) { " numeric_conversion " ; " interval " ; " odeint " ; " ublas " }
2020-05-13 20:26:05 +03:00
elseif ( $_ -eq " io_fwd " ) { " io " }
2017-12-05 13:00:50 -08:00
else { $_ }
} | group | % name | ? { $_ -ne $library }
#"`nFor ${library}:"
" [known] " + $ ( $groups | ? { $libraries_found -contains $_ } )
" [unknown] " + $ ( $groups | ? { $libraries_found -notcontains $_ } )
$deps = @ ( $groups | ? { $libraries_found -contains $_ } )
$deps = @ ( $deps | ? {
# Boost contains cycles, so remove a few dependencies to break the loop.
2019-01-31 10:04:17 +10:00
( ( $library -notmatch " core|assert|mpl|detail|throw_exception|type_traits|^exception " ) -or ( $_ -notmatch " utility " ) ) `
2018-08-09 22:56:09 -07:00
-and `
2020-05-13 20:26:05 +03:00
( ( $library -notmatch " assert " ) -or ( $_ -notmatch " integer " ) ) `
-and `
2018-08-09 22:56:09 -07:00
( ( $library -notmatch " range " ) -or ( $_ -notmatch " algorithm " ) ) `
-and `
( ( $library -ne " config " ) -or ( $_ -notmatch " integer " ) ) `
-and `
2019-05-16 18:33:32 -07:00
( ( $library -notmatch " multiprecision " ) -or ( $_ -notmatch " random|math " ) ) `
2017-12-05 13:00:50 -08:00
-and `
( ( $library -notmatch " lexical_cast " ) -or ( $_ -notmatch " math " ) ) `
-and `
( ( $library -notmatch " functional " ) -or ( $_ -notmatch " function " ) ) `
-and `
( ( $library -notmatch " detail " ) -or ( $_ -notmatch " static_assert|integer|mpl|type_traits " ) ) `
-and `
2018-02-17 12:54:43 +01:00
( $_ -notmatch " mpi " ) `
2017-12-05 13:00:50 -08:00
-and `
( ( $library -notmatch " spirit " ) -or ( $_ -notmatch " serialization " ) ) `
-and `
2019-01-31 10:04:17 +10:00
( ( $library -notmatch " throw_exception " ) -or ( $_ -notmatch " ^exception " ) ) `
-and `
( ( $library -notmatch " iostreams " ) -or ( $_ -notmatch " random " ) ) `
-and `
2017-12-05 13:00:50 -08:00
( ( $library -notmatch " utility|concept_check " ) -or ( $_ -notmatch " iterator " ) )
2020-08-07 11:41:21 -07:00
} | % { $_ -replace " _ " , " - " } | % {
" boost- " + ( TransformReference $_ )
2017-12-05 13:00:50 -08:00
} )
$deps + = @ ( " boost-vcpkg-helpers " )
$needsBuild = $false
2018-04-17 16:26:01 -07:00
if ( ( Test-Path $unpacked / build / Jamfile . v2 ) -and $library -ne " metaparse " -and $library -ne " graph_parallel " )
2017-12-05 13:00:50 -08:00
{
2018-03-11 23:01:33 -07:00
$deps + = @ ( " boost-build " , " boost-modular-build-helper " )
2017-12-05 13:00:50 -08:00
$needsBuild = $true
}
if ( $library -eq " python " )
{
2020-03-02 21:41:27 +03:00
$deps + = @ ( " python3 " )
2017-12-21 11:46:26 -08:00
$needsBuild = $true
2017-12-05 13:00:50 -08:00
}
elseif ( $library -eq " iostreams " )
{
2019-09-27 10:41:02 -07:00
$deps + = @ ( " zlib " , " bzip2 " , " liblzma " , " zstd " )
2017-12-05 13:00:50 -08:00
}
2018-04-17 16:26:01 -07:00
elseif ( $library -eq " locale " )
{
2019-09-27 10:41:02 -07:00
$deps + = @ ( " libiconv (!uwp&!windows) " , " boost-system " )
2018-04-17 16:26:01 -07:00
}
2018-01-19 16:26:30 -08:00
elseif ( $library -eq " asio " )
{
$deps + = @ ( " openssl " )
}
2018-02-17 12:54:43 +01:00
elseif ( $library -eq " mpi " )
{
2019-07-31 23:47:59 +02:00
$deps + = @ ( " mpi " )
2018-02-17 12:54:43 +01:00
}
2017-12-05 13:00:50 -08:00
2020-01-17 02:10:15 +03:00
$portName = $library -replace " _ " , " - "
2017-12-05 13:00:50 -08:00
Generate `
-Name $library `
2020-01-17 02:10:15 +03:00
-PortName $portName `
2017-12-05 13:00:50 -08:00
-Hash $hash `
-Depends $deps `
-NeedsBuild $needsBuild
2020-01-17 02:10:15 +03:00
$libraries_in_boost_port + = @ ( TransformReference $portName )
2017-12-05 13:00:50 -08:00
}
finally
{
popd
}
}
2019-01-31 10:04:17 +10:00
if ( $libraries_in_boost_port . length -gt 1 ) {
# Generate master boost control file which depends on each individual library
2020-06-11 11:13:09 -07:00
# mpi is excluded due to it having a dependency on msmpi/openmpi
2020-09-07 16:51:02 -07:00
$boostDependsList = @ ( $libraries_in_boost_port | % { " boost- $_ " } | ? { $_ -notmatch " boost-mpi " } ) -join " , "
2019-01-31 10:04:17 +10:00
@ (
" # Automatically generated by boost-vcpkg-helpers/generate-ports.ps1 "
" Source: boost "
" Version: $version "
2020-08-07 11:41:21 -07:00
" Port-Version: $( $port_versions . boost ) "
2019-09-27 10:41:02 -07:00
" Homepage: https://boost.org "
2019-01-31 10:04:17 +10:00
" Description: Peer-reviewed portable C++ source libraries "
" Build-Depends: $boostDependsList "
" "
" Feature: mpi "
" Description: Build with MPI support "
" Build-Depends: boost-mpi "
2019-09-27 10:41:02 -07:00
) | out-file -enc ascii $portsDir / boost / CONTROL
2019-01-31 10:04:17 +10:00
2019-09-27 10:41:02 -07:00
" set(VCPKG_POLICY_EMPTY_PACKAGE enabled) `n " | out-file -enc ascii $portsDir / boost / portfile . cmake
2019-01-31 10:04:17 +10:00
}
2017-12-05 13:00:50 -08:00
return