Reverts "Move native assets to isolated/ directory" (#143027)
Reverts flutter/flutter#142709 Initiated by: vashworth Reason for reverting: `Mac tool_tests_general` started failing on this commit: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20tool_tests_general/15552/overview Original PR Author: dcharkes Reviewed By: {christopherfujino, chingjun, reidbaker} This change reverts the following previous change: Original Description: Native assets in other build systems are not built with `package:native_assets_builder` invoking `build.dart` scripts. Instead all packages have their own blaze rules. Therefore we'd like to not depend on `package:native_assets_builder` from flutter tools in g3 at all. This PR aims to move the imports of `native_assets_builder` and `native_assets_cli` into the `isolated/` directory and into the files with a `main` function that are not used in with other build systems. In order to be able to remove all imports in files used by other build systems, two new interfaces are added `HotRunnerNativeAssetsBuilder` and `TestCompilerNativeAssetsBuilder`. New parameters are then piped all the way through from the entry points: * bin/fuchsia_tester.dart * lib/executable.dart The build_system/targets dir is already excluded in other build systems. So, after this PR only the two above files and build_system/targets import from `isolated/native_assets/` and only `isolated/native_assets/` import `package:native_assets_cli` and `package:native_assets_builder`. Context: * https://github.com/flutter/flutter/issues/142041
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
|
||||
import 'package:native_assets_builder/native_assets_builder.dart'
|
||||
show BuildResult, DryRunResult;
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
as native_assets_cli;
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
hide BuildMode;
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
as native_assets_cli;
|
||||
|
||||
import '../../../android/android_sdk.dart';
|
||||
import '../../../base/common.dart';
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../native_assets.dart';
|
||||
import 'android_sdk.dart';
|
||||
|
||||
/// Dry run the native builds.
|
||||
///
|
||||
@@ -7,18 +7,18 @@ import 'package:native_assets_cli/native_assets_cli_internal.dart' show Asset;
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import '../../android/gradle_utils.dart';
|
||||
import '../../android/native_assets.dart';
|
||||
import '../../base/common.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/platform.dart';
|
||||
import '../../build_info.dart';
|
||||
import '../../dart/package_map.dart';
|
||||
import '../../isolated/native_assets/android/native_assets.dart';
|
||||
import '../../isolated/native_assets/ios/native_assets.dart';
|
||||
import '../../isolated/native_assets/linux/native_assets.dart';
|
||||
import '../../isolated/native_assets/macos/native_assets.dart';
|
||||
import '../../isolated/native_assets/native_assets.dart';
|
||||
import '../../isolated/native_assets/windows/native_assets.dart';
|
||||
import '../../ios/native_assets.dart';
|
||||
import '../../linux/native_assets.dart';
|
||||
import '../../macos/native_assets.dart';
|
||||
import '../../macos/xcode.dart';
|
||||
import '../../native_assets.dart';
|
||||
import '../../windows/native_assets.dart';
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
|
||||
@@ -71,7 +71,6 @@ class AttachCommand extends FlutterCommand {
|
||||
required Platform platform,
|
||||
required ProcessInfo processInfo,
|
||||
required FileSystem fileSystem,
|
||||
HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) : _hotRunnerFactory = hotRunnerFactory ?? HotRunnerFactory(),
|
||||
_stdio = stdio,
|
||||
_logger = logger,
|
||||
@@ -79,8 +78,7 @@ class AttachCommand extends FlutterCommand {
|
||||
_signals = signals,
|
||||
_platform = platform,
|
||||
_processInfo = processInfo,
|
||||
_fileSystem = fileSystem,
|
||||
_nativeAssetsBuilder = nativeAssetsBuilder {
|
||||
_fileSystem = fileSystem {
|
||||
addBuildModeFlags(verboseHelp: verboseHelp, defaultToRelease: false, excludeRelease: true);
|
||||
usesTargetOption();
|
||||
usesPortOptions(verboseHelp: verboseHelp);
|
||||
@@ -152,7 +150,6 @@ class AttachCommand extends FlutterCommand {
|
||||
final Platform _platform;
|
||||
final ProcessInfo _processInfo;
|
||||
final FileSystem _fileSystem;
|
||||
final HotRunnerNativeAssetsBuilder? _nativeAssetsBuilder;
|
||||
|
||||
@override
|
||||
final String name = 'attach';
|
||||
@@ -419,7 +416,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
|
||||
device: device,
|
||||
flutterProject: flutterProject,
|
||||
usesIpv6: usesIpv6,
|
||||
nativeAssetsBuilder: _nativeAssetsBuilder,
|
||||
);
|
||||
late AppInstance app;
|
||||
try {
|
||||
@@ -453,7 +449,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
|
||||
device: device,
|
||||
flutterProject: flutterProject,
|
||||
usesIpv6: usesIpv6,
|
||||
nativeAssetsBuilder: _nativeAssetsBuilder,
|
||||
);
|
||||
final Completer<void> onAppStart = Completer<void>.sync();
|
||||
TerminalHandler? terminalHandler;
|
||||
@@ -510,7 +505,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
|
||||
required Device device,
|
||||
required FlutterProject flutterProject,
|
||||
required bool usesIpv6,
|
||||
required HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
|
||||
@@ -545,7 +539,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
|
||||
ipv6: usesIpv6,
|
||||
flutterProject: flutterProject,
|
||||
nativeAssetsYamlFile: stringArg(FlutterOptions.kNativeAssetsYamlFile),
|
||||
nativeAssetsBuilder: _nativeAssetsBuilder,
|
||||
analytics: analytics,
|
||||
)
|
||||
: ColdRunner(
|
||||
@@ -580,7 +573,6 @@ class HotRunnerFactory {
|
||||
bool ipv6 = false,
|
||||
FlutterProject? flutterProject,
|
||||
String? nativeAssetsYamlFile,
|
||||
required HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
required Analytics analytics,
|
||||
}) => HotRunner(
|
||||
devices,
|
||||
@@ -594,7 +586,6 @@ class HotRunnerFactory {
|
||||
stayResident: stayResident,
|
||||
ipv6: ipv6,
|
||||
nativeAssetsYamlFile: nativeAssetsYamlFile,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
analytics: analytics,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -654,7 +654,6 @@ class AppDomain extends Domain {
|
||||
bool machine = true,
|
||||
String? userIdentifier,
|
||||
bool enableDevTools = true,
|
||||
required HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) async {
|
||||
if (!await device.supportsRuntimeMode(options.buildInfo.mode)) {
|
||||
throw Exception(
|
||||
@@ -706,7 +705,6 @@ class AppDomain extends Domain {
|
||||
hostIsIde: true,
|
||||
machine: machine,
|
||||
analytics: globals.analytics,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
} else {
|
||||
runner = ColdRunner(
|
||||
|
||||
@@ -334,11 +334,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
||||
}
|
||||
|
||||
class RunCommand extends RunCommandBase {
|
||||
RunCommand({
|
||||
bool verboseHelp = false,
|
||||
HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) : _nativeAssetsBuilder = nativeAssetsBuilder,
|
||||
super(verboseHelp: verboseHelp) {
|
||||
RunCommand({ bool verboseHelp = false }) : super(verboseHelp: verboseHelp) {
|
||||
requiresPubspecYaml();
|
||||
usesFilesystemOptions(hide: !verboseHelp);
|
||||
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
|
||||
@@ -422,8 +418,6 @@ class RunCommand extends RunCommandBase {
|
||||
);
|
||||
}
|
||||
|
||||
final HotRunnerNativeAssetsBuilder? _nativeAssetsBuilder;
|
||||
|
||||
@override
|
||||
final String name = 'run';
|
||||
|
||||
@@ -666,7 +660,6 @@ class RunCommand extends RunCommandBase {
|
||||
ipv6: ipv6 ?? false,
|
||||
analytics: globals.analytics,
|
||||
nativeAssetsYamlFile: stringArg(FlutterOptions.kNativeAssetsYamlFile),
|
||||
nativeAssetsBuilder: _nativeAssetsBuilder,
|
||||
);
|
||||
} else if (webMode) {
|
||||
return webRunnerFactory!.createWebRunner(
|
||||
@@ -740,7 +733,6 @@ class RunCommand extends RunCommandBase {
|
||||
ipv6: ipv6 ?? false,
|
||||
userIdentifier: userIdentifier,
|
||||
enableDevTools: boolArg(FlutterCommand.kEnableDevTools),
|
||||
nativeAssetsBuilder: _nativeAssetsBuilder,
|
||||
);
|
||||
} on Exception catch (error) {
|
||||
throwToolExit(error.toString());
|
||||
|
||||
@@ -18,7 +18,6 @@ import '../runner/flutter_command.dart';
|
||||
import '../test/coverage_collector.dart';
|
||||
import '../test/event_printer.dart';
|
||||
import '../test/runner.dart';
|
||||
import '../test/test_compiler.dart';
|
||||
import '../test/test_time_recorder.dart';
|
||||
import '../test/test_wrapper.dart';
|
||||
import '../test/watcher.dart';
|
||||
@@ -64,7 +63,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
this.testWrapper = const TestWrapper(),
|
||||
this.testRunner = const FlutterTestRunner(),
|
||||
this.verbose = false,
|
||||
this.nativeAssetsBuilder,
|
||||
}) {
|
||||
requiresPubspecYaml();
|
||||
usesPubOption();
|
||||
@@ -239,8 +237,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
/// Interface for running the tester process.
|
||||
final FlutterTestRunner testRunner;
|
||||
|
||||
final TestCompilerNativeAssetsBuilder? nativeAssetsBuilder;
|
||||
|
||||
final bool verbose;
|
||||
|
||||
@visibleForTesting
|
||||
@@ -508,7 +504,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
integrationTestDevice: integrationTestDevice,
|
||||
integrationTestUserIdentifier: stringArg(FlutterOptions.kDeviceUser),
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
testTimeRecorder?.stop(TestTimePhases.TestRunner, testRunnerTimeRecorderStopwatch!);
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
as native_assets_cli;
|
||||
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../base/file_system.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
|
||||
import '../macos/native_assets_host.dart';
|
||||
import '../native_assets.dart';
|
||||
@@ -1,4 +0,0 @@
|
||||
The directory structure in here mirrors the directory structure in lib/src/.
|
||||
|
||||
The native assets feature lives in lib/src/isolated/ because this code is not
|
||||
used in other build systems.
|
||||
@@ -1,80 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Logic for native assets shared between all host OSes.
|
||||
|
||||
import '../../../base/os.dart';
|
||||
import '../../../base/platform.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../../../project.dart';
|
||||
import '../../../test/test_compiler.dart';
|
||||
import '../linux/native_assets.dart';
|
||||
import '../macos/native_assets.dart';
|
||||
import '../native_assets.dart';
|
||||
import '../windows/native_assets.dart';
|
||||
|
||||
class TestCompilerNativeAssetsBuilderImpl
|
||||
implements TestCompilerNativeAssetsBuilder {
|
||||
const TestCompilerNativeAssetsBuilderImpl();
|
||||
|
||||
@override
|
||||
Future<Uri?> build(BuildInfo buildInfo) =>
|
||||
testCompilerBuildNativeAssets(buildInfo);
|
||||
}
|
||||
|
||||
Future<Uri?> testCompilerBuildNativeAssets(BuildInfo buildInfo) async {
|
||||
Uri? nativeAssetsYaml;
|
||||
if (!buildInfo.buildNativeAssets) {
|
||||
nativeAssetsYaml = null;
|
||||
} else {
|
||||
final Uri projectUri = FlutterProject.current().directory.uri;
|
||||
final NativeAssetsBuildRunner buildRunner = NativeAssetsBuildRunnerImpl(
|
||||
projectUri,
|
||||
buildInfo.packageConfig,
|
||||
globals.fs,
|
||||
globals.logger,
|
||||
);
|
||||
if (globals.platform.isMacOS) {
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsMacOS(
|
||||
buildMode: buildInfo.mode,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else if (globals.platform.isLinux) {
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsLinux(
|
||||
buildMode: buildInfo.mode,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else if (globals.platform.isWindows) {
|
||||
final TargetPlatform targetPlatform;
|
||||
if (globals.os.hostPlatform == HostPlatform.windows_x64) {
|
||||
targetPlatform = TargetPlatform.windows_x64;
|
||||
} else {
|
||||
targetPlatform = TargetPlatform.windows_arm64;
|
||||
}
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsWindows(
|
||||
buildMode: buildInfo.mode,
|
||||
targetPlatform: targetPlatform,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else {
|
||||
await ensureNoNativeAssetsOrOsIsSupported(
|
||||
projectUri,
|
||||
const LocalPlatform().operatingSystem,
|
||||
globals.fs,
|
||||
buildRunner,
|
||||
);
|
||||
}
|
||||
}
|
||||
return nativeAssetsYaml;
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
hide BuildMode;
|
||||
|
||||
import '../../../base/common.dart';
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../base/io.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../native_assets.dart';
|
||||
|
||||
/// Dry run the native builds.
|
||||
@@ -9,9 +9,9 @@ import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
as native_assets_cli;
|
||||
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../base/file_system.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../native_assets.dart';
|
||||
import 'native_assets_host.dart';
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
hide BuildMode;
|
||||
|
||||
import '../../../base/common.dart';
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../base/io.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../convert.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../build_info.dart';
|
||||
import '../convert.dart';
|
||||
import '../globals.dart' as globals;
|
||||
|
||||
/// Create an `Info.plist` in [target] for a framework with a single dylib.
|
||||
///
|
||||
@@ -5,28 +5,25 @@
|
||||
// Logic for native assets shared between all host OSes.
|
||||
|
||||
import 'package:logging/logging.dart' as logging;
|
||||
import 'package:native_assets_builder/native_assets_builder.dart'
|
||||
as native_assets_builder show NativeAssetsBuildRunner;
|
||||
import 'package:native_assets_builder/native_assets_builder.dart'
|
||||
hide NativeAssetsBuildRunner;
|
||||
import 'package:native_assets_builder/native_assets_builder.dart' hide NativeAssetsBuildRunner;
|
||||
import 'package:native_assets_builder/native_assets_builder.dart' as native_assets_builder show NativeAssetsBuildRunner;
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart';
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import '../../base/common.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../base/platform.dart';
|
||||
import '../../build_info.dart' as build_info;
|
||||
import '../../cache.dart';
|
||||
import '../../features.dart';
|
||||
import '../../globals.dart' as globals;
|
||||
import '../../resident_runner.dart';
|
||||
import '../../run_hot.dart';
|
||||
import 'android/native_assets.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'build_info.dart' as build_info;
|
||||
import 'cache.dart';
|
||||
import 'features.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'ios/native_assets.dart';
|
||||
import 'linux/native_assets.dart';
|
||||
import 'macos/native_assets.dart';
|
||||
import 'macos/native_assets_host.dart';
|
||||
import 'resident_runner.dart';
|
||||
import 'windows/native_assets.dart';
|
||||
|
||||
/// Programmatic API to be used by Dart launchers to invoke native builds.
|
||||
@@ -313,32 +310,6 @@ Uri nativeAssetsBuildUri(Uri projectUri, OS os) {
|
||||
return projectUri.resolve('$buildDir/native_assets/$os/');
|
||||
}
|
||||
|
||||
class HotRunnerNativeAssetsBuilderImpl implements HotRunnerNativeAssetsBuilder {
|
||||
const HotRunnerNativeAssetsBuilderImpl();
|
||||
|
||||
@override
|
||||
Future<Uri?> dryRun({
|
||||
required Uri projectUri,
|
||||
required FileSystem fileSystem,
|
||||
required List<FlutterDevice> flutterDevices,
|
||||
required PackageConfig packageConfig,
|
||||
required Logger logger,
|
||||
}) async {
|
||||
final NativeAssetsBuildRunner buildRunner = NativeAssetsBuildRunnerImpl(
|
||||
projectUri,
|
||||
packageConfig,
|
||||
fileSystem,
|
||||
globals.logger,
|
||||
);
|
||||
return dryRunNativeAssets(
|
||||
projectUri: projectUri,
|
||||
fileSystem: fileSystem,
|
||||
buildRunner: buildRunner,
|
||||
flutterDevices: flutterDevices,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the native asset id to dylib mapping to embed in the kernel file.
|
||||
///
|
||||
/// Run hot compiles a kernel file that is pushed to the device after hot
|
||||
@@ -22,6 +22,7 @@ import 'dart/package_map.dart';
|
||||
import 'devfs.dart';
|
||||
import 'device.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'native_assets.dart';
|
||||
import 'project.dart';
|
||||
import 'reporting/reporting.dart';
|
||||
import 'resident_runner.dart';
|
||||
@@ -92,13 +93,13 @@ class HotRunner extends ResidentRunner {
|
||||
StopwatchFactory stopwatchFactory = const StopwatchFactory(),
|
||||
ReloadSourcesHelper reloadSourcesHelper = defaultReloadSourcesHelper,
|
||||
ReassembleHelper reassembleHelper = _defaultReassembleHelper,
|
||||
HotRunnerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
NativeAssetsBuildRunner? buildRunner,
|
||||
String? nativeAssetsYamlFile,
|
||||
required Analytics analytics,
|
||||
}) : _stopwatchFactory = stopwatchFactory,
|
||||
_reloadSourcesHelper = reloadSourcesHelper,
|
||||
_reassembleHelper = reassembleHelper,
|
||||
_nativeAssetsBuilder = nativeAssetsBuilder,
|
||||
_buildRunner = buildRunner,
|
||||
_nativeAssetsYamlFile = nativeAssetsYamlFile,
|
||||
_analytics = analytics,
|
||||
super(
|
||||
@@ -138,7 +139,7 @@ class HotRunner extends ResidentRunner {
|
||||
String? _sdkName;
|
||||
bool? _emulator;
|
||||
|
||||
final HotRunnerNativeAssetsBuilder? _nativeAssetsBuilder;
|
||||
NativeAssetsBuildRunner? _buildRunner;
|
||||
final String? _nativeAssetsYamlFile;
|
||||
|
||||
String? flavor;
|
||||
@@ -373,12 +374,17 @@ class HotRunner extends ResidentRunner {
|
||||
nativeAssetsYaml = globals.fs.path.toUri(_nativeAssetsYamlFile);
|
||||
} else {
|
||||
final Uri projectUri = Uri.directory(projectRootPath);
|
||||
nativeAssetsYaml = await _nativeAssetsBuilder?.dryRun(
|
||||
_buildRunner ??= NativeAssetsBuildRunnerImpl(
|
||||
projectUri,
|
||||
debuggingOptions.buildInfo.packageConfig,
|
||||
fileSystem,
|
||||
globals.logger,
|
||||
);
|
||||
nativeAssetsYaml = await dryRunNativeAssets(
|
||||
projectUri: projectUri,
|
||||
fileSystem: fileSystem,
|
||||
buildRunner: _buildRunner!,
|
||||
flutterDevices: flutterDevices,
|
||||
logger: logger,
|
||||
packageConfig: debuggingOptions.buildInfo.packageConfig,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1722,15 +1728,3 @@ class ReasonForCancelling {
|
||||
return '$message.\nTry performing a hot restart instead.';
|
||||
}
|
||||
}
|
||||
|
||||
/// An interface to enable overriding native assets build logic in other
|
||||
/// build systems.
|
||||
abstract class HotRunnerNativeAssetsBuilder {
|
||||
Future<Uri?> dryRun({
|
||||
required Uri projectUri,
|
||||
required FileSystem fileSystem,
|
||||
required List<FlutterDevice> flutterDevices,
|
||||
required PackageConfig packageConfig,
|
||||
required Logger logger,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ FlutterPlatform installHook({
|
||||
String? integrationTestUserIdentifier,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
UriConverter? uriConverter,
|
||||
TestCompilerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) {
|
||||
assert(enableVmService || enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
|
||||
|
||||
@@ -100,7 +99,6 @@ FlutterPlatform installHook({
|
||||
integrationTestUserIdentifier: integrationTestUserIdentifier,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
uriConverter: uriConverter,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
platformPluginRegistration(platform);
|
||||
return platform;
|
||||
@@ -293,7 +291,6 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
this.integrationTestUserIdentifier,
|
||||
this.testTimeRecorder,
|
||||
this.uriConverter,
|
||||
this.nativeAssetsBuilder,
|
||||
});
|
||||
|
||||
final String shellPath;
|
||||
@@ -310,7 +307,6 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
final FlutterProject? flutterProject;
|
||||
final String? icudtlPath;
|
||||
final TestTimeRecorder? testTimeRecorder;
|
||||
final TestCompilerNativeAssetsBuilder? nativeAssetsBuilder;
|
||||
|
||||
// This can be used by internal projects that require custom logic for converting package: URIs to local paths.
|
||||
final UriConverter? uriConverter;
|
||||
@@ -469,13 +465,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
// running this with a debugger attached. Initialize the resident
|
||||
// compiler in this case.
|
||||
if (debuggingOptions.startPaused) {
|
||||
compiler ??= TestCompiler(
|
||||
debuggingOptions.buildInfo,
|
||||
flutterProject,
|
||||
precompiledDillPath: precompiledDillPath,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, precompiledDillPath: precompiledDillPath, testTimeRecorder: testTimeRecorder);
|
||||
final Uri uri = globals.fs.file(path).uri;
|
||||
// Trigger a compilation to initialize the resident compiler.
|
||||
unawaited(compiler!.compile(uri));
|
||||
@@ -497,12 +487,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
// Integration test device takes care of the compilation.
|
||||
if (integrationTestDevice == null) {
|
||||
// Lazily instantiate compiler so it is built only if it is actually used.
|
||||
compiler ??= TestCompiler(
|
||||
debuggingOptions.buildInfo,
|
||||
flutterProject,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, testTimeRecorder: testTimeRecorder);
|
||||
mainDart = await compiler!.compile(globals.fs.file(mainDart).uri);
|
||||
|
||||
if (mainDart == null) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import '../web/chrome.dart';
|
||||
import '../web/memory_fs.dart';
|
||||
import 'flutter_platform.dart' as loader;
|
||||
import 'flutter_web_platform.dart';
|
||||
import 'test_compiler.dart';
|
||||
import 'test_time_recorder.dart';
|
||||
import 'test_wrapper.dart';
|
||||
import 'watcher.dart';
|
||||
@@ -54,7 +53,6 @@ abstract class FlutterTestRunner {
|
||||
Device? integrationTestDevice,
|
||||
String? integrationTestUserIdentifier,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
TestCompilerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +91,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
Device? integrationTestDevice,
|
||||
String? integrationTestUserIdentifier,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
TestCompilerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) async {
|
||||
// Configure package:test to use the Flutter engine for child processes.
|
||||
final String shellPath = globals.artifacts!.getArtifactPath(Artifact.flutterTester);
|
||||
@@ -213,7 +210,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
integrationTestDevice: integrationTestDevice,
|
||||
integrationTestUserIdentifier: integrationTestUserIdentifier,
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
nativeAssetsBuilder: nativeAssetsBuilder,
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
@@ -10,12 +10,18 @@ import 'package:meta/meta.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/os.dart' show HostPlatform;
|
||||
import '../base/platform.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart';
|
||||
import '../compile.dart';
|
||||
import '../flutter_plugins.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../linux/native_assets.dart';
|
||||
import '../macos/native_assets.dart';
|
||||
import '../native_assets.dart';
|
||||
import '../project.dart';
|
||||
import '../windows/native_assets.dart';
|
||||
import 'test_time_recorder.dart';
|
||||
|
||||
/// A request to the [TestCompiler] for recompilation.
|
||||
@@ -45,11 +51,9 @@ class TestCompiler {
|
||||
/// If [testTimeRecorder] is passed, times will be recorded in it.
|
||||
TestCompiler(
|
||||
this.buildInfo,
|
||||
this.flutterProject, {
|
||||
String? precompiledDillPath,
|
||||
this.testTimeRecorder,
|
||||
TestCompilerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
}) : testFilePath = precompiledDillPath ?? globals.fs.path.join(
|
||||
this.flutterProject,
|
||||
{ String? precompiledDillPath, this.testTimeRecorder }
|
||||
) : testFilePath = precompiledDillPath ?? globals.fs.path.join(
|
||||
flutterProject!.directory.path,
|
||||
getBuildDirectory(),
|
||||
'test_cache',
|
||||
@@ -58,8 +62,7 @@ class TestCompiler {
|
||||
dartDefines: buildInfo.dartDefines,
|
||||
extraFrontEndOptions: buildInfo.extraFrontEndOptions,
|
||||
)),
|
||||
shouldCopyDillFile = precompiledDillPath == null,
|
||||
_nativeAssetsBuilder = nativeAssetsBuilder {
|
||||
shouldCopyDillFile = precompiledDillPath == null {
|
||||
// Compiler maintains and updates single incremental dill file.
|
||||
// Incremental compilation requests done for each test copy that file away
|
||||
// for independent execution.
|
||||
@@ -80,7 +83,6 @@ class TestCompiler {
|
||||
final String testFilePath;
|
||||
final bool shouldCopyDillFile;
|
||||
final TestTimeRecorder? testTimeRecorder;
|
||||
final TestCompilerNativeAssetsBuilder? _nativeAssetsBuilder;
|
||||
|
||||
|
||||
ResidentCompiler? compiler;
|
||||
@@ -168,7 +170,57 @@ class TestCompiler {
|
||||
invalidatedRegistrantFiles.add(flutterProject!.dartPluginRegistrant.absolute.uri);
|
||||
}
|
||||
|
||||
final Uri? nativeAssetsYaml = await _nativeAssetsBuilder?.build(buildInfo);
|
||||
Uri? nativeAssetsYaml;
|
||||
if (!buildInfo.buildNativeAssets) {
|
||||
nativeAssetsYaml = null;
|
||||
} else {
|
||||
final Uri projectUri = FlutterProject.current().directory.uri;
|
||||
final NativeAssetsBuildRunner buildRunner = NativeAssetsBuildRunnerImpl(
|
||||
projectUri,
|
||||
buildInfo.packageConfig,
|
||||
globals.fs,
|
||||
globals.logger,
|
||||
);
|
||||
if (globals.platform.isMacOS) {
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsMacOS(
|
||||
buildMode: buildInfo.mode,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else if (globals.platform.isLinux) {
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsLinux(
|
||||
buildMode: buildInfo.mode,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else if (globals.platform.isWindows) {
|
||||
final TargetPlatform targetPlatform;
|
||||
if (globals.os.hostPlatform == HostPlatform.windows_x64) {
|
||||
targetPlatform = TargetPlatform.windows_x64;
|
||||
} else {
|
||||
targetPlatform = TargetPlatform.windows_arm64;
|
||||
}
|
||||
(nativeAssetsYaml, _) = await buildNativeAssetsWindows(
|
||||
buildMode: buildInfo.mode,
|
||||
targetPlatform: targetPlatform,
|
||||
projectUri: projectUri,
|
||||
flutterTester: true,
|
||||
fileSystem: globals.fs,
|
||||
buildRunner: buildRunner,
|
||||
);
|
||||
} else {
|
||||
await ensureNoNativeAssetsOrOsIsSupported(
|
||||
projectUri,
|
||||
const LocalPlatform().operatingSystem,
|
||||
globals.fs,
|
||||
buildRunner,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final CompilerOutput? compilerOutput = await compiler!.recompile(
|
||||
request.mainUri,
|
||||
@@ -218,9 +270,3 @@ class TestCompiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An interface to enable overriding native assets build logic in other
|
||||
/// build systems.
|
||||
abstract class TestCompilerNativeAssetsBuilder {
|
||||
Future<Uri?> build(BuildInfo buildInfo);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
import 'package:native_assets_cli/native_assets_cli_internal.dart'
|
||||
hide BuildMode;
|
||||
|
||||
import '../../../base/file_system.dart';
|
||||
import '../../../build_info.dart';
|
||||
import '../../../globals.dart' as globals;
|
||||
import '../../../windows/visual_studio.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../native_assets.dart';
|
||||
import 'visual_studio.dart';
|
||||
|
||||
/// Dry run the native builds.
|
||||
///
|
||||
@@ -66,6 +66,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future<CCompilerConfig> cCompilerConfigWindows() async {
|
||||
final VisualStudio visualStudio = VisualStudio(
|
||||
fileSystem: globals.fs,
|
||||
Reference in New Issue
Block a user