diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5741e7..4002eb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,31 +12,34 @@ jobs: strategy: fail-fast: true matrix: - os: - - ubuntu-latest - # - windows-latest - sm_version: - - "1.11" - - "latest" + os: [ubuntu-latest, windows-latest] + sm_version: [latest, "1.11"] include: + - os: ubuntu-latest + os_short: linux + + - os: windows-latest + os_short: win + - sm_version: latest sm_branch: master - sm_version: "1.11" sm_branch: "1.11-dev" - # - os: windows-latest - # os_short: win - - - os: ubuntu-latest - os_short: linux + env: + # 设置 Windows 系统的 Python 的默认编码为 UTF-8 + # 以修复 build 时错误: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 7158: character maps to + if: runner.os == 'Windows' + PYTHONUTF8: "1" steps: - name: Prepare env shell: bash run: | echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV + - name: Install (Linux) if: runner.os == 'Linux' run: | @@ -45,6 +48,40 @@ jobs: sudo apt-get install -y clang g++-multilib echo "CC=clang" >> $GITHUB_ENV echo "CXX=clang++" >> $GITHUB_ENV + + - name: Install (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + :: See https://github.com/microsoft/vswhere/wiki/Find-VC + for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do ( + call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x86 -host_arch=x64 + ) + + :: Loop over all environment variables and make them global. + for /f "delims== tokens=1,2" %%a in ('set') do ( + echo>>"%GITHUB_ENV%" %%a=%%b + ) + + - name: Install v143 Toolset + if: runner.os == 'Windows' + shell: powershell + run: | + Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" + $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $WorkLoads = '--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64' + $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"", $WorkLoads, '--quiet', '--norestart', '--nocache') + $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden + if ($process.ExitCode -eq 0) { + Write-Host "components have been successfully added" + } else { + Write-Host "components were not installed" + } + + - name: Add msbuild to PATH (Windows) + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v2 + - name: Getting SourceMod ${{ matrix.sm_version }} uses: actions/checkout@v4 with: @@ -62,39 +99,19 @@ jobs: - name: Setting up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Getting ambuild run: | python -m pip install wheel pip install git+https://github.com/alliedmodders/ambuild + - name: Getting own repository uses: actions/checkout@v4 with: path: extension submodules: true - # - name: Install v143 Toolset - # if: runner.os == 'Windows' - # shell: powershell - # run: | - # Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" - # $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" - # $WorkLoads = '--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64' - # $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"", $WorkLoads, '--quiet', '--norestart', '--nocache') - # $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden - # if ($process.ExitCode -eq 0) { - # Write-Host "components have been successfully added" - # } else { - # Write-Host "components were not installed" - # } - - # - uses: microsoft/setup-msbuild@v2 - # if: runner.os == 'Windows' - # with: - # msbuild-architecture: x64 - # vs-version: '15' - - name: Compiling ${{ github.event.repository.name }} files working-directory: extension run: | diff --git a/AMBuildScript b/AMBuildScript index 4139549..a5e0db5 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -114,22 +114,21 @@ class ExtensionConfig(object): '-msse', '-m32', '-fvisibility=hidden', - - #*** log4sp addition: 解决 spdlog 编译报错的问题 ***# - '-fPIC', # ref: https://github.com/gabime/spdlog/issues/1405 - '-fexceptions', # ref: https://github.com/nodejs/node-gyp/issues/17 ] cxx.cxxflags += [ '-std=c++14', - '-fno-exceptions', + + # '-fno-exceptions', + #*** log4sp addition: 启用异常控制编译支持, 解决编译时报错: "error: cannot use 'throw' with exceptions disabled" ***# + '-fexceptions', # ref: https://github.com/nodejs/node-gyp/issues/17 + '-fno-threadsafe-statics', '-Wno-non-virtual-dtor', '-Wno-overloaded-virtual', '-fvisibility-inlines-hidden', - #*** log4sp addition: 解决 spdlog 编译报错的问题 ***# - '-fPIC', # ref: https://github.com/gabime/spdlog/issues/1405 - '-fexceptions', # ref: https://github.com/nodejs/node-gyp/issues/17 + #*** log4sp addition: 启用生成位置无关的代码, 解决编译时警告(不处理可能导致性能下降): "warning: creating DT_TEXTREL in a shared object" ***# + '-fPIC', ] cxx.linkflags += ['-m32'] @@ -175,7 +174,11 @@ class ExtensionConfig(object): ] cxx.cxxflags += [ '/EHsc', - '/GR-', + + # '/GR-', + # #*** log4sp addition: 启用 RTTI,解决 windows 下 ClientConsoleSink dynamic_pointer_cast 编译报错的问题 ***# + '/GR', + '/TP', ] cxx.linkflags += [