diff --git a/tools/bind-ca-metal-components.py b/tools/bind-ca-metal-components.py index 6d458bf..e716729 100755 --- a/tools/bind-ca-metal-components.py +++ b/tools/bind-ca-metal-components.py @@ -12,6 +12,8 @@ import hashlib import json import subprocess +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] ORIGINAL = ROOT.parent / 'Snapintosh' sha = lambda p: hashlib.sha256(Path(p).read_bytes()).hexdigest() @@ -102,7 +104,7 @@ kext = ROOT / 'build/ca-integrated-kext-20260928-v1/AdrenoX2.kext' bind(kext / 'Contents/MacOS/AdrenoX2', '54d32bb79af174703a17a21286231b6af6d555ca67d57d7662815a9c4717a9d1') display = ROOT / 'gpu/adreno-kext/kext/src/AdrenoDisplay.cpp' accepted = ROOT.parent / 'Snapintosh-adreno-fill/gpu/adreno-kext/kext/src/AdrenoDisplay.cpp' -assert bind(display) == bind(accepted) +assert [bind(p) for p in source_files(display)] == [bind(p) for p in source_files(accepted)] # with its parts assert b'AdrenoIBCopyABI' in (kext / 'Contents/MacOS/AdrenoX2').read_bytes() for tree in (bundle, ROOT / 'gpu/adreno-kext/kext', ROOT / 'gpu/adreno-kext/plugin'): for path in tree.rglob('*'): diff --git a/tools/bind-composite-metal-components.py b/tools/bind-composite-metal-components.py index ead5593..c9f37d3 100755 --- a/tools/bind-composite-metal-components.py +++ b/tools/bind-composite-metal-components.py @@ -13,6 +13,8 @@ import hashlib import json import subprocess +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] NETWORK = ROOT.parent / 'Snapintosh-adreno-buffer-textures' PIPELINE = ROOT.parent / 'Snapintosh-adreno-pipeline' @@ -67,8 +69,9 @@ def main(): kext = Path(network['kext_bundle']) bind(kext / 'Contents/MacOS/AdrenoX2', network['kext_sha256']) assert b'AdrenoIBCopyABI' in (kext / 'Contents/MacOS/AdrenoX2').read_bytes() - assert bind(ROOT / 'gpu/adreno-kext/kext/src/AdrenoDisplay.cpp') == bind( - ROOT.parent / 'Snapintosh-adreno-fill/gpu/adreno-kext/kext/src/AdrenoDisplay.cpp') + display_unit = source_files(ROOT / 'gpu/adreno-kext/kext/src/AdrenoDisplay.cpp') # with its ordered parts + accepted_unit = source_files(ROOT.parent / 'Snapintosh-adreno-fill/gpu/adreno-kext/kext/src/AdrenoDisplay.cpp') + assert [bind(p) for p in display_unit] == [bind(p) for p in accepted_unit] native_path = ROOT / 'build/qc-pipelines-composite-20260928-v1.json' native = read(native_path, diff --git a/tools/build-panel-mode-candidate.py b/tools/build-panel-mode-candidate.py index 584f72e..65d78b4 100755 --- a/tools/build-panel-mode-candidate.py +++ b/tools/build-panel-mode-candidate.py @@ -8,6 +8,8 @@ from pathlib import Path import shutil import subprocess +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] BASELINE = ROOT / 'build/virtual-ethernet-clock-20260927/native-link-v3' SOURCE = ROOT.parent / 'Snapintosh-adreno-clear' @@ -32,7 +34,8 @@ def main(): for name, expected in objects.items(): assert sha(BASELINE / name) == expected, name source = SOURCE / 'gpu/adreno-kext/kext/src/AdrenoDisplay.cpp' - inputs = {str(source): sha(source), str(BASELINE / 'qualification.json'): sha(BASELINE / 'qualification.json')} + inputs = {str(f): sha(f) for f in source_files(source)} # the unit: AdrenoDisplay.cpp and its parts + inputs[str(BASELINE / 'qualification.json')] = sha(BASELINE / 'qualification.json') for folder in ['gpu/adreno-kext/kext/src', 'gpu/adreno-kext/kext/include', 'gpu/adreno-kext/include']: for f in (SOURCE / folder).glob('*.h'): inputs[str(f)] = sha(f) diff --git a/tools/qualify-adreno-gui-components.py b/tools/qualify-adreno-gui-components.py index a26f316..e9cccfc 100755 --- a/tools/qualify-adreno-gui-components.py +++ b/tools/qualify-adreno-gui-components.py @@ -12,6 +12,8 @@ import sys import time from source_text import read_source +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() @@ -146,7 +148,8 @@ def main(): bind(Path(abi['kernelcache'])) for name in ['tools/check-iomfb-vtable.py', 'tools/test-display-profile.py', 'gpu/adreno-kext/kext/src/AdrenoDisplay.cpp', 'gpu/adreno-kext/kext/src/AdrenoDisplay.h']: - bind(ROOT/name) + for path in source_files(ROOT/name): # a split unit binds its ordered parts too + bind(path) out = args.output.resolve() out.mkdir(parents=True, exist_ok=False) command = [sys.executable, 'tools/test-display-profile.py', '--firmware', str(original/'downloads/extracted/j700ap')] diff --git a/tools/qualify-adreno-ib-command.py b/tools/qualify-adreno-ib-command.py index 1f35c81..67345a0 100755 --- a/tools/qualify-adreno-ib-command.py +++ b/tools/qualify-adreno-ib-command.py @@ -40,6 +40,8 @@ import subprocess import sys from source_text import source_files +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] Q1N1 = ROOT.parent / 'q1n1' / 'tools' PLANS = ROOT / 'build' / 'adreno-pipeline-compiler-20260927' @@ -665,7 +667,8 @@ def main(): if monitor: inputs.append('compat/adreno-ib.h') for kext_source in ('AdrenoX2.cpp', 'AdrenoX2.h', 'AdrenoSegmentList.cpp', 'AdrenoMemoryMap.cpp'): - inputs.append(f'gpu/adreno-kext/kext/src/{kext_source}') + for path in source_files(ROOT / f'gpu/adreno-kext/kext/src/{kext_source}'): # with its ordered parts + inputs.append(str(path.relative_to(ROOT))) inputs.append('gpu/adreno-kext/kext/build.sh') inputs += [str(q.relative_to(ROOT)) for p in inputs if p.endswith('.c') for q in source_files(ROOT / p)[1:]] external = {str(p): sha(p) for p in [PLANS / 'draw-plan-v2/draw.ib.bin', PLANS / 'draw-plan-v2/references.json', diff --git a/tools/qualify-adreno-resource-kext.py b/tools/qualify-adreno-resource-kext.py index 75d8c02..a0f84d5 100755 --- a/tools/qualify-adreno-resource-kext.py +++ b/tools/qualify-adreno-resource-kext.py @@ -13,6 +13,8 @@ import re import struct import subprocess +from source_text import source_files + ROOT = Path(__file__).resolve().parents[1] KDK = Path('/Library/Developer/KDKs/KDK_27.0_26A428.kdk/System/Library') sha = lambda data: hashlib.sha256(data).hexdigest() @@ -152,8 +154,10 @@ def main(): funcs = {f['symbol']: f for im in native['images'] for f in im['functions']} update = funcs['__ZN14IOGPUMemoryMap10update_pteEjP18IOMemoryDescriptorS1_']['instructions'] assert any(i['mnemonic'] == 'tbnz' and i['operands'].startswith('w0, #0,') for i in update) + # AdrenoX2.cpp and its ordered parts + x2_unit = [str(p.relative_to(ROOT)) for p in source_files(ROOT/'gpu/adreno-kext/kext/src/AdrenoX2.cpp')] sources = ['compat/adreno-resource.c','compat/adreno-resource.h','compat/adreno-guest.h', - 'gpu/adreno-kext/kext/src/AdrenoMemoryMap.cpp','gpu/adreno-kext/kext/src/AdrenoX2.cpp', + 'gpu/adreno-kext/kext/src/AdrenoMemoryMap.cpp',*x2_unit, 'gpu/adreno-kext/kext/src/AdrenoX2.h','gpu/adreno-kext/kext/include/IOGPUFamily26A428.h', 'gpu/adreno-kext/kext/Info.plist','gpu/adreno-kext/kext/build.sh', 'tools/trace-adreno-resource-kext.py','tools/trace-adreno-memory-map.py', diff --git a/tools/test-adreno-residency.py b/tools/test-adreno-residency.py index 1c5e55d..13c7f85 100755 --- a/tools/test-adreno-residency.py +++ b/tools/test-adreno-residency.py @@ -31,6 +31,8 @@ import sys import tempfile import unittest +from source_text import read_source + ROOT = Path(__file__).resolve().parents[1] CORE = ROOT / 'compat/adreno-resource.c' HARNESS = ROOT / 'tools/test-adreno-residency.c' @@ -527,7 +529,7 @@ class VAKext(unittest.TestCase): @classmethod def setUpClass(cls): cls.source = MAP.read_text() - cls.display = (KEXT / 'src/AdrenoDisplay.cpp').read_text() + cls.display = read_source(KEXT / 'src/AdrenoDisplay.cpp') # with its ordered parts def test_filler_is_read_only_and_never_released(self): insert = between(self.source, 'static int fillerInsert(')