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

Consider the Linux template stable (#60163)

Remove the version checking and associated warnings. The Linux template
and build process will now be subject to more typical Flutter breaking
change policy, and should no longer require regularly deleting and
recreating the platform directory.
parent 42e67550
...@@ -487,13 +487,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi ...@@ -487,13 +487,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
// Warn about unstable templates. This shuold be last so that it's not // Warn about unstable templates. This shuold be last so that it's not
// lost among the other output. // lost among the other output.
if (featureFlags.isLinuxEnabled) { if (featureFlags.isWindowsEnabled && platforms.contains('windows')) {
globals.printStatus('');
globals.printStatus('WARNING: The Linux tooling and APIs are not yet stable. '
'You will likely need to re-create the "linux" directory after future '
'Flutter updates.');
}
if (featureFlags.isWindowsEnabled) {
globals.printStatus(''); globals.printStatus('');
globals.printStatus('WARNING: The Windows tooling and APIs are not yet stable. ' globals.printStatus('WARNING: The Windows tooling and APIs are not yet stable. '
'You will likely need to re-create the "windows" directory after future ' 'You will likely need to re-create the "windows" directory after future '
......
...@@ -27,20 +27,6 @@ Future<void> buildLinux( ...@@ -27,20 +27,6 @@ Future<void> buildLinux(
'to learn about adding Linux support to a project.'); 'to learn about adding Linux support to a project.');
} }
// Check for incompatibility between the Flutter tool version and the project
// template version, since the tempalte isn't stable yet.
final int templateCompareResult = _compareTemplateVersions(linuxProject);
if (templateCompareResult < 0) {
throwToolExit('The Linux runner was created with an earlier version of the '
'template, which is not yet stable.\n\n'
'Delete the linux/ directory and re-run \'flutter create .\', '
're-applying any previous changes.');
} else if (templateCompareResult > 0) {
throwToolExit('The Linux runner was created with a newer version of the '
'template, which is not yet stable.\n\n'
'Upgrade Flutter and try again.');
}
// Build the environment that needs to be set for the re-entrant flutter build // Build the environment that needs to be set for the re-entrant flutter build
// step. // step.
final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig(); final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig();
...@@ -127,25 +113,3 @@ Future<void> _runBuild(Directory buildDir) async { ...@@ -127,25 +113,3 @@ Future<void> _runBuild(Directory buildDir) async {
} }
globals.flutterUsage.sendTiming('build', 'linux-ninja', Duration(milliseconds: sw.elapsedMilliseconds)); globals.flutterUsage.sendTiming('build', 'linux-ninja', Duration(milliseconds: sw.elapsedMilliseconds));
} }
// Checks the template version of [project] against the current template
// version. Returns < 0 if the project is older than the current template, > 0
// if it's newer, and 0 if they match.
int _compareTemplateVersions(LinuxProject project) {
const String projectVersionBasename = '.template_version';
final int expectedVersion = int.parse(globals.fs.file(globals.fs.path.join(
globals.fs.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'templates',
'app',
'linux.tmpl',
'flutter',
projectVersionBasename,
)).readAsStringSync());
final File projectVersionFile = project.managedDirectory.childFile(projectVersionBasename);
final int version = projectVersionFile.existsSync()
? int.tryParse(projectVersionFile.readAsStringSync())
: 0;
return version.compareTo(expectedVersion);
}
...@@ -57,29 +57,9 @@ void main() { ...@@ -57,29 +57,9 @@ void main() {
} }
// Creates the mock files necessary to run a build. // Creates the mock files necessary to run a build.
void setUpMockProjectFilesForBuild({int templateVersion}) { void setUpMockProjectFilesForBuild() {
setUpMockCoreProjectFiles(); setUpMockCoreProjectFiles();
fileSystem.file(fileSystem.path.join('linux', 'CMakeLists.txt')).createSync(recursive: true); fileSystem.file(fileSystem.path.join('linux', 'CMakeLists.txt')).createSync(recursive: true);
final String versionFileSubpath = fileSystem.path.join('flutter', '.template_version');
const int expectedTemplateVersion = 10; // Arbitrary value for tests.
final File sourceTemplateVersionfile = fileSystem.file(fileSystem.path.join(
fileSystem.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'templates',
'app',
'linux.tmpl',
versionFileSubpath,
));
sourceTemplateVersionfile.createSync(recursive: true);
sourceTemplateVersionfile.writeAsStringSync(expectedTemplateVersion.toString());
final File projectTemplateVersionFile = fileSystem.file(
fileSystem.path.join('linux', versionFileSubpath));
templateVersion ??= expectedTemplateVersion;
projectTemplateVersionFile.createSync(recursive: true);
projectTemplateVersionFile.writeAsStringSync(templateVersion.toString());
} }
// Returns the command matching the build_linux call to cmake. // Returns the command matching the build_linux call to cmake.
...@@ -144,34 +124,6 @@ void main() { ...@@ -144,34 +124,6 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
}); });
testUsingContext('Linux build fails with instructions when template is too old', () async {
final BuildCommand command = BuildCommand();
setUpMockProjectFilesForBuild(templateVersion: 1);
expect(createTestCommandRunner(command).run(
const <String>['build', 'linux', '--no-pub']
), throwsToolExit(message: 'flutter create .'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => linuxPlatform,
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Linux build fails with instructions when template is too new', () async {
final BuildCommand command = BuildCommand();
setUpMockProjectFilesForBuild(templateVersion: 999);
expect(createTestCommandRunner(command).run(
const <String>['build', 'linux', '--no-pub']
), throwsToolExit(message: 'Upgrade Flutter'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => linuxPlatform,
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
});
testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async { testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
......
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