Skip to content

Commit f86231a

Browse files
authored
[Runner] Generate some fake XCode tools which are occasionally needed (#216)
* [Runner] Generate some fake XCode tools which are occasionally needed * [Runner] Implement more arguments for `sw_vers`
1 parent e7286d0 commit f86231a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Runner.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,39 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
802802
for tool in default_tools
803803
symlink("$(target)-$(tool)", joinpath(bin_path, triplet(platform), tool))
804804
end
805+
806+
# Generate other fake system-specific tools.
807+
if os(platform) == "macos"
808+
# `sw_vers -productVersion` is needed to make CMake correctly initialise the macOS
809+
# platform, ref: <https://github.com/JuliaPackaging/Yggdrasil/pull/4403>. In the
810+
# future we may add more arguments, see
811+
# <https://www.unix.com/man-page/osx/1/sw_vers/> for reference.
812+
product_version = macos_version(platform)
813+
product_name = VersionNumber(product_version) < v"10.12" ? "Mac OS X" : "macOS"
814+
sw_vers_path = joinpath(bin_path, triplet(platform), "sw_vers")
815+
write(sw_vers_path, """
816+
#!/bin/sh
817+
if [[ -z "\${@}" ]]; then
818+
echo "ProductName: $(product_name)"
819+
echo "ProductVersion: $(product_version)"
820+
elif [[ "\${@}" == "-productName" ]]; then
821+
echo "$(product_name)"
822+
elif [[ "\${@}" == "-productVersion" ]]; then
823+
echo "$(product_version)"
824+
fi
825+
""")
826+
chmod(sw_vers_path, 0o775)
827+
828+
# `xcrun` is another macOS-specific tool, which is occasionally needed to run some
829+
# commands, for example for the CGO linker. Ref:
830+
# <https://github.com/JuliaPackaging/Yggdrasil/pull/2962>.
831+
xcrun_path = joinpath(bin_path, triplet(platform), "xcrun")
832+
write(xcrun_path, """
833+
#!/bin/sh
834+
exec "\${@}"
835+
""")
836+
chmod(xcrun_path, 0o775)
837+
end
805838
end
806839

807840
# Translation mappers for our target names to cargo-compatible ones. See

0 commit comments

Comments
 (0)