updated build environment, can atm only build on 32bit, also needs hl2sdk-manifests in the folder
This commit is contained in:
		
							parent
							
								
									2eb343d6e0
								
							
						
					
					
						commit
						b17de382d8
					
				
							
								
								
									
										462
									
								
								AMBuildScript
									
									
									
									
									
								
							
							
						
						
									
										462
									
								
								AMBuildScript
									
									
									
									
									
								
							| @ -1,26 +1,5 @@ | |||||||
| # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: | ||||||
| import os, sys | import os | ||||||
| 
 |  | ||||||
| # Simple extensions do not need to modify this file. |  | ||||||
| 
 |  | ||||||
| class SDK(object): |  | ||||||
|   def __init__(self, sdk, ext, aDef, name, platform, dir): |  | ||||||
|     self.folder = 'hl2sdk-' + dir |  | ||||||
|     self.envvar = sdk |  | ||||||
|     self.ext = ext |  | ||||||
|     self.code = aDef |  | ||||||
|     self.define = name |  | ||||||
|     self.platform = platform |  | ||||||
|     self.name = dir |  | ||||||
|     self.path = None # Actual path |  | ||||||
| 
 |  | ||||||
| WinOnly = ['windows'] |  | ||||||
| WinLinux = ['windows', 'linux'] |  | ||||||
| WinLinuxMac = ['windows', 'linux', 'mac'] |  | ||||||
| 
 |  | ||||||
| PossibleSDKs = { |  | ||||||
|   'css':  SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'), |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| def ResolveEnvPath(env, folder): | def ResolveEnvPath(env, folder): | ||||||
|   if env in os.environ: |   if env in os.environ: | ||||||
| @ -42,15 +21,72 @@ def ResolveEnvPath(env, folder): | |||||||
| 
 | 
 | ||||||
| def Normalize(path): | def Normalize(path): | ||||||
|   return os.path.abspath(os.path.normpath(path)) |   return os.path.abspath(os.path.normpath(path)) | ||||||
|  |    | ||||||
|  | def SetArchFlags(compiler): | ||||||
|  |   if compiler.behavior == 'gcc': | ||||||
|  |     if compiler.target.arch == 'x86_64': | ||||||
|  |       compiler.cflags += ['-fPIC'] | ||||||
|  |   elif compiler.like('msvc'): | ||||||
|  |     if compiler.target.arch == 'x86_64': | ||||||
|  |       compiler.defines += ['WIN64'] | ||||||
|  | 
 | ||||||
|  | hl2sdk_manifests_path = None | ||||||
|  | 
 | ||||||
|  | # First we check if the manifest exists in the current path | ||||||
|  | hl2sdk_manifests_path = os.path.join(builder.sourcePath, 'hl2sdk-manifests/SdkHelpers.ambuild') | ||||||
|  | 
 | ||||||
|  | if not os.path.exists(hl2sdk_manifests_path): | ||||||
|  |   # manifests does not exists in the project file, use the path from --hl2sdk-manifest-path | ||||||
|  |   if not builder.options.hl2sdk_manifest: | ||||||
|  |     raise Exception('HL2SDK Manifest root path not set! (--hl2sdk-manifest-path)') | ||||||
|  |   else: | ||||||
|  |     hl2sdk_manifests_path = os.path.join(builder.options.hl2sdk_manifest, 'SdkHelpers.ambuild') | ||||||
|  | 
 | ||||||
|  |     if not os.path.exists(hl2sdk_manifests_path): | ||||||
|  |       raise Exception('Could not find SdkHelpers.ambuild in the given HL2SDK Manifest path!') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | SdkHelpers = builder.Eval(hl2sdk_manifests_path, { | ||||||
|  |     'Project': 'sm-extension' | ||||||
|  | }) | ||||||
| 
 | 
 | ||||||
| class ExtensionConfig(object): | class ExtensionConfig(object): | ||||||
|   def __init__(self): |   def __init__(self): | ||||||
|  |     self.sdk_manifests = [] | ||||||
|     self.sdks = {} |     self.sdks = {} | ||||||
|     self.binaries = [] |     self.sdk_targets = [] | ||||||
|     self.extensions = [] |     self.extensions = [] | ||||||
|     self.generated_headers = None |     self.generated_headers = None | ||||||
|     self.mms_root = None |     self.mms_root = None | ||||||
|     self.sm_root = None |     self.sm_root = None | ||||||
|  |     self.all_targets = [] | ||||||
|  |     self.target_archs = set() | ||||||
|  |     self.libsafetyhook = {} | ||||||
|  | 
 | ||||||
|  |     if builder.options.targets: | ||||||
|  |       target_archs = builder.options.targets.split(',') | ||||||
|  |     else: | ||||||
|  |       target_archs = ['x86', 'x86_64'] | ||||||
|  | 
 | ||||||
|  |     for arch in target_archs: | ||||||
|  |         try: | ||||||
|  |             cxx = builder.DetectCxx(target_arch = arch) | ||||||
|  |             self.target_archs.add(cxx.target.arch) | ||||||
|  |         except Exception as e: | ||||||
|  |             # Error if archs were manually overridden. | ||||||
|  |             if builder.options.targets: | ||||||
|  |                 raise | ||||||
|  |             print('Skipping target {}: {}'.format(arch, e)) | ||||||
|  |             continue | ||||||
|  |         self.all_targets.append(cxx) | ||||||
|  | 
 | ||||||
|  |     if not self.all_targets: | ||||||
|  |         raise Exception('No suitable C/C++ compiler was found.') | ||||||
|  | 
 | ||||||
|  |   def use_auto_versioning(self): | ||||||
|  |     if builder.backend != 'amb2': | ||||||
|  |       return False | ||||||
|  |     return not getattr(builder.options, 'disable_auto_versioning', False) | ||||||
| 
 | 
 | ||||||
|   @property |   @property | ||||||
|   def tag(self): |   def tag(self): | ||||||
| @ -58,48 +94,35 @@ class ExtensionConfig(object): | |||||||
|       return 'Debug' |       return 'Debug' | ||||||
|     return 'Release' |     return 'Release' | ||||||
| 
 | 
 | ||||||
|  |   def findSdkPath(self, sdk_name): | ||||||
|  |     dir_name = 'hl2sdk-{}'.format(sdk_name) | ||||||
|  |     if builder.options.hl2sdk_root: | ||||||
|  |       sdk_path = os.path.join(builder.options.hl2sdk_root, dir_name) | ||||||
|  |       if os.path.exists(sdk_path): | ||||||
|  |         return sdk_path | ||||||
|  |     return ResolveEnvPath('HL2SDK{}'.format(sdk_name.upper()), dir_name) | ||||||
|  | 
 | ||||||
|  |   def shouldIncludeSdk(self, sdk): | ||||||
|  |     return not sdk.get('source2', False) | ||||||
|  | 
 | ||||||
|   def detectSDKs(self): |   def detectSDKs(self): | ||||||
|     sdk_list = builder.options.sdks.split(',') |     sdk_list = [s for s in builder.options.sdks.split(',') if s] | ||||||
|     use_all = sdk_list[0] == 'all' |     SdkHelpers.sdk_filter = self.shouldIncludeSdk | ||||||
|     use_present = sdk_list[0] == 'present' |     SdkHelpers.find_sdk_path = self.findSdkPath | ||||||
|  |     SdkHelpers.findSdks(builder, self.all_targets, sdk_list) | ||||||
| 
 | 
 | ||||||
|     for sdk_name in PossibleSDKs: |     self.sdks = SdkHelpers.sdks | ||||||
|       sdk = PossibleSDKs[sdk_name] |     self.sdk_manifests = SdkHelpers.sdk_manifests | ||||||
|       if builder.target_platform in sdk.platform: |     self.sdk_targets = SdkHelpers.sdk_targets | ||||||
|         if builder.options.hl2sdk_root: |  | ||||||
|           sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder) |  | ||||||
|         else: |  | ||||||
|           sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder) |  | ||||||
|         if sdk_path is None or not os.path.isdir(sdk_path): |  | ||||||
|           if use_all or sdk_name in sdk_list: |  | ||||||
|             raise Exception('Could not find a valid path for {0}'.format(sdk.envvar)) |  | ||||||
|           continue |  | ||||||
|         if use_all or use_present or sdk_name in sdk_list: |  | ||||||
|           sdk.path = Normalize(sdk_path) |  | ||||||
|           self.sdks[sdk_name] = sdk |  | ||||||
| 
 |  | ||||||
