[flutter_tools] output release artifacts to build/winuwp (#80137)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../build_info.dart';
|
||||
@@ -253,13 +255,57 @@ 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);
|
||||
const WindowsAotBundle(this.aotTarget, {@required this.uwp});
|
||||
|
||||
/// The [AotElfBase] subclass that produces the app.so.
|
||||
final AotElfBase aotTarget;
|
||||
|
||||
/// Whether this is the UWP target.
|
||||
final bool uwp;
|
||||
|
||||
@override
|
||||
String get name => uwp ? 'windows_uwp_aot_bundle' : 'windows_aot_bundle';
|
||||
|
||||
@override
|
||||
List<Source> get inputs => const <Source>[
|
||||
Source.pattern('{BUILD_DIR}/app.so'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => uwp ?
|
||||
const <Source>[
|
||||
Source.pattern('{OUTPUT_DIR}/winuwp/app.so'),
|
||||
] :
|
||||
const <Source>[
|
||||
Source.pattern('{OUTPUT_DIR}/windows/app.so'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
aotTarget,
|
||||
];
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final File outputFile = environment.buildDir.childFile('app.so');
|
||||
final Directory outputDirectory = environment.outputDir.childDirectory(uwp ? 'winuwp' : 'windows');
|
||||
if (!outputDirectory.existsSync()) {
|
||||
outputDirectory.createSync(recursive: true);
|
||||
}
|
||||
outputFile.copySync(outputDirectory.childFile('app.so').path);
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper for AOT compilation that copies app.so into the output directory.
|
||||
class WindowsUwpAotBundle extends Target {
|
||||
/// Create a [WindowsAotBundle] wrapper for [aotTarget].
|
||||
const WindowsUwpAotBundle(this.aotTarget);
|
||||
|
||||
/// The [AotElfBase] subclass that produces the app.so.
|
||||
final AotElfBase aotTarget;
|
||||
|
||||
@override
|
||||
String get name => 'windows_aot_bundle';
|
||||
String get name => 'windows_uwp_aot_bundle';
|
||||
|
||||
@override
|
||||
List<Source> get inputs => const <Source>[
|
||||
@@ -268,7 +314,7 @@ class WindowsAotBundle extends Target {
|
||||
|
||||
@override
|
||||
List<Source> get outputs => const <Source>[
|
||||
Source.pattern('{OUTPUT_DIR}/windows/app.so'),
|
||||
Source.pattern('{OUTPUT_DIR}/winuwp/app.so'),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -279,7 +325,7 @@ class WindowsAotBundle extends Target {
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final File outputFile = environment.buildDir.childFile('app.so');
|
||||
final Directory outputDirectory = environment.outputDir.childDirectory('windows');
|
||||
final Directory outputDirectory = environment.outputDir.childDirectory('winuwp');
|
||||
if (!outputDirectory.existsSync()) {
|
||||
outputDirectory.createSync(recursive: true);
|
||||
}
|
||||
@@ -299,7 +345,7 @@ class ReleaseBundleWindowsAssets extends BundleWindowsAssets {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64)),
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64), uwp: false),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -315,7 +361,7 @@ class ProfileBundleWindowsAssets extends BundleWindowsAssets {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64)),
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64), uwp: false),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -348,7 +394,7 @@ class ReleaseBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_uwp_x64)),
|
||||
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_uwp_x64), uwp: true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -364,7 +410,7 @@ class ProfileBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[
|
||||
...super.dependencies,
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_uwp_x64)),
|
||||
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_uwp_x64), uwp: true),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ void main() {
|
||||
|
||||
environment.buildDir.childFile('app.so').createSync(recursive: true);
|
||||
|
||||
await const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64)).build(environment);
|
||||
await const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64), uwp: false).build(environment);
|
||||
await const ProfileBundleWindowsAssets().build(environment);
|
||||
|
||||
// Depfile is created and so is copied.
|
||||
@@ -302,6 +302,60 @@ void main() {
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('ReleaseBundleWindowsAssets creates correct bundle structure with UWP', () async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
artifacts: Artifacts.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'release',
|
||||
}
|
||||
);
|
||||
|
||||
environment.buildDir.childFile('app.so').createSync(recursive: true);
|
||||
|
||||
await const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64), uwp: true).build(environment);
|
||||
await const ReleaseBundleWindowsAssets().build(environment);
|
||||
|
||||
// Depfile is created and so is copied.
|
||||
expect(environment.buildDir.childFile('flutter_assets.d'), exists);
|
||||
expect(fileSystem.file(r'C:\winuwp\app.so'), exists);
|
||||
expect(fileSystem.file(r'C:\flutter_assets\kernel_blob.bin').existsSync(), false);
|
||||
expect(fileSystem.file(r'C:\flutter_assets\AssetManifest.json'), exists);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('ProfileBundleWindowsAssets creates correct bundle structure with UWP', () async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
artifacts: Artifacts.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'profile',
|
||||
}
|
||||
);
|
||||
|
||||
environment.buildDir.childFile('app.so').createSync(recursive: true);
|
||||
|
||||
await const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64), uwp: true).build(environment);
|
||||
await const ProfileBundleWindowsAssets().build(environment);
|
||||
|
||||
// Depfile is created and so is copied.
|
||||
expect(environment.buildDir.childFile('flutter_assets.d'), exists);
|
||||
expect(fileSystem.file(r'C:\winuwp\app.so'), exists);
|
||||
expect(fileSystem.file(r'C:\flutter_assets\kernel_blob.bin').existsSync(), false);
|
||||
expect(fileSystem.file(r'C:\flutter_assets\AssetManifest.json'), exists);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('ReleaseBundleWindowsAssets creates correct bundle structure', () async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
@@ -316,7 +370,7 @@ void main() {
|
||||
|
||||
environment.buildDir.childFile('app.so').createSync(recursive: true);
|
||||
|
||||
await const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64)).build(environment);
|
||||
await const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64), uwp: false).build(environment);
|
||||
await const ReleaseBundleWindowsAssets().build(environment);
|
||||
|
||||
// Depfile is created and so is copied.
|
||||
|
||||
Reference in New Issue
Block a user