upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 09:15:07 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 09:15:07 -0500
commit2fc613a32a7b784367c8ea3573bcf034b742199f (patch)
tree3b01af27cbfbb00381b47976a760fc64b3ad7564
parenta3263e79e62544349e56c1c41667b55c21c42b5b (diff)
parent2ac20a662240aab8a6d58354be19fe53e75358e6 (diff)
Merge pull request #1758 from sovljanskii
-rw-r--r--make_game.py17
-rw-r--r--tests/test_make_game_preflight.py21
2 files changed, 35 insertions, 3 deletions
diff --git a/make_game.py b/make_game.py
index 397fad2cf..cff1068e1 100644
--- a/make_game.py
+++ b/make_game.py
@@ -334,7 +334,19 @@ def choose_game() -> str:
334 print(" That folder isn't a supported version of the game. Try again.") 334 print(" That folder isn't a supported version of the game. Try again.")
335 335
336 336
337def icloud_documents() -> bool:
338 """macOS: whether iCloud Drive holds Desktop & Documents. With that sync on, ~/Documents lives in iCloud Drive,
339 which uploads what goes in it and may evict files from the disk ("Optimize Mac Storage"). The folder can stay in
340 iCloud Drive after the sync is turned off; leaving Documents alone then costs nothing."""
341 return sys.platform == "darwin" and os.path.isdir(
342 os.path.join(os.path.expanduser("~"), "Library", "Mobile Documents", "com~apple~CloudDocs", "Documents"))
343
344
337def default_out() -> str: 345def default_out() -> str:
346 """Documents/Leonida, except on a Mac whose Documents iCloud syncs: the port and its work folder (hundreds of
347 GB made from the game) must stay on this computer, so they go to ~/Leonida there."""
348 if icloud_documents():
349 return os.path.join(os.path.expanduser("~"), "Leonida")
338 return os.path.join(os.path.expanduser("~"), "Documents", "Leonida") 350 return os.path.join(os.path.expanduser("~"), "Documents", "Leonida")
339 351
340 352
@@ -1235,7 +1247,8 @@ def main() -> int:
1235 ap = argparse.ArgumentParser(description="Build the PC port from your own copy of the game.") 1247 ap = argparse.ArgumentParser(description="Build the PC port from your own copy of the game.")
1236 ap.add_argument("--game", help="your package folder (found automatically if left out)") 1248 ap.add_argument("--game", help="your package folder (found automatically if left out)")
1237 ap.add_argument("--pick", action="store_true", help="choose your package folder in a folder dialog") 1249 ap.add_argument("--pick", action="store_true", help="choose your package folder in a folder dialog")
1238 ap.add_argument("--out", help="folder for the finished port (default Documents/Leonida)") 1250 ap.add_argument("--out", help="folder for the finished port (default Documents/Leonida; ~/Leonida on a Mac "
1251 "whose Documents iCloud syncs)")
1239 ap.add_argument("--work", help="folder for intermediate files (hundreds of GB; default <out>/work)") 1252 ap.add_argument("--work", help="folder for intermediate files (hundreds of GB; default <out>/work)")
1240 ap.add_argument("--stages", help="comma list from: " + ",".join(STAGES)) 1253 ap.add_argument("--stages", help="comma list from: " + ",".join(STAGES))
1241 ap.add_argument("--check", action="store_true", help="only check the game files") 1254 ap.add_argument("--check", action="store_true", help="only check the game files")
@@ -1336,6 +1349,8 @@ def main() -> int:
1336 fallbacks = fallback_flags(a) if "shaders" in stages else () 1349 fallbacks = fallback_flags(a) if "shaders" in stages else ()
1337 preflight(stages, work, a.wav, runtime_build, emulate=emulate, keep_emulated=keep_emulated, 1350 preflight(stages, work, a.wav, runtime_build, emulate=emulate, keep_emulated=keep_emulated,
1338 fallbacks=fallbacks, jobs=a.jobs) 1351 fallbacks=fallbacks, jobs=a.jobs)
1352 if not a.out and icloud_documents():
1353 log("iCloud syncs Documents on this Mac: building into ~/Leonida instead, so the game's files stay off iCloud")
1339 log(f"building into {out} (work files in {work})") 1354 log(f"building into {out} (work files in {work})")
1340 t0 = time.time() 1355 t0 = time.time()
1341 if "shaders" in stages: 1356 if "shaders" in stages:
diff --git a/tests/test_make_game_preflight.py b/tests/test_make_game_preflight.py
index eb6964bb1..f1950cd34 100644
--- a/tests/test_make_game_preflight.py
+++ b/tests/test_make_game_preflight.py
@@ -654,9 +654,26 @@ class PathAndGameSelectionTest(PreflightTestBase):
654 self.assert_fails(make_game.choose_game, 654 self.assert_fails(make_game.choose_game,
655 match="More than one copy found: choose one with --game.") 655 match="More than one copy found: choose one with --game.")
656 656
657 def default_out_in(self, platform, icloud_documents):
658 """default_out() with a temporary home folder; icloud_documents makes the folder macOS keeps in iCloud
659 Drive when Desktop & Documents sync is on (~/Library/Mobile Documents/com~apple~CloudDocs/Documents)."""
660 with tempfile.TemporaryDirectory() as home:
661 if icloud_documents:
662 os.makedirs(os.path.join(home, "Library", "Mobile Documents", "com~apple~CloudDocs", "Documents"))
663 with mock.patch.object(make_game.os.path, "expanduser", lambda p: home + p[1:] if p.startswith("~") else p), \
664 mock.patch.object(make_game.sys, "platform", platform):
665 return os.path.relpath(make_game.default_out(), home)
666
657 def test_default_out_matches_documents_folder(self): 667 def test_default_out_matches_documents_folder(self):
658 expected = os.path.join(os.path.expanduser("~"), "Documents", "Leonida") 668 for platform in ("win32", "linux", "darwin"):
659 self.assertEqual(make_game.default_out(), expected) 669 self.assertEqual(self.default_out_in(platform, False), os.path.join("Documents", "Leonida"), platform)
670
671 def test_default_out_leaves_icloud_synced_documents_on_a_mac(self):
672 # Before: with iCloud Desktop & Documents sync on, ~/Documents/Leonida (and its work folder, hundreds of GB
673 # made from the game) went into iCloud Drive, which uploads it and can evict the work files from the disk.
674 self.assertEqual(self.default_out_in("darwin", True), "Leonida")
675 # Only macOS keeps Documents in iCloud Drive this way; elsewhere the folder means nothing.
676 self.assertEqual(self.default_out_in("linux", True), os.path.join("Documents", "Leonida"))
660 677
661 def test_constants_definitions(self): 678 def test_constants_definitions(self):
662 self.assertEqual(make_game.STAGES, ["check", "shaders", "assets", "runtime", "pipelines"]) 679 self.assertEqual(make_game.STAGES, ["check", "shaders", "assets", "runtime", "pipelines"])