]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | [CmdletBinding()]\r |
2 | param (\r | |
3 | $libraries = @(),\r | |
4 | $version = "1.75.0",\r | |
5 | $portsDir = $null\r | |
6 | )\r | |
7 | \r | |
8 | $ErrorActionPreference = 'Stop'\r | |
9 | \r | |
10 | $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition\r | |
11 | if ($null -eq $portsDir)\r | |
12 | {\r | |
13 | $portsDir = "$scriptsDir/../../ports"\r | |
14 | }\r | |
15 | \r | |
16 | if ($IsWindows)\r | |
17 | {\r | |
18 | $vcpkg = "$scriptsDir/../../vcpkg.exe"\r | |
19 | $curl = "curl.exe"\r | |
20 | }\r | |
21 | else\r | |
22 | {\r | |
23 | $vcpkg = "$scriptsDir/../../vcpkg"\r | |
24 | $curl = "curl"\r | |
25 | }\r | |
26 | \r | |
27 | # Clear this array when moving to a new boost version\r | |
28 | $port_versions = @{\r | |
29 | #e.g. "asio" = 1;\r | |
30 | "asio" = 1;\r | |
31 | "python" = 2;\r | |
32 | "context" = 2;\r | |
33 | "concept-check" = 2;\r | |
34 | }\r | |
35 | \r | |
36 | $per_port_data = @{\r | |
37 | "asio" = @{ "supports" = "!emscripten" };\r | |
38 | "beast" = @{ "supports" = "!emscripten" };\r | |
39 | "fiber" = @{ "supports" = "!osx&!uwp&!arm&!emscripten" };\r | |
40 | "filesystem" = @{ "supports" = "!uwp" };\r | |
41 | "iostreams" = @{ "supports" = "!uwp" };\r | |
42 | "context" = @{ "supports" = "!uwp&!emscripten" };\r | |
43 | "stacktrace" = @{ "supports" = "!uwp" };\r | |
44 | "coroutine" = @{ "supports" = "!arm&!uwp&!emscripten" };\r | |
45 | "coroutine2" = @{ "supports" = "!emscripten" };\r | |
46 | "test" = @{ "supports" = "!uwp" };\r | |
47 | "wave" = @{ "supports" = "!uwp" };\r | |
48 | "log" = @{ "supports" = "!uwp&!emscripten" };\r | |
49 | "locale" = @{\r | |
50 | "supports" = "!uwp";\r | |
51 | "features" = @{\r | |
52 | icu=@{\r | |
53 | dependencies=@("icu")\r | |
54 | description="ICU backend for Boost.Locale"\r | |
55 | }\r | |
56 | }\r | |
57 | };\r | |
58 | "parameter-python" = @{ "supports" = "!emscripten" };\r | |
59 | "process" = @{ "supports" = "!emscripten" };\r | |
60 | "python" = @{\r | |
61 | "supports" = "!uwp&!(arm&windows)&!emscripten";\r | |
62 | "features" = @{\r | |
63 | python2=@{\r | |
64 | dependencies=@(@{name="python2"; platform="windows"})\r | |
65 | description="Build with Python2 support"\r | |
66 | }\r | |
67 | }\r | |
68 | };\r | |
69 | "regex" = @{\r | |
70 | "features" = @{\r | |
71 | icu=@{\r | |
72 | dependencies=@("icu")\r | |
73 | description="ICU backend for Boost.Regex"\r | |
74 | }\r | |
75 | }\r | |
76 | }\r | |
77 | }\r | |
78 | \r | |
79 | function TransformReference()\r | |
80 | {\r | |
81 | param (\r | |
82 | [string]$library\r | |
83 | )\r | |
84 | \r | |
85 | if ($per_port_data[$library].supports)\r | |
86 | {\r | |
87 | @{name="boost-$library"; platform=$per_port_data[$library].supports}\r | |
88 | }\r | |
89 | else\r | |
90 | {\r | |
91 | "boost-$library"\r | |
92 | }\r | |
93 | }\r | |
94 | \r | |
95 | function Generate()\r | |
96 | {\r | |
97 | param (\r | |
98 | [string]$Name,\r | |
99 | [string]$PortName,\r | |
100 | [string]$Hash,\r | |
101 | [bool]$NeedsBuild,\r | |
102 | $Depends = @()\r | |
103 | )\r | |
104 | \r | |
105 | New-Item -ItemType "Directory" "$portsDir/boost-$PortName" -erroraction SilentlyContinue | out-null\r | |
106 | $controlLines = @{\r | |
107 | name="boost-$PortName"; `\r | |
108 | "version-string"=$version; `\r | |
109 | dependencies=$Depends; `\r | |
110 | homepage="https://github.com/boostorg/$Name"; `\r | |
111 | description="Boost $Name module" `\r | |
112 | }\r | |
113 | if ($port_versions[$PortName])\r | |
114 | {\r | |
115 | $controlLines["port-version"] = $port_versions[$PortName]\r | |
116 | }\r | |
117 | elseif ($NeedsBuild)\r | |
118 | {\r | |
119 | # This can be removed on next update; this is used to track the host dependencies change\r | |
120 | $controlLines["port-version"] = 1\r | |
121 | }\r | |
122 | \r | |
123 | if ($per_port_data[$PortName])\r | |
124 | {\r | |
125 | $controlLines += $per_port_data[$PortName]\r | |
126 | }\r | |
127 | $controlLines | ConvertTo-Json -Depth 10 -Compress | out-file -enc ascii "$portsDir/boost-$PortName/vcpkg.json"\r | |
128 | & $vcpkg format-manifest "$portsDir/boost-$PortName/vcpkg.json"\r | |
129 | \r | |
130 | $portfileLines = @(\r | |
131 | "# Automatically generated by scripts/boost/generate-ports.ps1"\r | |
132 | ""\r | |
133 | )\r | |
134 | \r | |
135 | if ($PortName -eq "system")\r | |
136 | {\r | |
137 | $portfileLines += @(\r | |
138 | "vcpkg_buildpath_length_warning(37)"\r | |
139 | ""\r | |
140 | )\r | |
141 | }\r | |
142 | \r | |
143 | $portfileLines += @(\r | |
144 | "vcpkg_from_github("\r | |
145 | " OUT_SOURCE_PATH SOURCE_PATH"\r | |
146 | " REPO boostorg/$Name"\r | |
147 | " REF boost-$version"\r | |
148 | " SHA512 $Hash"\r | |
149 | " HEAD_REF master"\r | |
150 | )\r | |
151 | $patches = Get-ChildItem $portsDir/boost-$PortName/*.patch\r | |
152 | if ($patches.Count -eq 0)\r | |
153 | {\r | |
154 | }\r | |
155 | elseif ($patches.Count -eq 1)\r | |
156 | {\r | |
157 | $portfileLines += @(" PATCHES $($patches.name)")\r | |
158 | }\r | |
159 | else\r | |
160 | {\r | |
161 | $portfileLines += @(" PATCHES")\r | |
162 | foreach ($patch in $patches)\r | |
163 | {\r | |
164 | $portfileLines += @(" $($patch.name)")\r | |
165 | }\r | |
166 | }\r | |
167 | $portfileLines += @(\r | |
168 | ")"\r | |
169 | ""\r | |
170 | )\r | |
171 | \r | |
172 | if (Test-Path "$scriptsDir/post-source-stubs/$PortName.cmake")\r | |
173 | {\r | |
174 | $portfileLines += @(get-content "$scriptsDir/post-source-stubs/$PortName.cmake")\r | |
175 | }\r | |
176 | \r | |
177 | if ($NeedsBuild)\r | |
178 | {\r | |
179 | $portfileLines += @(\r | |
180 | "if(NOT DEFINED CURRENT_HOST_INSTALLED_DIR)"\r | |
181 | " message(FATAL_ERROR `"boost-$PortName requires a newer version of vcpkg in order to build.`")"\r | |
182 | "endif()"\r | |
183 | "include(`${CURRENT_HOST_INSTALLED_DIR}/share/boost-build/boost-modular-build.cmake)"\r | |
184 | )\r | |
185 | # b2-options.cmake contains port-specific build options\r | |
186 | if (Test-Path "$portsDir/boost-$PortName/b2-options.cmake")\r | |
187 | {\r | |
188 | $portfileLines += @(\r | |
189 | "boost_modular_build("\r | |
190 | " SOURCE_PATH `${SOURCE_PATH}"\r | |
191 | " BOOST_CMAKE_FRAGMENT `"`${CMAKE_CURRENT_LIST_DIR}/b2-options.cmake`""\r | |
192 | ")"\r | |
193 | )\r | |
194 | }\r | |
195 | elseif (Test-Path "$portsDir/boost-$PortName/b2-options.cmake.in")\r | |
196 | {\r | |
197 | $portfileLines += @(\r | |
198 | 'configure_file('\r | |
199 | ' "${CMAKE_CURRENT_LIST_DIR}/b2-options.cmake.in"'\r | |
200 | ' "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake"'\r | |
201 | ' @ONLY'\r | |
202 | ')'\r | |
203 | 'boost_modular_build('\r | |
204 | ' SOURCE_PATH ${SOURCE_PATH}'\r | |
205 | ' BOOST_CMAKE_FRAGMENT "${CURRENT_BUILDTREES_DIR}/vcpkg-b2-options.cmake"'\r | |
206 | ')'\r | |
207 | )\r | |
208 | }\r | |
209 | else\r | |
210 | {\r | |
211 | $portfileLines += @(\r | |
212 | "boost_modular_build(SOURCE_PATH `${SOURCE_PATH})"\r | |
213 | )\r | |
214 | }\r | |
215 | }\r | |
216 | \r | |
217 | $portfileLines += @(\r | |
218 | "include(`${CURRENT_INSTALLED_DIR}/share/boost-vcpkg-helpers/boost-modular-headers.cmake)"\r | |
219 | "boost_modular_headers(SOURCE_PATH `${SOURCE_PATH})"\r | |
220 | )\r | |
221 | \r | |
222 | if (Test-Path "$scriptsDir/post-build-stubs/$PortName.cmake")\r | |
223 | {\r | |
224 | $portfileLines += @(get-content "$scriptsDir/post-build-stubs/$PortName.cmake")\r | |
225 | }\r | |
226 | \r | |
227 | $portfileLines += @("")\r | |
228 | $($portfileLines -join "`r`n") | out-file -enc ascii "$portsDir/boost-$PortName/portfile.cmake" -NoNewline\r | |
229 | }\r | |
230 | \r | |
231 | if (!(Test-Path "$scriptsDir/boost"))\r | |
232 | {\r | |
233 | "Cloning boost..."\r | |
234 | pushd $scriptsDir\r | |
235 | try\r | |
236 | {\r | |
237 | git clone https://github.com/boostorg/boost --branch boost-$version\r | |
238 | }\r | |
239 | finally\r | |
240 | {\r | |
241 | popd\r | |
242 | }\r | |
243 | }\r | |
244 | else\r | |
245 | {\r | |
246 | pushd $scriptsDir/boost\r | |
247 | try\r | |
248 | {\r | |
249 | git fetch\r | |
250 | git checkout -f boost-$version\r | |
251 | }\r | |
252 | finally\r | |
253 | {\r | |
254 | popd\r | |
255 | }\r | |
256 | }\r | |
257 | \r | |
258 | $libraries_found = Get-ChildItem $scriptsDir/boost/libs -directory | % name | % {\r | |
259 | if ($_ -match "numeric")\r | |
260 | {\r | |
261 | "numeric_conversion"\r | |
262 | "interval"\r | |
263 | "odeint"\r | |
264 | "ublas"\r | |
265 | "safe_numerics"\r | |
266 | }\r | |
267 | elseif ($_ -eq "headers")\r | |
268 | {\r | |
269 | }\r | |
270 | else\r | |
271 | {\r | |
272 | $_\r | |
273 | }\r | |
274 | }\r | |
275 | \r | |
276 | New-Item -ItemType "Directory" $scriptsDir/downloads -erroraction SilentlyContinue | out-null\r | |
277 | \r | |
278 | if ($libraries.Length -eq 0)\r | |
279 | {\r | |
280 | $libraries = $libraries_found\r | |
281 | }\r | |
282 | \r | |
283 | $libraries_in_boost_port = @()\r | |
284 | \r | |
285 | foreach ($library in $libraries)\r | |
286 | {\r | |
287 | "Handling boost/$library..."\r | |
288 | $archive = "$scriptsDir/downloads/$library-boost-$version.tar.gz"\r | |
289 | if (!(Test-Path $archive))\r | |
290 | {\r | |
291 | "Downloading boost/$library..."\r | |
292 | & $curl -L "https://github.com/boostorg/$library/archive/boost-$version.tar.gz" --output "$scriptsDir/downloads/$library-boost-$version.tar.gz"\r | |
293 | }\r | |
294 | $hash = & $vcpkg hash $archive\r | |
295 | $unpacked = "$scriptsDir/libs/$library-boost-$version"\r | |
296 | if (!(Test-Path $unpacked))\r | |
297 | {\r | |
298 | "Unpacking boost/$library..."\r | |
299 | New-Item -ItemType "Directory" $scriptsDir/libs -erroraction SilentlyContinue | out-null\r | |
300 | pushd $scriptsDir/libs\r | |
301 | try\r | |
302 | {\r | |
303 | cmake -E tar xf $archive\r | |
304 | }\r | |
305 | finally\r | |
306 | {\r | |
307 | popd\r | |
308 | }\r | |
309 | }\r | |
310 | pushd $unpacked\r | |
311 | try\r | |
312 | {\r | |
313 | if ($IsWindows)\r | |
314 | {\r | |
315 | $groups = $(\r | |
316 | findstr /si /C:"include <boost/" include/*\r | |
317 | findstr /si /C:"include <boost/" src/*\r | |
318 | ) | % { $_ -replace "^[^:]*:","" }\r | |
319 | }\r | |
320 | else\r | |
321 | {\r | |
322 | $groups = $(\r | |
323 | grep -irhs "include <boost/" include src\r | |
324 | )\r | |
325 | }\r | |
326 | \r | |
327 | $groups = $groups |\r | |
328 | % { $_ `\r | |
329 | -replace "boost/numeric/conversion/","boost/numeric_conversion/" `\r | |
330 | -replace "boost/functional/hash.hpp","boost/container_hash/hash.hpp" `\r | |
331 | -replace "boost/detail/([^/]+)/","boost/`$1/" `\r | |
332 | -replace " *# *include *<boost/([a-zA-Z0-9\._]*)(/|>).*", "`$1" `\r | |
333 | -replace "/|\.hp?p?| ","" } | group | % name | % {\r | |
334 | # mappings\r | |
335 | Write-Verbose "${library}: $_"\r | |
336 | if ($_ -match "aligned_storage") { "type_traits" }\r | |
337 | elseif ($_ -match "noncopyable|ref|swap|get_pointer|checked_delete|visit_each") { "core" }\r | |
338 | elseif ($_ -eq "type") { "core" }\r | |
339 | elseif ($_ -match "concept|concept_archetype") { "concept_check" }\r | |
340 | elseif ($_ -match "unordered_") { "unordered" }\r | |
341 | elseif ($_ -match "cstdint|integer_fwd|integer_traits") { "integer" }\r | |
342 | elseif ($_ -match "call_traits|operators|current_function|cstdlib|next_prior|compressed_pair") { "utility" }\r | |
343 | elseif ($_ -match "^version|^workaround") { "config" }\r | |
344 | 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" }\r | |
345 | elseif ($_ -match "iterator_adaptors|generator_iterator|pointee") { "iterator" }\r | |
346 | elseif ($_ -eq "regex_fwd") { "regex" }\r | |
347 | elseif ($_ -eq "make_default") { "convert" }\r | |
348 | elseif ($_ -eq "foreach_fwd") { "foreach" }\r | |
349 | elseif ($_ -eq "cerrno") { "system" }\r | |
350 | elseif ($_ -eq "circular_buffer_fwd") { "circular_buffer" }\r | |
351 | elseif ($_ -eq "archive") { "serialization" }\r | |
352 | elseif ($_ -match "none|none_t") { "optional" }\r | |
353 | elseif ($_ -eq "limits") { "compatibility" }\r | |
354 | elseif ($_ -match "cstdfloat|math_fwd") { "math" }\r | |
355 | elseif ($_ -eq "cast") { "conversion"; "numeric_conversion" } # DEPRECATED header file, includes <boost/polymorphic_cast.hpp> and <boost/numeric/conversion/cast.hpp>\r | |
356 | elseif ($_ -match "polymorphic_cast|implicit_cast") { "conversion" }\r | |
357 | elseif ($_ -eq "nondet_random") { "random" }\r | |
358 | elseif ($_ -eq "memory_order") { "atomic" }\r | |
359 | elseif ($_ -match "blank|blank_fwd|numeric_traits|fenv") { "detail" }\r | |
360 | elseif ($_ -match "is_placeholder|mem_fn") { "bind" }\r | |
361 | elseif ($_ -eq "exception_ptr") { "exception" }\r | |
362 | elseif ($_ -match "multi_index_container|multi_index_container_fwd") { "multi_index" }\r | |
363 | elseif ($_ -eq "lexical_cast") { "lexical_cast"; "math" }\r | |
364 | elseif ($_ -match "token_iterator|token_functions") { "tokenizer" }\r | |
365 | elseif ($_ -eq "numeric" -and $library -notmatch "numeric_conversion|interval|odeint|ublas") { "numeric_conversion"; "interval"; "odeint"; "ublas" }\r | |
366 | elseif ($_ -eq "io_fwd") { "io" }\r | |
367 | else { $_ }\r | |
368 | } | group | % name | ? { $_ -ne $library }\r | |
369 | \r | |
370 | #"`nFor ${library}:"\r | |
371 | " [known] " + $($groups | ? { $libraries_found -contains $_ })\r | |
372 | " [unknown] " + $($groups | ? { $libraries_found -notcontains $_ })\r | |
373 | \r | |
374 | $deps = @($groups | ? { $libraries_found -contains $_ })\r | |
375 | \r | |
376 | $deps = @($deps | ? {\r | |
377 | # Boost contains cycles, so remove a few dependencies to break the loop.\r | |
378 | (($library -notmatch "core|assert|mpl|detail|throw_exception|type_traits|^exception") -or ($_ -notmatch "utility")) `\r | |
379 | -and `\r | |
380 | (($library -notmatch "assert") -or ($_ -notmatch "integer"))`\r | |
381 | -and `\r | |
382 | (($library -notmatch "range") -or ($_ -notmatch "algorithm"))`\r | |
383 | -and `\r | |
384 | (($library -ne "config") -or ($_ -notmatch "integer"))`\r | |
385 | -and `\r | |
386 | (($library -notmatch "multiprecision") -or ($_ -notmatch "random|math"))`\r | |
387 | -and `\r | |
388 | (($library -notmatch "lexical_cast") -or ($_ -notmatch "math"))`\r | |
389 | -and `\r | |
390 | (($library -notmatch "functional") -or ($_ -notmatch "function"))`\r | |
391 | -and `\r | |
392 | (($library -notmatch "detail") -or ($_ -notmatch "static_assert|integer|mpl|type_traits"))`\r | |
393 | -and `\r | |
394 | ($_ -notmatch "mpi")`\r | |
395 | -and `\r | |
396 | (($library -notmatch "spirit") -or ($_ -notmatch "serialization"))`\r | |
397 | -and `\r | |
398 | (($library -notmatch "throw_exception") -or ($_ -notmatch "^exception"))`\r | |
399 | -and `\r | |
400 | (($library -notmatch "iostreams|math") -or ($_ -notmatch "random"))`\r | |
401 | -and `\r | |
402 | (($library -notmatch "utility|concept_check") -or ($_ -notmatch "iterator"))\r | |
403 | } | % { $_ -replace "_","-" } | % { TransformReference $_ })\r | |
404 | \r | |
405 | $deps += @("boost-vcpkg-helpers")\r | |
406 | \r | |
407 | $needsBuild = $false\r | |
408 | if ((Test-Path $unpacked/build/Jamfile.v2) -and $library -ne "metaparse" -and $library -ne "graph_parallel")\r | |
409 | {\r | |
410 | $deps += @(\r | |
411 | @{ name="boost-build"; host=$True },\r | |
412 | @{ name="boost-modular-build-helper"; host=$True }\r | |
413 | )\r | |
414 | $needsBuild = $true\r | |
415 | }\r | |
416 | \r | |
417 | if ($library -eq "python")\r | |
418 | {\r | |
419 | $deps += @("python3")\r | |
420 | $needsBuild = $true\r | |
421 | }\r | |
422 | elseif ($library -eq "iostreams")\r | |
423 | {\r | |
424 | $deps += @("zlib", "bzip2", "liblzma", "zstd")\r | |
425 | }\r | |
426 | elseif ($library -eq "locale")\r | |
427 | {\r | |
428 | $deps += @(@{ name="libiconv"; platform="!uwp&!windows&!mingw" }, "boost-system")\r | |
429 | }\r | |
430 | elseif ($library -eq "asio")\r | |
431 | {\r | |
432 | $deps += @("openssl")\r | |
433 | }\r | |
434 | elseif ($library -eq "mpi")\r | |
435 | {\r | |
436 | $deps += @("mpi")\r | |
437 | }\r | |
438 | \r | |
439 | $portName = $library -replace "_","-"\r | |
440 | \r | |
441 | Generate `\r | |
442 | -Name $library `\r | |
443 | -PortName $portName `\r | |
444 | -Hash $hash `\r | |
445 | -Depends $deps `\r | |
446 | -NeedsBuild $needsBuild\r | |
447 | \r | |
448 | $libraries_in_boost_port += @(TransformReference $portName)\r | |
449 | }\r | |
450 | finally\r | |
451 | {\r | |
452 | popd\r | |
453 | }\r | |
454 | }\r | |
455 | \r | |
456 | if ($libraries_in_boost_port.length -gt 1) {\r | |
457 | # Generate master boost control file which depends on each individual library\r | |
458 | # mpi is excluded due to it having a dependency on msmpi/openmpi\r | |
459 | $boostDependsList = $libraries_in_boost_port | ? { $_ -notmatch "boost-mpi" }\r | |
460 | \r | |
461 | @{\r | |
462 | name="boost";\r | |
463 | "version-string"=$version;\r | |
464 | "port-version"= $port_versions.boost ? $port_versions.boost : 0;\r | |
465 | homepage="https://boost.org";\r | |
466 | description="Peer-reviewed portable C++ source libraries";\r | |
467 | dependencies=$boostDependsList;\r | |
468 | features=@(\r | |
469 | @{\r | |
470 | name="mpi";\r | |
471 | description="Build with MPI support";\r | |
472 | dependencies=@("boost-mpi");\r | |
473 | }\r | |
474 | );\r | |
475 | } | ConvertTo-Json -Depth 10 -Compress | out-file -enc ascii $portsDir/boost/vcpkg.json\r | |
476 | & $vcpkg format-manifest "$portsDir/boost/vcpkg.json"\r | |
477 | \r | |
478 | "set(VCPKG_POLICY_EMPTY_PACKAGE enabled)`n" | out-file -enc ascii $portsDir/boost/portfile.cmake\r | |
479 | }\r | |
480 | \r | |
481 | return\r |