From d9902a5474724177e7d4c855358b469c9a267a89 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 24 Jun 2020 12:23:57 -0700 Subject: [PATCH] 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. --- .../lib/src/commands/create.dart | 8 +-- .../lib/src/linux/build_linux.dart | 36 ------------- .../app/linux.tmpl/flutter/.template_version | 1 - .../hermetic/build_linux_test.dart | 50 +------------------ 4 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 packages/flutter_tools/templates/app/linux.tmpl/flutter/.template_version diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 068018ccd8..112cd39ce0 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -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 // lost among the other output. - if (featureFlags.isLinuxEnabled) { - 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) { + if (featureFlags.isWindowsEnabled && platforms.contains('windows')) { globals.printStatus(''); globals.printStatus('WARNING: The Windows tooling and APIs are not yet stable. ' 'You will likely need to re-create the "windows" directory after future ' diff --git a/packages/flutter_tools/lib/src/linux/build_linux.dart b/packages/flutter_tools/lib/src/linux/build_linux.dart index 42c92fad9c..2ff86909d7 100644 --- a/packages/flutter_tools/lib/src/linux/build_linux.dart +++ b/packages/flutter_tools/lib/src/linux/build_linux.dart @@ -27,20 +27,6 @@ Future buildLinux( '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 // step. final Map environmentConfig = buildInfo.toEnvironmentConfig(); @@ -127,25 +113,3 @@ Future _runBuild(Directory buildDir) async { } 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); -} diff --git a/packages/flutter_tools/templates/app/linux.tmpl/flutter/.template_version b/packages/flutter_tools/templates/app/linux.tmpl/flutter/.template_version deleted file mode 100644 index b8626c4cff..0000000000 --- a/packages/flutter_tools/templates/app/linux.tmpl/flutter/.template_version +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart index bf53a138c2..184a3b3944 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart @@ -57,29 +57,9 @@ void main() { } // Creates the mock files necessary to run a build. - void setUpMockProjectFilesForBuild({int templateVersion}) { + void setUpMockProjectFilesForBuild() { setUpMockCoreProjectFiles(); 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. @@ -144,34 +124,6 @@ void main() { 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 ['build', 'linux', '--no-pub'] - ), throwsToolExit(message: 'flutter create .')); - }, overrides: { - 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 ['build', 'linux', '--no-pub'] - ), throwsToolExit(message: 'Upgrade Flutter')); - }, overrides: { - FileSystem: () => fileSystem, - ProcessManager: () => processManager, - Platform: () => linuxPlatform, - FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), - }); - testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async { final BuildCommand command = BuildCommand(); processManager = FakeProcessManager.list([