@@ -1278,167 +1278,6 @@ struct ExportLibsData {
1278
1278
String dest_dir;
1279
1279
};
1280
1280
1281
- bool EditorExportPlatformIOS::_archive_has_arm64 (const String &p_path, uint32_t *r_cputype, uint32_t *r_cpusubtype) const {
1282
- bool has_arm64_image = false ;
1283
- if (FileAccess::exists (p_path)) {
1284
- if (LipO::is_lipo (p_path)) {
1285
- // LipO.
1286
- Ref<LipO> lipo;
1287
- lipo.instantiate ();
1288
- if (lipo->open_file (p_path)) {
1289
- for (int i = 0 ; i < lipo->get_arch_count (); i++) {
1290
- if (lipo->get_arch_cputype (i) == 0x100000c && lipo->get_arch_cpusubtype (i) == 0 ) {
1291
- has_arm64_image = true ;
1292
- break ;
1293
- }
1294
- }
1295
- }
1296
- lipo->close ();
1297
- } else {
1298
- // Single architecture archive.
1299
- Ref<FileAccess> sim_f = FileAccess::open (p_path, FileAccess::READ);
1300
- if (sim_f.is_valid ()) {
1301
- char magic[9 ] = {};
1302
- sim_f->get_buffer ((uint8_t *)&magic[0 ], 8 );
1303
- if (String (magic) == String (" !<arch>\n " )) {
1304
- while (!sim_f->eof_reached ()) {
1305
- // Read file metadata.
1306
- char name_short[17 ] = {};
1307
- char size_short[11 ] = {};
1308
- sim_f->get_buffer ((uint8_t *)&name_short[0 ], 16 );
1309
- sim_f->seek (sim_f->get_position () + 12 + 6 + 6 + 8 ); // Skip modification time, owner ID, group ID, file mode.
1310
- sim_f->get_buffer ((uint8_t *)&size_short[0 ], 10 );
1311
- sim_f->seek (sim_f->get_position () + 2 ); // Skip end marker.
1312
-
1313
- int64_t file_size = String (size_short).to_int ();
1314
- int64_t next_off = sim_f->get_position () + file_size;
1315
-
1316
- String name = String (name_short); // Skip extended name.
1317
- if (name.is_empty () || file_size == 0 ) {
1318
- break ;
1319
- }
1320
- if (name.begins_with (" #1/" )) {
1321
- int64_t name_len = String (name_short).replace (" #1/" , " " ).to_int ();
1322
- sim_f->seek (sim_f->get_position () + name_len);
1323
- }
1324
-
1325
- // Read file content.
1326
- uint32_t obj_magic = sim_f->get_32 ();
1327
-
1328
- bool swap = (obj_magic == 0xcffaedfe || obj_magic == 0xcefaedfe );
1329
- if (obj_magic == 0xcefaedfe || obj_magic == 0xfeedface || obj_magic == 0xcffaedfe || obj_magic == 0xfeedfacf ) {
1330
- uint32_t cputype = sim_f->get_32 ();
1331
- uint32_t cpusubtype = sim_f->get_32 ();
1332
- if (swap) {
1333
- cputype = BSWAP32 (cputype);
1334
- cpusubtype = BSWAP32 (cpusubtype);
1335
- }
1336
- if (r_cputype) {
1337
- *r_cputype = cputype;
1338
- }
1339
- if (r_cpusubtype) {
1340
- *r_cpusubtype = cpusubtype;
1341
- }
1342
- if (cputype == 0x100000c && cpusubtype == 0 ) {
1343
- has_arm64_image = true ;
1344
- }
1345
- break ;
1346
- }
1347
- sim_f->seek (next_off);
1348
- }
1349
- }
1350
- sim_f->close ();
1351
- }
1352
- }
1353
- }
1354
- return has_arm64_image;
1355
- }
1356
-
1357
- int EditorExportPlatformIOS::_archive_convert_to_simulator (const String &p_path) const {
1358
- int commands_patched = 0 ;
1359
- Ref<FileAccess> sim_f = FileAccess::open (p_path, FileAccess::READ_WRITE);
1360
- if (sim_f.is_valid ()) {
1361
- char magic[9 ] = {};
1362
- sim_f->get_buffer ((uint8_t *)&magic[0 ], 8 );
1363
- if (String (magic) == String (" !<arch>\n " )) {
1364
- while (!sim_f->eof_reached ()) {
1365
- // Read file metadata.
1366
- char name_short[17 ] = {};
1367
- char size_short[11 ] = {};
1368
- sim_f->get_buffer ((uint8_t *)&name_short[0 ], 16 );
1369
- sim_f->seek (sim_f->get_position () + 12 + 6 + 6 + 8 ); // Skip modification time, owner ID, group ID, file mode.
1370
- sim_f->get_buffer ((uint8_t *)&size_short[0 ], 10 );
1371
- sim_f->seek (sim_f->get_position () + 2 ); // Skip end marker.
1372
-
1373
- int64_t file_size = String (size_short).to_int ();
1374
- int64_t next_off = sim_f->get_position () + file_size;
1375
-
1376
- String name = String (name_short); // Skip extended name.
1377
- if (name.is_empty () || file_size == 0 ) {
1378
- break ;
1379
- }
1380
- if (name.begins_with (" #1/" )) {
1381
- int64_t name_len = String (name_short).replace (" #1/" , " " ).to_int ();
1382
- sim_f->seek (sim_f->get_position () + name_len);
1383
- }
1384
-
1385
- // Read file content.
1386
- uint32_t obj_magic = sim_f->get_32 ();
1387
-
1388
- bool swap = (obj_magic == 0xcffaedfe || obj_magic == 0xcefaedfe );
1389
- if (obj_magic == 0xcefaedfe || obj_magic == 0xfeedface || obj_magic == 0xcffaedfe || obj_magic == 0xfeedfacf ) {
1390
- uint32_t cputype = sim_f->get_32 ();
1391
- uint32_t cpusubtype = sim_f->get_32 ();
1392
- uint32_t filetype = sim_f->get_32 ();
1393
- uint32_t ncmds = sim_f->get_32 ();
1394
- sim_f->get_32 (); // Commands total size.
1395
- sim_f->get_32 (); // Commands flags.
1396
- if (obj_magic == 0xcffaedfe || obj_magic == 0xfeedfacf ) {
1397
- sim_f->get_32 (); // Reserved, 64-bit only.
1398
- }
1399
- if (swap) {
1400
- ncmds = BSWAP32 (ncmds);
1401
- cputype = BSWAP32 (cputype);
1402
- cpusubtype = BSWAP32 (cpusubtype);
1403
- filetype = BSWAP32 (filetype);
1404
- }
1405
- if (cputype == 0x100000C && cpusubtype == 0 && filetype == 1 ) {
1406
- // ARM64, object file.
1407
- for (uint32_t i = 0 ; i < ncmds; i++) {
1408
- int64_t cmdofs = sim_f->get_position ();
1409
- uint32_t cmdid = sim_f->get_32 ();
1410
- uint32_t cmdsize = sim_f->get_32 ();
1411
- if (swap) {
1412
- cmdid = BSWAP32 (cmdid);
1413
- cmdsize = BSWAP32 (cmdsize);
1414
- }
1415
- if (cmdid == MachO::LoadCommandID::LC_BUILD_VERSION) {
1416
- int64_t platform = sim_f->get_32 ();
1417
- if (swap) {
1418
- platform = BSWAP32 (platform);
1419
- }
1420
- if (platform == MachO::PlatformID::PLATFORM_IOS) {
1421
- sim_f->seek (cmdofs + 4 + 4 );
1422
- uint32_t new_id = MachO::PlatformID::PLATFORM_IOSSIMULATOR;
1423
- if (swap) {
1424
- new_id = BSWAP32 (new_id);
1425
- }
1426
- sim_f->store_32 (new_id);
1427
- commands_patched++;
1428
- }
1429
- }
1430
- sim_f->seek (cmdofs + cmdsize);
1431
- }
1432
- }
1433
- }
1434
- sim_f->seek (next_off);
1435
- }
1436
- }
1437
- sim_f->close ();
1438
- }
1439
- return commands_patched;
1440
- }
1441
-
1442
1281
void EditorExportPlatformIOS::_check_xcframework_content (const String &p_path, int &r_total_libs, int &r_static_libs, int &r_dylibs, int &r_frameworks) const {
1443
1282
Ref<PList> plist;
1444
1283
plist.instantiate ();
@@ -2443,82 +2282,6 @@ Error EditorExportPlatformIOS::_export_project_helper(const Ref<EditorExportPres
2443
2282
return ERR_FILE_NOT_FOUND;
2444
2283
}
2445
2284
2446
- // HACK: We don't want to run the simulator library generation code anymore after GH-102179, but removing it
2447
- // triggers an internal compiler error with latest mingw-gcc... For now we bring it back as a workaround
2448
- // with a condition that should never be true (that project setting doesn't exist).
2449
-
2450
- // Check and generate missing ARM64 simulator library.
2451
- if (ProjectSettings::get_singleton ()->has_setting (" __dummy_setting_blame_akien_if_you_define_this_somehow" )) {
2452
- String sim_lib_path = dest_dir + String (binary_name + " .xcframework" ).path_join (" ios-arm64_x86_64-simulator" ).path_join (" libgodot.a" );
2453
- String dev_lib_path = dest_dir + String (binary_name + " .xcframework" ).path_join (" ios-arm64" ).path_join (" libgodot.a" );
2454
- String tmp_lib_path = EditorPaths::get_singleton ()->get_temp_dir ().path_join (binary_name + " _lipo_" );
2455
- uint32_t cputype = 0 ;
2456
- uint32_t cpusubtype = 0 ;
2457
- if (!_archive_has_arm64 (sim_lib_path, &cputype, &cpusubtype) && _archive_has_arm64 (dev_lib_path) && FileAccess::exists (dev_lib_path)) {
2458
- add_message (EXPORT_MESSAGE_INFO, TTR (" Export" ), TTR (" ARM64 simulator library, generating from device library." ));
2459
-
2460
- Vector<String> tmp_lib_files;
2461
- Vector<Vector2i> tmp_lib_cputypes;
2462
- // Extract/copy simulator lib.
2463
- if (FileAccess::exists (sim_lib_path)) {
2464
- if (LipO::is_lipo (sim_lib_path)) {
2465
- Ref<LipO> lipo;
2466
- lipo.instantiate ();
2467
- if (lipo->open_file (sim_lib_path)) {
2468
- for (int i = 0 ; i < lipo->get_arch_count (); i++) {
2469
- const String &f_name = tmp_lib_path + itos (tmp_lib_files.size ());
2470
- lipo->extract_arch (i, f_name);
2471
- tmp_lib_files.push_back (f_name);
2472
- tmp_lib_cputypes.push_back (Vector2i (lipo->get_arch_cputype (i), lipo->get_arch_cpusubtype (i)));
2473
- }
2474
- }
2475
- } else {
2476
- const String &f_name = tmp_lib_path + itos (tmp_lib_files.size ());
2477
- tmp_app_path->copy (sim_lib_path, f_name);
2478
- tmp_lib_files.push_back (f_name);
2479
- tmp_lib_cputypes.push_back (Vector2i (cputype, cpusubtype));
2480
- }
2481
- }
2482
- // Copy device lib.
2483
- if (LipO::is_lipo (dev_lib_path)) {
2484
- Ref<LipO> lipo;
2485
- lipo.instantiate ();
2486
- if (lipo->open_file (dev_lib_path)) {
2487
- for (int i = 0 ; i < lipo->get_arch_count (); i++) {
2488
- if (lipo->get_arch_cputype (i) == 0x100000c && lipo->get_arch_cpusubtype (i) == 0 ) {
2489
- const String &f_name = tmp_lib_path + itos (tmp_lib_files.size ());
2490
- lipo->extract_arch (i, f_name);
2491
- tmp_lib_files.push_back (f_name);
2492
- tmp_lib_cputypes.push_back (Vector2i (0x100000c , 0 )); // ARM64.
2493
- break ;
2494
- }
2495
- }
2496
- }
2497
- } else {
2498
- const String &f_name = tmp_lib_path + itos (tmp_lib_files.size ());
2499
- tmp_app_path->copy (dev_lib_path, f_name);
2500
- tmp_lib_files.push_back (f_name);
2501
- tmp_lib_cputypes.push_back (Vector2i (0x100000c , 0 )); // ARM64.
2502
- }
2503
-
2504
- // Patch device lib.
2505
- int patch_count = _archive_convert_to_simulator (tmp_lib_path + itos (tmp_lib_files.size () - 1 ));
2506
- if (patch_count == 0 ) {
2507
- add_message (EXPORT_MESSAGE_WARNING, TTR (" Export" ), TTR (" Unable to generate ARM64 simulator library." ));
2508
- } else {
2509
- // Repack.
2510
- Ref<LipO> lipo;
2511
- lipo.instantiate ();
2512
- lipo->create_file (sim_lib_path, tmp_lib_files, tmp_lib_cputypes);
2513
- }
2514
-
2515
- // Cleanup.
2516
- for (const String &E : tmp_lib_files) {
2517
- tmp_app_path->remove (E);
2518
- }
2519
- }
2520
- }
2521
-
2522
2285
// Generate translations files.
2523
2286
2524
2287
Dictionary appnames = GLOBAL_GET (" application/config/name_localized" );
0 commit comments