| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import json
- from pathlib import Path
- import re
- import sys
- import xml.etree.ElementTree as ET
- PACKAGE = Path(__file__).resolve().parents[1]
- errors = []
- def check(condition, message):
- if not condition:
- errors.append(message)
- def visible(path):
- return not any(p.startswith('.') or p.endswith('~') for p in path.relative_to(PACKAGE).parts)
- manifest = json.loads((PACKAGE / 'package.json').read_text(encoding='utf-8-sig'))
- check(manifest['name'] == 'come.app.runtimes', 'Unexpected technical name')
- check(manifest['displayName'] == 'AppRuntimes', 'Unexpected display name')
- for name, version in manifest['dependencies'].items():
- check(re.fullmatch(r'\d+\.\d+\.\d+(?:-[\w.-]+)?', version), f'Non-registry dependency: {name}')
- check('com.unity.inputsystem' not in manifest['dependencies'], 'Input System must remain optional')
- check('com.unity.modules.androidjni' in manifest['dependencies'], 'Android JNI support missing')
- for sample in manifest.get('samples', []):
- check((PACKAGE / sample['path']).is_dir(), f'Missing sample: {sample["path"]}')
- guids = {}
- for meta in PACKAGE.rglob('*.meta'):
- if not visible(meta):
- continue
- match = re.search(r'^guid: ([0-9a-f]{32})$', meta.read_text(encoding='utf-8-sig'), re.M)
- check(match is not None, f'Invalid meta: {meta.relative_to(PACKAGE)}')
- if match:
- check(match[1] not in guids, f'Duplicate GUID: {meta} / {guids.get(match[1])}')
- guids[match[1]] = meta
- check(meta.with_suffix('').exists(), f'Orphan meta: {meta.relative_to(PACKAGE)}')
- definitions = {}
- names = set()
- for path in PACKAGE.rglob('*.asmdef'):
- if not visible(path):
- continue
- definition = json.loads(path.read_text(encoding='utf-8-sig'))
- name = definition['name']
- check(name not in names, f'Duplicate assembly: {name}')
- names.add(name)
- definitions[path.parent] = definition
- check(path.with_name(path.name + '.meta').exists(), f'Missing assembly meta: {path}')
- check('dotween' not in json.dumps(definition).lower(), f'DOTween reference: {path}')
- if name == 'AppRuntimes':
- check(not definition.get('includePlatforms') and not definition.get('excludePlatforms'), 'Runtime platforms restricted')
- scripts = [p for p in PACKAGE.rglob('*.cs') if visible(p)]
- for script in scripts:
- parent = script.parent
- while parent != PACKAGE and parent not in definitions:
- parent = parent.parent
- check(parent in definitions, f'Script outside an assembly: {script.relative_to(PACKAGE)}')
- if parent in definitions and 'Editor' in script.relative_to(PACKAGE).parts:
- check(definitions[parent].get('includePlatforms') == ['Editor'], f'Editor code in runtime assembly: {script}')
- check(script.with_name(script.name + '.meta').exists(), f'Missing script metadata: {script}')
- for forbidden in ('DOTweenSettings.asset', 'DOTween.dll', 'AndroidManifest.xml'):
- check(not any(visible(p) for p in PACKAGE.rglob(forbidden)), f'Project-specific or removed content shipped: {forbidden}')
- for filename in ('AppSettings.asset', 'FacebookSettings.asset', 'settings.asset'):
- expected = PACKAGE / 'Editor' / 'DefaultSettings' / filename
- check(expected.is_file(), f'Missing default settings template: {filename}')
- check(expected.with_name(filename + '.meta').is_file(), f'Missing default settings metadata: {filename}')
- check(all(p == expected for p in PACKAGE.rglob(filename) if visible(p)),
- f'Settings must only ship as Editor templates: {filename}')
- check(len(list(PACKAGE.rglob('package.json'))) == 1, 'Nested package manifest found')
- for relative in (
- 'ThirdParty/FacebookSDK/Plugins/Android/Facebook.Unity.Android.dll',
- 'ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml',
- 'ThirdParty/ExternalDependencyManager/Editor/1.2.187/Google.JarResolver.dll',
- 'ThirdParty/ExternalDependencyManager/Editor/1.2.187/Google.IOSResolver.dll',
- 'ThirdParty/UniWebView/Plugins/Android/UniWebView.aar',
- 'ThirdParty/UniWebView/Plugins/iOS/UniWebView.xcframework/Info.plist',
- 'ThirdParty/UniWebView/Plugins/macOS/UniWebView.bundle/Contents/Info.plist',
- 'ThirdParty/UniTask/LICENSE.md', 'Runtime/Resources/Loading.prefab',
- 'Runtime/IAP/IAPWrapper.cs', 'Runtime/IAP/IAPAndroidImpl.cs',
- 'ThirdParty/IAPiOS/IAP/Editor/iOS/IAPUnityInterface.mm',
- 'ThirdParty/IAPiOS/IAP/Editor/iOS/IAPSK1.mm',
- 'ThirdParty/IAPiOS/IAP/Editor/iOS/Swift/IAPSK2.swift',
- 'ThirdParty/IAPiOS/IAP/Editor/iOS/FBSDKUnityStoreKit.storekit',
- 'StreamingAssets~/meta.mp4', 'StreamingAssets~/meta-logo.png'
- ):
- check((PACKAGE / relative).is_file(), f'Missing dependency/resource: {relative}')
- for relative in ('ThirdParty/FacebookSDK/link.xml', 'ThirdParty/UniWebView/link.xml'):
- check(ET.parse(PACKAGE / relative).getroot().tag == 'linker', f'Invalid linker file: {relative}')
- if errors:
- print('\n'.join('ERROR: ' + error for error in errors))
- sys.exit(1)
- print(f'PASS: {manifest["name"]}; {len(names)} assemblies, {len(scripts)} scripts, {len(guids)} GUIDs')
|