diff --git a/AMBuildScript b/AMBuildScript index b79987f86..1a335dbcb 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -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 += [ @@ -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') @@ -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() @@ -520,7 +549,6 @@ class SourcePawn(object): builder.cxx = None return rvalue - if builder.parent is None: root = Config() root.configure()