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
|
python -m pip install --upgrade pip setuptools wheel
|
||||||
pip install git+https://github.com/alliedmodders/ambuild
|
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')
|
if: startsWith(runner.os, 'macOS')
|
||||||
run: echo "ARCH=x86_64" >> $GITHUB_ENV
|
run: echo "ARCH=x86_64,arm64" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
- name: Install Linux dependencies
|
||||||
if: startsWith(runner.os, 'Linux')
|
if: startsWith(runner.os, 'Linux')
|
||||||
|
@ -123,7 +123,7 @@ class SMConfig(object):
|
|||||||
self.mms_root = None
|
self.mms_root = None
|
||||||
self.mysql_root = {}
|
self.mysql_root = {}
|
||||||
self.spcomp = None
|
self.spcomp = None
|
||||||
self.spcomp_bins = None
|
self.spcomp_bins = []
|
||||||
self.smx_files = {}
|
self.smx_files = {}
|
||||||
self.versionlib = None
|
self.versionlib = None
|
||||||
self.all_targets = []
|
self.all_targets = []
|
||||||
@ -243,7 +243,14 @@ class SMConfig(object):
|
|||||||
def configure(self):
|
def configure(self):
|
||||||
builder.AddConfigureFile('pushbuild.txt')
|
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))
|
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
|
||||||
|
|
||||||
for cxx in self.all_targets:
|
for cxx in self.all_targets:
|
||||||
@ -313,9 +320,10 @@ class SMConfig(object):
|
|||||||
'-Wno-unused',
|
'-Wno-unused',
|
||||||
'-Wno-switch',
|
'-Wno-switch',
|
||||||
'-Wno-array-bounds',
|
'-Wno-array-bounds',
|
||||||
'-msse',
|
|
||||||
'-fvisibility=hidden',
|
'-fvisibility=hidden',
|
||||||
]
|
]
|
||||||
|
if cxx.target.arch in ['x86', 'x86_64']:
|
||||||
|
cxx.cflags += ['-msse']
|
||||||
|
|
||||||
cxx.cxxflags += ['-std=c++17']
|
cxx.cxxflags += ['-std=c++17']
|
||||||
|
|
||||||
@ -462,9 +470,9 @@ class SMConfig(object):
|
|||||||
|
|
||||||
def configure_mac(self, cxx):
|
def configure_mac(self, cxx):
|
||||||
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
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 += [
|
cxx.linkflags += [
|
||||||
'-mmacosx-version-min=10.7',
|
'-mmacosx-version-min=10.15',
|
||||||
'-stdlib=libc++',
|
'-stdlib=libc++',
|
||||||
'-lc++',
|
'-lc++',
|
||||||
]
|
]
|
||||||
@ -810,11 +818,24 @@ SP = builder.Build('sourcepawn/AMBuildScript', {
|
|||||||
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
|
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
|
||||||
'external_build': SP_build_parts,
|
'external_build': SP_build_parts,
|
||||||
})
|
})
|
||||||
if len(SP.spcomp) > 1:
|
|
||||||
SM.spcomp = SP.spcomp['x86']
|
def IsBetterDefaultSpcomp(spcomp, other):
|
||||||
else:
|
if other is None:
|
||||||
SM.spcomp = SP.spcomp[list(SP.spcomp.keys())[0]]
|
return True
|
||||||
SM.spcomp_bins = list(SP.spcomp.values())
|
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):
|
if not getattr(builder.options, 'scripting_only', False):
|
||||||
for cxx in SM.all_targets:
|
for cxx in SM.all_targets:
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 032a9ac082a47b6a8c0231044ab295ae9d1b07b6
|
Subproject commit d59a51b5741823903ecbe8c014632ee1f8aad65d
|
@ -14,32 +14,14 @@ class PackageHelpers:
|
|||||||
self.folder_map[folder] = self.builder.AddFolder(norm_folder)
|
self.folder_map[folder] = self.builder.AddFolder(norm_folder)
|
||||||
return self.folder_map
|
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):
|
def CopySpcomp(self, target_folder):
|
||||||
if self.builder.host.platform == 'mac' and len(SM.target_archs) > 1:
|
for bin_task in SM.spcomp_bins:
|
||||||
self.lipo(SM.spcomp_bins, target_folder)
|
if bin_task.target.arch == 'x86_64':
|
||||||
else:
|
root, ext = os.path.splitext(os.path.basename(bin_task.binary.path))
|
||||||
for bin_task in SM.spcomp_bins:
|
file = root + '64' + ext
|
||||||
if bin_task.target.arch == 'x86_64':
|
self.builder.AddCopy(bin_task.binary, os.path.join(target_folder, file))
|
||||||
root, ext = os.path.splitext(os.path.basename(bin_task.binary.path))
|
else:
|
||||||
file = root + '64' + ext
|
self.builder.AddCopy(bin_task.binary, self.folder_map[target_folder])
|
||||||
self.builder.AddCopy(bin_task.binary, os.path.join(target_folder, file))
|
|
||||||
else:
|
|
||||||
self.builder.AddCopy(bin_task.binary, self.folder_map[target_folder])
|
|
||||||
|
|
||||||
if self.builder.host.platform == 'windows':
|
if self.builder.host.platform == 'windows':
|
||||||
self.CopyFiles('tools/batchtool', target_folder, '.exe')
|
self.CopyFiles('tools/batchtool', target_folder, '.exe')
|
||||||
@ -70,4 +52,4 @@ class PackageHelpers:
|
|||||||
|
|
||||||
self.CopyFiles('plugins/include', target_folder, '.inc')
|
self.CopyFiles('plugins/include', target_folder, '.inc')
|
||||||
|
|
||||||
SM.package_helpers = PackageHelpers(builder)
|
SM.package_helpers = PackageHelpers(builder)
|
||||||
|
Loading…
Reference in New Issue
Block a user