Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

chore(pr): rebase #776 on latest upstream and isolate CI check (#776)

A Hazy Reign Is Fluid11d97d5e9992
diff --git a/Makefile b/Makefile
index b993520..9aacb74 100644
--- a/Makefile
+++ b/Makefile
@@ -874,6 +874,11 @@ native-shim-tests:
@if [ ! -f native-shim/tests/run.sh ]; then $(call SKIP,native-shim-tests,native-shim/tests/run.sh); exit 0; fi; \
sh native-shim/tests/run.sh
+# Inventory fixtures exercise modern and legacy Steam libraries offline.
+.PHONY: np-inventory-check
+np-inventory-check:
+ @python3 scripts/tests/np-inventory.py
+
# Every check .github/workflows/app.yml runs, after `make app`.
# scripts/build-local.sh --checks runs this same target, so a local release build
# and CI gate on one list. Each check runs even when an earlier one failed.
@@ -882,7 +887,7 @@ CI_CHECKS := mincheck l10ncheck \
sigcheck callscheck np-test-batch-check webpatch-fixtures peicon-fixtures panel-behavior spawn-env \
activatecheck compatcheck compatsvc-check prefixstate-check shortcutcheck launch-shell envcheck \
buildcheck settingscheck routecheck bridgecheck envpasscheck prefixnotecheck powernotecheck exitcheck gamedrivecheck launchercheck \
- seedcheck gamefixescheck versioncheck cicheck padcheck compat-reported-check np-native-tests native-shim-tests \
+ seedcheck gamefixescheck versioncheck cicheck padcheck compat-reported-check np-inventory-check np-native-tests native-shim-tests \
app-tests native-installercheck
# app.yml runs the checks that need the built app in its build job and the rest in a
diff --git a/scripts/np-inventory.py b/scripts/np-inventory.py
index e399ef7..bcbbde4 100755
--- a/scripts/np-inventory.py
+++ b/scripts/np-inventory.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Inventory installed Steam games and rate them for Bridgeplay.
-Reads ~/Library/Application Support/Steam/steamapps/appmanifest_*.acf, queries the Steam store
+Reads appmanifest_*.acf from all configured Steam libraries, queries the Steam store
(native Mac?), PCGamingWiki (D3D/Vulkan, 64-bit) and AreWeAntiCheatYet (anti-cheat), writes
compat/installed.json and prints a table.
"""
@@ -19,16 +19,40 @@ STEAMAPPS = os.path.expanduser("~/Library/Application Support/Steam/steamapps")
SKIP = {228980} # Steamworks Common Redistributables
+def installed_manifests():
+ libraries = [STEAMAPPS]
+ # Modern Steam keeps the index in steamapps; older installs kept it in config.
+ # Read both when available, then deduplicate library paths and app IDs.
+ for index in (
+ os.path.join(STEAMAPPS, "libraryfolders.vdf"),
+ os.path.join(os.path.dirname(STEAMAPPS), "config", "libraryfolders.vdf"),
+ ):
+ if os.path.isfile(index):
+ with open(index, encoding="utf-8", errors="replace") as f:
+ for raw in re.findall(r'^\s*"path"\s+"((?:\\.|[^"\\])*)"', f.read(), re.M):
+ library = re.sub(r'\\(["\\])', r'\1', raw)
+ libraries.append(os.path.join(library, "steamapps"))
+
+ seen = set()
+ for steamapps in dict.fromkeys(os.path.realpath(p) for p in libraries):
+ for manifest in sorted(glob.glob(os.path.join(steamapps, "appmanifest_*.acf"))):
+ appid = os.path.basename(manifest)[len("appmanifest_"):-len(".acf")]
+ if appid not in seen:
+ seen.add(appid)
+ yield manifest
+
+
def main():
rows = []
- for f in sorted(glob.glob(os.path.join(STEAMAPPS, "appmanifest_*.acf"))):
- txt = open(f, encoding="utf-8", errors="replace").read()
+ for f in installed_manifests():
+ with open(f, encoding="utf-8", errors="replace") as manifest_file:
+ txt = manifest_file.read()
g = lambda k: (re.search(r'"%s"\s+"(.*)"' % k, txt) or [None, ""])[1]
appid = int(g("appid"))
if appid in SKIP:
continue
name = g("name")
- idir = os.path.join(STEAMAPPS, "common", g("installdir"))
+ idir = os.path.join(os.path.dirname(f), "common", g("installdir"))
skip = re.compile(r"unins|crash|redist|vcredist|dxsetup|dotnet|installer|setup|eac|battleye|helper|touchup|cleanup|overlayinjector|bugsplat|bssndrpt|repair|crs-|activationui", re.I)
exes = sorted({os.path.relpath(os.path.join(d, x), idir) for d, _, fs in os.walk(idir) for x in fs
if x.lower().endswith(".exe") and not skip.search(x) and d[len(idir):].count(os.sep) <= 4})
@@ -50,7 +74,8 @@ def main():
print(f" fetched {appid} {name}", file=sys.stderr)
out = os.path.join(ROOT, "compat", "installed.json")
os.makedirs(os.path.dirname(out), exist_ok=True)
- json.dump(rows, open(out, "w"), indent=2)
+ with open(out, "w", encoding="utf-8") as inventory_file:
+ json.dump(rows, inventory_file, indent=2)
hdr = ("appid", "name", "mac native?", "D3D/Vulkan", "64-bit", "anti-cheat", "suggested first backend")
table = [hdr] + [(str(r["appid"]), r["name"], "yes" if r["mac_native"] else "no", r["api"], r["win64"],
r["anticheat"], r["suggested_backend"]) for r in rows]
diff --git a/scripts/tests/np-inventory.py b/scripts/tests/np-inventory.py
new file mode 100644
index 0000000..05d1bdd
--- /dev/null
+++ b/scripts/tests/np-inventory.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+"""Offline regression for Steam libraries outside the default install."""
+import importlib.util
+import json
+from pathlib import Path
+import tempfile
+import unittest
+from unittest.mock import patch
+
+
+SCRIPT = Path(__file__).resolve().parents[1] / "np-inventory.py"
+spec = importlib.util.spec_from_file_location("bridgeplay_np_inventory", SCRIPT)
+module = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(module)
+
+
+class InventoryTests(unittest.TestCase):
+ def test_external_library_manifests_and_executables(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ primary = root / "Steam" / "steamapps"
+ other = root / "Library with spaces" / "steamapps"
+ for directory in (primary, other):
+ (directory / "common" / "Game").mkdir(parents=True)
+ (primary / "libraryfolders.vdf").write_text(
+ '"libraryfolders"\n{\n "1"\n {\n "path" "' + str(other.parent) + '"\n }\n}\n')
+ for folder, appid in ((primary, 101), (other, 102), (other, 101)):
+ (folder / f"appmanifest_{appid}.acf").write_text(
+ '"AppState"\n{\n "appid" "' + str(appid) +
+ '"\n "name" "Game"\n "installdir" "Game"\n}\n')
+ (other / "common" / "Game" / "game.exe").write_text("")
+ with patch.object(module, "STEAMAPPS", str(primary)), \
+ patch.object(module, "ROOT", str(root)), \
+ patch.object(module.L, "store", return_value={"mac": False, "windows": True}), \
+ patch.object(module.L, "pcgw", return_value=None), \
+ patch.object(module.L, "awacy", return_value=(None, [])):
+ module.main()
+ rows = json.loads((root / "compat" / "installed.json").read_text())
+ self.assertEqual([101, 102], sorted(r["appid"] for r in rows))
+ external = next(r for r in rows if r["appid"] == 102)
+ self.assertEqual(["game.exe"], external["exes"])
+
+
+ def test_legacy_config_index(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ steam = root / "Steam"
+ primary = steam / "steamapps"
+ legacy = root / "Older Library" / "steamapps"
+ primary.mkdir(parents=True)
+ legacy.mkdir(parents=True)
+ config = steam / "config"
+ config.mkdir()
+ (config / "libraryfolders.vdf").write_text(
+ '"libraryfolders"\n{\n "1"\n {\n "path" "' +
+ str(legacy.parent) + '"\n }\n}\n')
+ (legacy / "appmanifest_201.acf").write_text('"AppState"\n{}\n')
+ with patch.object(module, "STEAMAPPS", str(primary)):
+ found = list(module.installed_manifests())
+ self.assertEqual(
+ [(legacy / "appmanifest_201.acf").resolve()],
+ [Path(manifest).resolve() for manifest in found],
+ )
+
+ def test_modern_and_legacy_indexes_are_combined(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ steam = root / "Steam"
+ primary = steam / "steamapps"
+ modern = root / "Modern Library" / "steamapps"
+ legacy = root / "Older Library" / "steamapps"
+ for folder in (primary, modern, legacy):
+ folder.mkdir(parents=True)
+ (primary / "libraryfolders.vdf").write_text(
+ '"libraryfolders"\n{\n "1"\n {\n "path" "' +
+ str(modern.parent) + '"\n }\n}\n')
+ (steam / "config").mkdir()
+ (steam / "config" / "libraryfolders.vdf").write_text(
+ '"libraryfolders"\n{\n "2"\n {\n "path" "' +
+ str(legacy.parent) + '"\n }\n}\n')
+ (modern / "appmanifest_301.acf").write_text('"AppState"\n{}\n')
+ (legacy / "appmanifest_302.acf").write_text('"AppState"\n{}\n')
+ with patch.object(module, "STEAMAPPS", str(primary)):
+ found = sorted(Path(p).name for p in module.installed_manifests())
+ self.assertEqual(["appmanifest_301.acf", "appmanifest_302.acf"], found)
+
+
+if __name__ == "__main__":
+ unittest.main()