|     if len(self.sdks) < 1: |  | ||||||
|       raise Exception('At least one SDK must be available.') |  | ||||||
| 
 |  | ||||||
|     if builder.options.sm_path: |  | ||||||
|       self.sm_root = builder.options.sm_path |  | ||||||
|     else: |  | ||||||
|       self.sm_root = ResolveEnvPath('SOURCEMOD18', 'sourcemod-1.8') |  | ||||||
|       if not self.sm_root: |  | ||||||
|         self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod') |  | ||||||
|       if not self.sm_root: |  | ||||||
|         self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod-central') |  | ||||||
| 
 |  | ||||||
|     if not self.sm_root or not os.path.isdir(self.sm_root): |  | ||||||
|       raise Exception('Could not find a source copy of SourceMod') |  | ||||||
|     self.sm_root = Normalize(self.sm_root) |  | ||||||
| 
 | 
 | ||||||
|     if builder.options.mms_path: |     if builder.options.mms_path: | ||||||
|       self.mms_root = builder.options.mms_path |       self.mms_root = builder.options.mms_path | ||||||
|     else: |     else: | ||||||
|       self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10') |       self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12') | ||||||
|       if not self.mms_root: |       if not self.mms_root: | ||||||
|         self.mms_root = ResolveEnvPath('MMSOURCE', 'metamod-source') |         self.mms_root = ResolveEnvPath('MMSOURCE', 'metamod-source') | ||||||
|  |       if not self.mms_root: | ||||||
|  |         self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source') | ||||||
|       if not self.mms_root: |       if not self.mms_root: | ||||||
|         self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central') |         self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central') | ||||||
| 
 | 
 | ||||||
| @ -107,15 +130,48 @@ class ExtensionConfig(object): | |||||||
|       raise Exception('Could not find a source copy of Metamod:Source') |       raise Exception('Could not find a source copy of Metamod:Source') | ||||||
|     self.mms_root = Normalize(self.mms_root) |     self.mms_root = Normalize(self.mms_root) | ||||||
| 
 | 
 | ||||||
|  |     if builder.options.sm_path: | ||||||
|  |       self.sm_root = builder.options.sm_path | ||||||
|  |     else: | ||||||
|  |       self.sm_root = ResolveEnvPath('SOURCEMOD112', 'sourcemod-1.12') | ||||||
|  |       if not self.sm_root: | ||||||
|  |         self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod') | ||||||
|  |       if not self.sm_root: | ||||||
|  |         self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod') | ||||||
|  |       if not self.sm_root: | ||||||
|  |         self.sm_root = ResolveEnvPath('SOURCEMOD_DEV', 'sourcemod-central') | ||||||
|  | 
 | ||||||
|  |     if not self.sm_root or not os.path.isdir(self.sm_root): | ||||||
|  |       raise Exception('Could not find a source copy of SourceMod') | ||||||
|  |     self.sm_root = Normalize(self.sm_root) | ||||||
|  | 
 | ||||||
