Merge pull request #21 from alliedmodders/components
Convert build scripts to the new project-based API.
This commit is contained in:
commit
195104487e
@ -75,6 +75,12 @@ class SMConfig(object):
|
||||
def use_auto_versioning(self):
|
||||
return builder.backend == 'amb2'
|
||||
|
||||
@property
|
||||
def tag(self):
|
||||
if builder.options.debug == '1':
|
||||
return 'Debug'
|
||||
return 'Release'
|
||||
|
||||
def detectProductVersion(self):
|
||||
builder.AddConfigureFile('product.version')
|
||||
|
||||
@ -275,8 +281,7 @@ class SMConfig(object):
|
||||
cxx.includes += [os.path.join(builder.buildPath, 'includes')]
|
||||
cxx.includes += [os.path.join(builder.sourcePath, 'versionlib')]
|
||||
|
||||
def LibraryBuilder(self, compiler, name):
|
||||
binary = compiler.Library(name)
|
||||
def AddVersioning(self, binary):
|
||||
if builder.target_platform == 'windows':
|
||||
binary.sources += ['version.rc']
|
||||
binary.compiler.rcdefines += [
|
||||
@ -286,40 +291,25 @@ class SMConfig(object):
|
||||
if self.use_auto_versioning():
|
||||
binary.compiler.rcdefines += ['SM_GENERATED_BUILD']
|
||||
elif builder.target_platform == 'mac':
|
||||
binary.compiler.postlink += [
|
||||
'-compatibility_version', '1.0.0',
|
||||
'-current_version', self.productVersion
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
binary.compiler.linkflags += [self.versionlib]
|
||||
binary.compiler.sourcedeps += SM.generated_headers
|
||||
return binary
|
||||
|
||||
def ProgramBuilder(self, compiler, name):
|
||||
binary = compiler.Program(name)
|
||||
if builder.target_platform == 'windows':
|
||||
binary.sources += ['version.rc']
|
||||
binary.compiler.rcdefines += [
|
||||
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
||||
'RC_COMPILE',
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
binary.compiler.rcdefines += ['SM_GENERATED_BUILD']
|
||||
if binary.type == 'library':
|
||||
binary.compiler.postlink += [
|
||||
'-compatibility_version', '1.0.0',
|
||||
'-current_version', self.productVersion
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
binary.compiler.linkflags += [self.versionlib]
|
||||
binary.compiler.sourcedeps += SM.generated_headers
|
||||
return binary
|
||||
|
||||
def Library(self, context, name):
|
||||
compiler = context.compiler.clone()
|
||||
return self.LibraryBuilder(compiler, name)
|
||||
binary = context.compiler.Library(name)
|
||||
return self.AddVersioning(binary)
|
||||
|
||||
def Program(self, context, name):
|
||||
compiler = context.compiler.clone()
|
||||
return self.ProgramBuilder(compiler, name)
|
||||
binary = context.compiler.Program(name)
|
||||
return self.AddVersioning(binary)
|
||||
|
||||
def ExtCompiler(self, context):
|
||||
compiler = context.compiler.clone()
|
||||
def ConfigureForExtension(self, context, compiler):
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(context.currentSourcePath),
|
||||
os.path.join(context.currentSourcePath, 'sdk'),
|
||||
@ -330,8 +320,13 @@ class SMConfig(object):
|
||||
]
|
||||
return compiler
|
||||
|
||||
def HL2Compiler(self, context, sdk):
|
||||
compiler = self.ExtCompiler(context)
|
||||
def ExtLibrary(self, context, name):
|
||||
binary = context.compiler.Library(name)
|
||||
self.ConfigureForExtension(context, binary.compiler)
|
||||
return self.AddVersioning(binary)
|
||||
|
||||
def ConfigureForHL2(self, binary, sdk):
|
||||
compiler = binary.compiler
|
||||
|
||||
if sdk.name == 'episode1':
|
||||
mms_path = os.path.join(self.mms_root, 'core-legacy')
|
||||
@ -345,6 +340,7 @@ class SMConfig(object):
|
||||
|
||||
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
|
||||
compiler.defines += defines
|
||||
|
||||
paths = [
|
||||
['public'],
|
||||
['public', 'engine'],
|
||||
@ -388,15 +384,6 @@ class SMConfig(object):
|
||||
for path in paths:
|
||||
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
|
||||
|
||||
return compiler
|
||||
|
||||
def ExtLibrary(self, context, name):
|
||||
compiler = self.ExtCompiler(context)
|
||||
return self.LibraryBuilder(compiler, name)
|
||||
|
||||
def HL2Library(self, context, name, sdk):
|
||||
compiler = self.HL2Compiler(context, sdk)
|
||||
|
||||
if builder.target_platform == 'linux':
|
||||
if sdk.name == 'episode1':
|
||||
lib_folder = os.path.join(sdk.path, 'linux_sdk')
|
||||
@ -425,7 +412,7 @@ class SMConfig(object):
|
||||
if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']:
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
|
||||
|
||||
binary = self.LibraryBuilder(compiler, name)
|
||||
self.AddVersioning(binary)
|
||||
|
||||
dynamic_libs = []
|
||||
if builder.target_platform == 'linux':
|
||||
@ -437,7 +424,7 @@ class SMConfig(object):
|
||||
else:
|
||||
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
|
||||
elif builder.target_platform == 'mac':
|
||||
binary.compiler.linkflags.append('-liconv')
|
||||
compiler.linkflags.append('-liconv')
|
||||
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
|
||||
elif builder.target_platform == 'windows':
|
||||
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
|
||||
@ -445,7 +432,7 @@ class SMConfig(object):
|
||||
libs.append('interfaces')
|
||||
for lib in libs:
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
|
||||
binary.compiler.linkflags.append(binary.Dep(lib_path))
|
||||
compiler.linkflags.append(compiler.Dep(lib_path))
|
||||
|
||||
for library in dynamic_libs:
|
||||
source_path = os.path.join(lib_folder, library)
|
||||
@ -458,10 +445,24 @@ class SMConfig(object):
|
||||
return link
|
||||
|
||||
linker = make_linker(source_path, output_path)
|
||||
binary.compiler.linkflags[0:0] = [binary.Dep(library, linker)]
|
||||
compiler.linkflags[0:0] = [compiler.Dep(library, linker)]
|
||||
|
||||
return binary
|
||||
|
||||
def HL2Library(self, context, name, sdk):
|
||||
binary = context.compiler.Library(name)
|
||||
self.ConfigureForExtension(context, binary.compiler)
|
||||
return self.ConfigureForHL2(binary, sdk)
|
||||
|
||||
def HL2Project(self, context, name):
|
||||
project = context.compiler.LibraryProject(name)
|
||||
self.ConfigureForExtension(context, project.compiler)
|
||||
return project
|
||||
|
||||
def HL2Config(self, project, name, sdk):
|
||||
binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name))
|
||||
return self.ConfigureForHL2(binary, sdk)
|
||||
|
||||
SM = SMConfig()
|
||||
SM.detectProductVersion()
|
||||
SM.detectSDKs()
|
||||
|
@ -1,11 +1,54 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
project = SM.HL2Project(builder, 'sourcemod')
|
||||
project.sources += [
|
||||
'MenuStyle_Valve.cpp',
|
||||
'logic_bridge.cpp',
|
||||
'smn_entities.cpp',
|
||||
'sm_stringutil.cpp',
|
||||
'MenuVoting.cpp',
|
||||
'smn_events.cpp',
|
||||
'smn_menus.cpp',
|
||||
'CDataPack.cpp',
|
||||
'frame_hooks.cpp',
|
||||
'smn_nextmap.cpp',
|
||||
'sourcemm_api.cpp',
|
||||
'ChatTriggers.cpp',
|
||||
'smn_player.cpp',
|
||||
'sourcemod.cpp',
|
||||
'concmd_cleaner.cpp',
|
||||
'HalfLife2.cpp',
|
||||
'NextMap.cpp',
|
||||
'ConCmdManager.cpp',
|
||||
'ConVarManager.cpp',
|
||||
'LibrarySys.cpp',
|
||||
'PlayerManager.cpp',
|
||||
'TimerSys.cpp',
|
||||
'CoreConfig.cpp',
|
||||
'Logger.cpp',
|
||||
'smn_halflife.cpp',
|
||||
'smn_console.cpp',
|
||||
'UserMessages.cpp',
|
||||
'MenuManager.cpp',
|
||||
'smn_core.cpp',
|
||||
'smn_hudtext.cpp',
|
||||
'smn_usermsgs.cpp',
|
||||
'MenuStyle_Base.cpp',
|
||||
'smn_keyvalues.cpp',
|
||||
'smn_vector.cpp',
|
||||
'EventManager.cpp',
|
||||
'MenuStyle_Radio.cpp',
|
||||
'sm_autonatives.cpp',
|
||||
'sm_srvcmds.cpp',
|
||||
'ConsoleDetours.cpp'
|
||||
]
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
binary_name = 'sourcemod.' + sdk.ext
|
||||
|
||||
binary = SM.HL2Library(builder, binary_name, sdk)
|
||||
binary = SM.HL2Config(project, binary_name, sdk)
|
||||
compiler = binary.compiler
|
||||
|
||||
if sdk.name == 'csgo':
|
||||
@ -51,48 +94,6 @@ for sdk_name in SM.sdks:
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'win32', 'release', 'vs' + vs_year, 'libprotobuf.lib')
|
||||
compiler.linkflags.insert(0, binary.Dep(lib_path))
|
||||
|
||||
binary.sources += [
|
||||
'MenuStyle_Valve.cpp',
|
||||
'logic_bridge.cpp',
|
||||
'smn_entities.cpp',
|
||||
'sm_stringutil.cpp',
|
||||
'MenuVoting.cpp',
|
||||
'smn_events.cpp',
|
||||
'smn_menus.cpp',
|
||||
'CDataPack.cpp',
|
||||
'frame_hooks.cpp',
|
||||
'smn_nextmap.cpp',
|
||||
'sourcemm_api.cpp',
|
||||
'ChatTriggers.cpp',
|
||||
'smn_player.cpp',
|
||||
'sourcemod.cpp',
|
||||
'concmd_cleaner.cpp',
|
||||
'HalfLife2.cpp',
|
||||
'NextMap.cpp',
|
||||
'ConCmdManager.cpp',
|
||||
'ConVarManager.cpp',
|
||||
'LibrarySys.cpp',
|
||||
'PlayerManager.cpp',
|
||||
'TimerSys.cpp',
|
||||
'CoreConfig.cpp',
|
||||
'Logger.cpp',
|
||||
'smn_halflife.cpp',
|
||||
'smn_console.cpp',
|
||||
'UserMessages.cpp',
|
||||
'MenuManager.cpp',
|
||||
'smn_core.cpp',
|
||||
'smn_hudtext.cpp',
|
||||
'smn_usermsgs.cpp',
|
||||
'MenuStyle_Base.cpp',
|
||||
'smn_keyvalues.cpp',
|
||||
'smn_vector.cpp',
|
||||
'EventManager.cpp',
|
||||
'MenuStyle_Radio.cpp',
|
||||
'sm_autonatives.cpp',
|
||||
'sm_srvcmds.cpp',
|
||||
'ConsoleDetours.cpp'
|
||||
]
|
||||
|
||||
if sdk.name in ['csgo', 'dota']:
|
||||
binary.sources += ['smn_protobuf.cpp']
|
||||
else:
|
||||
@ -115,5 +116,5 @@ for sdk_name in SM.sdks:
|
||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf', 'dota_usermessage_helpers.cpp'),
|
||||
]
|
||||
|
||||
SM.binaries += [builder.Add(binary)]
|
||||
SM.binaries += builder.Add(project)
|
||||
|
||||
|
@ -1,21 +1,24 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
project = SM.HL2Project(builder, 'game.cstrike.ext')
|
||||
project.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'RegNatives.cpp',
|
||||
'timeleft.cpp',
|
||||
'forwards.cpp',
|
||||
'util_cstrike.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
]
|
||||
|
||||
for sdk_name in ['css', 'csgo']:
|
||||
if sdk_name not in SM.sdks:
|
||||
continue
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
binary = SM.HL2Library(builder, 'game.cstrike.ext.' + sdk.ext, sdk)
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'RegNatives.cpp',
|
||||
'timeleft.cpp',
|
||||
'forwards.cpp',
|
||||
'util_cstrike.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.HL2Config(project, 'game.cstrike.ext.' + sdk.ext, sdk)
|
||||
|
||||
SM.extensions += builder.Add(project)
|
||||
|
@ -1,21 +1,23 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
project = SM.HL2Project(builder, 'sdkhooks.ext')
|
||||
project.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'takedamageinfohack.cpp',
|
||||
'util.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
binary = SM.HL2Library(builder, 'sdkhooks.ext.' + sdk.ext, sdk)
|
||||
binary = SM.HL2Config(project, 'sdkhooks.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared')
|
||||
]
|
||||
if binary.compiler.cxx.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'takedamageinfohack.cpp',
|
||||
'util.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += builder.Add(project)
|
||||
|
@ -1,10 +1,37 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
project = SM.HL2Project(builder, 'sdktools.ext')
|
||||
project.sources += [
|
||||
'extension.cpp',
|
||||
'inputnatives.cpp',
|
||||
'output.cpp',
|
||||
'outputnatives.cpp',
|
||||
'tempents.cpp',
|
||||
'tenatives.cpp',
|
||||
'teamnatives.cpp',
|
||||
'trnatives.cpp',
|
||||
'vcaller.cpp',
|
||||
'vcallbuilder.cpp',
|
||||
'vdecoder.cpp',
|
||||
'vglobals.cpp',
|
||||
'vhelpers.cpp',
|
||||
'vnatives.cpp',
|
||||
'voice.cpp',
|
||||
'vsound.cpp',
|
||||
'clientnatives.cpp',
|
||||
'hooks.cpp',
|
||||
'gamerulesnatives.cpp',
|
||||
'vstringtable.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
]
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
binary = SM.HL2Library(builder, 'sdktools.ext.' + sdk.ext, sdk)
|
||||
binary = SM.HL2Config(project, 'sdktools.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
@ -17,29 +44,4 @@ for sdk_name in SM.sdks:
|
||||
if binary.compiler.cxx.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'inputnatives.cpp',
|
||||
'output.cpp',
|
||||
'outputnatives.cpp',
|
||||
'tempents.cpp',
|
||||
'tenatives.cpp',
|
||||
'teamnatives.cpp',
|
||||
'trnatives.cpp',
|
||||
'vcaller.cpp',
|
||||
'vcallbuilder.cpp',
|
||||
'vdecoder.cpp',
|
||||
'vglobals.cpp',
|
||||
'vhelpers.cpp',
|
||||
'vnatives.cpp',
|
||||
'voice.cpp',
|
||||
'vsound.cpp',
|
||||
'clientnatives.cpp',
|
||||
'hooks.cpp',
|
||||
'gamerulesnatives.cpp',
|
||||
'vstringtable.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += builder.Add(project)
|
||||
|
Loading…
Reference in New Issue
Block a user