Explorar el Código

Add build steps for plugin

nosoop hace 1 año
padre
commit
8f70ad7104
Se han modificado 4 ficheros con 58 adiciones y 0 borrados
  1. 13 0
      AMBuildScript
  2. 38 0
      AMBuilder
  3. 5 0
      PackageScript
  4. 2 0
      configure.py

+ 13 - 0
AMBuildScript

@@ -1,5 +1,6 @@
 # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
 import os, sys
+import shutil
 
 # Simple extensions do not need to modify this file.
 
@@ -68,9 +69,12 @@ class ExtensionConfig(object):
     self.sdks = {}
     self.binaries = []
     self.extensions = []
+    self.plugins = {}
     self.generated_headers = None
     self.mms_root = None
     self.sm_root = None
+    self.spcomp_path = None
+    self.spcomp_bin = None
 
   @property
   def tag(self):
@@ -123,6 +127,15 @@ class ExtensionConfig(object):
       if not self.mms_root:
         self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
 
+    self.spcomp_path = builder.options.spcomp_path
+    if not self.spcomp_path or not os.path.isdir(self.spcomp_path):
+      spcomp_found = shutil.which("spcomp")
+      if not spcomp_found:
+        raise Exception('Could not find a path for spcomp')
+      self.spcomp_path = os.path.dirname(spcomp_found)
+    self.spcomp_path = Normalize(self.spcomp_path)
+    self.spcomp_bin = shutil.which('spcomp', path = self.spcomp_path)
+
     if not self.mms_root or not os.path.isdir(self.mms_root):
       raise Exception('Could not find a source copy of Metamod:Source')
     self.mms_root = Normalize(self.mms_root)

+ 38 - 0
AMBuilder

@@ -9,6 +9,18 @@ sourceFiles = [
   'natives.cpp',
 ]
 
+pluginFiles = [
+  'tf_econ_dynamic_compat.sp'
+]
+
+spcomp_argv = [
+  Extension.spcomp_bin,
+  '-i' + os.path.relpath(os.path.join(builder.sourcePath, 'scripting', 'include'),
+                         os.path.join(builder.buildPath, builder.buildFolder)),
+  '-h',
+  '-E',
+]
+
 ###############
 # Make sure to edit PackageScript, which copies your files to their appropriate locations
 # Simple extensions do not need to modify past this point.
@@ -29,4 +41,30 @@ for sdk_name in Extension.sdks:
   
   binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk)
 
+def build_plugin(script_path, smx_file):
+  inputs = [
+    Extension.spcomp_bin,
+    script_path,
+  ]
+  outputs = [
+    smx_file
+  ]
+  argv = spcomp_argv + [script_path]
+  result = builder.AddCommand(
+    inputs = inputs,
+    argv = argv,
+    outputs = outputs,
+    dep_type = 'msvc',
+  )
+
+  # ???
+  (smx_command, smx_outputs) = result
+  out, *_ = smx_outputs
+  Extension.plugins[smx_file] = out
+
+for script_file in pluginFiles:
+  script_path = os.path.join(builder.currentSourcePath, 'scripting', script_file)
+  smx_file = os.path.splitext(script_file)[0] + '.smx'
+  build_plugin(script_path, smx_file)
+
 Extension.extensions = builder.Add(project)

+ 5 - 0
PackageScript

@@ -9,6 +9,7 @@ builder.SetBuildFolder('package')
 folder_list = [
   'addons/sourcemod/extensions',
   'addons/sourcemod/gamedata',
+  'addons/sourcemod/plugins',
 ]
 
 # Create the distribution folder hierarchy.
@@ -33,3 +34,7 @@ CopyFiles('gamedata', 'addons/sourcemod/gamedata', [
 # Copy binaries.
 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'])

+ 2 - 0
configure.py

@@ -19,5 +19,7 @@ builder.options.add_option('--enable-optimize', action='store_const', const='1',
 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)')
+builder.options.add_option('--spcomp-path', type=str, dest='spcomp_path', default=None,
+                           help='Path to directory containing spcomp')
 
 builder.Configure()