From 1dee5890f3ef043726a5d6326024f57687dd6cfc Mon Sep 17 00:00:00 2001 From: penev92 Date: Sun, 1 Oct 2023 20:55:50 +0300 Subject: [PATCH] Update ModSDK scripts to release-202310xx --- .editorconfig | 35 ++++++++++++++++++++++++------- .github/workflows/ci.yml | 5 +++-- Makefile | 12 +++++------ launch-dedicated.cmd | 5 +++-- launch-dedicated.sh | 6 ++++-- make.ps1 | 8 +++---- packaging/windows/buildpackage.sh | 15 +++++++++++-- 7 files changed, 59 insertions(+), 27 deletions(-) diff --git a/.editorconfig b/.editorconfig index fa7e52c..1786a6e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,15 +9,11 @@ insert_final_newline = true trim_trailing_whitespace = true ; 4-column tab indentation -[*.yaml] -indent_style = tab -indent_size = 4 - -; 4-column tab indentation and .NET coding conventions -[*.cs] +[*.{cs,csproj,yaml,lua,sh,ps1}] indent_style = tab indent_size = 4 +; .NET coding conventions #### Code Style Rules #### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ @@ -616,6 +612,9 @@ dotnet_code_quality.api_surface = all #dotnet_code_quality.CA1010.additional_required_generic_interfaces = dotnet_diagnostic.CA1010.severity = warning +# Abstract types should not have public constructors. +dotnet_diagnostic.CA1012.severity = warning + # Mark attributes with 'AttributeUsageAttribute'. dotnet_diagnostic.CA1018.severity = warning @@ -631,6 +630,9 @@ dotnet_diagnostic.CA1047.severity = warning # Declare types in namespaces. dotnet_diagnostic.CA1050.severity = warning +# Static holder types should be 'Static' or 'NotInheritable'. +dotnet_diagnostic.CA1052.severity = warning + # Do not hide base class methods. dotnet_diagnostic.CA1061.severity = warning @@ -686,9 +688,17 @@ dotnet_diagnostic.CA1717.severity = warning ### Performance Rules ### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/performance-warnings +# Use Literals Where Appropriate. +#dotnet_code_quality.CA1802.required_modifiers = static +dotnet_diagnostic.CA1802.severity = warning + # Remove empty finalizers. dotnet_diagnostic.CA1821.severity = warning +# Mark members as static. +dotnet_code_quality.CA1822.api_surface = private,internal +dotnet_diagnostic.CA1822.severity = warning + # Avoid unused private fields. dotnet_diagnostic.CA1823.severity = warning @@ -753,8 +763,8 @@ dotnet_diagnostic.CA1843.severity = warning # Provide memory-based overrides of async methods when subclassing 'Stream'. dotnet_diagnostic.CA1844.severity = warning -# Use span-based 'string.Concat'. -dotnet_diagnostic.CA1845.severity = warning +# Use span-based 'string.Concat'. (Not available on mono) +dotnet_diagnostic.CA1845.severity = none # Prefer AsSpan over Substring. dotnet_diagnostic.CA1846.severity = warning @@ -768,9 +778,15 @@ dotnet_diagnostic.CA1849.severity = warning # Prefer static HashData method over ComputeHash. (Not available on mono) dotnet_diagnostic.CA1850.severity = none +# Seal internal types. +dotnet_diagnostic.CA1852.severity = warning + # Unnecessary call to 'Dictionary.ContainsKey(key)'. dotnet_diagnostic.CA1853.severity = warning +# Prefer the IDictionary.TryGetValue(TKey, out TValue) method. +dotnet_diagnostic.CA1854.severity = warning + # Use Span.Clear() instead of Span.Fill(). dotnet_diagnostic.CA1855.severity = warning @@ -813,6 +829,9 @@ dotnet_diagnostic.CA5351.severity = warning ### Usage Rules ### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/usage-warnings +# Call GC.SuppressFinalize correctly. +dotnet_diagnostic.CA1816.severity = warning + # Rethrow to preserve stack details. dotnet_diagnostic.CA2200.severity = warning diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36b86ee..73749d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: run: | sudo apt-get install lua5.1 make check-scripts - make test + make TREAT_WARNINGS_AS_ERRORS=true test linux-mono: name: Linux (mono) @@ -59,7 +59,7 @@ jobs: - name: Check Mod run: | # check-scripts does not depend on .net/mono, so is not needed here - make RUNTIME=mono test + make RUNTIME=mono TREAT_WARNINGS_AS_ERRORS=true test windows: name: Windows (.NET 6.0) @@ -85,5 +85,6 @@ jobs: run: | choco install lua --version 5.1.5.52 $ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\" + $ENV:TREAT_WARNINGS_AS_ERRORS = "true" .\make.ps1 check-scripts .\make.ps1 test diff --git a/Makefile b/Makefile index 91097d1..9452a97 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # to compile, run: # make # -# to compile using Mono (version 6.4 or greater) instead of .NET 6, run: +# to compile using Mono (version 6.12 or greater) instead of .NET 6, run: # make RUNTIME=mono # # to compile using system libraries for native dependencies, run: @@ -22,7 +22,7 @@ # make [RUNTIME=net6] check # # to check your mod yaml for errors, run: -# make [RUNTIME=net6] test +# make [RUNTIME=net6] [TREAT_WARNINGS_AS_ERRORS=false] test # # the following are internal sdk helpers that are not intended to be run directly: # make check-variables @@ -145,7 +145,7 @@ engine: check-variables check-sdk-scripts all: engine ifeq ($(RUNTIME), mono) - @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.4."; exit 1) + @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.12."; exit 1) ifneq ("$(MOD_SOLUTION_FILES)","") @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true \; endif @@ -181,12 +181,10 @@ check: engine ifneq ("$(MOD_SOLUTION_FILES)","") @echo "Compiling in Debug mode..." ifeq ($(RUNTIME), mono) -# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. - @$(MSBUILD) -t:clean\;build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true + @$(MSBUILD) -t:clean\;build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) else -# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. @$(DOTNET) clean -c Debug --nologo --verbosity minimal - @$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true + @$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) endif endif @echo "Checking for explicit interface violations..." diff --git a/launch-dedicated.cmd b/launch-dedicated.cmd index c504ace..df7aced 100644 --- a/launch-dedicated.cmd +++ b/launch-dedicated.cmd @@ -3,6 +3,7 @@ @echo on set Name="Dedicated Server" +set Map="" set ListenPort=1234 set AdvertiseOnline=True set Password="" @@ -18,7 +19,7 @@ set EnableGeoIP=True set EnableLintChecks=True set ShareAnonymizedIPs=True -set JoinChatDelay=5000 +set FloodLimitJoinCooldown=5000 @echo off setlocal EnableDelayedExpansion @@ -37,7 +38,7 @@ if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine cd %ENGINE_DIRECTORY% :loop -bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.RecordReplays=%RecordReplays% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Server.EnableLintChecks=%EnableLintChecks% Engine.SupportDir=%SupportDir% Server.JoinChatDelay=%JoinChatDelay% +bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.Map=%Map% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.RecordReplays=%RecordReplays% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Server.EnableLintChecks=%EnableLintChecks% Engine.SupportDir=%SupportDir% Server.FloodLimitJoinCooldown=%FloodLimitJoinCooldown% goto loop :noengine diff --git a/launch-dedicated.sh b/launch-dedicated.sh index ae94231..44281fd 100755 --- a/launch-dedicated.sh +++ b/launch-dedicated.sh @@ -50,6 +50,7 @@ fi NAME="${Name:-"Dedicated Server"}" LAUNCH_MOD="${Mod:-"${MOD_ID}"}" +MAP="${Map:-""}" LISTEN_PORT="${ListenPort:-"1234"}" ADVERTISE_ONLINE="${AdvertiseOnline:-"True"}" PASSWORD="${Password:-""}" @@ -65,7 +66,7 @@ ENABLE_GEOIP="${EnableGeoIP:-"True"}" ENABLE_LINT_CHECKS="${EnableLintChecks:-"True"}" SHARE_ANONYMISED_IPS="${ShareAnonymizedIPs:-"True"}" -JOIN_CHAT_DELAY="${JoinChatDelay:-"5000"}" +FLOOD_LIMIT_JOIN_COOLDOWN="${FloodLimitJoinCooldown:-"5000"}" SUPPORT_DIR="${SupportDir:-""}" @@ -82,6 +83,7 @@ while true; do MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" \ ${RUNTIME_LAUNCHER} bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="${LAUNCH_MOD}" \ Server.Name="${NAME}" \ + Server.Map="${MAP}" \ Server.ListenPort="${LISTEN_PORT}" \ Server.AdvertiseOnline="${ADVERTISE_ONLINE}" \ Server.Password="${PASSWORD}" \ @@ -94,6 +96,6 @@ while true; do Server.EnableGeoIP="${ENABLE_GEOIP}" \ Server.EnableLintChecks="${ENABLE_LINT_CHECKS}" \ Server.ShareAnonymizedIPs="${SHARE_ANONYMISED_IPS}" \ - Server.JoinChatDelay="${JOIN_CHAT_DELAY}" \ + Server.FloodLimitJoinCooldown="${FLOOD_LIMIT_JOIN_COOLDOWN}" \ Engine.SupportDir="${SUPPORT_DIR}" done diff --git a/make.ps1 b/make.ps1 index 2ad23e8..548adbe 100644 --- a/make.ps1 +++ b/make.ps1 @@ -118,9 +118,9 @@ function Check-Command Write-Host "Compiling $modID in Debug configuration..." -ForegroundColor Cyan - # Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. dotnet clean -c Debug --nologo --verbosity minimal - dotnet build -c Debug --nologo -warnaserror -p:TargetPlatform=win-x64 -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true + dotnet build -c Debug --nologo -warnaserror -p:TargetPlatform=win-x64 + if ($lastexitcode -ne 0) { Write-Host "Build failed." -ForegroundColor Red @@ -293,8 +293,8 @@ if (Test-Path "user.config") $modID = $env:MOD_ID -$env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods,./mods" -$env:ENGINE_DIR = ".." +$env:MOD_SEARCH_PATHS = "./mods,$env:ENGINE_DIRECTORY/mods" +$env:ENGINE_DIR = ".." # Set to potentially be used by the Utility and different than $env:ENGINE_DIRECTORY, which is for the script. # Fetch the engine if required if ($command -eq "all" -or $command -eq "clean" -or $command -eq "check") diff --git a/packaging/windows/buildpackage.sh b/packaging/windows/buildpackage.sh index a5fbcee..499e728 100755 --- a/packaging/windows/buildpackage.sh +++ b/packaging/windows/buildpackage.sh @@ -108,12 +108,23 @@ function build_platform() echo "Mod version ${MOD_VERSION} will remain unchanged."; fi + TAG_TYPE="${TAG%%-*}" + TAG_VERSION="${TAG#*-}" + BACKWARDS_TAG="${TAG_VERSION}-${TAG_TYPE}" + # Create multi-resolution icon convert "${ARTWORK_DIR}/icon_16x16.png" "${ARTWORK_DIR}/icon_24x24.png" "${ARTWORK_DIR}/icon_32x32.png" "${ARTWORK_DIR}/icon_48x48.png" "${ARTWORK_DIR}/icon_256x256.png" "${BUILTDIR}/${MOD_ID}.ico" echo "Compiling Windows launcher (${PLATFORM})" - install_windows_launcher "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "${MOD_ID}" "${PACKAGING_WINDOWS_LAUNCHER_NAME}" "${PACKAGING_DISPLAY_NAME}" "${PACKAGING_FAQ_URL}" - + install_windows_launcher "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "${MOD_ID}" "${PACKAGING_WINDOWS_LAUNCHER_NAME}" "${PACKAGING_DISPLAY_NAME}" "${PACKAGING_FAQ_URL}" "${TAG}" + + # Use rcedit to patch the generated EXE with missing assembly/PortableExecutable information because .NET 6 ignores that when building on Linux. + # Using a backwards version tag because rcedit is unable to set versions starting with a letter. + wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-product-version "${BACKWARDS_TAG}" + wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-version-string "ProductName" "OpenRA" + wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-version-string "CompanyName" "The OpenRA team" + wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-version-string "FileDescription" "${PACKAGING_WINDOWS_LAUNCHER_NAME} mod for OpenRA" + wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-version-string "LegalCopyright" "Copyright (c) The OpenRA Developers and Contributors" wine64 rcedit-x64.exe "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" --set-icon "${BUILTDIR}/${MOD_ID}.ico" echo "Building Windows setup.exe (${PLATFORM})"