1#!/usr/bin/env python3 2import sys 3import subprocess 4 5# get the strings XNU build-folder strings for the given device 6def main(): 7 sdkroot = sys.argv[1] 8 target_name = sys.argv[2] # e.g. j414c 9 query = f"SELECT DISTINCT KernelMachOArchitecture, KernelPlatform, SDKPlatform FROM Targets WHERE TargetType == '{target_name}'" 10 r = subprocess.check_output(["xcrun", "--sdk", sdkroot, "embedded_device_map", "-query", query], encoding="ascii") 11 r = r.strip() 12 if len(r) == 0: 13 raise Exception(f"target not found {target_name}") 14 arch, kernel_platform, sdk_platform = r.split("|") 15 16 if arch.startswith("arm64"): # can be arm64, arm64e 17 arch = "ARM64" 18 elif arch.startswith("arm"): 19 arch = "ARM" 20 else: 21 raise Exception(f"unsupported arch {arch}") 22 23 if sdk_platform == "macosx": 24 file_name_prefix = "kernel" 25 else: 26 file_name_prefix = "mach" 27 print(arch + " " + kernel_platform + " " + file_name_prefix) 28 29if __name__ == "__main__": 30 sys.exit(main()) 31