mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
remove input files argument to target (#39701)
This commit is contained in:
parent
63c3de1091
commit
5e7beaf7b8
@ -113,7 +113,7 @@ abstract class Target {
|
|||||||
List<Source> get outputs;
|
List<Source> get outputs;
|
||||||
|
|
||||||
/// The action which performs this build step.
|
/// The action which performs this build step.
|
||||||
Future<void> build(List<File> inputFiles, Environment environment);
|
Future<void> build(Environment environment);
|
||||||
|
|
||||||
/// Collect hashes for all inputs to determine if any have changed.
|
/// Collect hashes for all inputs to determine if any have changed.
|
||||||
///
|
///
|
||||||
@ -585,7 +585,7 @@ class _BuildInstance {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printStatus('${target.name}: Starting');
|
printStatus('${target.name}: Starting');
|
||||||
await target.build(inputs, environment);
|
await target.build(environment);
|
||||||
printStatus('${target.name}: Complete');
|
printStatus('${target.name}: Complete');
|
||||||
|
|
||||||
final List<File> outputs = target.resolveOutputs(environment, implicit: true);
|
final List<File> outputs = target.resolveOutputs(environment, implicit: true);
|
||||||
|
@ -74,7 +74,7 @@ class CopyAssets extends Target {
|
|||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final Directory output = environment
|
final Directory output = environment
|
||||||
.buildDir
|
.buildDir
|
||||||
.childDirectory('flutter_assets');
|
.childDirectory('flutter_assets');
|
||||||
@ -128,7 +128,7 @@ class FlutterPlugins extends Target {
|
|||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
// The pubspec may change for reasons other than plugins changing, so we compare
|
// The pubspec may change for reasons other than plugins changing, so we compare
|
||||||
// the manifest before writing. Some hosting build systems use timestamps
|
// the manifest before writing. Some hosting build systems use timestamps
|
||||||
// so we need to be careful to avoid tricking them into doing more work than
|
// so we need to be careful to avoid tricking them into doing more work than
|
||||||
|
@ -81,7 +81,7 @@ class KernelSnapshot extends Target {
|
|||||||
List<Target> get dependencies => <Target>[];
|
List<Target> get dependencies => <Target>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final KernelCompiler compiler = await kernelCompilerFactory.create(
|
final KernelCompiler compiler = await kernelCompilerFactory.create(
|
||||||
FlutterProject.fromDirectory(environment.projectDir),
|
FlutterProject.fromDirectory(environment.projectDir),
|
||||||
);
|
);
|
||||||
@ -118,7 +118,7 @@ abstract class AotElfBase extends Target {
|
|||||||
const AotElfBase();
|
const AotElfBase();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final AOTSnapshotter snapshotter = AOTSnapshotter(reportTimings: false);
|
final AOTSnapshotter snapshotter = AOTSnapshotter(reportTimings: false);
|
||||||
final String outputPath = environment.buildDir.path;
|
final String outputPath = environment.buildDir.path;
|
||||||
if (environment.defines[kBuildMode] == null) {
|
if (environment.defines[kBuildMode] == null) {
|
||||||
|
@ -20,7 +20,7 @@ abstract class AotAssemblyBase extends Target {
|
|||||||
const AotAssemblyBase();
|
const AotAssemblyBase();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final AOTSnapshotter snapshotter = AOTSnapshotter(reportTimings: false);
|
final AOTSnapshotter snapshotter = AOTSnapshotter(reportTimings: false);
|
||||||
final String outputPath = environment.buildDir.path;
|
final String outputPath = environment.buildDir.path;
|
||||||
if (environment.defines[kBuildMode] == null) {
|
if (environment.defines[kBuildMode] == null) {
|
||||||
|
@ -36,12 +36,11 @@ class UnpackLinux extends Target {
|
|||||||
List<Target> get dependencies => <Target>[];
|
List<Target> get dependencies => <Target>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final String basePath = artifacts.getArtifactPath(Artifact.linuxDesktopPath);
|
final String basePath = artifacts.getArtifactPath(Artifact.linuxDesktopPath);
|
||||||
for (File input in inputFiles) {
|
for (File input in fs.directory(basePath)
|
||||||
if (fs.path.basename(input.path) == 'linux.dart') {
|
.listSync(recursive: true)
|
||||||
continue;
|
.whereType<File>()) {
|
||||||
}
|
|
||||||
final String outputPath = fs.path.join(
|
final String outputPath = fs.path.join(
|
||||||
environment.projectDir.path,
|
environment.projectDir.path,
|
||||||
'linux',
|
'linux',
|
||||||
|
@ -113,7 +113,7 @@ abstract class UnpackMacOS extends Target {
|
|||||||
List<Target> get dependencies => <Target>[];
|
List<Target> get dependencies => <Target>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
if (environment.defines[kBuildMode] == null) {
|
if (environment.defines[kBuildMode] == null) {
|
||||||
throw MissingDefineException(kBuildMode, 'unpack_macos');
|
throw MissingDefineException(kBuildMode, 'unpack_macos');
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ class DebugMacOSFramework extends Target {
|
|||||||
String get name => 'debug_macos_framework';
|
String get name => 'debug_macos_framework';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
final File outputFile = fs.file(fs.path.join(
|
final File outputFile = fs.file(fs.path.join(
|
||||||
environment.buildDir.path, 'App.framework', 'App'));
|
environment.buildDir.path, 'App.framework', 'App'));
|
||||||
outputFile.createSync(recursive: true);
|
outputFile.createSync(recursive: true);
|
||||||
@ -236,7 +236,7 @@ class CompileMacOSFramework extends Target {
|
|||||||
String get name => 'compile_macos_framework';
|
String get name => 'compile_macos_framework';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
if (environment.defines[kBuildMode] == null) {
|
if (environment.defines[kBuildMode] == null) {
|
||||||
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ abstract class MacOSBundleFlutterAssets extends Target {
|
|||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
if (environment.defines[kBuildMode] == null) {
|
if (environment.defines[kBuildMode] == null) {
|
||||||
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
throw MissingDefineException(kBuildMode, 'compile_macos_framework');
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,12 @@ class UnpackWindows extends Target {
|
|||||||
List<Target> get dependencies => const <Target>[];
|
List<Target> get dependencies => const <Target>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) async {
|
Future<void> build(Environment environment) async {
|
||||||
// This path needs to match the prefix in the rule below.
|
// This path needs to match the prefix in the rule below.
|
||||||
final String basePath = artifacts.getArtifactPath(Artifact.windowsDesktopPath);
|
final String basePath = artifacts.getArtifactPath(Artifact.windowsDesktopPath);
|
||||||
for (File input in inputFiles) {
|
for (File input in fs.directory(basePath)
|
||||||
if (fs.path.basename(input.path) == 'windows.dart') {
|
.listSync(recursive: true)
|
||||||
continue;
|
.whereType<File>()) {
|
||||||
}
|
|
||||||
final String outputPath = fs.path.join(
|
final String outputPath = fs.path.join(
|
||||||
environment.projectDir.path,
|
environment.projectDir.path,
|
||||||
'windows',
|
'windows',
|
||||||
|
@ -40,7 +40,7 @@ void main() {
|
|||||||
when(mockPlatform.isWindows).thenReturn(false);
|
when(mockPlatform.isWindows).thenReturn(false);
|
||||||
|
|
||||||
/// Create various testing targets.
|
/// Create various testing targets.
|
||||||
fooTarget = TestTarget((List<File> inputFiles, Environment environment) async {
|
fooTarget = TestTarget((Environment environment) async {
|
||||||
environment
|
environment
|
||||||
.buildDir
|
.buildDir
|
||||||
.childFile('out')
|
.childFile('out')
|
||||||
@ -56,7 +56,7 @@ void main() {
|
|||||||
Source.pattern('{BUILD_DIR}/out'),
|
Source.pattern('{BUILD_DIR}/out'),
|
||||||
]
|
]
|
||||||
..dependencies = <Target>[];
|
..dependencies = <Target>[];
|
||||||
barTarget = TestTarget((List<File> inputFiles, Environment environment) async {
|
barTarget = TestTarget((Environment environment) async {
|
||||||
environment.buildDir
|
environment.buildDir
|
||||||
.childFile('bar')
|
.childFile('bar')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
@ -71,7 +71,7 @@ void main() {
|
|||||||
Source.pattern('{BUILD_DIR}/bar'),
|
Source.pattern('{BUILD_DIR}/bar'),
|
||||||
]
|
]
|
||||||
..dependencies = <Target>[];
|
..dependencies = <Target>[];
|
||||||
fizzTarget = TestTarget((List<File> inputFiles, Environment environment) async {
|
fizzTarget = TestTarget((Environment environment) async {
|
||||||
throw Exception('something bad happens');
|
throw Exception('something bad happens');
|
||||||
})
|
})
|
||||||
..name = 'fizz'
|
..name = 'fizz'
|
||||||
@ -82,7 +82,7 @@ void main() {
|
|||||||
Source.pattern('{BUILD_DIR}/fizz'),
|
Source.pattern('{BUILD_DIR}/fizz'),
|
||||||
]
|
]
|
||||||
..dependencies = <Target>[fooTarget];
|
..dependencies = <Target>[fooTarget];
|
||||||
sharedTarget = TestTarget((List<File> inputFiles, Environment environment) async {
|
sharedTarget = TestTarget((Environment environment) async {
|
||||||
shared += 1;
|
shared += 1;
|
||||||
})
|
})
|
||||||
..name = 'shared'
|
..name = 'shared'
|
||||||
@ -116,7 +116,7 @@ void main() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
test('Throws exception if it does not produce a specified output', () => testbed.run(() async {
|
test('Throws exception if it does not produce a specified output', () => testbed.run(() async {
|
||||||
final Target badTarget = TestTarget((List<File> inputFiles, Environment environment) async {})
|
final Target badTarget = TestTarget((Environment environment) async {})
|
||||||
..inputs = const <Source>[
|
..inputs = const <Source>[
|
||||||
Source.pattern('{PROJECT_DIR}/foo.dart'),
|
Source.pattern('{PROJECT_DIR}/foo.dart'),
|
||||||
]
|
]
|
||||||
@ -251,10 +251,10 @@ T nonconst<T>(T input) => input;
|
|||||||
class TestTarget extends Target {
|
class TestTarget extends Target {
|
||||||
TestTarget([this._build]);
|
TestTarget([this._build]);
|
||||||
|
|
||||||
final Future<void> Function(List<File> inputFiles, Environment environment) _build;
|
final Future<void> Function(Environment environment) _build;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) => _build(inputFiles, environment);
|
Future<void> build(Environment environment) => _build(environment);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Target> dependencies = <Target>[];
|
List<Target> dependencies = <Target>[];
|
||||||
|
@ -64,10 +64,10 @@ void main() {
|
|||||||
class TestTarget extends Target {
|
class TestTarget extends Target {
|
||||||
TestTarget([this._build]);
|
TestTarget([this._build]);
|
||||||
|
|
||||||
final Future<void> Function(List<File> inputFiles, Environment environment) _build;
|
final Future<void> Function(Environment environment) _build;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> build(List<File> inputFiles, Environment environment) => _build(inputFiles, environment);
|
Future<void> build(Environment environment) => _build(environment);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Target> dependencies = <Target>[];
|
List<Target> dependencies = <Target>[];
|
||||||
|
@ -71,7 +71,7 @@ flutter:
|
|||||||
fs.file('pubspec.yaml')
|
fs.file('pubspec.yaml')
|
||||||
..writeAsStringSync('name: foo\ndependencies:\n foo: any\n');
|
..writeAsStringSync('name: foo\ndependencies:\n foo: any\n');
|
||||||
|
|
||||||
await const FlutterPlugins().build(<File>[], Environment(
|
await const FlutterPlugins().build(Environment(
|
||||||
outputDir: fs.currentDirectory,
|
outputDir: fs.currentDirectory,
|
||||||
projectDir: fs.currentDirectory,
|
projectDir: fs.currentDirectory,
|
||||||
));
|
));
|
||||||
|
@ -135,7 +135,7 @@ flutter_tools:lib/''');
|
|||||||
return const CompilerOutput('example', 0, <Uri>[]);
|
return const CompilerOutput('example', 0, <Uri>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
await const KernelSnapshot().build(<File>[], androidEnvironment);
|
await const KernelSnapshot().build(androidEnvironment);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
KernelCompilerFactory: () => MockKernelCompilerFactory(),
|
KernelCompilerFactory: () => MockKernelCompilerFactory(),
|
||||||
}));
|
}));
|
||||||
@ -159,7 +159,7 @@ flutter_tools:lib/''');
|
|||||||
return const CompilerOutput('example', 0, <Uri>[]);
|
return const CompilerOutput('example', 0, <Uri>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
await const KernelSnapshot().build(<File>[], Environment(
|
await const KernelSnapshot().build(Environment(
|
||||||
outputDir: fs.currentDirectory,
|
outputDir: fs.currentDirectory,
|
||||||
projectDir: fs.currentDirectory,
|
projectDir: fs.currentDirectory,
|
||||||
defines: <String, String>{
|
defines: <String, String>{
|
||||||
|
@ -102,7 +102,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
return FakeProcessResult()..exitCode = 0;
|
return FakeProcessResult()..exitCode = 0;
|
||||||
});
|
});
|
||||||
await const DebugUnpackMacOS().build(<File>[], environment);
|
await const DebugUnpackMacOS().build(environment);
|
||||||
|
|
||||||
expect(fs.directory('$_kOutputPrefix').existsSync(), true);
|
expect(fs.directory('$_kOutputPrefix').existsSync(), true);
|
||||||
for (File file in inputs) {
|
for (File file in inputs) {
|
||||||
@ -116,7 +116,7 @@ void main() {
|
|||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('testing');
|
..writeAsStringSync('testing');
|
||||||
|
|
||||||
expect(() async => await const DebugMacOSBundleFlutterAssets().build(<File>[], environment),
|
expect(() async => await const DebugMacOSBundleFlutterAssets().build(environment),
|
||||||
throwsA(isInstanceOf<Exception>()));
|
throwsA(isInstanceOf<Exception>()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ void main() {
|
|||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('testing');
|
..writeAsStringSync('testing');
|
||||||
|
|
||||||
await const DebugMacOSBundleFlutterAssets().build(<File>[], environment);
|
await const DebugMacOSBundleFlutterAssets().build(environment);
|
||||||
|
|
||||||
expect(fs.file(outputKernel).readAsStringSync(), 'testing');
|
expect(fs.file(outputKernel).readAsStringSync(), 'testing');
|
||||||
expect(fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app'));
|
expect(fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app'));
|
||||||
@ -156,7 +156,7 @@ void main() {
|
|||||||
'flutter_assets', 'vm_snapshot_data');
|
'flutter_assets', 'vm_snapshot_data');
|
||||||
final String precompiledIsolate = fs.path.join('App.framework', 'Resources',
|
final String precompiledIsolate = fs.path.join('App.framework', 'Resources',
|
||||||
'flutter_assets', 'isolate_snapshot_data');
|
'flutter_assets', 'isolate_snapshot_data');
|
||||||
await const ProfileMacOSBundleFlutterAssets().build(<File>[], environment..defines[kBuildMode] = 'profile');
|
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
|
||||||
|
|
||||||
expect(fs.file(outputKernel).existsSync(), false);
|
expect(fs.file(outputKernel).existsSync(), false);
|
||||||
expect(fs.file(precompiledVm).existsSync(), false);
|
expect(fs.file(precompiledVm).existsSync(), false);
|
||||||
@ -186,7 +186,7 @@ void main() {
|
|||||||
# Generated
|
# Generated
|
||||||
sky_engine:file:///bin/cache/pkg/sky_engine/lib/
|
sky_engine:file:///bin/cache/pkg/sky_engine/lib/
|
||||||
flutter_tools:lib/''');
|
flutter_tools:lib/''');
|
||||||
await const CompileMacOSFramework().build(<File>[], environment..defines[kBuildMode] = 'release');
|
await const CompileMacOSFramework().build(environment..defines[kBuildMode] = 'release');
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
GenSnapshot: () => MockGenSnapshot(),
|
GenSnapshot: () => MockGenSnapshot(),
|
||||||
Xcode: () => MockXCode(),
|
Xcode: () => MockXCode(),
|
||||||
|
Loading…
Reference in New Issue
Block a user