Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize Sample Extensions's AMBuildScript #2107

Merged
merged 8 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
461 changes: 205 additions & 256 deletions public/sample_ext/AMBuildScript

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions public/sample_ext/AMBuilder
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os, sys
import os

# Name of your extesion, this will also be it's file name.
projectName = 'sample'

# smsdk_ext.cpp will be automatically added later
sourceFiles = [
'extension.cpp',
]

###############
# Make sure to edit PackageScript, which copies your files to their appropriate locations
# Simple extensions do not need to modify past this point.

project = Extension.HL2Project(builder, projectName + '.ext')
project = builder.LibraryProject(projectName)

if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')):
# Use the copy included in the project
Expand All @@ -22,10 +19,16 @@ else:
project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')]

project.sources += sourceFiles

for sdk_name in Extension.sdks:
sdk = Extension.sdks[sdk_name]

binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk)
if sdk['name'] in ['mock']:
continue

for cxx in builder.targets:
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
continue

binary = Extension.HL2ExtConfig(project, builder, cxx, projectName + '.ext.' + sdk['extension'], sdk)

Extension.extensions = builder.Add(project)
Extension.extensions += builder.Add(project)
10 changes: 9 additions & 1 deletion public/sample_ext/PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ folder_list = [
#'addons/sourcemod/configs',
]

if 'x86_64' in Extension.target_archs:
folder_list.extend([
'addons/sourcemod/extensions/x64',
])

# Create the distribution folder hierarchy.
folder_map = {}
for folder in folder_list:
Expand Down Expand Up @@ -49,4 +54,7 @@ def CopyFiles(src, dest, files):

# Copy binaries.
for cxx_task in Extension.extensions:
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions'])
if cxx_task.target.arch == 'x86_64':
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions/x64'])
else:
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions'])
30 changes: 17 additions & 13 deletions public/sample_ext/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@

# Simple extensions do not need to modify this file.

builder = run.PrepareBuild(sourcePath = sys.path[0])

builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')
builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None,
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
parser.options.add_argument('--hl2sdk-manifest-path', type=str, dest='hl2sdk_manifest', default=None,
help='Path to HL2SDK Manifests')
parser.options.add_argument('--sm-path', type=str, dest='sm_path', default=None,
help='Path to SourceMod')
builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')

parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
help='Enable debugging symbols')
builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization')
builder.options.add_option('-s', '--sdks', default='all', dest='sdks',
help='Build against specified SDKs; valid args are "all", "present", or '
'comma-delimited list of engine names (default: %default)')
parser.options.add_argument('-s', '--sdks', default='present', dest='sdks',
help='Build against specified SDKs; valid args are "none", "all", "present",'
' 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).")
parser.Configure()

builder.Configure()
Loading