Unverified Commit 44c284ba authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] output release artifacts to build/winuwp (#80137)

parent 24f0d285
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
// @dart = 2.8 // @dart = 2.8
import 'package:meta/meta.dart';
import '../../artifacts.dart'; import '../../artifacts.dart';
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../../build_info.dart'; import '../../build_info.dart';
...@@ -253,13 +255,57 @@ abstract class BundleWindowsAssetsUwp extends BundleWindowsAssets { ...@@ -253,13 +255,57 @@ abstract class BundleWindowsAssetsUwp extends BundleWindowsAssets {
/// A wrapper for AOT compilation that copies app.so into the output directory. /// A wrapper for AOT compilation that copies app.so into the output directory.
class WindowsAotBundle extends Target { class WindowsAotBundle extends Target {
/// Create a [WindowsAotBundle] wrapper for [aotTarget]. /// 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. /// The [AotElfBase] subclass that produces the app.so.
final AotElfBase aotTarget; final AotElfBase aotTarget;
@override @override
String get name => 'windows_aot_bundle'; String get name => 'windows_uwp_aot_bundle';
@override @override
List<Source> get inputs => const <Source>[ List<Source> get inputs => const <Source>[
...@@ -268,7 +314,7 @@ class WindowsAotBundle extends Target { ...@@ -268,7 +314,7 @@ class WindowsAotBundle extends Target {
@override @override
List<Source> get outputs => const <Source>[ List<Source> get outputs => const <Source>[
Source.pattern('{OUTPUT_DIR}/windows/app.so'), Source.pattern('{OUTPUT_DIR}/winuwp/app.so'),
]; ];
@override @override
...@@ -279,7 +325,7 @@ class WindowsAotBundle extends Target { ...@@ -279,7 +325,7 @@ class WindowsAotBundle extends Target {
@override @override
Future<void> build(Environment environment) async { Future<void> build(Environment environment) async {
final File outputFile = environment.buildDir.childFile('app.so'); 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()) { if (!outputDirectory.existsSync()) {
outputDirectory.createSync(recursive: true); outputDirectory.createSync(recursive: true);
} }
...@@ -299,7 +345,7 @@ class ReleaseBundleWindowsAssets extends BundleWindowsAssets { ...@@ -299,7 +345,7 @@ class ReleaseBundleWindowsAssets extends BundleWindowsAssets {
@override @override
List<Target> get dependencies => <Target>[ List<Target> get dependencies => <Target>[
...super.dependencies, ...super.dependencies,
const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64)), const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64), uwp: false),
]; ];
} }
...@@ -315,7 +361,7 @@ class ProfileBundleWindowsAssets extends BundleWindowsAssets { ...@@ -315,7 +361,7 @@ class ProfileBundleWindowsAssets extends BundleWindowsAssets {
@override @override
List<Target> get dependencies => <Target>[ List<Target> get dependencies => <Target>[
...super.dependencies, ...super.dependencies,
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64)), const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64), uwp: false),
]; ];
} }
...@@ -348,7 +394,7 @@ class ReleaseBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp { ...@@ -348,7 +394,7 @@ class ReleaseBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
@override @override
List<Target> get dependencies => <Target>[ List<Target> get dependencies => <Target>[
...super.dependencies, ...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 { ...@@ -364,7 +410,7 @@ class ProfileBundleWindowsAssetsUwp extends BundleWindowsAssetsUwp {
@override @override
List<Target> get dependencies => <Target>[ List<Target> get dependencies => <Target>[
...super.dependencies, ...super.dependencies,
const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_uwp_x64)), const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_uwp_x64), uwp: true),
]; ];
} }
......
...@@ -289,7 +289,7 @@ void main() { ...@@ -289,7 +289,7 @@ void main() {
environment.buildDir.childFile('app.so').createSync(recursive: true); 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); await const ProfileBundleWindowsAssets().build(environment);
// Depfile is created and so is copied. // Depfile is created and so is copied.
...@@ -302,6 +302,60 @@ void main() { ...@@ -302,6 +302,60 @@ void main() {
ProcessManager: () => FakeProcessManager.any(), 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 { testUsingContext('ReleaseBundleWindowsAssets creates correct bundle structure', () async {
final Environment environment = Environment.test( final Environment environment = Environment.test(
fileSystem.currentDirectory, fileSystem.currentDirectory,
...@@ -316,7 +370,7 @@ void main() { ...@@ -316,7 +370,7 @@ void main() {
environment.buildDir.childFile('app.so').createSync(recursive: true); 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); await const ReleaseBundleWindowsAssets().build(environment);
// Depfile is created and so is copied. // Depfile is created and so is copied.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment