Unverified Commit d03aecab authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Add an ephemeral directory for Linux (#40587)

Moves the generated config into that directory. Matches the structure of
the other desktop projects.

Also fixes #40265
parent 0df1594b
......@@ -37,7 +37,7 @@ or
String cacheDirectory;
switch (targetPlatform) {
case 'linux-x64':
cacheDirectory = 'linux/flutter';
cacheDirectory = 'linux/flutter/ephemeral';
break;
case 'windows-x64':
cacheDirectory = 'windows/flutter/ephemeral';
......
......@@ -51,9 +51,15 @@ class CleanCommand extends FlutterCommand {
final Directory iosEphemeralDirectory = flutterProject.ios.ephemeralDirectory;
deleteFile(iosEphemeralDirectory);
final Directory linuxEphemeralDirectory = flutterProject.linux.ephemeralDirectory;
deleteFile(linuxEphemeralDirectory);
final Directory macosEphemeralDirectory = flutterProject.macos.ephemeralDirectory;
deleteFile(macosEphemeralDirectory);
final Directory windowsEphemeralDirectory = flutterProject.windows.ephemeralDirectory;
deleteFile(windowsEphemeralDirectory);
return const FlutterCommandResult(ExitStatus.success);
}
......
......@@ -34,7 +34,7 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
}
/// Cache flutter configuration files in the linux directory.
linuxProject.cacheDirectory.childFile('generated_config')
linuxProject.generatedMakeConfigFile
..createSync(recursive: true)
..writeAsStringSync(buffer.toString());
......@@ -52,7 +52,7 @@ export PROJECT_DIR=${linuxProject.project.directory.path}
final Process process = await processManager.start(<String>[
'make',
'-C',
linuxProject.editableHostAppDirectory.path,
linuxProject.makeFile.parent.path,
], runInShell: true);
final Status status = logger.startProgress(
'Building Linux application...',
......
......@@ -795,16 +795,26 @@ class LinuxProject {
final FlutterProject project;
Directory get editableHostAppDirectory => project.directory.childDirectory('linux');
Directory get _editableDirectory => project.directory.childDirectory('linux');
// TODO(stuartmorgan): Move to using an ephemeralDirectory to match the other
// desktop projects.
Directory get cacheDirectory => editableHostAppDirectory.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');
bool existsSync() => editableHostAppDirectory.existsSync();
/// 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');
bool existsSync() => _editableDirectory.existsSync();
/// The Linux project makefile.
File get makeFile => editableHostAppDirectory.childFile('Makefile');
File get makeFile => _editableDirectory.childFile('Makefile');
/// Contains definitions for FLUTTER_ROOT, LOCAL_ENGINE, and more flags for
/// the build.
File get generatedMakeConfigFile => ephemeralDirectory.childFile('generated_config.mk');
}
/// The Fuchisa sub project
......
......@@ -100,7 +100,7 @@ void main() {
await createTestCommandRunner(command).run(
const <String>['build', 'linux']
);
expect(fs.file('linux/flutter/generated_config').existsSync(), true);
expect(fs.file('linux/flutter/ephemeral/generated_config.mk').existsSync(), true);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
......
......@@ -41,7 +41,9 @@ void main() {
projectUnderTest.dartTool.createSync(recursive: true);
projectUnderTest.android.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.ios.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.linux.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.macos.ephemeralDirectory.createSync(recursive: true);
projectUnderTest.windows.ephemeralDirectory.createSync(recursive: true);
});
group(CleanCommand, () {
......@@ -53,7 +55,9 @@ void main() {
expect(projectUnderTest.dartTool.existsSync(), isFalse);
expect(projectUnderTest.android.ephemeralDirectory.existsSync(), isFalse);
expect(projectUnderTest.ios.ephemeralDirectory.existsSync(), isFalse);
expect(projectUnderTest.linux.ephemeralDirectory.existsSync(), isFalse);
expect(projectUnderTest.macos.ephemeralDirectory.existsSync(), isFalse);
expect(projectUnderTest.windows.ephemeralDirectory.existsSync(), isFalse);
verify(xcodeProjectInterpreter.cleanWorkspace(any, 'Runner')).called(2);
}, overrides: <Type, Generator>{
......
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