Browse Source

Use separate AMBuild scripts

nosoop 2 years ago
parent
commit
50691a0f06
7 changed files with 79 additions and 69 deletions
  1. 11 63
      AMBuildScript
  2. 24 0
      AMBuilder
  3. 38 0
      PackageScript
  4. 1 1
      memscan.cpp
  5. 2 2
      memscan.h
  6. 1 1
      mmsplugin.cpp
  7. 2 2
      tf2dynschema.vdf

+ 11 - 63
AMBuildScript

@@ -1,24 +1,3 @@
-proj_name = 'tf2dynschema'
-proj_srcs = [
-  'mmsplugin.cpp',
-  'memscan.cpp',
-]
-proj_c_flags = [
-  '-Wall',
-  '-Wno-non-virtual-dtor',
-  '-Wno-overloaded-virtual',
-  '-Werror',
-]
-proj_c_flags_opt = [
-  '-O3',
-  '-funroll-loops',
-  '-pipe',
-]
-proj_c_flags_dbg = [
-  '-g',
-  '-ggdb3',
-]
-
 import os, sys
 
 class SDK(object):
@@ -59,28 +38,7 @@ Source2 = {
 }
 
 PossibleSDKs = {
-  'episode1':  SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
-  'ep2':  SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
-  'css':  SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
-  'hl2dm':  SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
-  'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
-  'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
   'tf2':  SDK('HL2SDKTF2', '2.tf2', '11', 'TF2', WinLinuxMac, 'tf2'),
-  'l4d':  SDK('HL2SDKL4D', '2.l4d', '12', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
-  'nucleardawn': SDK('HL2SDKND', '2.nd', '13', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
-  'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '15', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
-  'darkm':  SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
-  'swarm':  SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'),
-  'bgt':  SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
-  'eye':  SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
-  'csgo': SDK('HL2SDKCSGO', '2.csgo', '21', 'CSGO', CSGO, 'csgo'),
-  'dota': SDK('HL2SDKDOTA', '2.dota', '22', 'DOTA', Source2, 'dota'),
-  'portal2':  SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'),
-  'blade':  SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinLinux, 'blade'),
-  'insurgency':  SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'),
-  'doi':  SDK('HL2SDKDOI', '2.doi', '20', 'DOI', WinLinuxMac, 'doi'),
-  'contagion':  SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'),
-  'bms':  SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'),
 }
 
 def ResolveEnvPath(env, folder):
@@ -156,7 +114,7 @@ class MMSConfig(object):
           sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
         else:
           sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
-        if sdk_path is None:
+        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
@@ -276,10 +234,7 @@ class MMSConfig(object):
         '-lc++',
         '-mmacosx-version-min=10.9',
       ]
-    elif builder.target.platform == 'windows':
-      cxx.defines += [
-        'WINDOWS',
-      ]
+    # elif builder.target.platform == 'windows': # todo: implement MSVC support
 
   def HL2Compiler(self, context, sdk, arch):
     compiler = context.cxx.clone()
@@ -401,7 +356,7 @@ class MMSConfig(object):
 
     dynamic_libs = [] # todo: this whole section is slightly different, but I imagine it is "more correct"
     if builder.target.platform == 'linux':
-      binary.compiler.linkflags[0:0] = ['-lm', '-ldl', '-lelf'] # todo: do we need -ldl?
+      compiler.linkflags[0:0] = ['-lm', '-ldl'] # todo: do we need -ldl?
       if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']:
         dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
       elif arch == 'x64' and sdk.name == 'csgo':
@@ -447,25 +402,18 @@ MMS.detectProductVersion()
 MMS.detectSDKs()
 MMS.configure()
 
-BuildScripts = [] # add sub-modules here
+BuildScripts = [
+  'AMBuilder'
+]
+
 if getattr(builder.options, 'enable_tests', False):
     BuildScripts += [] # add tests here
 
 import os
 
