@@ -358,6 +358,52 @@ Examples of builders that depend on other binaries include:
358
358
depends on ` Xorg_libxcb_jll ` , and ` Xorg_xtrans_jll ` at build- and run-time,
359
359
and on ` Xorg_xorgproto_jll ` and ` Xorg_util_macros_jll ` only at build-time.
360
360
361
+ ### Platform-dependent dependencies
362
+
363
+ By default, all dependencies are used for all platforms, but there are some
364
+ cases where a package requires some dependencies only on some platforms. You
365
+ can specify the platforms where a dependency is needed by passing the
366
+ ` platforms ` keyword argument to the dependency constructor, which is the vector
367
+ of ` AbstractPlatforms ` where the dependency should be used.
368
+
369
+ For example, assuming that the variable ` platforms ` holds the vector of the
370
+ platforms for which to build your package, you can specify that ` Package_jl ` is
371
+ required on all platforms excluding Windows one with
372
+
373
+ ``` julia
374
+ Dependency (" Package_jll" ; platforms= filter (! Sys. iswindows, platforms))
375
+ ```
376
+
377
+ The information that a dependency is only needed on some platforms is
378
+ transferred to the JLL package as well: the wrappers will load the
379
+ platform-dependent JLL dependencies only when needed.
380
+
381
+ !!! warning
382
+
383
+ Julia's package manager doesn't have the concept of optional (or
384
+ platform-dependent) dependencies: this means that when installing a JLL
385
+ package in your environment, all of its dependencies will always be
386
+ installed as well in any case. It's only at runtime that platform-specific
387
+ dependencies will be loaded where necessary.
388
+
389
+ For the same reason, even if you specify a dependency to be not needed on
390
+ for a platform, the build recipe may still pull it in if that's also an
391
+ indirect dependency required by some other dependencies. At the moment
392
+ `BinaryBuilder.jl` isn't able to propagate the information that a dependency
393
+ is platform-dependent when installing the artifacts of the dependencies.
394
+
395
+ Examples:
396
+
397
+ * [ ` ADIOS2 ` ] ( https://github.com/JuliaPackaging/Yggdrasil/blob/0528e0f31b55355df632c79a2784621583443d9c/A/ADIOS2/build_tarballs.jl#L122-L123 )
398
+ uses ` MPICH_jll ` to provide an MPI implementations on all platforms excluding
399
+ Windows, and ` MicrosoftMPI_jll ` for Windows.
400
+ * [ ` GTK3 ` ] ( https://github.com/JuliaPackaging/Yggdrasil/blob/0528e0f31b55355df632c79a2784621583443d9c/G/GTK3/build_tarballs.jl#L70-L104 )
401
+ uses the X11 software stack only on Linux and FreeBSD platforms, and Wayland
402
+ only on Linux.
403
+ * [ ` NativeFileDialog ` ] ( https://github.com/JuliaPackaging/Yggdrasil/blob/0528e0f31b55355df632c79a2784621583443d9c/N/NativeFileDialog/build_tarballs.jl#L40-L44 )
404
+ uses GTK3 only on Linux and FreeBSD, on all other platforms it uses system
405
+ libraries, so no other packages are needed in those cases.
406
+
361
407
### Version number of dependencies
362
408
363
409
There are two different ways to specify the version of a dependency, with two
0 commit comments