Skip to content

Commit

Permalink
Build universal binaries for spcomp on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvander committed Nov 5, 2023
1 parent f4cef31 commit cfab14b
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ class SourcePawn(object):
for cxx in self.root.targets:
builder.CallBuilder(lambda builder: self.BuildCoreForArch(cxx, builder))

builder.CallBuilder(lambda builder: self.BuildFatSpcomp(builder))

def SetupBinForArch(self, binary, builder):
if binary.compiler.like('gcc'):
binary.compiler.cflags += [
Expand Down Expand Up @@ -430,7 +432,7 @@ class SourcePawn(object):
self.AddStaticLibraries(binary)

cppnodes = builder.Add(binary)
self.spcomp[builder.cxx.target.arch] = cppnodes
self.spcomp[builder.cxx.target] = cppnodes

def BuildSpshell(self, builder):
binary = self.root.Program(builder, 'spshell')
Expand Down Expand Up @@ -476,6 +478,33 @@ class SourcePawn(object):
if binary.compiler.linker.like('gcc') and binary.compiler.target.platform == 'linux':
binary.compiler.linkflags += ['-Wl,--end-group']

def BuildFatSpcomp(self, builder):
# Building fat binaries is currently only supported on macOS hosts
# building macOS targets.
if builder.host.platform != 'mac':
return

mac_targets = []
for target, spcomp in self.spcomp.items():
if target.platform == 'mac':
mac_targets.append(spcomp.binary)

if len(mac_targets) == 0:
return

lipo_argv = [
'lipo', '-create',
]
for spcomp in mac_targets:
lipo_argv += [os.path.join(builder.buildPath, spcomp.path)]
lipo_argv += ['-output', 'spcomp']

out = builder.AddCommand(inputs = mac_targets,
argv = lipo_argv,
outputs = ['spcomp'],
folder = builder.AddFolder('spcomp/mac-universal'))
self.spcomp['mac-universal'] = out

def BuildSuite(self):
self.BuildCore()

Expand Down Expand Up @@ -520,7 +549,6 @@ class SourcePawn(object):
builder.cxx = None
return rvalue


if builder.parent is None:
root = Config()
root.configure()
Expand Down

0 comments on commit cfab14b

Please sign in to comment.