From fcd869cb8dd9afbac362f56d1d4e2ad79c150ab4 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Mon, 24 Jul 2023 15:38:49 +0000 Subject: [PATCH 1/4] Add CI for plugins Fix path includes not being packaged Package test plugins with releases Fix compilation for cbasenpc_example.sp Fix compilation warnings for baseanimatingoverlay.inc --- .github/workflows/ci-extension.yml | 144 ++++++++++++ .github/workflows/ci-scripting.yml | 66 ++++++ .github/workflows/ci.yml | 210 ------------------ .github/workflows/release.yml | 90 ++++++++ AMBuildScript | 122 ++++++---- PackageScript | 6 + configure.py | 8 + scripting/AMBuilder | 37 +++ scripting/cbasenpc_example.sp | 2 +- .../include/cbasenpc/baseanimatingoverlay.inc | 9 +- 10 files changed, 437 insertions(+), 257 deletions(-) create mode 100644 .github/workflows/ci-extension.yml create mode 100644 .github/workflows/ci-scripting.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 scripting/AMBuilder diff --git a/.github/workflows/ci-extension.yml b/.github/workflows/ci-extension.yml new file mode 100644 index 0000000..2f07719 --- /dev/null +++ b/.github/workflows/ci-extension.yml @@ -0,0 +1,144 @@ +name: Extension CI + +on: + workflow_call: + pull_request: + branches: [ master ] + paths: + - 'AMBuildScript' + - 'PackageScript' + - 'extension/**' + - 'extension/**' + +jobs: + build-options: + runs-on: ubuntu-latest + outputs: + exclude: ${{ steps.set.outputs.exclude }} + steps: + - id: set + run: | + echo "exclude=[${{ github.event_name == 'push' && '{"platform": { "release": false } }' || '' }}]" >> $GITHUB_OUTPUT + + build: + needs: build-options + + strategy: + matrix: + platform: [ + { os: ubuntu-20.04, cc: clang-8, cxx: clang++-8, release: true }, + { os: ubuntu-latest, cc: clang, cxx: clang++, release: false }, + { os: windows-2019, cc: msvc, release: true }, + { os: windows-latest, cc: msvc, release: false } + ] + exclude: ${{ fromJson(needs.build-options.outputs.exclude) }} + + name: ${{ matrix.platform.os }} - ${{ matrix.platform.cc }} + runs-on: ${{ matrix.platform.os }} + + env: + # We currently only support tf2 - however when we support more sdks + # we will have to deal with the special case of our custom tf2 + AM's sdks + SDKS: '["tf2"]' + MMSOURCE_VERSION: '1.10' + SOURCEMOD_VERSION: '1.11' + CACHE_PATH: ${{ github.workspace }}/cache + steps: + + - uses: actions/checkout@v3 + name: Repository checkout + with: + fetch-depth: 0 + path: CBaseNPC + + - uses: actions/checkout@v3 + name: Sourcemod checkout + with: + repository: alliedmodders/sourcemod + ref: ${{ env.SOURCEMOD_VERSION }}-dev + submodules: true + path: cache/sourcemod + + - uses: actions/checkout@v3 + name: Metamod-Source checkout + with: + repository: alliedmodders/metamod-source + ref: ${{ env.MMSOURCE_VERSION }}-dev + path: cache/metamod + + - uses: actions/checkout@v3 + name: AMBuild checkout + with: + repository: alliedmodders/ambuild + ref: master + path: cache/ambuild + + - uses: actions/checkout@v3 + name: Custom TF2 SDK checkout + with: + repository: TF2-DMB/hl2sdk-tf2 + ref: tf2 + path: cache/hl2sdk-tf2 + + #- uses: actions/cache@v2 + # name: Setup cache + # with: + # path: ${{ env.CACHE_PATH }} + # key: ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }} + # restore-keys: | + # ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }} + + - uses: actions/setup-python@v3 + name: Setup Python 3.8 + with: + python-version: 3.8 + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + + - name: Setup AMBuild + working-directory: cache + shell: bash + run: | + pip install ./ambuild + + - name: Linux dependencies + if: startsWith(runner.os, 'Linux') + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \ + libc6-dev libc6-dev-i386 linux-libc-dev \ + linux-libc-dev:i386 lib32z1-dev ${{ matrix.platform.cc }} + + - name: Select clang compiler + if: startsWith(runner.os, 'Linux') + run: | + echo "CC=${{ matrix.platform.cc }}" >> $GITHUB_ENV + echo "CXX=${{ matrix.platform.cxx }}" >> $GITHUB_ENV + ${{ matrix.platform.cc }} --version + ${{ matrix.platform.cxx }} --version + + - name: Build + working-directory: CBaseNPC + run: | + mkdir build + cd build + python ../configure.py --extension-only --enable-auto-versioning --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --mms-path=${{ env.CACHE_PATH }}/metamod --hl2sdk-root=${{ env.CACHE_PATH }} --sm-path=${{ env.CACHE_PATH }}/sourcemod + ambuild + + - name: Upload artifact + if: github.event_name == 'push' && matrix.platform.release + uses: actions/upload-artifact@v3 + with: + name: cbasenpc_${{ runner.os }} + path: ${{ github.workspace }}/CBaseNPC/build/package + + - name: Upload artifact + if: github.event_name == 'push' && strategy.job-index == 0 + uses: actions/upload-artifact@v3 + with: + name: cbasenpc_versioning_files + path: ${{ github.workspace }}/CBaseNPC/build/includes \ No newline at end of file diff --git a/.github/workflows/ci-scripting.yml b/.github/workflows/ci-scripting.yml new file mode 100644 index 0000000..02b5eda --- /dev/null +++ b/.github/workflows/ci-scripting.yml @@ -0,0 +1,66 @@ +name: SourcePawn CI +on: + workflow_call: + pull_request: + branches: [ master ] + paths: + - 'AMBuildScript' + - 'PackageScript' + - 'scripting/**' + - 'scripting/**' + +jobs: + build-options: + runs-on: ubuntu-latest + outputs: + exclude: ${{ steps.set.outputs.exclude }} + steps: + - id: set + run: | + echo "exclude=[${{ github.event_name == 'push' && '{"platform": { "release": false } }' || '' }}]" >> $GITHUB_OUTPUT + + build: + needs: build-options + + strategy: + matrix: + platform: [ + { sm-version: '1.11.x', release: true }, + { sm-version: '1.12.x', release: false } + ] + exclude: ${{ fromJson(needs.build-options.outputs.exclude) }} + + name: SM version ${{ matrix.platform.sm-version }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v3 + name: Setup Python 3.8 + with: + python-version: '3.8' + + - name: Install AMBuild + run: | + python -m pip install --upgrade pip setuptools wheel + pip install git+https://github.com/alliedmodders/ambuild + + - name: Setup SP + uses: rumblefrog/setup-sp@master + with: + version: ${{ matrix.platform.sm-version }} + no-spcomp-proxy: true + + - name: Build + run: | + mkdir -p build && cd build + python ../configure.py --scripting-only + ambuild + + - name: Upload artifact + if: github.event_name == 'push' && matrix.platform.release + uses: actions/upload-artifact@v3 + with: + name: cbasenpc_plugins + path: build/package \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b87a500..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,210 +0,0 @@ -name: Extension builder - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - - -jobs: - build: - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-latest, windows-2019, windows-latest] - include: - - os: ubuntu-20.04 - release: true - cc: clang-8 - cxx: clang++-8 - - os: ubuntu-latest - release: false - cc: clang - cxx: clang++ - - os: windows-2019 - release: true - cc: msvc - - os: windows-latest - release: false - cc: msvc - fail-fast: false - - - name: ${{ matrix.os }} - ${{ matrix.cc }} - runs-on: ${{ matrix.os }} - - env: - # We currently only support tf2 - however when we support more sdks - # we will have to deal with the special case of our custom tf2 + AM's sdks - SDKS: '["tf2"]' - MMSOURCE_VERSION: '1.10' - SOURCEMOD_VERSION: '1.11' - CACHE_PATH: ${{ github.workspace }}/cache - steps: - - - uses: actions/checkout@v2 - name: Repository checkout - with: - fetch-depth: 0 - path: CBaseNPC - - - uses: actions/checkout@v2 - name: Sourcemod checkout - with: - repository: alliedmodders/sourcemod - ref: ${{ env.SOURCEMOD_VERSION }}-dev - submodules: true - path: cache/sourcemod - - - uses: actions/checkout@v2 - name: Metamod-Source checkout - with: - repository: alliedmodders/metamod-source - ref: ${{ env.MMSOURCE_VERSION }}-dev - path: cache/metamod - - - uses: actions/checkout@v2 - name: AMBuild checkout - with: - repository: alliedmodders/ambuild - ref: master - path: cache/ambuild - - - uses: actions/checkout@v2 - name: Custom TF2 SDK checkout - with: - repository: TF2-DMB/hl2sdk-tf2 - ref: tf2 - path: cache/hl2sdk-tf2 - - #- uses: actions/cache@v2 - # name: Setup cache - # with: - # path: ${{ env.CACHE_PATH }} - # key: ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }} - # restore-keys: | - # ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }} - - - uses: actions/setup-python@v2 - name: Setup Python 3.8 - with: - python-version: 3.8 - - - name: Install Python dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - - - name: Setup AMBuild - working-directory: cache - shell: bash - run: | - pip install ./ambuild - - - name: Linux dependencies - if: startsWith(runner.os, 'Linux') - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \ - libc6-dev libc6-dev-i386 linux-libc-dev \ - linux-libc-dev:i386 lib32z1-dev ${{ matrix.cc }} - - - name: Select clang compiler - if: startsWith(runner.os, 'Linux') - run: | - echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV - echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV - ${{ matrix.cc }} --version - ${{ matrix.cxx }} --version - - - name: Build - working-directory: CBaseNPC - run: | - mkdir build - cd build - python ../configure.py --enable-auto-versioning --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --mms-path=${{ env.CACHE_PATH }}/metamod --hl2sdk-root=${{ env.CACHE_PATH }} --sm-path=${{ env.CACHE_PATH }}/sourcemod - ambuild - - - name: Upload artifact - if: github.event_name == 'push' && matrix.release - uses: actions/upload-artifact@v1 - with: - name: cbasenpc_${{ runner.os }} - path: ${{ github.workspace }}/CBaseNPC/build/package - - - name: Upload artifact - if: github.event_name == 'push' && strategy.job-index == 0 - uses: actions/upload-artifact@v1 - with: - name: cbasenpc_versioning_files - path: ${{ github.workspace }}/CBaseNPC/build/includes - - release: - if: github.event_name == 'push' - runs-on: ubuntu-latest - needs: build - - steps: - - run: sudo apt-get install -y tree - - - name: Download Linux release - uses: actions/download-artifact@v1 - with: - name: cbasenpc_Linux - path: cbasenpc_linux - - - name: Download Windows release - uses: actions/download-artifact@v1 - with: - name: cbasenpc_Windows - path: cbasenpc_windows - - - name: Download CBaseNPC verisioning files - uses: actions/download-artifact@v1 - with: - name: cbasenpc_versioning_files - path: cbasenpc_versioning_files - - - name: Prepare archives - run: | - cd cbasenpc_linux - tar -czf cbasenpc_linux.tar.gz * - cd ../cbasenpc_windows - zip -r cbasenpc_windows.zip . - cd .. - RELEASE="$(cat ./cbasenpc_versioning_files/git_action_release)" - echo "GITHUB_RELEASE_TAG=$RELEASE" >> $GITHUB_ENV - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.GITHUB_RELEASE_TAG }} - release_name: CBaseNPC ${{ env.GITHUB_RELEASE_TAG }} - body: | - ${{ github.event.head_commit.message }} - draft: false - prerelease: false - - - name: Upload Linux release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./cbasenpc_linux/cbasenpc_linux.tar.gz - asset_name: cbasenpc${{ env.GITHUB_RELEASE_TAG }}_linux.tar.gz - asset_content_type: application/gzip - - - name: Upload Windows release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./cbasenpc_windows/cbasenpc_windows.zip - asset_name: cbasenpc${{ env.GITHUB_RELEASE_TAG }}_windows.zip - asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7f8308d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,90 @@ +name: Build Release + +on: + workflow_dispatch: + push: + branches: [ master ] + +jobs: + build-plugins: + uses: ./.github/workflows/ci-scripting.yml + + build-extension: + uses: ./.github/workflows/ci-extension.yml + + release: + permissions: write-all + runs-on: ubuntu-latest + needs: [build-plugins, build-extension] + + steps: + - run: sudo apt-get install -y tree + + - name: Download Linux release + uses: actions/download-artifact@v3 + with: + name: cbasenpc_Linux + path: cbasenpc_linux + + - name: Download Windows release + uses: actions/download-artifact@v3 + with: + name: cbasenpc_Windows + path: cbasenpc_windows + + - name: Download Plugins + uses: actions/download-artifact@v3 + with: + name: cbasenpc_plugins + path: cbasenpc_plugins + + - name: Download CBaseNPC verisioning files + uses: actions/download-artifact@v3 + with: + name: cbasenpc_versioning_files + path: cbasenpc_versioning_files + + - name: Prepare archives + run: | + cp -r cbasenpc_plugins/. cbasenpc_linux/ + cp -r cbasenpc_plugins/. cbasenpc_windows/ + cd cbasenpc_linux + tar -czf cbasenpc_linux.tar.gz * + cd ../cbasenpc_windows + zip -r cbasenpc_windows.zip . + cd .. + RELEASE="$(cat ./cbasenpc_versioning_files/git_action_release)" + echo "GITHUB_RELEASE_TAG=$RELEASE" >> $GITHUB_ENV + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.GITHUB_RELEASE_TAG }} + release_name: CBaseNPC ${{ env.GITHUB_RELEASE_TAG }} + body: | + ${{ github.event.head_commit.message }} + draft: false + prerelease: false + + - name: Upload Linux release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./cbasenpc_linux/cbasenpc_linux.tar.gz + asset_name: cbasenpc${{ env.GITHUB_RELEASE_TAG }}_linux.tar.gz + asset_content_type: application/gzip + + - name: Upload Windows release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./cbasenpc_windows/cbasenpc_windows.zip + asset_name: cbasenpc${{ env.GITHUB_RELEASE_TAG }}_windows.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/AMBuildScript b/AMBuildScript index 5065a4c..d293f84 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -1,5 +1,5 @@ # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: -import os, sys +import os, sys, shutil # Simple extensions do not need to modify this file. @@ -56,21 +56,22 @@ PossibleSDKs = { # 'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'), } -def ResolveEnvPath(env, folder): +def ResolveEnvPath(env, folder=None): if env in os.environ: path = os.environ[env] if os.path.isdir(path): return path return None - head = os.getcwd() - oldhead = None - while head != None and head != oldhead: - path = os.path.join(head, folder) - if os.path.isdir(path): - return path - oldhead = head - head, tail = os.path.split(head) + if folder: + head = os.getcwd() + oldhead = None + while head != None and head != oldhead: + path = os.path.join(head, folder) + if os.path.isdir(path): + return path + oldhead = head + head, tail = os.path.split(head) return None @@ -93,30 +94,34 @@ class ExtensionConfig(object): self.generated_headers = None self.mms_root = None self.sm_root = None + self.smx_files = {} + self.spcomp_path = None + self.smapi_path = None self.all_targets = [] self.target_archs = set() - if builder.options.targets: - target_archs = builder.options.targets.split(',') - else: - target_archs = ['x86'] - if builder.backend != 'amb2': - target_archs.append('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.') + if not getattr(builder.options, 'scripting_only', False): + if builder.options.targets: + target_archs = builder.options.targets.split(',') + else: + target_archs = ['x86'] + if builder.backend != 'amb2': + target_archs.append('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': @@ -185,13 +190,48 @@ class ExtensionConfig(object): self.mms_root = Normalize(self.mms_root) def configure(self): - if not set(self.target_archs).issubset(['x86', 'x86_64']): raise Exception('Unknown target architecture: {0}'.format(self.target_archs)) - for cxx in self.all_targets: + if not getattr(builder.options, 'scripting_only', False): + for cxx in self.all_targets: self.configure_cxx(cxx) + if not getattr(builder.options, 'extension_only', False): + self.configure_sp() + + def configure_sp(self): + if builder.options.spcomp_path: + self.spcomp_path = builder.options.spcomp_path + else: + spcomp_name = 'spcomp' if sys.platform != 'win32' else 'spcomp.exe' + + self.spcomp_path = ResolveEnvPath('SPCOMP') + if not self.spcomp_path: + self.spcomp_path = ResolveEnvPath('SCRIPTING_PATH') + if self.spcomp_path: + self.spcomp_path = os.path.join(self.spcomp_path, spcomp_name) + if not self.spcomp_path: + self.spcomp_path = shutil.which('spcomp') + + if not self.spcomp_path or not os.path.isfile(self.spcomp_path): + raise Exception('Could not find spcomp') + + if builder.options.smapi_path: + self.smapi_path = builder.options.smapi_path + else: + self.smapi_path = ResolveEnvPath('SOURCEMOD_API') + if not self.smapi_path: + self.smapi_path = ResolveEnvPath('SCRIPTING_PATH') + if self.smapi_path: + self.smapi_path = os.path.join(self.smapi_path, 'include') + if not self.smapi_path: + if self.spcomp_path: + self.smapi_path = os.path.join(os.path.dirname(self.spcomp_path), 'include') + + if not self.smapi_path or not os.path.isdir(self.smapi_path): + raise Exception('Could not find SourceMod includes folder') + def configure_cxx(self, cxx): if cxx.family == 'msvc': if cxx.version < 1900: @@ -567,7 +607,8 @@ class ExtensionConfig(object): Extension = ExtensionConfig() Extension.detectProductVersion() -Extension.detectSDKs() +if not getattr(builder.options, 'scripting_only', False): + Extension.detectSDKs() Extension.configure() if Extension.use_auto_versioning(): @@ -578,9 +619,14 @@ if Extension.use_auto_versioning(): builder.targets = builder.CloneableList(Extension.all_targets) # Add additional buildscripts here -BuildScripts = [ - 'extension/AMBuilder', - 'PackageScript' -] +BuildScripts = [] + +if not getattr(builder.options, 'extension_only', False): + BuildScripts += ['scripting/AMBuilder'] + +if not getattr(builder.options, 'scripting_only', False): + BuildScripts += ['extension/AMBuilder'] + +BuildScripts += ['PackageScript'] builder.Build(BuildScripts, {'Extension': Extension}) diff --git a/PackageScript b/PackageScript index 7d9c617..c192d46 100644 --- a/PackageScript +++ b/PackageScript @@ -13,7 +13,9 @@ folder_list = [ 'addons/sourcemod/scripting/include/cbasenpc', 'addons/sourcemod/scripting/include/cbasenpc/tf', 'addons/sourcemod/scripting/include/cbasenpc/nextbot', + 'addons/sourcemod/scripting/include/cbasenpc/nextbot/path', 'addons/sourcemod/gamedata', + 'addons/sourcemod/plugins/disabled' ] # Create the distribution folder hierarchy. @@ -38,11 +40,15 @@ def CopyDirContent(src, dest): # Copy binaries. for cxx_task in Extension.extensions: builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions']) +for smx_file in Extension.smx_files: + smx_entry = Extension.smx_files[smx_file] + builder.AddCopy(smx_entry, folder_map['addons/sourcemod/plugins/disabled']) # Include files CopyDirContent('scripting/include', 'addons/sourcemod/scripting/include') CopyDirContent('scripting/include/cbasenpc', 'addons/sourcemod/scripting/include/cbasenpc') CopyDirContent('scripting/include/cbasenpc/tf', 'addons/sourcemod/scripting/include/cbasenpc/tf') CopyDirContent('scripting/include/cbasenpc/nextbot', 'addons/sourcemod/scripting/include/cbasenpc/nextbot') +CopyDirContent('scripting/include/cbasenpc/nextbot/path', 'addons/sourcemod/scripting/include/cbasenpc/nextbot/path') CopyDirContent('gamedata', 'addons/sourcemod/gamedata') #shutil.make_archive(builder.buildFolder, 'gztar', builder.buildFolder) \ No newline at end of file diff --git a/configure.py b/configure.py index 4a027d1..dead1fe 100644 --- a/configure.py +++ b/configure.py @@ -23,4 +23,12 @@ 'comma-delimited list of engine names (default: %default)') parser.options.add_argument('--targets', type=str, dest='targets', default=None, help="Override the target architecture (use commas to separate multiple targets).") +parser.options.add_argument('--extension-only', action='store_true', dest='extension_only', default=False, + help='Only build the extension.') +parser.options.add_argument('--scripting-only', action='store_true', dest='scripting_only', default=False, + help='Only build and package the files required for scripting in SourcePawn.') +parser.options.add_argument('--spcomp-path', type=str, dest='spcomp_path', default=None, + help="Path to spcomp") +parser.options.add_argument('--sm-api-path', type=str, dest='smapi_path', default=None, + help="Path to base SourceMod includes folder") parser.Configure() \ No newline at end of file diff --git a/scripting/AMBuilder b/scripting/AMBuilder new file mode 100644 index 0000000..7a34dcb --- /dev/null +++ b/scripting/AMBuilder @@ -0,0 +1,37 @@ +import os + +files = [ + 'cbasenpc_actiontest.sp', + 'cbasenpc_example.sp' +] + +spcomp_argv = [ + os.path.join(builder.buildPath, Extension.spcomp_path), + '-i' + os.path.join(builder.currentSourcePath, 'include'), + '-i' + Extension.smapi_path, + '-O2', + '-h', +] + +def build_plugin(script_path, smx_file): + inputs = [ + Extension.spcomp_path, + script_path, + ] + outputs = [ + smx_file + ] + argv = spcomp_argv + [script_path] + (smx_entry,) = builder.AddCommand( + inputs = inputs, + argv = argv, + outputs = outputs, + dep_type = 'msvc', + weak_inputs = Extension.generated_headers or [] + ) + Extension.smx_files[smx_file] = smx_entry + +for script_file in files: + script_path = os.path.join(builder.currentSourcePath, script_file) + smx_file = os.path.splitext(script_file)[0] + '.smx' + build_plugin(script_path, smx_file) \ No newline at end of file diff --git a/scripting/cbasenpc_example.sp b/scripting/cbasenpc_example.sp index dba9a7c..1b861a9 100644 --- a/scripting/cbasenpc_example.sp +++ b/scripting/cbasenpc_example.sp @@ -176,7 +176,7 @@ public Action Command_SpawnNPC(int iClient, int iArgs) TR_GetEndPosition(endPos, hTrace); delete hTrace; - CBaseNPC npc = new CBaseNPC(); + CBaseNPC npc = CBaseNPC(); if (npc == INVALID_NPC) { ReplyToCommand(iClient, "Failed to create npc!"); diff --git a/scripting/include/cbasenpc/baseanimatingoverlay.inc b/scripting/include/cbasenpc/baseanimatingoverlay.inc index f315800..d7de063 100644 --- a/scripting/include/cbasenpc/baseanimatingoverlay.inc +++ b/scripting/include/cbasenpc/baseanimatingoverlay.inc @@ -9,17 +9,10 @@ #define ANIM_LAYER_DONTRESTORE 0x0008 #define ANIM_LAYER_CHECKACCESS 0x0010 #define ANIM_LAYER_DYING 0x0020 +#define ANIM_LAYER_NOEVENTS 0x0040 #define MAX_OVERLAYS 15 -#define ANIM_LAYER_ACTIVE 0x0001 -#define ANIM_LAYER_AUTOKILL 0x0002 -#define ANIM_LAYER_KILLME 0x0004 -#define ANIM_LAYER_DONTRESTORE 0x0008 -#define ANIM_LAYER_CHECKACCESS 0x0010 -#define ANIM_LAYER_DYING 0x0020 -#define ANIM_LAYER_NOEVENTS 0x0040 - #pragma deprecated Use CAnimationLayer instead enum //CAnimationLayer { From 542857c5fe9889405007538054bfbb4493704eb7 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Tue, 25 Jul 2023 00:42:23 +0000 Subject: [PATCH 2/4] Compile plugins against stable only --- .github/workflows/ci-scripting.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-scripting.yml b/.github/workflows/ci-scripting.yml index 02b5eda..2b2218f 100644 --- a/.github/workflows/ci-scripting.yml +++ b/.github/workflows/ci-scripting.yml @@ -25,12 +25,11 @@ jobs: strategy: matrix: platform: [ - { sm-version: '1.11.x', release: true }, - { sm-version: '1.12.x', release: false } + { sm-version: '1.11.x', release: true } ] exclude: ${{ fromJson(needs.build-options.outputs.exclude) }} - name: SM version ${{ matrix.platform.sm-version }} + name: SM (Stable) runs-on: ubuntu-latest steps: From d8bbfa3a21e4a07c41da6cb119f50efc9afbd997 Mon Sep 17 00:00:00 2001 From: KitRifty Date: Tue, 25 Jul 2023 00:47:53 +0000 Subject: [PATCH 3/4] More descriptive name --- .github/workflows/ci-scripting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-scripting.yml b/.github/workflows/ci-scripting.yml index 2b2218f..b09ceff 100644 --- a/.github/workflows/ci-scripting.yml +++ b/.github/workflows/ci-scripting.yml @@ -25,11 +25,11 @@ jobs: strategy: matrix: platform: [ - { sm-version: '1.11.x', release: true } + { name: Stable, sm-version: '1.11.x', release: true } ] exclude: ${{ fromJson(needs.build-options.outputs.exclude) }} - name: SM (Stable) + name: SM (${{ matrix.platform.name }}) runs-on: ubuntu-latest steps: From a6de078d58919a74e99d6cb918dd516379e0bbcc Mon Sep 17 00:00:00 2001 From: KitRifty Date: Tue, 25 Jul 2023 12:43:11 +0000 Subject: [PATCH 4/4] Flag checking to functions --- AMBuildScript | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index d293f84..b942aad 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -100,7 +100,7 @@ class ExtensionConfig(object): self.all_targets = [] self.target_archs = set() - if not getattr(builder.options, 'scripting_only', False): + if self.build_extension(): if builder.options.targets: target_archs = builder.options.targets.split(',') else: @@ -123,6 +123,12 @@ class ExtensionConfig(object): if not self.all_targets: raise Exception('No suitable C/C++ compiler was found.') + def build_extension(self): + return not getattr(builder.options, 'scripting_only', False) + + def build_plugins(self): + return not getattr(builder.options, 'extension_only', False) + def use_auto_versioning(self): if builder.backend != 'amb2': return False @@ -190,14 +196,14 @@ class ExtensionConfig(object): self.mms_root = Normalize(self.mms_root) def configure(self): - if not set(self.target_archs).issubset(['x86', 'x86_64']): - raise Exception('Unknown target architecture: {0}'.format(self.target_archs)) + if self.build_extension(): + if not set(self.target_archs).issubset(['x86', 'x86_64']): + raise Exception('Unknown target architecture: {0}'.format(self.target_archs)) - if not getattr(builder.options, 'scripting_only', False): for cxx in self.all_targets: self.configure_cxx(cxx) - if not getattr(builder.options, 'extension_only', False): + if self.build_plugins(): self.configure_sp() def configure_sp(self): @@ -607,7 +613,7 @@ class ExtensionConfig(object): Extension = ExtensionConfig() Extension.detectProductVersion() -if not getattr(builder.options, 'scripting_only', False): +if Extension.build_extension(): Extension.detectSDKs() Extension.configure() @@ -621,10 +627,10 @@ builder.targets = builder.CloneableList(Extension.all_targets) # Add additional buildscripts here BuildScripts = [] -if not getattr(builder.options, 'extension_only', False): +if Extension.build_plugins(): BuildScripts += ['scripting/AMBuilder'] -if not getattr(builder.options, 'scripting_only', False): +if Extension.build_extension(): BuildScripts += ['extension/AMBuilder'] BuildScripts += ['PackageScript']