mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add an ephemeral directory to Windows projects (#40194)
Moves files generated in windows/flutter/ as part of the build to an ephemeral/ subdirectory, matching the approach used on macOS (and in the future, Windows). Adds that directory to the generated properties file to minimize hard-coding of paths in the project.
This commit is contained in:
parent
ef97a69dab
commit
e6ae95c4ce
@ -40,7 +40,7 @@ or
|
||||
cacheDirectory = 'linux/flutter';
|
||||
break;
|
||||
case 'windows-x64':
|
||||
cacheDirectory = 'windows/flutter';
|
||||
cacheDirectory = 'windows/flutter/ephemeral';
|
||||
break;
|
||||
default:
|
||||
stderr.write('Unsupported target platform $targetPlatform');
|
||||
|
@ -752,11 +752,19 @@ class WindowsProject {
|
||||
|
||||
Directory get _editableDirectory => project.directory.childDirectory('windows');
|
||||
|
||||
Directory get _cacheDirectory => _editableDirectory.childDirectory('flutter');
|
||||
/// The directory in the project that is managed by Flutter. As much as
|
||||
/// possible, files that are edited by Flutter tooling after initial project
|
||||
/// creation should live here.
|
||||
Directory get managedDirectory => _editableDirectory.childDirectory('flutter');
|
||||
|
||||
/// The subdirectory of [managedDirectory] that contains files that are
|
||||
/// generated on the fly. All generated files that are not intended to be
|
||||
/// checked in should live here.
|
||||
Directory get ephemeralDirectory => managedDirectory.childDirectory('ephemeral');
|
||||
|
||||
/// Contains definitions for FLUTTER_ROOT, LOCAL_ENGINE, and more flags for
|
||||
/// the build.
|
||||
File get generatedPropertySheetFile => _cacheDirectory.childFile('Generated.props');
|
||||
File get generatedPropertySheetFile => ephemeralDirectory.childFile('Generated.props');
|
||||
|
||||
// The MSBuild project file.
|
||||
File get vcprojFile => _editableDirectory.childFile('Runner.vcxproj');
|
||||
@ -767,7 +775,7 @@ class WindowsProject {
|
||||
/// The file where the VS build will write the name of the built app.
|
||||
///
|
||||
/// Ideally this will be replaced in the future with inspection of the project.
|
||||
File get nameFile => _cacheDirectory.childFile('exe_filename');
|
||||
File get nameFile => ephemeralDirectory.childFile('exe_filename');
|
||||
}
|
||||
|
||||
/// The Linux sub project.
|
||||
@ -778,6 +786,8 @@ class LinuxProject {
|
||||
|
||||
Directory get editableHostAppDirectory => project.directory.childDirectory('linux');
|
||||
|
||||
// TODO(stuartmorgan): Move to using an ephemeralDirectory to match the other
|
||||
// desktop projects.
|
||||
Directory get cacheDirectory => editableHostAppDirectory.childDirectory('flutter');
|
||||
|
||||
bool existsSync() => editableHostAppDirectory.existsSync();
|
||||
|
@ -22,6 +22,7 @@ import 'visual_studio.dart';
|
||||
Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {String target}) async {
|
||||
final Map<String, String> environment = <String, String>{
|
||||
'FLUTTER_ROOT': Cache.flutterRoot,
|
||||
'FLUTTER_EPHEMERAL_DIR': windowsProject.ephemeralDirectory.path,
|
||||
'PROJECT_DIR': windowsProject.project.directory.path,
|
||||
'TRACK_WIDGET_CREATION': (buildInfo?.trackWidgetCreation == true).toString(),
|
||||
};
|
||||
|
@ -129,7 +129,7 @@ void main() {
|
||||
);
|
||||
|
||||
// Spot-check important elements from the properties file.
|
||||
final File propsFile = fs.file(r'C:\windows\flutter\Generated.props');
|
||||
final File propsFile = fs.file(r'C:\windows\flutter\ephemeral\Generated.props');
|
||||
expect(propsFile.existsSync(), true);
|
||||
final xml.XmlDocument props = xml.parse(propsFile.readAsStringSync());
|
||||
expect(props.findAllElements('PropertyGroup').first.getAttribute('Label'), 'UserMacros');
|
||||
|
Loading…
Reference in New Issue
Block a user