Hello, I am a relatively new Nim user who is seeking information that might layout a sequence of steps to build a macOS universal binary. I have reviewed some of the documentation about the compiler regarding Cross-compilation, but am struggling a bit on what steps to take.
Does anyone have any guidance or advice on how to do this?
Thank you kindly :-)
Here's one way, using NAKE (from Nimble):
import nake
const
ExeName = "hello"
ArmExe = ExeName & ".arm64"
X64Exe = ExeName & ".x64"
LipoExe = "/usr/bin/lipo"
ArmFlags = "-l:'-target arm64-apple-macos11' -t:'-target arm64-apple-macos11'"
X64Flags = "-l:'-target x86_64-apple-macos10.12' -t:'-target x86_64-apple-macos10.12'"
task "universal", "Create Universal Mac Binary (M1/Intel)":
if shell(nimExe, "c", ArmFlags, "-d:release", "-o:" & ArmExe, ExeName):
## do something useful here?
if shell(nimExe, "c", X64Flags, "-d:release", "-o:" & X64Exe, ExeName):
## do something useful here?
if shell(LipoExe, "-create", "-output", ExeName, ArmExe, X64Exe):
removeFile ArmExe
removeFile X64Exe
Of course change the 'ExeName' constant to the name of your source file (without the .nim extension).
Hope this Helps!
AIR.