|   def configure(self): |   def configure(self): | ||||||
|     cxx = builder.DetectCompilers() |      | ||||||
|  |     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) | ||||||
|  | 
 | ||||||
|  |   def configure_cxx(self, cxx): | ||||||
|  |     if cxx.family == 'msvc': | ||||||
|  |       if cxx.version < 1914 and builder.options.generator != 'vs': | ||||||
|  |         raise Exception(f'Only MSVC 2017 15.7 and later are supported, full C++17 support is required. ({str(cxx.version)} < 1914)') | ||||||
|  |     elif cxx.family == 'gcc': | ||||||
|  |       if cxx.version < 'gcc-8': | ||||||
|  |         raise Exception('Only GCC versions 8 or later are supported, full C++17 support is required.') | ||||||
|  |     elif cxx.family == 'clang': | ||||||
|  |       if cxx.version < 'clang-5': | ||||||
|  |         raise Exception('Only clang versions 5 or later are supported, full C++17 support is required.') | ||||||
| 
 | 
 | ||||||
|     if cxx.like('gcc'): |     if cxx.like('gcc'): | ||||||
|       self.configure_gcc(cxx) |       self.configure_gcc(cxx) | ||||||
|     elif cxx.vendor == 'msvc': |     elif cxx.family == 'msvc': | ||||||
|       self.configure_msvc(cxx) |       self.configure_msvc(cxx) | ||||||
| 
 | 
 | ||||||
|     # Optimizaiton |     # Optimization | ||||||
|     if builder.options.opt == '1': |     if builder.options.opt == '1': | ||||||
|       cxx.defines += ['NDEBUG'] |       cxx.defines += ['NDEBUG'] | ||||||
| 
 | 
 | ||||||
| @ -124,18 +180,13 @@ class ExtensionConfig(object): | |||||||
|       cxx.defines += ['DEBUG', '_DEBUG'] |       cxx.defines += ['DEBUG', '_DEBUG'] | ||||||
| 
 | 
 | ||||||
|     # Platform-specifics |     # Platform-specifics | ||||||
|     if builder.target_platform == 'linux': |     if cxx.target.platform == 'linux': | ||||||
|       self.configure_linux(cxx) |       self.configure_linux(cxx) | ||||||
|     elif builder.target_platform == 'mac': |     elif cxx.target.platform == 'mac': | ||||||
|       self.configure_mac(cxx) |       self.configure_mac(cxx) | ||||||
|     elif builder.target_platform == 'windows': |     elif cxx.target.platform == 'windows': | ||||||
|       self.configure_windows(cxx) |       self.configure_windows(cxx) | ||||||
| 
 | 
 | ||||||
|     # Finish up. |  | ||||||
|     cxx.includes += [ |  | ||||||
|       os.path.join(self.sm_root, 'public'), |  | ||||||
|     ] |  | ||||||
| 
 |  | ||||||
|   def configure_gcc(self, cxx): |   def configure_gcc(self, cxx): | ||||||
|     cxx.defines += [ |     cxx.defines += [ | ||||||
|       'stricmp=strcasecmp', |       'stricmp=strcasecmp', | ||||||
| @ -149,50 +200,52 @@ class ExtensionConfig(object): | |||||||
|       '-pipe', |       '-pipe', | ||||||
|       '-fno-strict-aliasing', |       '-fno-strict-aliasing', | ||||||
|       '-Wall', |       '-Wall', | ||||||
| #      '-Werror', |       '-Werror', | ||||||
|       '-Wno-unused', |       '-Wno-unused', | ||||||
|       '-Wno-switch', |       '-Wno-switch', | ||||||
|       '-Wno-array-bounds', |       '-Wno-array-bounds', | ||||||
|       '-msse', |  | ||||||
|       '-m32', |  | ||||||
|       '-fvisibility=hidden', |       '-fvisibility=hidden', | ||||||
|     ] |     ] | ||||||
|  | 
 | ||||||
|  |     if cxx.target.arch in ['x86', 'x86_64']: | ||||||
|  |       cxx.cflags += ['-msse'] | ||||||
|  | 
 | ||||||
|     cxx.cxxflags += [ |     cxx.cxxflags += [ | ||||||
|       '-std=c++11', |  | ||||||
|       '-fno-exceptions', |  | ||||||
|       '-fno-threadsafe-statics', |       '-fno-threadsafe-statics', | ||||||
|       '-Wno-non-virtual-dtor', |       '-Wno-non-virtual-dtor', | ||||||
|       '-Wno-overloaded-virtual', |       '-Wno-overloaded-virtual', | ||||||
|  |       '-Wno-register', | ||||||
|       '-fvisibility-inlines-hidden', |       '-fvisibility-inlines-hidden', | ||||||
|  |       '-std=c++17', | ||||||
|     ] |     ] | ||||||
|     cxx.linkflags += ['-m32'] |  | ||||||
| 
 | 
 | ||||||
|     have_gcc = cxx.vendor == 'gcc' |      | ||||||
|     have_clang = cxx.vendor == 'clang' |     have_gcc = cxx.family == 'gcc' | ||||||
|     if cxx.version >= 'clang-3.6': |     have_clang = cxx.family == 'clang' | ||||||
|       cxx.cxxflags += ['-Wno-inconsistent-missing-override'] |  | ||||||
|     if have_clang or (cxx.version >= 'gcc-4.6'): |  | ||||||
|       cxx.cflags += ['-Wno-narrowing'] |  | ||||||
|     if have_clang or (cxx.version >= 'gcc-4.7'): |  | ||||||
|       cxx.cxxflags += ['-Wno-delete-non-virtual-dtor'] |  | ||||||
|     if cxx.version >= 'gcc-4.8': |  | ||||||
|       cxx.cflags += ['-Wno-unused-result'] |  | ||||||
| 
 | 
 | ||||||
