Skip to content

Commit

Permalink
[Git] Improve builder so that it runs only for requested platfor… (#240)
Browse files Browse the repository at this point in the history
* [Git] Improve builder so that it runs only for requested platforms

* Add fancy toys under the  🌳 tree
  • Loading branch information
giordano authored and staticfloat committed Dec 4, 2019
1 parent d6436bc commit e7bf1d2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
17 changes: 14 additions & 3 deletions G/Git/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,19 @@ dependencies = [

# Install first for win32, then win64. This will accumulate files into `products` and also wrappers into the JLL package.
non_reg_ARGS = filter(arg -> arg != "--register", ARGS)
build_tarballs(non_reg_ARGS, name, version, sources_w32, script_win, [Windows(:i686)], products, [])
build_tarballs(non_reg_ARGS, name, version, sources_w64, script_win, [Windows(:x86_64)], products, [])

include("../../fancy_toys.jl")

if should_build_platform("i686-w64-mingw32")
build_tarballs(non_reg_ARGS, name, version, sources_w32, script_win, [Windows(:i686)], products, [])
end
if should_build_platform("x86_64-w64-mingw32")
build_tarballs(non_reg_ARGS, name, version, sources_w64, script_win, [Windows(:x86_64)], products, [])
end
# Then for everything else. This is the only one that we try to register, and this is the step that will open a PR against General
build_tarballs(ARGS, name, version, sources_unix, script_unix, filter(p -> !isa(p, Windows), supported_platforms()), products, dependencies)
platforms = filter!(p -> !isa(p, Windows), supported_platforms())
# Get the non-Windows platforms that have been actually requested
filter!(p -> should_build_platform(triplet(p)), platforms)
if !isempty(platforms)
build_tarballs(ARGS, name, version, sources_unix, script_unix, platforms, products, dependencies)
end
34 changes: 34 additions & 0 deletions fancy_toys.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is a collection of toys under the Yggdrasil tree for the good <s>kids</s>
# developers. These utilities can be employed in builder files.

using BinaryBuilder

"""
should_build_platform(platform) -> Bool
Return whether the tarballs for the given `platform` should be built.
This is useful when the builder has different platform-dependent elements
(sources, script, products, etc...) that make it hard to have a single
`build_tarballs` call.
"""
function should_build_platform(platform)
# If you need inspiration for how to use this function, look at the builder
# for Git.

# Get the list of platforms requested from the command line. This should be
# the only argument not prefixed with "--".
requested_platforms = filter(arg -> !occursin(r"^--.*", arg), ARGS)

if isone(length(requested_platforms))
# `requested_platforms` has only one element: the comma-separated list
# of platform. We'll run the platform only if it's in the list
return platform in split(requested_platforms[1], ",")
else
# `requested_platforms` doesn't have only one element: if its length is
# zero, no platform has been explicitely passed from the command line
# and we we'll run all platforms, otherwise we don't know what to do, so
# let's return false to be safe.
return iszero(length(requested_platforms))
end
end

0 comments on commit e7bf1d2

Please sign in to comment.