mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Migrate build_system targets to null safety (#92869)
This commit is contained in:
parent
1fe5b75c0e
commit
e56c83a1ac
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../android/deferred_components_gen_snapshot_validator.dart';
|
||||
@ -19,8 +17,8 @@ import 'android.dart';
|
||||
class DeferredComponentsGenSnapshotValidatorTarget extends Target {
|
||||
/// Create an [AndroidAotDeferredComponentsBundle] implementation for a given [targetPlatform] and [buildMode].
|
||||
DeferredComponentsGenSnapshotValidatorTarget({
|
||||
@required this.deferredComponentsDependencies,
|
||||
@required this.nonDeferredComponentsDependencies,
|
||||
required this.deferredComponentsDependencies,
|
||||
required this.nonDeferredComponentsDependencies,
|
||||
this.title,
|
||||
this.exitOnFail = true,
|
||||
});
|
||||
@ -31,7 +29,7 @@ class DeferredComponentsGenSnapshotValidatorTarget extends Target {
|
||||
|
||||
/// The title of the [DeferredComponentsGenSnapshotValidator] that is
|
||||
/// displayed to the developer when logging results.
|
||||
final String title;
|
||||
final String? title;
|
||||
|
||||
/// Whether to exit the tool if a recommended change is found by the
|
||||
/// [DeferredComponentsGenSnapshotValidator].
|
||||
@ -72,7 +70,7 @@ class DeferredComponentsGenSnapshotValidatorTarget extends Target {
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
DeferredComponentsGenSnapshotValidator validator;
|
||||
DeferredComponentsGenSnapshotValidator? validator;
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
@ -92,18 +90,18 @@ class DeferredComponentsGenSnapshotValidatorTarget extends Target {
|
||||
abis: _abis
|
||||
);
|
||||
|
||||
validator
|
||||
validator!
|
||||
..checkAppAndroidManifestComponentLoadingUnitMapping(
|
||||
FlutterProject.current().manifest.deferredComponents,
|
||||
FlutterProject.current().manifest.deferredComponents ?? <DeferredComponent>[],
|
||||
generatedLoadingUnits,
|
||||
)
|
||||
..checkAgainstLoadingUnitsCache(generatedLoadingUnits)
|
||||
..writeLoadingUnitsCache(generatedLoadingUnits);
|
||||
|
||||
validator.handleResults();
|
||||
validator!.handleResults();
|
||||
|
||||
depfileService.writeToFile(
|
||||
Depfile(validator.inputs, validator.outputs),
|
||||
Depfile(validator!.inputs, validator!.outputs),
|
||||
environment.buildDir.childFile('flutter_$name.d'),
|
||||
);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../artifacts.dart';
|
||||
@ -37,45 +35,47 @@ abstract class AotAssemblyBase extends Target {
|
||||
final AOTSnapshotter snapshotter = AOTSnapshotter(
|
||||
fileSystem: environment.fileSystem,
|
||||
logger: environment.logger,
|
||||
xcode: globals.xcode,
|
||||
xcode: globals.xcode!,
|
||||
artifacts: environment.artifacts,
|
||||
processManager: environment.processManager,
|
||||
);
|
||||
final String buildOutputPath = environment.buildDir.path;
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? environmentBuildMode = environment.defines[kBuildMode];
|
||||
if (environmentBuildMode == null) {
|
||||
throw MissingDefineException(kBuildMode, 'aot_assembly');
|
||||
}
|
||||
if (environment.defines[kTargetPlatform] == null) {
|
||||
final String? environmentTargetPlatform = environment.defines[kTargetPlatform];
|
||||
if (environmentTargetPlatform== null) {
|
||||
throw MissingDefineException(kTargetPlatform, 'aot_assembly');
|
||||
}
|
||||
if (environment.defines[kSdkRoot] == null) {
|
||||
final String? sdkRoot = environment.defines[kSdkRoot];
|
||||
if (sdkRoot == null) {
|
||||
throw MissingDefineException(kSdkRoot, 'aot_assembly');
|
||||
}
|
||||
|
||||
final List<String> extraGenSnapshotOptions = decodeCommaSeparated(environment.defines, kExtraGenSnapshotOptions);
|
||||
final bool bitcode = environment.defines[kBitcodeFlag] == 'true';
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
final String splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
final BuildMode buildMode = getBuildModeForName(environmentBuildMode);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environmentTargetPlatform);
|
||||
final String? splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
final bool dartObfuscation = environment.defines[kDartObfuscation] == 'true';
|
||||
final List<DarwinArch> darwinArchs = environment.defines[kIosArchs]
|
||||
?.split(' ')
|
||||
?.map(getIOSArchForName)
|
||||
?.toList()
|
||||
.map(getIOSArchForName)
|
||||
.toList()
|
||||
?? <DarwinArch>[DarwinArch.arm64];
|
||||
if (targetPlatform != TargetPlatform.ios) {
|
||||
throw Exception('aot_assembly is only supported for iOS applications.');
|
||||
}
|
||||
|
||||
final String sdkRoot = environment.defines[kSdkRoot];
|
||||
final EnvironmentType environmentType = environmentTypeFromSdkroot(sdkRoot, environment.fileSystem);
|
||||
final EnvironmentType? environmentType = environmentTypeFromSdkroot(sdkRoot, environment.fileSystem);
|
||||
if (environmentType == EnvironmentType.simulator) {
|
||||
throw Exception(
|
||||
'release/profile builds are only supported for physical devices. '
|
||||
'attempted to build for simulator.'
|
||||
);
|
||||
}
|
||||
final String codeSizeDirectory = environment.defines[kCodeSizeDirectory];
|
||||
final String? codeSizeDirectory = environment.defines[kCodeSizeDirectory];
|
||||
|
||||
// If we're building multiple iOS archs the binaries need to be lipo'd
|
||||
// together.
|
||||
@ -220,14 +220,13 @@ class DebugUniversalFramework extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kSdkRoot] == null) {
|
||||
final String? sdkRoot = environment.defines[kSdkRoot];
|
||||
if (sdkRoot == null) {
|
||||
throw MissingDefineException(kSdkRoot, name);
|
||||
}
|
||||
|
||||
// Generate a trivial App.framework.
|
||||
final Set<String> iosArchNames = environment.defines[kIosArchs]
|
||||
?.split(' ')
|
||||
?.toSet();
|
||||
final Set<String>? iosArchNames = environment.defines[kIosArchs]?.split(' ').toSet();
|
||||
final File output = environment.buildDir
|
||||
.childDirectory('App.framework')
|
||||
.childFile('App');
|
||||
@ -236,6 +235,7 @@ class DebugUniversalFramework extends Target {
|
||||
output,
|
||||
environment,
|
||||
iosArchNames,
|
||||
sdkRoot,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -272,30 +272,31 @@ abstract class UnpackIOS extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kSdkRoot] == null) {
|
||||
final String? sdkRoot = environment.defines[kSdkRoot];
|
||||
if (sdkRoot == null) {
|
||||
throw MissingDefineException(kSdkRoot, name);
|
||||
}
|
||||
if (environment.defines[kIosArchs] == null) {
|
||||
final String? archs = environment.defines[kIosArchs];
|
||||
if (archs == null) {
|
||||
throw MissingDefineException(kIosArchs, name);
|
||||
}
|
||||
if (environment.defines[kBitcodeFlag] == null) {
|
||||
throw MissingDefineException(kBitcodeFlag, name);
|
||||
}
|
||||
_copyFramework(environment);
|
||||
_copyFramework(environment, sdkRoot);
|
||||
|
||||
final File frameworkBinary = environment.outputDir.childDirectory('Flutter.framework').childFile('Flutter');
|
||||
final String frameworkBinaryPath = frameworkBinary.path;
|
||||
if (!frameworkBinary.existsSync()) {
|
||||
throw Exception('Binary $frameworkBinaryPath does not exist, cannot thin');
|
||||
}
|
||||
_thinFramework(environment, frameworkBinaryPath);
|
||||
_thinFramework(environment, frameworkBinaryPath, archs);
|
||||
_bitcodeStripFramework(environment, frameworkBinaryPath);
|
||||
_signFramework(environment, frameworkBinaryPath, buildMode);
|
||||
}
|
||||
|
||||
void _copyFramework(Environment environment) {
|
||||
final String sdkRoot = environment.defines[kSdkRoot];
|
||||
final EnvironmentType environmentType = environmentTypeFromSdkroot(sdkRoot, environment.fileSystem);
|
||||
void _copyFramework(Environment environment, String sdkRoot) {
|
||||
final EnvironmentType? environmentType = environmentTypeFromSdkroot(sdkRoot, environment.fileSystem);
|
||||
final String basePath = environment.artifacts.getArtifactPath(
|
||||
Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios,
|
||||
@ -321,8 +322,7 @@ abstract class UnpackIOS extends Target {
|
||||
}
|
||||
|
||||
/// Destructively thin Flutter.framework to include only the specified architectures.
|
||||
void _thinFramework(Environment environment, String frameworkBinaryPath) {
|
||||
final String archs = environment.defines[kIosArchs];
|
||||
void _thinFramework(Environment environment, String frameworkBinaryPath, String archs) {
|
||||
final List<String> archList = archs.split(' ').toList();
|
||||
final ProcessResult infoResult = environment.processManager.runSync(<String>[
|
||||
'lipo',
|
||||
@ -454,10 +454,11 @@ abstract class IosAssetBundle extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? environmentBuildMode = environment.defines[kBuildMode];
|
||||
if (environmentBuildMode == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final BuildMode buildMode = getBuildModeForName(environmentBuildMode);
|
||||
final Directory frameworkDirectory = environment.outputDir.childDirectory('App.framework');
|
||||
final String frameworkBinaryPath = frameworkDirectory.childFile('App').path;
|
||||
final Directory assetDirectory = frameworkDirectory.childDirectory('flutter_assets');
|
||||
@ -574,7 +575,7 @@ class ReleaseIosApplicationBundle extends IosAssetBundle {
|
||||
/// but it isn't actually executed. To generate something valid, we compile a trivial
|
||||
/// constant.
|
||||
Future<void> _createStubAppFramework(File outputFile, Environment environment,
|
||||
Set<String> iosArchNames) async {
|
||||
Set<String>? iosArchNames, String sdkRoot) async {
|
||||
try {
|
||||
outputFile.createSync(recursive: true);
|
||||
} on Exception catch (e) {
|
||||
@ -590,13 +591,12 @@ Future<void> _createStubAppFramework(File outputFile, Environment environment,
|
||||
static const int Moo = 88;
|
||||
''');
|
||||
|
||||
final String sdkRoot = environment.defines[kSdkRoot];
|
||||
final EnvironmentType environmentType = environmentTypeFromSdkroot(sdkRoot, fileSystem);
|
||||
final EnvironmentType? environmentType = environmentTypeFromSdkroot(sdkRoot, fileSystem);
|
||||
|
||||
await globals.xcode.clang(<String>[
|
||||
await globals.xcode!.clang(<String>[
|
||||
'-x',
|
||||
'c',
|
||||
for (String arch in iosArchNames) ...<String>['-arch', arch],
|
||||
for (String arch in iosArchNames ?? <String>{}) ...<String>['-arch', arch],
|
||||
stubSource.path,
|
||||
'-dynamiclib',
|
||||
'-fembed-bitcode-marker',
|
||||
@ -625,7 +625,7 @@ Future<void> _createStubAppFramework(File outputFile, Environment environment,
|
||||
}
|
||||
|
||||
void _signFramework(Environment environment, String binaryPath, BuildMode buildMode) {
|
||||
String codesignIdentity = environment.defines[kCodesignIdentity];
|
||||
String? codesignIdentity = environment.defines[kCodesignIdentity];
|
||||
if (codesignIdentity == null || codesignIdentity.isEmpty) {
|
||||
codesignIdentity = '-';
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../build_info.dart';
|
||||
@ -49,7 +47,11 @@ class UnpackLinux extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.linuxDesktopPath,
|
||||
@ -117,10 +119,11 @@ abstract class BundleLinuxAssets extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, 'bundle_linux_assets');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final Directory outputDirectory = environment.outputDir
|
||||
.childDirectory('flutter_assets');
|
||||
if (!outputDirectory.existsSync()) {
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/build.dart';
|
||||
import '../../base/file_system.dart';
|
||||
@ -46,10 +44,11 @@ abstract class UnpackMacOS extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, 'unpack_macos');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final String basePath = environment.artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode);
|
||||
|
||||
final ProcessResult result = environment.processManager.runSync(<String>[
|
||||
@ -182,7 +181,7 @@ class DebugMacOSFramework extends Target {
|
||||
|
||||
final Iterable<DarwinArch> darwinArchs = environment.defines[kDarwinArchs]
|
||||
?.split(' ')
|
||||
?.map(getDarwinArchForName)
|
||||
.map(getDarwinArchForName)
|
||||
?? <DarwinArch>[DarwinArch.x86_64];
|
||||
|
||||
final Iterable<String> darwinArchArguments =
|
||||
@ -193,7 +192,7 @@ class DebugMacOSFramework extends Target {
|
||||
..writeAsStringSync(r'''
|
||||
static const int Moo = 88;
|
||||
''');
|
||||
final RunResult result = await globals.xcode.clang(<String>[
|
||||
final RunResult result = await globals.xcode!.clang(<String>[
|
||||
'-x',
|
||||
'c',
|
||||
debugApp.path,
|
||||
@ -231,23 +230,28 @@ class CompileMacOSFramework extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String? targetPlatformEnvironment = environment.defines[kTargetPlatform];
|
||||
if (targetPlatformEnvironment == null) {
|
||||
throw MissingDefineException(kTargetPlatform, 'kernel_snapshot');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
if (buildMode == BuildMode.debug) {
|
||||
throw Exception('precompiled macOS framework only supported in release/profile builds.');
|
||||
}
|
||||
final String buildOutputPath = environment.buildDir.path;
|
||||
final String codeSizeDirectory = environment.defines[kCodeSizeDirectory];
|
||||
final String splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
final String? codeSizeDirectory = environment.defines[kCodeSizeDirectory];
|
||||
final String? splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
final bool dartObfuscation = environment.defines[kDartObfuscation] == 'true';
|
||||
final List<String> extraGenSnapshotOptions = decodeCommaSeparated(environment.defines, kExtraGenSnapshotOptions);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(targetPlatformEnvironment);
|
||||
final List<DarwinArch> darwinArchs = environment.defines[kDarwinArchs]
|
||||
?.split(' ')
|
||||
?.map(getDarwinArchForName)
|
||||
?.toList()
|
||||
.map(getDarwinArchForName)
|
||||
.toList()
|
||||
?? <DarwinArch>[DarwinArch.x86_64];
|
||||
if (targetPlatform != TargetPlatform.darwin) {
|
||||
throw Exception('compile_macos_framework is only supported for darwin TargetPlatform.');
|
||||
@ -256,7 +260,7 @@ class CompileMacOSFramework extends Target {
|
||||
final AOTSnapshotter snapshotter = AOTSnapshotter(
|
||||
fileSystem: environment.fileSystem,
|
||||
logger: environment.logger,
|
||||
xcode: globals.xcode,
|
||||
xcode: globals.xcode!,
|
||||
artifacts: environment.artifacts,
|
||||
processManager: environment.processManager
|
||||
);
|
||||
@ -353,10 +357,11 @@ abstract class MacOSBundleFlutterAssets extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final Directory frameworkRootDirectory = environment
|
||||
.outputDir
|
||||
.childDirectory('App.framework');
|
||||
|
@ -2,12 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
|
||||
import '../../artifacts.dart';
|
||||
@ -22,6 +19,7 @@ import '../../globals.dart' as globals;
|
||||
import '../../project.dart';
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
import 'assets.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
@ -64,7 +62,7 @@ const String kOfflineFirst = 'offline-first';
|
||||
const String kNoneWorker = 'none';
|
||||
|
||||
/// Convert a [value] into a [ServiceWorkerStrategy].
|
||||
ServiceWorkerStrategy _serviceWorkerStrategyFromString(String value) {
|
||||
ServiceWorkerStrategy _serviceWorkerStrategyFromString(String? value) {
|
||||
switch (value) {
|
||||
case kNoneWorker:
|
||||
return ServiceWorkerStrategy.none;
|
||||
@ -97,7 +95,7 @@ class WebEntrypointTarget extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final String targetFile = environment.defines[kTargetFile];
|
||||
final String? targetFile = environment.defines[kTargetFile];
|
||||
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
|
||||
final Uri importUri = environment.fileSystem.file(targetFile).absolute.uri;
|
||||
// TODO(zanderso): support configuration of this file.
|
||||
@ -110,7 +108,7 @@ class WebEntrypointTarget extends Target {
|
||||
final LanguageVersion languageVersion = determineLanguageVersion(
|
||||
environment.fileSystem.file(targetFile),
|
||||
packageConfig[flutterProject.manifest.appName],
|
||||
Cache.flutterRoot,
|
||||
Cache.flutterRoot!,
|
||||
);
|
||||
|
||||
// Use the PackageConfig to find the correct package-scheme import path
|
||||
@ -211,16 +209,21 @@ class Dart2JSTarget extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final bool sourceMapsEnabled = environment.defines[kSourceMapsEnabled] == 'true';
|
||||
final bool nativeNullAssertions = environment.defines[kNativeNullAssertions] == 'true';
|
||||
final String librariesSpec = (globals.artifacts.getHostArtifact(HostArtifact.flutterWebSdk) as Directory).childFile('libraries.json').path;
|
||||
final Artifacts artifacts = globals.artifacts!;
|
||||
final String librariesSpec = (artifacts.getHostArtifact(HostArtifact.flutterWebSdk) as Directory).childFile('libraries.json').path;
|
||||
final List<String> sharedCommandOptions = <String>[
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
'--disable-dart-dev',
|
||||
globals.artifacts.getHostArtifact(HostArtifact.dart2jsSnapshot).path,
|
||||
artifacts.getHostArtifact(HostArtifact.dart2jsSnapshot).path,
|
||||
'--libraries-spec=$librariesSpec',
|
||||
...?decodeCommaSeparated(environment.defines, kExtraFrontEndOptions),
|
||||
...decodeCommaSeparated(environment.defines, kExtraFrontEndOptions),
|
||||
if (nativeNullAssertions)
|
||||
'--native-null-assertions',
|
||||
if (buildMode == BuildMode.profile)
|
||||
@ -247,7 +250,7 @@ class Dart2JSTarget extends Target {
|
||||
throw Exception(_collectOutput(kernelResult));
|
||||
}
|
||||
|
||||
final String dart2jsOptimization = environment.defines[kDart2jsOptimization];
|
||||
final String? dart2jsOptimization = environment.defines[kDart2jsOptimization];
|
||||
final File outputJSFile = environment.buildDir.childFile('main.dart.js');
|
||||
final bool csp = environment.defines[kCspMode] == 'true';
|
||||
|
||||
@ -384,12 +387,11 @@ class WebReleaseBundle extends Target {
|
||||
"navigator.serviceWorker.register('flutter_service_worker.js')",
|
||||
"navigator.serviceWorker.register('flutter_service_worker.js?v=$randomHash')",
|
||||
);
|
||||
if (resultString.contains(kBaseHrefPlaceholder) &&
|
||||
environment.defines[kBaseHref] == null) {
|
||||
final String? baseHref = environment.defines[kBaseHref];
|
||||
if (resultString.contains(kBaseHrefPlaceholder) && baseHref == null) {
|
||||
resultString = resultString.replaceAll(kBaseHrefPlaceholder, '/');
|
||||
} else if (resultString.contains(kBaseHrefPlaceholder) &&
|
||||
environment.defines[kBaseHref] != null) {
|
||||
resultString = resultString.replaceAll(kBaseHrefPlaceholder, environment.defines[kBaseHref]);
|
||||
} else if (resultString.contains(kBaseHrefPlaceholder) && baseHref != null) {
|
||||
resultString = resultString.replaceAll(kBaseHrefPlaceholder, baseHref);
|
||||
}
|
||||
outputFile.writeAsStringSync(resultString);
|
||||
continue;
|
||||
@ -549,7 +551,7 @@ class WebServiceWorker extends Target {
|
||||
String generateServiceWorker(
|
||||
Map<String, String> resources,
|
||||
List<String> coreBundle, {
|
||||
@required ServiceWorkerStrategy serviceWorkerStrategy,
|
||||
required ServiceWorkerStrategy serviceWorkerStrategy,
|
||||
}) {
|
||||
if (serviceWorkerStrategy == ServiceWorkerStrategy.none) {
|
||||
return '';
|
||||
|
@ -2,10 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../build_info.dart';
|
||||
@ -68,7 +64,11 @@ class UnpackWindows extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.windowsDesktopPath,
|
||||
@ -135,7 +135,11 @@ class UnpackWindowsUwp extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, name);
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final String engineSourcePath = environment.artifacts
|
||||
.getArtifactPath(
|
||||
Artifact.windowsUwpDesktopPath,
|
||||
@ -209,10 +213,11 @@ abstract class BundleWindowsAssets extends Target {
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
if (environment.defines[kBuildMode] == null) {
|
||||
final String? buildModeEnvironment = environment.defines[kBuildMode];
|
||||
if (buildModeEnvironment == null) {
|
||||
throw MissingDefineException(kBuildMode, 'bundle_windows_assets');
|
||||
}
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
|
||||
final Directory outputDirectory = environment.outputDir
|
||||
.childDirectory('flutter_assets');
|
||||
if (!outputDirectory.existsSync()) {
|
||||
@ -255,7 +260,7 @@ abstract class BundleWindowsAssetsUwp extends BundleWindowsAssets {
|
||||
/// A wrapper for AOT compilation that copies app.so into the output directory.
|
||||
class WindowsAotBundle extends Target {
|
||||
/// Create a [WindowsAotBundle] wrapper for [aotTarget].
|
||||
const WindowsAotBundle(this.aotTarget, {@required this.uwp});
|
||||
const WindowsAotBundle(this.aotTarget, {required this.uwp});
|
||||
|
||||
/// The [AotElfBase] subclass that produces the app.so.
|
||||
final AotElfBase aotTarget;
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
@ -15,8 +13,8 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver _flutter;
|
||||
late Directory tempDir;
|
||||
late FlutterRunTestDriver _flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
|
Loading…
Reference in New Issue
Block a user