Skip to content

Commit

Permalink
Update ModSDK scripts to release-202310xx
Browse files Browse the repository at this point in the history
  • Loading branch information
penev92 authored and pchote committed Oct 7, 2023
1 parent 2b17847 commit 1dee589
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 27 deletions.
35 changes: 27 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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<T>.Clear() instead of Span<T>.Fill().
dotnet_diagnostic.CA1855.severity = warning

Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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..."
Expand Down
5 changes: 3 additions & 2 deletions launch-dedicated.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@echo on

set Name="Dedicated Server"
set Map=""
set ListenPort=1234
set AdvertiseOnline=True
set Password=""
Expand All @@ -18,7 +19,7 @@ set EnableGeoIP=True
set EnableLintChecks=True
set ShareAnonymizedIPs=True

set JoinChatDelay=5000
set FloodLimitJoinCooldown=5000

@echo off
setlocal EnableDelayedExpansion
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions launch-dedicated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-""}"
Expand All @@ -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:-""}"

Expand All @@ -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}" \
Expand All @@ -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
8 changes: 4 additions & 4 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
15 changes: 13 additions & 2 deletions packaging/windows/buildpackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand Down

0 comments on commit 1dee589

Please sign in to comment.