-for sdk_name in MMS.sdks:
-  for arch in MMS.archs:
-    sdk = MMS.sdks[sdk_name]
-
-    if not arch in sdk.platformSpec[builder.target.platform]:
-      continue
-
-    name = proj_name + '.' + sdk.ext
-    binary = MMS.HL2Library(builder, name, sdk, arch)
-
-    binary.sources += proj_srcs
-
-    nodes = builder.Add(binary)
-    MMS.binaries += [nodes]
+if builder.backend == 'amb2':
+  BuildScripts += [
+    'PackageScript',
+  ]
 
 builder.Build(BuildScripts, { 'MMS': MMS })

+ 24 - 0
AMBuilder

@@ -0,0 +1,24 @@
+# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
+import os, sys
+
+proj_name = 'tf2dynschema'
+
+proj_srcs = [
+  'mmsplugin.cpp',
+  'memscan.cpp',
+]
+
+for sdk_name in MMS.sdks:
+  for arch in MMS.archs:
+    sdk = MMS.sdks[sdk_name]
+
+    if not arch in sdk.platformSpec[builder.target.platform]:
+      continue
+
+    name = proj_name + '.' + sdk.ext
+    binary = MMS.HL2Library(builder, name, sdk, arch)
+
+    binary.sources += proj_srcs
+
+    nodes = builder.Add(binary)
+    MMS.binaries += [nodes]

+ 38 - 0
PackageScript

@@ -0,0 +1,38 @@
+# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
+import os
+
+mms_plugin_directory = 'addons/dynattrs'
+
+# This is where the files will be output to
+# package is the default
+builder.SetBuildFolder('package')
+
+# Add any folders you need to this list
+folder_list = [
+  mms_plugin_directory + '/bin',
+  
+  'addons/metamod', ## !CHANGEME! if you want to add the VDF loader
+]
+
+# Create the distribution folder hierarchy.
+folder_map = {}
+for folder in folder_list:
+  norm_folder = os.path.normpath(folder)
+  folder_map[folder] = builder.AddFolder(norm_folder)
+
+# Do all straight-up file copies from the source tree.
+def CopyFiles(src, dest, files):
+  if not dest:
+    dest = src
+  dest_entry = folder_map[dest]
+  for source_file in files:
+    source_path = os.path.join(builder.sourcePath, src, source_file)
+    builder.AddCopy(source_path, dest_entry)
+
+CopyFiles('', 'addons/metamod', [
+  'tf2dynschema.vdf', ## !CHANGEME! if you want to add the VDF loader
+])
+
+# Copy binaries.
+for cxx_task in MMS.binaries:
+  builder.AddCopy(cxx_task.binary, folder_map[mms_plugin_directory + '/bin'])

+ 1 - 1
memscan.cpp

@@ -19,7 +19,7 @@ uintptr_t FindPattern(uintptr_t start, uintptr_t end, const char* pattern, size_
 	return 0;
 }
 
-#if WINDOWS
+#if _WINDOWS
 CWinLibInfo::CWinLibInfo(void* pInBase) {
 	MEMORY_BASIC_INFORMATION info;
 	if (!VirtualQuery(pInBase, &info, sizeof(MEMORY_BASIC_INFORMATION))) {

+ 2 - 2
memscan.h

@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include <cstdint>
 
-#if WINDOWS
+#if _WINDOWS
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #elif _LINUX
@@ -23,7 +23,7 @@ protected:
 	bool m_bValid;
 };
 
-#if WINDOWS
+#if _WINDOWS
 class CWinLibInfo : public ILibInfo {
 public:
 	CWinLibInfo(void* pInBase);

+ 1 - 1
mmsplugin.cpp

@@ -88,7 +88,7 @@ bool DynSchema::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, boo
 	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, server, this, &DynSchema::Hook_LevelInitPost, true);
 
 	// get the base address of the server
-#if WINDOWS
+#if _WINDOWS
 	CWinLibInfo lib(server);
 	
 	lib.LocatePattern("\xE8\x2A\x2A\x2A\x2A\x83\xC0\x04\xC3", 9, (void**) &fnGetEconItemSchema);

+ 2 - 2
tf2dynschema.vdf

@@ -1,5 +1,5 @@
 "Metamod Plugin"
 {
-	"alias"		"sample"
-	"file"		"addons/sample_mm"
+	"alias"		"dynschema"
+	"file"		"addons/dynattrs/bin/tf2dynschema.2.tf2"
 }