mkxp-z/macos/Dependencies/setup
2021-01-03 03:07:06 -05:00

45 lines
1.3 KiB
Ruby
Executable file

#!/usr/bin/env ruby
HOST = `clang -dumpmachine`.strip
ARCH = HOST[/x86_64|arm64/]
def run_build(arch)
puts "Building all dependencies. This'll take a while.\n"
case arch
when "x86_64"
return system("make everything -f .Intel")
when "arm64"
code = system("make everything -f .AppleSilicon")
return code if !code
code = (system("arch -x86_64 make everything -f .Intel"))
return code if !code
return system("./make_macuniversal")
else
raise "Unsupported architecture"
end
end
def fix_steam(libpath)
# Don't need to do anything if it's already set to runpath
return 0 if (`otool -L #{libpath}`[/@rpath/])
puts "Patching Steamworks SDK...\n"
# Remove 32-bit code from the binary
if `lipo -info #{libpath}`[/i386/]
return 1 if !system("lipo -remove i386 #{libpath} -o #{libpath}")
end
# Set the install name to runpath
return 1 if !system("install_name_tool -id @rpath/libsteam_api.dylib #{libpath}")
# Resign
puts "Done.\n"
return (system("codesign -fs - #{libpath}") ? 0 : 1)
end
exitcode = run_build(ARCH) ? 0 : 1
exit(exitcode) if (exitcode != 0)
STEAM_LIB = "Frameworks/steam/sdk/redistributable_bin/osx/libsteam_api.dylib"
if File.exists?(STEAM_LIB)
exitcode = fix_steam(STEAM_LIB)
end
exit(exitcode)