Fix macOS scripting SDK build.
This also enables universal spcomp binaries with arm64 support.
This commit is contained in:
parent
7bfd5e521e
commit
4b2d8b53fa
4
.github/workflows/scripting.yml
vendored
4
.github/workflows/scripting.yml
vendored
@ -41,9 +41,9 @@ jobs:
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install git+https://github.com/alliedmodders/ambuild
|
||||
|
||||
- name: Build only for x64 on macOS
|
||||
- name: Build universal x64/arm64 on macOS
|
||||
if: startsWith(runner.os, 'macOS')
|
||||
run: echo "ARCH=x86_64" >> $GITHUB_ENV
|
||||
run: echo "ARCH=x86_64,arm64" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: startsWith(runner.os, 'Linux')
|
||||
|
@ -123,7 +123,7 @@ class SMConfig(object):
|
||||
self.mms_root = None
|
||||
self.mysql_root = {}
|
||||
self.spcomp = None
|
||||
self.spcomp_bins = None
|
||||
self.spcomp_bins = []
|
||||
self.smx_files = {}
|
||||
self.versionlib = None
|
||||
self.all_targets = []
|
||||
@ -243,7 +243,14 @@ class SMConfig(object):
|
||||
def configure(self):
|
||||
builder.AddConfigureFile('pushbuild.txt')
|
||||
|
||||
if not set(self.target_archs).issubset(['x86', 'x86_64']):
|
||||
allowed_archs = ['x86_64']
|
||||
if builder.host.platform == 'mac':
|
||||
if getattr(builder.options, 'scripting_only', False):
|
||||
allowed_archs += ['arm64']
|
||||
else:
|
||||
allowed_archs += ['x86']
|
||||
|
||||
if not set(self.target_archs).issubset(allowed_archs):
|
||||
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
|
||||
|
||||
for cxx in self.all_targets:
|
||||
@ -313,9 +320,10 @@ class SMConfig(object):
|
||||
'-Wno-unused',
|
||||
'-Wno-switch',
|
||||
'-Wno-array-bounds',
|
||||
'-msse',
|
||||
'-fvisibility=hidden',
|
||||
]
|
||||
if cxx.target.arch in ['x86', 'x86_64']:
|
||||
cxx.cflags += ['-msse']
|
||||
|
||||
cxx.cxxflags += ['-std=c++17']
|
||||
|
||||
@ -462,9 +470,9 @@ class SMConfig(object):
|
||||
|
||||
def configure_mac(self, cxx):
|
||||
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.7']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.15']
|
||||
cxx.linkflags += [
|
||||
'-mmacosx-version-min=10.7',
|
||||
'-mmacosx-version-min=10.15',
|
||||
'-stdlib=libc++',
|
||||
'-lc++',
|
||||
]
|
||||
@ -810,11 +818,24 @@ SP = builder.Build('sourcepawn/AMBuildScript', {
|
||||
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
|
||||
'external_build': SP_build_parts,
|
||||
})
|
||||
if len(SP.spcomp) > 1:
|
||||
SM.spcomp = SP.spcomp['x86']
|
||||
else:
|
||||
SM.spcomp = SP.spcomp[list(SP.spcomp.keys())[0]]
|
||||
SM.spcomp_bins = list(SP.spcomp.values())
|
||||
|
||||
def IsBetterDefaultSpcomp(spcomp, other):
|
||||
if other is None:
|
||||
return True
|
||||
if spcomp.target.arch == 'universal':
|
||||
return True
|
||||
if other.target.arch == 'universal':
|
||||
return False
|
||||
return spcomp.target.arch == 'x86'
|
||||
|
||||
for spcomp in SP.spcomp:
|
||||
if IsBetterDefaultSpcomp(spcomp, SM.spcomp):
|
||||
SM.spcomp = spcomp
|
||||
SM.spcomp_bins.append(spcomp)
|
||||
|
||||
# If we have a universal binary, ignore all other spcomps.
|
||||
if SM.spcomp.target.arch == 'universal':
|
||||
SM.spcomp_bins = [SM.spcomp]
|
||||
|
||||
if not getattr(builder.options, 'scripting_only', False):
|
||||
for cxx in SM.all_targets:
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 032a9ac082a47b6a8c0231044ab295ae9d1b07b6
|
||||
Subproject commit d59a51b5741823903ecbe8c014632ee1f8aad65d
|
@ -14,25 +14,7 @@ class PackageHelpers:
|
||||
self.folder_map[folder] = self.builder.AddFolder(norm_folder)
|
||||
return self.folder_map
|
||||
|
||||
def lipo(self, binaries, outFolder):
|
||||
bins = []
|
||||
binPaths = []
|
||||
for b in binaries:
|
||||
bins.append(b.binary)
|
||||
binPaths.append(os.path.join(self.builder.buildPath, b.binary.path))
|
||||
argv = ['lipo', '-create']
|
||||
binary = os.path.basename(binPaths[0])
|
||||
outputPath = os.path.join(self.builder.buildPath, self.builder.buildFolder, outFolder, binary)
|
||||
self.builder.AddCommand(
|
||||
argv = argv + binPaths + ['-output', outputPath],
|
||||
inputs = bins,
|
||||
outputs = [os.path.join(outFolder, binary)],
|
||||
)
|
||||
|
||||
def CopySpcomp(self, target_folder):
|
||||
if self.builder.host.platform == 'mac' and len(SM.target_archs) > 1:
|
||||
self.lipo(SM.spcomp_bins, target_folder)
|
||||
else:
|
||||
for bin_task in SM.spcomp_bins:
|
||||
if bin_task.target.arch == 'x86_64':
|
||||
root, ext = os.path.splitext(os.path.basename(bin_task.binary.path))
|
||||
|
Loading…
Reference in New Issue
Block a user