|  |     # Work around errors from smsdk_ext.cpp | ||||||
|     if have_clang: |     if have_clang: | ||||||
|       cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch'] |       cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch'] | ||||||
|       if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4': | 
 | ||||||
|         cxx.cxxflags += ['-Wno-deprecated-register'] |     # Work around SDK warnings. | ||||||
|       else: |     if cxx.version >= 'clang-10.0' or cxx.version >= 'apple-clang-12.0': | ||||||
|         cxx.cxxflags += ['-Wno-deprecated'] |         cxx.cflags += [ | ||||||
|       cxx.cflags += ['-Wno-sometimes-uninitialized'] |             '-Wno-implicit-int-float-conversion', | ||||||
|  |             '-Wno-tautological-overlap-compare', | ||||||
|  |         ] | ||||||
| 
 | 
 | ||||||
|     if have_gcc: |     if have_gcc: | ||||||
|       cxx.cflags += ['-mfpmath=sse'] |       cxx.cflags += ['-mfpmath=sse'] | ||||||
|  |       cxx.cflags += ['-Wno-maybe-uninitialized'] | ||||||
| 
 | 
 | ||||||
|     if builder.options.opt == '1': |     if builder.options.opt == '1': | ||||||
|       cxx.cflags += ['-O3'] |         cxx.cflags += ['-O3'] | ||||||
|  | 
 | ||||||
|  |     # Don't omit the frame pointer. | ||||||
|  |     cxx.cflags += ['-fno-omit-frame-pointer'] | ||||||
| 
 | 
 | ||||||
|   def configure_msvc(self, cxx): |   def configure_msvc(self, cxx): | ||||||
|  | 
 | ||||||
