A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
check.sh: find the Linux Unity editor for the dotnet compile step (#2033)
Beri3d76574f154a
diff --git a/changelog.d/laneNP-1970.md b/changelog.d/laneNP-1970.mdnew file mode 100644index 000000000..b606cfb99--- /dev/null+++ b/changelog.d/laneNP-1970.md@@ -0,0 +1,3 @@+### Fixed+- `scripts/check.sh`'s Unity compile step now finds a Linux editor (`~/Unity/Hub/Editor/<version>/Editor/Data`), and+ `scripts/unity_compile/compile.sh` accepts that layout, so the check no longer always skips on Linux. macOS is unchanged.diff --git a/scripts/check.sh b/scripts/check.shindex c5eb423e3..596656768 100755--- a/scripts/check.sh+++ b/scripts/check.sh@@ -48,6 +48,9 @@ run "sim build, warnings as errors" dotnet build sim/Statecraft.sln -c Release -unity_version="$(sed -n 's/^m_EditorVersion: //p' unity/ProjectSettings/ProjectVersion.txt)"[ -n "$unity_version" ] || { echo "FAILED: unity compile: no m_EditorVersion in unity/ProjectSettings/ProjectVersion.txt"; exit 1; }unity_contents="${CHECK_UNITY_CONTENTS:-/Applications/Unity/Hub/Editor/$unity_version/Unity.app/Contents}"+# The Linux (and Windows) editor has no Unity.app/Contents; its Editor/Data holds the same Managed and NetStandard folders.+linux_data="$HOME/Unity/Hub/Editor/$unity_version/Editor/Data"+if [ -z "${CHECK_UNITY_CONTENTS:-}" ] && [ ! -d "$unity_contents" ] && [ -d "$linux_data" ]; then unity_contents="$linux_data"; fiif [ ! -d "$unity_contents" ]; thenecho "== unity compile: SKIPPED, no Unity $unity_version editor at $unity_contents"elif [ ! -d unity/Library ]; thendiff --git a/scripts/unity_compile/Common.props b/scripts/unity_compile/Common.propsindex 794f470a7..586ce0bfa 100644--- a/scripts/unity_compile/Common.props+++ b/scripts/unity_compile/Common.props@@ -2,8 +2,8 @@<!-- The compile-only check of unity/ that scripts/check.sh runs when a Unity editor and a Library are present(T72, option (a) of the CI proposal). It compiles the two asmdefs, Statecraft.Game and Statecraft.Tests.EditMode,with the settings Unity uses for them: netstandard2.1, C# 9, Unity's own BCL and the editor's define list.- Properties set by check.sh: Editor (Unity.app/Contents), Lib (unity/Library), Src (unity/), Sim (the published- sim DLLs) and OutputPath. UnityVersion is the editor the define list below was copied from (Unity's generated+ Properties set by check.sh: Scripting (the editor's Resources/Scripting, or Editor/Data on Linux/Windows),+ Lib (unity/Library), Src (unity/), Sim (the published sim DLLs) and OutputPath. UnityVersion is the editor the define list below was copied from (Unity's generatedStatecraft.Game.csproj, 6000.3.25f1); check.sh refuses to run against another version until this file isupdated. Not covered: Assets/Editor, Unity's source generators, ILPP and Burst. Needs no Unity licence. --><PropertyGroup>@@ -22,7 +22,7 @@<UnityDefines>UNITY_6000_3_25;UNITY_6000_3;UNITY_6000;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;UNITY_2022_1_OR_NEWER;UNITY_2022_2_OR_NEWER;UNITY_2022_3_OR_NEWER;UNITY_2023_1_OR_NEWER;UNITY_2023_2_OR_NEWER;UNITY_2023_3_OR_NEWER;UNITY_6000_0_OR_NEWER;UNITY_6000_1_OR_NEWER;UNITY_6000_2_OR_NEWER;UNITY_6000_3_OR_NEWER;PLATFORM_ARCH_64;UNITY_64;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_AUDIO_SCRIPTABLE_PIPELINE;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_VIRTUALTEXTURING;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_UNITY_CONSENT;ENABLE_UNITY_CLOUD_IDENTIFIERS;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_NATIVE_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_EDITOR_GAME_SERVICES;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_GENERATE_NATIVE_PLUGINS_FOR_ASSEMBLIES_API;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_MANAGED_UNITYTLS;INCLUDE_DYNAMIC_GI;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_MARSHALLING_TESTS;ENABLE_VIDEO;ENABLE_NAVIGATION_OFFMESHLINK_TO_NAVMESHLINK;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;ENABLE_ACCESSIBILITY_SCREEN_READER;TEXTCORE_1_0_OR_NEWER;EDITOR_ONLY_NAVMESH_BUILDER_DEPRECATED;PLATFORM_STANDALONE_OSX;PLATFORM_STANDALONE;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_GAMECENTER;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_CLOUD_SERVICES_ENGINE_DIAGNOSTICS;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;ENABLE_SPATIALTRACKING;PLATFORM_HAS_CUSTOM_MUTEX;PLATFORM_UPDATES_TIME_OUTSIDE_OF_PLAYER_LOOP;PLATFORM_SUPPORTS_SPLIT_GRAPHICS_JOBS;ENABLE_MONO;ENABLE_PROFILER;ENABLE_PROFILER_ASSISTANT_INTEGRATION;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_INPUT_SYSTEM;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;TEXTCORE_TEXT_ENGINE_1_5_OR_NEWER;TEXTCORE_FONT_ENGINE_1_6_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</UnityDefines></PropertyGroup><ItemGroup>- <Reference Include="$(Editor)/Resources/Scripting/Managed/UnityEngine/*.dll" Private="false" />+ <Reference Include="$(Scripting)/Managed/UnityEngine/*.dll" Private="false" /><Reference Include="$(Sim)/Statecraft.Sim.dll;$(Sim)/YamlDotNet.dll" Private="false" /><Reference Include="$(Lib)/ScriptAssemblies/Unity.RenderPipelines.Core.Runtime.dll;$(Lib)/ScriptAssemblies/Unity.RenderPipelines.Universal.Runtime.dll;$(Lib)/ScriptAssemblies/Unity.InputSystem.dll" Private="false" /></ItemGroup>diff --git a/scripts/unity_compile/Game.csproj b/scripts/unity_compile/Game.csprojindex c91c94449..025c5ef54 100644--- a/scripts/unity_compile/Game.csproj+++ b/scripts/unity_compile/Game.csproj@@ -5,7 +5,7 @@<DefineConstants>$(UnityDefines);NET_STANDARD;NET_STANDARD_2_0;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1</DefineConstants></PropertyGroup><ItemGroup>- <Reference Include="$(Editor)/Resources/Scripting/NetStandard/ref/2.1.0/netstandard.dll" Private="false" />+ <Reference Include="$(Scripting)/NetStandard/ref/2.1.0/netstandard.dll" Private="false" /><Compile Include="$(Src)/Assets/Scripts/**/*.cs" /></ItemGroup></Project>diff --git a/scripts/unity_compile/Tests.csproj b/scripts/unity_compile/Tests.csprojindex 79a9e9eff..b7e1be9a9 100644--- a/scripts/unity_compile/Tests.csproj+++ b/scripts/unity_compile/Tests.csproj@@ -5,8 +5,8 @@<DefineConstants>$(UnityDefines);NET_4_6;NET_UNITY_4_8;UNITY_EDITOR_ONLY_COMPILATION</DefineConstants></PropertyGroup><ItemGroup>- <Reference Include="$(Editor)/Resources/Scripting/UnityReferenceAssemblies/unity-4.8-api/*.dll" Private="false" />- <Reference Include="$(Editor)/Resources/Scripting/UnityReferenceAssemblies/unity-4.8-api/Facades/*.dll" Private="false" />+ <Reference Include="$(Scripting)/UnityReferenceAssemblies/unity-4.8-api/*.dll" Private="false" />+ <Reference Include="$(Scripting)/UnityReferenceAssemblies/unity-4.8-api/Facades/*.dll" Private="false" /><Reference Include="$(Lib)/ScriptAssemblies/UnityEngine.TestRunner.dll;$(Lib)/ScriptAssemblies/UnityEditor.TestRunner.dll;$(Lib)/ScriptAssemblies/Unity.InputSystem.TestFramework.dll" Private="false" /><Reference Include="$(Lib)/PackageCache/com.unity.ext.nunit@*/net40/unity-custom/nunit.framework.dll" Private="false" /><ProjectReference Include="Game.csproj" />diff --git a/scripts/unity_compile/compile.sh b/scripts/unity_compile/compile.shindex aa5ec065b..9df1d52f4 100755--- a/scripts/unity_compile/compile.sh+++ b/scripts/unity_compile/compile.sh@@ -3,12 +3,16 @@# PR deleted, in about 2 seconds and with no Unity licence. scripts/check.sh runs it only where the project's editor# and a unity/Library exist. It does not run any test: the EditMode suite still needs Unity.#-# Usage: scripts/unity_compile/compile.sh <path to Unity.app/Contents>+# Usage: scripts/unity_compile/compile.sh <path to Unity.app/Contents, or to Editor/Data on Linux and Windows># Writes nothing into the checkout: the project files, the published sim DLLs and the output go to a temp folder.set -euo pipefailcd "$(dirname "$0")/../.."contents="${1:?usage: compile.sh <Unity.app/Contents>}"here=scripts/unity_compile+# macOS keeps its managed DLLs under <Contents>/Resources/Scripting; the Linux and Windows editors have the same folders+# directly under Editor/Data.+scripting="$contents/Resources/Scripting"+[ -d "$scripting" ] || scripting="$contents"version="$(sed -n 's/^m_EditorVersion: //p' unity/ProjectSettings/ProjectVersion.txt)"pinned="$(sed -n 's:.*<UnityVersion>\(.*\)</UnityVersion>.*:\1:p' "$here/Common.props")"if [ "$version" != "$pinned" ]; then@@ -18,8 +22,8 @@ if [ "$version" != "$pinned" ]; thenfi# A Library without these (never opened in Unity, or an import that failed) is an error here, not a skip.lib=unity/Library-for f in "$contents/Resources/Scripting/Managed/UnityEngine/UnityEngine.CoreModule.dll" \- "$contents/Resources/Scripting/NetStandard/ref/2.1.0/netstandard.dll" \+for f in "$scripting/Managed/UnityEngine/UnityEngine.CoreModule.dll" \+ "$scripting/NetStandard/ref/2.1.0/netstandard.dll" \"$lib"/ScriptAssemblies/{Unity.RenderPipelines.Core.Runtime,Unity.RenderPipelines.Universal.Runtime}.dll \"$lib"/ScriptAssemblies/{Unity.InputSystem,Unity.InputSystem.TestFramework,UnityEngine.TestRunner,UnityEditor.TestRunner}.dll; do[ -f "$f" ] || { echo "missing: $f (open the project in Unity once so it builds its Library)"; exit 1; }@@ -30,7 +34,7 @@ tmp="$(mktemp -d)"trap 'rm -rf "$tmp"' EXITcp "$here"/Common.props "$here"/Game.csproj "$here"/Tests.csproj "$tmp/"dotnet publish sim/Statecraft.Sim -c Release -o "$tmp/sim" --nologo -v q-if ! dotnet build "$tmp/Tests.csproj" --nologo -v q -p:Editor="$contents" -p:Lib="$PWD/unity/Library" \+if ! dotnet build "$tmp/Tests.csproj" --nologo -v q -p:Scripting="$scripting" -p:Lib="$PWD/unity/Library" \-p:Src="$PWD/unity" -p:Sim="$tmp/sim" -p:OutputPath="$tmp/bin/"; thenecho "unity/ does not compile. If the error names a package type (URP, Input System, the test framework),"echo "unity/Library may be older than unity/Packages: open the project in Unity once and run this again."diff --git a/tools/tests/test_unity_compile_layout.py b/tools/tests/test_unity_compile_layout.pynew file mode 100644index 000000000..9e53e27d8--- /dev/null+++ b/tools/tests/test_unity_compile_layout.py@@ -0,0 +1,37 @@+"""scripts/unity_compile/compile.sh finds the editor's managed DLLs in both layouts (#1970): macOS keeps them under+<Contents>/Resources/Scripting, the Linux/Windows editor under Editor/Data directly. The script runs in a scratch copy+of the repo with no unity/Library, so it stops at the first missing file and the "missing:" line shows which layout it+looked in; no Unity, no dotnet."""+import shutil+import subprocess+from pathlib import Path++REPO = Path(__file__).resolve().parents[2]+++def _missing_line(tmp_path, scripting_dir):+ """Run a scratch copy of compile.sh against an editor root whose Managed/NetStandard DLLs sit in scripting_dir."""+ shutil.copytree(REPO / "scripts" / "unity_compile", tmp_path / "scripts" / "unity_compile")+ version = "6000.0.0f1"+ (tmp_path / "unity" / "ProjectSettings").mkdir(parents=True)+ (tmp_path / "unity" / "ProjectSettings" / "ProjectVersion.txt").write_text(f"m_EditorVersion: {version}\n")+ common = tmp_path / "scripts" / "unity_compile" / "Common.props"+ common.write_text(common.read_text().replace("6000.3.25f1", version))+ root = tmp_path / "editor"+ scripting = root / scripting_dir if scripting_dir else root+ for rel in ("Managed/UnityEngine/UnityEngine.CoreModule.dll", "NetStandard/ref/2.1.0/netstandard.dll"):+ (scripting / rel).parent.mkdir(parents=True, exist_ok=True)+ (scripting / rel).write_bytes(b"")+ run = subprocess.run(["bash", str(tmp_path / "scripts" / "unity_compile" / "compile.sh"), str(root)],+ capture_output=True, text=True)+ assert run.returncode == 1, run.stdout + run.stderr+ return run.stdout.strip()+++def test_macos_layout_is_found_under_resources_scripting(tmp_path):+ # Both editor DLLs are found, so the first missing file is the Library's, not the editor's.+ assert "ScriptAssemblies/Unity.RenderPipelines.Core.Runtime.dll" in _missing_line(tmp_path, "Resources/Scripting")+++def test_linux_layout_is_found_directly_under_editor_data(tmp_path):+ assert "ScriptAssemblies/Unity.RenderPipelines.Core.Runtime.dll" in _missing_line(tmp_path, "")