[flutter_tools] run UWP builds ahead of cmake (#80879)
This commit is contained in:
parent
9c0270d960
commit
8663aea5e4
@ -164,12 +164,72 @@ Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildIn
|
||||
'Building Windows application...',
|
||||
);
|
||||
try {
|
||||
// The Cmake re-entrant build does not work for UWP, so the flutter build is
|
||||
// run in advance.
|
||||
await _runFlutterBuild(buildDirectory, buildInfo, target);
|
||||
await _runCmakeGeneration(cmakePath, buildDirectory, windowsProject.cmakeFile.parent);
|
||||
await _runBuild(cmakePath, buildDirectory, buildModeName, install: false);
|
||||
} finally {
|
||||
status.cancel();
|
||||
}
|
||||
throwToolExit('Windows UWP builds are not implemented.');
|
||||
}
|
||||
|
||||
const Map<BuildMode, String> _targets = <BuildMode, String>{
|
||||
BuildMode.debug: 'debug_bundle_windows_assets_uwp',
|
||||
BuildMode.profile: 'profile_bundle_windows_assets_uwp',
|
||||
BuildMode.release: 'release_bundle_windows_assets_uwp',
|
||||
};
|
||||
|
||||
Future<void> _runFlutterBuild(Directory buildDirectory, BuildInfo buildInfo, String targetFile) async {
|
||||
await buildDirectory.create(recursive: true);
|
||||
int result;
|
||||
String flutterEngine;
|
||||
String localEngine;
|
||||
if (globals.artifacts is LocalEngineArtifacts) {
|
||||
final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
|
||||
final String engineOutPath = localEngineArtifacts.engineOutPath;
|
||||
flutterEngine = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
|
||||
localEngine = globals.fs.path.basename(engineOutPath);
|
||||
}
|
||||
try {
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
globals.fs.path.join(Cache.flutterRoot, 'bin', 'flutter'),
|
||||
if (globals.logger.isVerbose)
|
||||
'--verbose',
|
||||
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
|
||||
if (localEngine != null) '--local-engine=$localEngine',
|
||||
'assemble',
|
||||
'--no-version-check',
|
||||
'--output=build',
|
||||
'-dTargetPlatform=windows-uwp-x64',
|
||||
'-dTrackWidgetCreation=${buildInfo.trackWidgetCreation}',
|
||||
'-dBuildMode=${getNameForBuildMode(buildInfo.mode)}',
|
||||
'-dTargetFile=$targetFile',
|
||||
'-dTreeShakeIcons="${buildInfo.treeShakeIcons}"',
|
||||
'-dDartObfuscation=${buildInfo.dartObfuscation}',
|
||||
if (buildInfo.bundleSkSLPath != null)
|
||||
'-iBundleSkSLPath=${buildInfo.bundleSkSLPath}',
|
||||
if (buildInfo.codeSizeDirectory != null)
|
||||
'-dCodeSizeDirectory=${buildInfo.codeSizeDirectory}',
|
||||
if (buildInfo.splitDebugInfoPath != null)
|
||||
'-dSplitDebugInfo=${buildInfo.splitDebugInfoPath}',
|
||||
if (buildInfo.dartDefines != null && buildInfo.dartDefines.isNotEmpty)
|
||||
'--DartDefines=${encodeDartDefines(buildInfo.dartDefines)}',
|
||||
if (buildInfo.extraGenSnapshotOptions != null && buildInfo.extraGenSnapshotOptions.isNotEmpty)
|
||||
'--ExtraGenSnapshotOptions=${buildInfo.extraGenSnapshotOptions}',
|
||||
if (buildInfo.extraFrontEndOptions != null && buildInfo.extraFrontEndOptions.isNotEmpty)
|
||||
'--ExtraFrontEndOptions=${buildInfo.extraFrontEndOptions}',
|
||||
_targets[buildInfo.mode],
|
||||
],
|
||||
trace: true,
|
||||
);
|
||||
} on ArgumentError {
|
||||
throwToolExit("cmake not found. Run 'flutter doctor' for more information.");
|
||||
}
|
||||
if (result != 0) {
|
||||
throwToolExit('Unable to generate build files');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _runCmakeGeneration(String cmakePath, Directory buildDir, Directory sourceDir) async {
|
||||
|
@ -51,5 +51,5 @@ Future<void> createManifest({
|
||||
outputs.add(project.ephemeralDirectory.childFile('icudtl.dat'));
|
||||
project.ephemeralDirectory.childFile('install_manifest')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(outputs.map((File file) => file.absolute.path).join('\n'));
|
||||
..writeAsStringSync(outputs.map((File file) => file.absolute.uri.path.substring(1)).join('\n'));
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ void main() {
|
||||
|
||||
setUpAll(() {
|
||||
Cache.disableLocking();
|
||||
Cache.flutterRoot = '';
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
@ -530,7 +531,7 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
// This message should include 'To enable, run "flutter config --enable-windows-uwp-desktop"."
|
||||
// once the `windowsUwpEmbedding` feature is available on all platforms.
|
||||
// once the `windowsUwpEmbedding` feature is available on all channels.
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['winuwp', '--no-pub']
|
||||
), throwsToolExit(message: RegExp(r'"build winuwp" is not currently supported\.$')));
|
||||
@ -541,19 +542,34 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: false),
|
||||
});
|
||||
|
||||
testUsingContext('Windows UWP build fails after writing Cmake file', () async {
|
||||
testUsingContext('Windows UWP build completes successfully', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
|
||||
..visualStudioOverride = fakeVisualStudio;
|
||||
setUpMockUwpFilesForBuild(0);
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['winuwp', '--no-pub']
|
||||
), throwsToolExit(message: 'Windows UWP builds are not implemented'));
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => windowsPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: <String>[
|
||||
r'C:\flutter\bin\flutter',
|
||||
'assemble',
|
||||
'--no-version-check',
|
||||
'--output=build',
|
||||
'-dTargetPlatform=windows-uwp-x64',
|
||||
'-dTrackWidgetCreation=true',
|
||||
'-dBuildMode=release',
|
||||
r'-dTargetFile=lib\main.dart',
|
||||
'-dTreeShakeIcons="true"',
|
||||
'-dDartObfuscation=false',
|
||||
'release_bundle_windows_assets_uwp'
|
||||
],
|
||||
),
|
||||
cmakeGenerationCommand(winuwp: true),
|
||||
buildCommand('Release', stdout: 'STDOUT STUFF', winuwp: true),
|
||||
]),
|
||||
|
@ -22,7 +22,7 @@ void main() {
|
||||
FileSystem fileSystem;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
|
||||
});
|
||||
|
||||
testUsingContext('Generates install manifest for a debug build', () async {
|
||||
@ -44,11 +44,11 @@ void main() {
|
||||
final File manifest = flutterProject.windowsUwp.ephemeralDirectory.childFile('install_manifest');
|
||||
expect(manifest, exists);
|
||||
expect(manifest.readAsLinesSync(), unorderedEquals(<String>[
|
||||
'/build/winuwp/flutter_assets/kernel_blob.bin',
|
||||
'/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'/winuwp/flutter/ephemeral/icudtl.dat',
|
||||
'C:/build/winuwp/flutter_assets/kernel_blob.bin',
|
||||
'C:/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'C:/winuwp/flutter/ephemeral/icudtl.dat',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
@ -74,11 +74,11 @@ void main() {
|
||||
final File manifest = flutterProject.windowsUwp.ephemeralDirectory.childFile('install_manifest');
|
||||
expect(manifest, exists);
|
||||
expect(manifest.readAsLinesSync(), unorderedEquals(<String>[
|
||||
'/build/winuwp/app.so',
|
||||
'/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'/winuwp/flutter/ephemeral/icudtl.dat'
|
||||
'C:/build/winuwp/app.so',
|
||||
'C:/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'C:/winuwp/flutter/ephemeral/icudtl.dat'
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
@ -128,14 +128,14 @@ flutter:
|
||||
final File manifest = flutterProject.windowsUwp.ephemeralDirectory.childFile('install_manifest');
|
||||
expect(manifest, exists);
|
||||
expect(manifest.readAsLinesSync(), unorderedEquals(<String>[
|
||||
'/build/winuwp/app.so',
|
||||
'/build/winuwp/flutter_assets/assets/foo.png',
|
||||
'/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'/build/winuwp/flutter_assets/FontManifest.json',
|
||||
'/build/winuwp/flutter_assets/NOTICES',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'/winuwp/flutter/ephemeral/icudtl.dat'
|
||||
'C:/build/winuwp/app.so',
|
||||
'C:/build/winuwp/flutter_assets/assets/foo.png',
|
||||
'C:/build/winuwp/flutter_assets/AssetManifest.json',
|
||||
'C:/build/winuwp/flutter_assets/FontManifest.json',
|
||||
'C:/build/winuwp/flutter_assets/NOTICES',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll',
|
||||
'C:/winuwp/flutter/ephemeral/flutter_windows_winuwp.dll.pdb',
|
||||
'C:/winuwp/flutter/ephemeral/icudtl.dat'
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
|
Loading…
x
Reference in New Issue
Block a user