|     if builder.options.debug == '1': |     if builder.options.debug == '1': | ||||||
|       cxx.cflags += ['/MTd'] |       cxx.cflags += ['/MTd'] | ||||||
|       cxx.linkflags += ['/NODEFAULTLIB:libcmt'] |       cxx.linkflags += ['/NODEFAULTLIB:libcmt'] | ||||||
| @ -211,9 +264,9 @@ class ExtensionConfig(object): | |||||||
|       '/EHsc', |       '/EHsc', | ||||||
|       '/GR-', |       '/GR-', | ||||||
|       '/TP', |       '/TP', | ||||||
|  |       '/std:c++17', | ||||||
|     ] |     ] | ||||||
|     cxx.linkflags += [ |     cxx.linkflags += [ | ||||||
|       '/MACHINE:X86', |  | ||||||
|       'kernel32.lib', |       'kernel32.lib', | ||||||
|       'user32.lib', |       'user32.lib', | ||||||
|       'gdi32.lib', |       'gdi32.lib', | ||||||
| @ -240,27 +293,40 @@ class ExtensionConfig(object): | |||||||
|     cxx.cflags += ['/Oy-'] |     cxx.cflags += ['/Oy-'] | ||||||
| 
 | 
 | ||||||
|   def configure_linux(self, cxx): |   def configure_linux(self, cxx): | ||||||
|     cxx.defines += ['_LINUX', 'POSIX'] |     cxx.defines += ['LINUX', '_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64'] | ||||||
|     cxx.linkflags += ['-Wl,--exclude-libs,ALL', '-lm'] |     cxx.linkflags += ['-lm'] | ||||||
|     if cxx.vendor == 'gcc': |     if cxx.family == 'gcc': | ||||||
|       cxx.linkflags += ['-static-libgcc'] |       cxx.linkflags += ['-static-libgcc'] | ||||||
|     elif cxx.vendor == 'clang': |     elif cxx.family == 'clang': | ||||||
|       cxx.linkflags += ['-lgcc_eh'] |       cxx.linkflags += ['-lgcc_eh'] | ||||||
|  |     cxx.linkflags += ['-static-libstdc++'] | ||||||
| 
 | 
 | ||||||
|   def configure_mac(self, cxx): |   def configure_mac(self, cxx): | ||||||
|     cxx.defines += ['OSX', '_OSX', 'POSIX'] |     cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL'] | ||||||
|     cxx.cflags += ['-mmacosx-version-min=10.5'] |     cxx.cflags += ['-mmacosx-version-min=10.15'] | ||||||
|     cxx.linkflags += [ |     cxx.linkflags += [ | ||||||
|       '-mmacosx-version-min=10.5', |       '-mmacosx-version-min=10.15', | ||||||
|       '-arch', 'i386', |       '-stdlib=libc++', | ||||||
|       '-lstdc++', |       '-lc++', | ||||||
|       '-stdlib=libstdc++', |  | ||||||
|     ] |     ] | ||||||
|     cxx.cxxflags += ['-stdlib=libstdc++'] |     cxx.cxxflags += ['-stdlib=libc++'] | ||||||
| 
 | 
 | ||||||
|   def configure_windows(self, cxx): |   def configure_windows(self, cxx): | ||||||
|     cxx.defines += ['WIN32', '_WINDOWS'] |     cxx.defines += ['WIN32', '_WINDOWS'] | ||||||
|    |      | ||||||
|  |   def LibraryBuilder(self, compiler, name): | ||||||
|  |     binary = compiler.Library(name) | ||||||
|  |     self.AddVersioning(binary) | ||||||
|  |     if binary.compiler.like('msvc'): | ||||||
|  |       binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS'] | ||||||
|  |     self.AddCxxCompat(binary) | ||||||
|  |     return binary | ||||||
|  | 
 | ||||||
|  |   def Library(self, context, compiler, name): | ||||||
|  |     compiler = compiler.clone() | ||||||
|  |     SetArchFlags(compiler) | ||||||
|  |     return self.LibraryBuilder(compiler, name) | ||||||
|  | 
 | ||||||
|   def ConfigureForExtension(self, context, compiler): |   def ConfigureForExtension(self, context, compiler): | ||||||
|     compiler.cxxincludes += [ |     compiler.cxxincludes += [ | ||||||
|       os.path.join(context.currentSourcePath), |       os.path.join(context.currentSourcePath), | ||||||
| @ -272,157 +338,85 @@ class ExtensionConfig(object): | |||||||
|       os.path.join(self.sm_root, 'public', 'amtl'), |       os.path.join(self.sm_root, 'public', 'amtl'), | ||||||
|     ] |     ] | ||||||
|     return compiler |     return compiler | ||||||
|  | 	 | ||||||
|  |   def AddCDetour(self, binary): | ||||||
|  |     public_path = os.path.join(self.sm_root, 'public') | ||||||
|  |     binary.sources += [  | ||||||
|  |       os.path.join(public_path, 'CDetour', 'detours.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'allocator.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'easy.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'inline_hook.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'mid_hook.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'os.linux.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'utility.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'src', 'vmt_hook.cpp'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'zydis', 'Zydis.c') | ||||||
|  |     ] | ||||||
|  | 	 | ||||||
|  |     binary.compiler.includes += [ | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'include'), | ||||||
|  |       os.path.join(public_path, 'safetyhook', 'zydis'), | ||||||
|  |     ] | ||||||
| 
 | 
 | ||||||
|   def ConfigureForHL2(self, binary, sdk): |   def ExtLibrary(self, context, compiler, name): | ||||||
|  |     binary = self.Library(context, compiler, name) | ||||||
|  |     SetArchFlags(compiler) | ||||||
|  |     self.ConfigureForExtension(context, binary.compiler) | ||||||
|  |     return binary | ||||||
|  | 
 | ||||||
|  |   def AddCxxCompat(self, binary): | ||||||
|  |     if binary.compiler.target.platform == 'linux': | ||||||
|  |       binary.sources += [ | ||||||
|  |         os.path.join(self.sm_root, 'public', 'amtl', 'compat', 'stdcxx.cpp'), | ||||||
|  |       ] | ||||||
|  | 
 | ||||||
|  |   def ConfigureForHL2(self, context, binary, sdk): | ||||||
|     compiler = binary.compiler |     compiler = binary.compiler | ||||||
| 
 |     SetArchFlags(compiler) | ||||||
|     if sdk.name == 'episode1': |  | ||||||
|       mms_path = os.path.join(self.mms_root, 'core-legacy') |  | ||||||
|     else: |  | ||||||
|       mms_path = os.path.join(self.mms_root, 'core') |  | ||||||
| 
 | 
 | ||||||
|     compiler.cxxincludes += [ |     compiler.cxxincludes += [ | ||||||
|       os.path.join(mms_path), |       os.path.join(self.mms_root, 'core'), | ||||||
|       os.path.join(mms_path, 'sourcehook'), |       os.path.join(self.mms_root, 'core', 'sourcehook'), | ||||||
|     ] |     ] | ||||||
| 
 | 
 | ||||||
|     defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs] |     for other_sdk in self.sdk_manifests: | ||||||
|     compiler.defines += defines |       compiler.defines += ['SE_{}={}'.format(other_sdk['define'], other_sdk['code'])] | ||||||
| 
 | 
 | ||||||
|     paths = [ |     SdkHelpers.configureCxx(context, binary, sdk) | ||||||
|       ['public'], |  | ||||||
|       ['public', 'engine'], |  | ||||||
|       ['public', 'mathlib'], |  | ||||||
|       ['public', 'vstdlib'], |  | ||||||
|       ['public', 'tier0'], |  | ||||||
|       ['public', 'tier1'] |  | ||||||
|     ] |  | ||||||
|     if sdk.name == 'episode1' or sdk.name == 'darkm': |  | ||||||
|       paths.append(['public', 'dlls']) |  | ||||||
|       paths.append(['game_shared']) |  | ||||||
|     else: |  | ||||||
|       paths.append(['public', 'game', 'server']) |  | ||||||
|       paths.append(['public', 'toolframework']) |  | ||||||
|       paths.append(['game', 'shared']) |  | ||||||
|       paths.append(['common']) |  | ||||||
| 
 |  | ||||||
|     compiler.defines += ['SOURCE_ENGINE=' + sdk.code] |  | ||||||
| 
 |  | ||||||
|     if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'): |  | ||||||
|       # The 2013 SDK already has these in public/tier0/basetypes.h |  | ||||||
|       compiler.defines.remove('stricmp=strcasecmp') |  | ||||||
|       compiler.defines.remove('_stricmp=strcasecmp') |  | ||||||
|       compiler.defines.remove('_snprintf=snprintf') |  | ||||||
|       compiler.defines.remove('_vsnprintf=vsnprintf') |  | ||||||
| 
 |  | ||||||
|     if compiler.like('msvc'): |  | ||||||
|       compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32'] |  | ||||||
|     else: |  | ||||||
|       compiler.defines += ['COMPILER_GCC'] |  | ||||||
| 
 |  | ||||||
|     # For everything after Swarm, this needs to be defined for entity networking |  | ||||||
|     # to work properly with sendprop value changes. |  | ||||||
|     if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']: |  | ||||||
|       compiler.defines += ['NETWORK_VARS_ENABLED'] |  | ||||||
| 
 |  | ||||||
|     if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']: |  | ||||||
|       if builder.target_platform in ['linux', 'mac']: |  | ||||||
|         compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE'] |  | ||||||
| 
 |  | ||||||
|     if sdk.name == 'csgo' and builder.target_platform == 'linux': |  | ||||||
|       compiler.linkflags += ['-lstdc++'] |  | ||||||
| 
 |  | ||||||
|     for path in paths: |  | ||||||
|       compiler.cxxincludes += [os.path.join(sdk.path, *path)] |  | ||||||
| 
 |  | ||||||
|     if builder.target_platform == 'linux': |  | ||||||
|       if sdk.name == 'episode1': |  | ||||||
|         lib_folder = os.path.join(sdk.path, 'linux_sdk') |  | ||||||
|       elif sdk.name in ['sdk2013', 'bms']: |  | ||||||
|         lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32') |  | ||||||
|       else: |  | ||||||
|         lib_folder = os.path.join(sdk.path, 'lib', 'linux') |  | ||||||
|     elif builder.target_platform == 'mac': |  | ||||||
|       if sdk.name in ['sdk2013', 'bms']: |  | ||||||
|         lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32') |  | ||||||
|       else: |  | ||||||
|         lib_folder = os.path.join(sdk.path, 'lib', 'mac') |  | ||||||
| 
 |  | ||||||
|     if builder.target_platform in ['linux', 'mac']: |  | ||||||
|       if sdk.name in ['sdk2013', 'bms']: |  | ||||||
|         compiler.postlink += [ |  | ||||||
|           compiler.Dep(os.path.join(lib_folder, 'tier1.a')), |  | ||||||
|           compiler.Dep(os.path.join(lib_folder, 'mathlib.a')) |  | ||||||
|         ] |  | ||||||
|       else: |  | ||||||
|         compiler.postlink += [ |  | ||||||
|           compiler.Dep(os.path.join(lib_folder, 'tier1_i486.a')), |  | ||||||
|           compiler.Dep(os.path.join(lib_folder, 'mathlib_i486.a')) |  | ||||||
|         ] |  | ||||||
| 
 |  | ||||||
|       if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']: |  | ||||||
|         compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))] |  | ||||||
| 
 |  | ||||||
|     dynamic_libs = [] |  | ||||||
|     if builder.target_platform == 'linux': |  | ||||||
|       if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']: |  | ||||||
|         dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so'] |  | ||||||
|       elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo']: |  | ||||||
|         dynamic_libs = ['libtier0.so', 'libvstdlib.so'] |  | ||||||
|       else: |  | ||||||
|         dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so'] |  | ||||||
|     elif builder.target_platform == 'mac': |  | ||||||
|       compiler.linkflags.append('-liconv') |  | ||||||
|       dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib'] |  | ||||||
|     elif builder.target_platform == 'windows': |  | ||||||
|       libs = ['tier0', 'tier1', 'vstdlib', 'mathlib'] |  | ||||||
|       if sdk.name in ['swarm', 'blade', 'insurgency', 'doi', 'csgo']: |  | ||||||
|         libs.append('interfaces') |  | ||||||
|       for lib in libs: |  | ||||||
|         lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib' |  | ||||||
|         compiler.linkflags.append(compiler.Dep(lib_path)) |  | ||||||
| 
 |  | ||||||
|     for library in dynamic_libs: |  | ||||||
|       source_path = os.path.join(lib_folder, library) |  | ||||||
|       output_path = os.path.join(binary.localFolder, library) |  | ||||||
| 
 |  | ||||||
|       def make_linker(source_path, output_path): |  | ||||||
|         def link(context, binary): |  | ||||||
|           cmd_node, (output,) = context.AddSymlink(source_path, output_path) |  | ||||||
|           return output |  | ||||||
|         return link |  | ||||||
| 
 |  | ||||||
|       linker = make_linker(source_path, output_path) |  | ||||||
|       compiler.linkflags[0:0] = [compiler.Dep(library, linker)] |  | ||||||
| 
 | 
 | ||||||
|     return binary |     return binary | ||||||
| 
 | 
 | ||||||
|   def HL2Library(self, context, name, sdk): |   def HL2Library(self, context, compiler, name, sdk): | ||||||
|     binary = context.compiler.Library(name) |     binary = self.Library(context, compiler, name) | ||||||
|     self.ConfigureForExtension(context, binary.compiler) |     self.ConfigureForExtension(context, binary.compiler) | ||||||
|     return self.ConfigureForHL2(binary, sdk) |     return self.ConfigureForHL2(context, binary, sdk) | ||||||
| 
 | 
 | ||||||
