Skip to content

Commit

Permalink
Fix plugin compilation stage for AMBuild 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nosoop committed Jul 11, 2024
1 parent 6ed2fdf commit 9666cfd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
25 changes: 21 additions & 4 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ExtensionConfig(object):
self.all_targets = []
self.target_archs = set()
self.libsafetyhook = {}
self.spcomp_bin = None
self.plugins = {}

if builder.options.targets:
target_archs = builder.options.targets.split(',')
Expand Down Expand Up @@ -142,13 +144,22 @@ class ExtensionConfig(object):
raise Exception('Could not find a source copy of SourceMod')
self.sm_root = Normalize(self.sm_root)

def detectSPCompiler(self):
if builder.options.no_plugins:
return
spcomp_path = builder.options.spcomp_path
if not spcomp_path or not os.path.isdir(spcomp_path):
spcomp_found = shutil.which("spcomp")
if not spcomp_found:
raise Exception('Could not find a path for spcomp')
self.spcomp_bin = shutil.which('spcomp', path = spcomp_path)
if not self.spcomp_bin:
raise Exception('Could not find spcomp')

def configure(self):

allowed_archs = ['x86','x86_64']

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:
self.configure_cxx(cxx)

Expand Down Expand Up @@ -332,7 +343,7 @@ class ExtensionConfig(object):

def configure_windows(self, cxx):
cxx.defines += ['WIN32', '_WINDOWS']

def LibraryBuilder(self, compiler, name):
binary = compiler.Library(name)
self.AddVersioning(binary)
Expand Down Expand Up @@ -449,6 +460,7 @@ class SafetyHookShim(object):

Extension = ExtensionConfig()
Extension.detectSDKs()
Extension.detectSPCompiler()
Extension.configure()

# we need to pull safetyhook in locally because ambuild does not take kindly to outside relpaths
Expand All @@ -468,6 +480,11 @@ BuildScripts = [
'extension/AMBuilder',
]

if not builder.options.no_plugins:
BuildScripts += [
'pawn/AMBuilder',
]

if builder.backend == 'amb2':
BuildScripts += [
'buildbot/PackageScript',
Expand Down
12 changes: 6 additions & 6 deletions buildbot/PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ folder_list = [
'addons/sourcemod/scripting/include',
]

# if Extension.plugins:
# folder_list += [
# 'addons/sourcemod/plugins/optional',
# ]
if Extension.plugins:
folder_list += [
'addons/sourcemod/plugins/optional',
]

# Create the distribution folder hierarchy.
folder_map = {}
Expand Down Expand Up @@ -60,5 +60,5 @@ for cxx_task in Extension.extensions:
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions'])

# Copy plugins
# for smx_file, smx_entry in Extension.plugins.items():
# builder.AddCopy(smx_entry, folder_map['addons/sourcemod/plugins/optional'])
for smx_file, smx_entry in Extension.plugins.items():
builder.AddCopy(smx_entry, folder_map['addons/sourcemod/plugins/optional'])
7 changes: 3 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
' or comma-delimited list of engine names')
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
help="Override the target architecture (use commas to separate multiple targets).")
# builder.options.add_option('--spcomp-path', type=str, dest='spcomp_path', default=None,
# help='Path to directory containing spcomp')
# builder.options.add_option('--no-plugins', action='store_true',
# help='Do not compile plugins')
parser.options.add_argument('--spcomp-path', type=str, dest='spcomp_path', default=None,
help='Path to directory containing spcomp')
parser.options.add_argument('--no-plugins', action='store_true', help='Do not compile plugins')
parser.Configure()
4 changes: 1 addition & 3 deletions pawn/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def build_plugin(script_path, smx_file):
)

# ???
(smx_command, smx_outputs) = result
out, *_ = smx_outputs
Extension.plugins[smx_file] = out
Extension.plugins[smx_file], *_ = result

for script_file in pluginFiles:
script_path = os.path.join(builder.currentSourcePath, script_file)
Expand Down

0 comments on commit 9666cfd

Please sign in to comment.