@@ -8,17 +8,20 @@ import 'package:file/file.dart';
8
8
import 'package:meta/meta.dart' ;
9
9
import 'package:platform/platform.dart' ;
10
10
11
- import '../aot.dart' ;
12
11
import '../artifacts.dart' ;
13
12
import '../base/common.dart' ;
14
13
import '../base/file_system.dart' ;
15
14
import '../base/logger.dart' ;
16
15
import '../base/process.dart' ;
17
16
import '../base/utils.dart' ;
18
17
import '../build_info.dart' ;
18
+ import '../build_system/build_system.dart' ;
19
+ import '../build_system/targets/dart.dart' ;
20
+ import '../build_system/targets/icon_tree_shaker.dart' ;
19
21
import '../build_system/targets/ios.dart' ;
20
22
import '../bundle.dart' ;
21
23
import '../cache.dart' ;
24
+ import '../convert.dart' ;
22
25
import '../globals.dart' as globals;
23
26
import '../macos/cocoapod_utils.dart' ;
24
27
import '../macos/xcode.dart' ;
@@ -35,12 +38,12 @@ import 'build.dart';
35
38
class BuildIOSFrameworkCommand extends BuildSubCommand {
36
39
BuildIOSFrameworkCommand ({
37
40
FlutterVersion flutterVersion, // Instantiating FlutterVersion kicks off networking, so delay until it's needed, but allow test injection.
38
- @required AotBuilder aotBuilder,
39
41
@required BundleBuilder bundleBuilder,
42
+ @required BuildSystem buildSystem,
40
43
Cache cache,
41
44
Platform platform
42
45
}) : _flutterVersion = flutterVersion,
43
- _aotBuilder = aotBuilder ,
46
+ _buildSystem = buildSystem ,
44
47
_bundleBuilder = bundleBuilder,
45
48
_injectedCache = cache,
46
49
_injectedPlatform = platform {
@@ -95,8 +98,9 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
95
98
);
96
99
}
97
100
98
- final AotBuilder _aotBuilder;
99
101
final BundleBuilder _bundleBuilder;
102
+ final BuildSystem _buildSystem;
103
+ BuildSystem get buildSystem => _buildSystem ?? globals.buildSystem;
100
104
101
105
Cache get _cache => _injectedCache ?? globals.cache;
102
106
final Cache _injectedCache;
@@ -367,15 +371,17 @@ end
367
371
final Status status = globals.logger.startProgress (
368
372
' ├─Assembling Flutter resources for App.framework...' , timeout: timeoutConfiguration.slowOperation);
369
373
try {
374
+ if (buildInfo.mode == BuildMode .debug) {
370
375
await _bundleBuilder.build (
371
- platform: TargetPlatform .ios,
372
- buildInfo: buildInfo,
373
- // Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
374
- mainPath: globals.fs.path.absolute (targetFile),
375
- assetDirPath: destinationAppFrameworkDirectory.childDirectory ('flutter_assets' ).path,
376
- precompiledSnapshot: buildInfo.mode != BuildMode .debug,
377
- treeShakeIcons: boolArg ('tree-shake-icons' )
378
- );
376
+ platform: TargetPlatform .ios,
377
+ buildInfo: buildInfo,
378
+ // Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
379
+ mainPath: globals.fs.path.absolute (targetFile),
380
+ assetDirPath: destinationAppFrameworkDirectory.childDirectory ('flutter_assets' ).path,
381
+ precompiledSnapshot: buildInfo.mode != BuildMode .debug,
382
+ treeShakeIcons: boolArg ('tree-shake-icons' )
383
+ );
384
+ }
379
385
} finally {
380
386
status.stop ();
381
387
}
@@ -429,16 +435,41 @@ end
429
435
timeout: timeoutConfiguration.slowOperation,
430
436
);
431
437
try {
432
- await _aotBuilder.build (
433
- platform: TargetPlatform .ios,
434
- outputPath: destinationDirectory.path,
435
- buildInfo: buildInfo,
436
- // Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
437
- mainDartFile: globals.fs.path.absolute (targetFile),
438
- quiet: true ,
439
- bitcode: true ,
440
- iosBuildArchs: < DarwinArch > [DarwinArch .armv7, DarwinArch .arm64],
438
+ final Target target = buildInfo.isRelease
439
+ ? const ReleaseIosApplicationBundle ()
440
+ : const ProfileIosApplicationBundle ();
441
+ final Environment environment = Environment (
442
+ projectDir: globals.fs.currentDirectory,
443
+ outputDir: destinationDirectory,
444
+ buildDir: _project.dartTool.childDirectory ('flutter_build' ),
445
+ cacheDir: null ,
446
+ flutterRootDir: globals.fs.directory (Cache .flutterRoot),
447
+ defines: < String , String > {
448
+ kTargetFile: targetFile,
449
+ kBuildMode: getNameForBuildMode (buildInfo.mode),
450
+ kTargetPlatform: getNameForTargetPlatform (TargetPlatform .ios),
451
+ kIconTreeShakerFlag: buildInfo.treeShakeIcons.toString (),
452
+ kDartDefines: jsonEncode (buildInfo.dartDefines),
453
+ kBitcodeFlag: 'true' ,
454
+ if (buildInfo? .extraGenSnapshotOptions? .isNotEmpty ?? false )
455
+ kExtraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions.join (',' ),
456
+ if (buildInfo? .extraFrontEndOptions? .isNotEmpty ?? false )
457
+ kExtraFrontEndOptions: buildInfo.extraFrontEndOptions.join (',' ),
458
+ kIosArchs: < DarwinArch > [DarwinArch .armv7, DarwinArch .arm64]
459
+ .map (getNameForDarwinArch).join (' ' ),
460
+ },
461
+ artifacts: globals.artifacts,
462
+ fileSystem: globals.fs,
463
+ logger: globals.logger,
464
+ processManager: globals.processManager,
441
465
);
466
+ final BuildResult result = await buildSystem.build (target, environment);
467
+ if (! result.success) {
468
+ for (final ExceptionMeasurement measurement in result.exceptions.values) {
469
+ globals.printError (measurement.exception.toString ());
470
+ }
471
+ throwToolExit ('The aot build failed.' );
472
+ }
442
473
} finally {
443
474
status.stop ();
444
475
}
0 commit comments