|   def HL2Project(self, context, name): |   def HL2Config(self, project, context, compiler, name, sdk): | ||||||
|     project = context.compiler.LibraryProject(name) |     binary = project.Configure(compiler, name, | ||||||
|     self.ConfigureForExtension(context, project.compiler) |                                '{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch)) | ||||||
|     return project |     self.AddCxxCompat(binary) | ||||||
|  |     return self.ConfigureForHL2(context, binary, sdk) | ||||||
| 
 | 
 | ||||||
|   def HL2Config(self, project, name, sdk): |   def HL2ExtConfig(self, project, context, compiler, name, sdk): | ||||||
|     binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name)) |     binary = project.Configure(compiler, name, | ||||||
|     return self.ConfigureForHL2(binary, sdk) |                                '{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch)) | ||||||
|  |     self.AddCxxCompat(binary) | ||||||
|  |     self.ConfigureForHL2(context, binary, sdk) | ||||||
|  |     self.ConfigureForExtension(context, binary.compiler) | ||||||
|  |     return binary | ||||||
| 
 | 
 | ||||||
| Extension = ExtensionConfig() | Extension = ExtensionConfig() | ||||||
| Extension.detectSDKs() | Extension.detectSDKs() | ||||||
| Extension.configure() | Extension.configure() | ||||||
| 
 | 
 | ||||||
| # Add additional buildscripts here | # This will clone the list and each cxx object as we recurse, preventing child | ||||||
|  | # scripts from messing up global state. | ||||||
|  | builder.targets = builder.CloneableList(Extension.all_targets) | ||||||
|  | 
 | ||||||
| BuildScripts = [ | BuildScripts = [ | ||||||
|   'AMBuilder', |   'AMBuilder', | ||||||
|  |   'PackageScript', | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| if builder.backend == 'amb2': | builder.Build(BuildScripts, { 'Extension': Extension }) | ||||||
|   BuildScripts += [ |  | ||||||
|     'PackageScript', |  | ||||||
|   ] |  | ||||||
| 
 | 
 | ||||||
| builder.RunBuildScripts(BuildScripts, { 'Extension': Extension}) |  | ||||||
|  | |||||||
							
								
								
									
										48
									
								
								AMBuilder
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								AMBuilder
									
									
									
									
									
								
							| @ -2,33 +2,43 @@ | |||||||
| import os | import os | ||||||
| 
 | 
 | ||||||
| if not "SM" in globals(): | if not "SM" in globals(): | ||||||
| 	SM = Extension |   SM = Extension | ||||||
| 
 | 
 | ||||||
| projectName = 'Voice' | projectName = 'Voice' | ||||||
| 
 | 
 | ||||||
| project = SM.HL2Project(builder, projectName + '.ext') | project = builder.LibraryProject(projectName) | ||||||
| project.sources += [ | project.sources += [ | ||||||
|   'extension.cpp', |   'extension.cpp', | ||||||
|   'ringbuffer.cpp', |   os.path.join(SM.sm_root, 'public', 'smsdk_ext.cpp') | ||||||
|   '../../public/smsdk_ext.cpp', |  | ||||||
|   '../../public/CDetour/detours.cpp', |  | ||||||
|   '../../public/asm/asm.c', |  | ||||||
|   '../../public/libudis86/decode.c', |  | ||||||
|   '../../public/libudis86/itab.c', |  | ||||||
|   '../../public/libudis86/syn-att.c', |  | ||||||
|   '../../public/libudis86/syn-intel.c', |  | ||||||
|   '../../public/libudis86/syn.c', |  | ||||||
|   '../../public/libudis86/udis86.c', |  | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| for sdk_name in SM.sdks: | for sdk_name in SM.sdks: | ||||||
|   sdk = SM.sdks[sdk_name] |   sdk = SM.sdks[sdk_name] | ||||||
|   binary = SM.HL2Config(project, projectName + '.ext', sdk) |   if sdk['name'] in ['mock']: | ||||||
|   binary.compiler.cxxincludes += [ |     continue | ||||||
|     os.path.join(builder.sourcePath, 'celt') | 
 | ||||||
|   ] |   for cxx in builder.targets: | ||||||
|   binary.compiler.linkflags += [ |     cxx.defines += ['HAVE_STRING_H']; | ||||||
|     os.path.join(builder.sourcePath, 'celt', 'libcelt0.a') |     if not cxx.target.arch in sdk['platforms'][cxx.target.platform]: | ||||||
|   ] |       continue | ||||||
|  | 
 | ||||||
|  |     binary = Extension.HL2ExtConfig(project, builder, cxx, projectName + '.ext.' + sdk['extension'], sdk) | ||||||
|  | 	 | ||||||
|  |     SM.AddCDetour(binary) | ||||||
|  | 	 | ||||||
|  |     binary.compiler.cxxflags += [ | ||||||
|  |       '-Wno-dangling-else', | ||||||
|  |       '-Wno-unknown-pragmas', | ||||||
|  |       '-Wno-unused-result', | ||||||
|  |       '-Wno-sign-compare', | ||||||
|  | 	] | ||||||
|  | 
 | ||||||
|  |     binary.compiler.cxxincludes += [ | ||||||
|  |         os.path.join(builder.sourcePath, 'celt') | ||||||
|  |     ] | ||||||
|  |     binary.compiler.linkflags += [ | ||||||
|  |         os.path.join(builder.sourcePath, 'celt', 'libcelt0.a') | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| SM.extensions += builder.Add(project) | SM.extensions += builder.Add(project) | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -109,7 +109,7 @@ else | |||||||
| 	LIB_SUFFIX = .$(LIB_EXT) | 	LIB_SUFFIX = .$(LIB_EXT) | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn | INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/sourcepawn/include | ||||||
| 
 | 
 | ||||||
| ifeq "$(USEMETA)" "true" | ifeq "$(USEMETA)" "true" | ||||||
| 	LINK_HL2 = $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) | 	LINK_HL2 = $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) | ||||||
| @ -131,7 +131,7 @@ LINK += -m32 -lm -ldl | |||||||
| CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
 | CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
 | ||||||
| 	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \
 | 	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Werror \
 | ||||||
| 	-Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 | 	-Wno-overloaded-virtual -Wno-switch -Wno-unused -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32 | ||||||
| CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti | CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti -std=c++11 | ||||||
| 
 | 
 | ||||||
| ################################################
 | ################################################
 | ||||||
| ### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
 | ### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
 | ||||||
|  | |||||||
| @ -7,9 +7,14 @@ builder.SetBuildFolder('package') | |||||||
| 
 | 
 | ||||||
| # Add any folders you need to this list | # Add any folders you need to this list | ||||||
| folder_list = [ | folder_list = [ | ||||||
|   'addons/sourcemod/extensions' |   'addons/sourcemod/extensions', | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
|  | if 'x86_64' in Extension.target_archs: | ||||||
|  |   folder_list.extend([ | ||||||
|  |     'addons/sourcemod/extensions/x64', | ||||||
|  |   ]) | ||||||
|  | 
 | ||||||
| # Create the distribution folder hierarchy. | # Create the distribution folder hierarchy. | ||||||
| folder_map = {} | folder_map = {} | ||||||
| for folder in folder_list: | for folder in folder_list: | ||||||
| @ -25,6 +30,10 @@ def CopyFiles(src, dest, files): | |||||||
|     source_path = os.path.join(builder.sourcePath, src, source_file) |     source_path = os.path.join(builder.sourcePath, src, source_file) | ||||||
|     builder.AddCopy(source_path, dest_entry) |     builder.AddCopy(source_path, dest_entry) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| # Copy binaries. | # Copy binaries. | ||||||
| for cxx_task in Extension.extensions: | 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']) | ||||||
|  | |||||||
							
								
								
									
										34
									
								
								configure.py
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								configure.py
									
									
									
									
									
								
							| @ -4,20 +4,24 @@ from ambuild2 import run | |||||||
| 
 | 
 | ||||||
| # Simple extensions do not need to modify this file. | # Simple extensions do not need to modify this file. | ||||||
| 
 | 
 | ||||||
| builder = run.PrepareBuild(sourcePath = sys.path[0]) | parser = run.BuildParser(sourcePath=sys.path[0], api='2.2') | ||||||
| 
 | parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, | ||||||
| builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, |                        help='Root search folder for HL2SDKs') | ||||||
| 		                   help='Root search folder for HL2SDKs') | parser.options.add_argument('--hl2sdk-manifest-path', type=str, dest='hl2sdk_manifest', default=None, | ||||||
| builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None, |                        help='Path to HL2SDK Manifests') | ||||||
|                        help='Path to Metamod:Source') | parser.options.add_argument('--sm-path', type=str, dest='sm_path', default=None, | ||||||
| builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, |  | ||||||
|                        help='Path to SourceMod') |                        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='Enable debugging symbols') |                        help='Path to Metamod:Source') | ||||||
| builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', | 
 | ||||||
|                        help='Enable optimization') | parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug', | ||||||
| builder.options.add_option('-s', '--sdks', default='all', dest='sdks', |                        help='Enable debugging symbols') | ||||||
|                        help='Build against specified SDKs; valid args are "all", "present", or ' | parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt', | ||||||
|                             'comma-delimited list of engine names (default: %default)') |                        help='Enable optimization') | ||||||
|  | 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() |  | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ ConVar g_SmVoicePort("sm_voice_port", "27020", FCVAR_PROTECTED, "Voice server li | |||||||
|  * @brief Implement extension code here. |  * @brief Implement extension code here. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| template <typename T> inline T min(T a, T b) { return a<b?a:b; } | template <typename T> inline T min_ext(T a, T b) { return a<b?a:b; } | ||||||
| 
 | 
 | ||||||
| CVoice g_Interface; | CVoice g_Interface; | ||||||
| SMEXT_LINK(&g_Interface); | SMEXT_LINK(&g_Interface); | ||||||
| @ -483,7 +483,7 @@ void CVoice::HandleNetwork() | |||||||
| 		if(Client != MAX_CLIENTS) | 		if(Client != MAX_CLIENTS) | ||||||
| 		{ | 		{ | ||||||
| 			sockaddr_in addr; | 			sockaddr_in addr; | ||||||
| 			size_t size = sizeof(sockaddr_in); | 			socklen_t size = sizeof(sockaddr_in); | ||||||
| 			int Socket = accept(m_ListenSocket, (sockaddr *)&addr, &size); | 			int Socket = accept(m_ListenSocket, (sockaddr *)&addr, &size); | ||||||
| 
 | 
 | ||||||
| 			m_aClients[Client].m_Socket = Socket; | 			m_aClients[Client].m_Socket = Socket; | ||||||
| @ -546,7 +546,7 @@ void CVoice::HandleNetwork() | |||||||
| 
 | 
 | ||||||
| 		// Don't recv() when we can't fit data into the ringbuffer
 | 		// Don't recv() when we can't fit data into the ringbuffer
 | ||||||
| 		unsigned char aBuf[32768]; | 		unsigned char aBuf[32768]; | ||||||
| 		if(min(BytesAvailable, sizeof(aBuf)) > m_Buffer.CurrentFree() * sizeof(int16_t)) | 		if(min_ext(BytesAvailable, sizeof(aBuf)) > m_Buffer.CurrentFree() * sizeof(int16_t)) | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		// Edge case: previously received data is uneven and last recv'd byte has to be prepended
 | 		// Edge case: previously received data is uneven and last recv'd byte has to be prepended
 | ||||||
| @ -657,7 +657,7 @@ void CVoice::HandleVoiceData() | |||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	// 5 = max frames per packet
 | 	// 5 = max frames per packet
 | ||||||
| 	FramesAvailable = min(FramesAvailable, 5); | 	FramesAvailable = min_ext(FramesAvailable, 5); | ||||||
| 
 | 
 | ||||||
| 	// 0 = SourceTV
 | 	// 0 = SourceTV
 | ||||||
| 	IClient *pClient = iserver->GetClient(0); | 	IClient *pClient = iserver->GetClient(0); | ||||||
| @ -675,7 +675,7 @@ void CVoice::HandleVoiceData() | |||||||
| 
 | 
 | ||||||
| 		if(!m_Buffer.Pop(aBuffer, SamplesPerFrame)) | 		if(!m_Buffer.Pop(aBuffer, SamplesPerFrame)) | ||||||
| 		{ | 		{ | ||||||
| 			printf("Buffer pop failed!!! Samples: %u, Length: %u\n", SamplesPerFrame, m_Buffer.TotalLength()); | 			printf("Buffer pop failed!!! Samples: %u, Length: %zu\n", SamplesPerFrame, m_Buffer.TotalLength()); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user