1
- export build_tarballs, autobuild, print_artifacts_toml, build, get_meta_json
1
+ export build_tarballs, autobuild, print_artifacts_toml, build, get_meta_json, preferred_platform_compiler, set_preferred_compiler_version!
2
2
import GitHub: gh_get_json, DEFAULT_API
3
3
import SHA: sha256, sha1
4
4
using TOML, Dates, UUIDs
@@ -720,6 +720,49 @@ function compose_debug_prompt(workspace)
720
720
return debug_shell_prompt
721
721
end
722
722
723
+ """
724
+ preferred_platform_compiler(platforms::Vector{<:Platform}, version::Union{Nothing,VersionNumber}=nothing)
725
+
726
+ Initializes a dictionary with an entry for every platform given
727
+ that will store platform-specific compiler versions (if any).
728
+ """
729
+ function preferred_platform_compiler (platforms:: Vector{<:Platform} , version:: Union{Nothing,VersionNumber} = nothing )
730
+ compiler_versions = Dict {Platform, Union{Nothing,VersionNumber}} (p => version for p in platforms)
731
+ return compiler_versions
732
+ end
733
+
734
+ """
735
+ set_preferred_compiler_version!(compiler_versions::Dict{Platform, Union{Nothing,VersionNumber}},
736
+ version::VersionNumber,
737
+ selector::Union{Vector{<:Platform},Function})
738
+
739
+ Set the preferred compiler version for the platforms matching `selector` to `version`.
740
+ """
741
+ function set_preferred_compiler_version! (compiler_versions:: Dict{Platform, Union{Nothing,VersionNumber}} ,
742
+ version:: VersionNumber ,
743
+ selector:: Union{Vector{<:Platform},Function} )
744
+ matching_platform (selector:: Function , platform) = selector (platform)
745
+ matching_platform (selector:: Vector{<:Platform} , platform) = platform in selector
746
+
747
+ for (platform, compiler) in compiler_versions
748
+ if matching_platform (selector, platform)
749
+ compiler_versions[platform] = version
750
+ end
751
+ end
752
+
753
+ return compiler_versions
754
+ end
755
+
756
+ function get_platform_compiler_version! (compiler_args, key, platform, version)
757
+ if version isa VersionNumber
758
+ compiler_args[key] = version
759
+ elseif version isa Dict
760
+ if ! isnothing (version[platform])
761
+ compiler_args[key] = version[platform]
762
+ end
763
+ end
764
+ end
765
+
723
766
"""
724
767
autobuild(dir::AbstractString, src_name::AbstractString,
725
768
src_version::VersionNumber, sources::Vector,
@@ -823,11 +866,17 @@ function autobuild(dir::AbstractString,
823
866
timer = BuildTimer ()
824
867
timer. begin_setup = time ()
825
868
869
+ compiler_args = Dict ()
870
+
871
+ for (k, v) in extract_kwargs (kwargs, (:preferred_gcc_version ,:preferred_llvm_version ,:preferred_rust_version ,:preferred_go_version ))
872
+ get_platform_compiler_version! (compiler_args, k, platform, kwargs[k])
873
+ end
874
+
826
875
# We build in a platform-specific directory
827
876
build_path = joinpath (dir, " build" , triplet (platform))
828
877
mkpath (build_path)
829
878
830
- shards = choose_shards (platform; extract_kwargs (kwargs, (:preferred_gcc_version , :preferred_llvm_version , :preferred_rust_version , :preferred_go_version , :bootstrap_list ,:compilers ))... )
879
+ shards = choose_shards (platform; compiler_args ... , extract_kwargs (kwargs, (:bootstrap_list ,:compilers ))... )
831
880
concrete_platform = get_concrete_platform (platform, shards)
832
881
833
882
prefix = setup_workspace (
@@ -854,7 +903,8 @@ function autobuild(dir::AbstractString,
854
903
compiler_wrapper_dir = joinpath (prefix, " compiler_wrappers" ),
855
904
src_name = src_name,
856
905
shards = shards,
857
- extract_kwargs (kwargs, (:preferred_gcc_version ,:preferred_llvm_version ,:compilers ,:allow_unsafe_flags ,:lock_microarchitecture ,:clang_use_lld ))... ,
906
+ compiler_args... ,
907
+ extract_kwargs (kwargs, (:compilers ,:allow_unsafe_flags ,:lock_microarchitecture ,:clang_use_lld ))... ,
858
908
)
859
909
860
910
# Set up some bash traps
0 commit comments