From 50fd10fc6f09797ff0eb538fe00b6af331bc3100 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Thu, 17 Sep 2020 18:24:28 -0400 Subject: [PATCH] Consider the Windows app template stable (#66022) Removes the template version from the Windows template; the API and tooling boundary will now be considered stable, so there will no longer be frequent breaking changes. Also updates the link for adding desktop support to a project for all three platforms to reflect the current location. Fixes https://github.com/flutter/flutter/issues/52748 --- .../lib/src/linux/build_linux.dart | 2 +- .../lib/src/macos/build_macos.dart | 2 +- .../lib/src/windows/build_windows.dart | 40 +------------- .../windows.tmpl/flutter/.template_version | 1 - .../templates/template_manifest.json | 2 - .../hermetic/build_windows_test.dart | 52 ------------------- 6 files changed, 4 insertions(+), 95 deletions(-) delete mode 100644 packages/flutter_tools/templates/app/windows.tmpl/flutter/.template_version diff --git a/packages/flutter_tools/lib/src/linux/build_linux.dart b/packages/flutter_tools/lib/src/linux/build_linux.dart index c5cda52e21..e1cd4cf40b 100644 --- a/packages/flutter_tools/lib/src/linux/build_linux.dart +++ b/packages/flutter_tools/lib/src/linux/build_linux.dart @@ -26,7 +26,7 @@ Future buildLinux( }) async { if (!linuxProject.cmakeFile.existsSync()) { throwToolExit('No Linux desktop project configured. See ' - 'https://github.com/flutter/flutter/wiki/Desktop-shells#create ' + 'https://flutter.dev/desktop#add-desktop-support-to-an-existing-app ' 'to learn about adding Linux support to a project.'); } diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index 3d29f1ac56..67779cc65b 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -31,7 +31,7 @@ Future buildMacOS({ }) async { if (!flutterProject.macos.xcodeWorkspace.existsSync()) { throwToolExit('No macOS desktop project configured. ' - 'See https://flutter.dev/desktop#add-desktop-support-to-an-existing-flutter-project ' + 'See https://flutter.dev/desktop#add-desktop-support-to-an-existing-app ' 'to learn about adding macOS support to a project.'); } diff --git a/packages/flutter_tools/lib/src/windows/build_windows.dart b/packages/flutter_tools/lib/src/windows/build_windows.dart index 9ad43cd92e..fb7ef417b6 100644 --- a/packages/flutter_tools/lib/src/windows/build_windows.dart +++ b/packages/flutter_tools/lib/src/windows/build_windows.dart @@ -31,25 +31,11 @@ Future buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, { }) async { if (!windowsProject.cmakeFile.existsSync()) { throwToolExit( - 'No Windows desktop project configured. ' - 'See https://github.com/flutter/flutter/wiki/Desktop-shells#create ' + 'No Windows desktop project configured. See ' + 'https://flutter.dev/desktop#add-desktop-support-to-an-existing-app ' 'to learn about adding Windows 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(windowsProject); - if (templateCompareResult < 0) { - throwToolExit('The Windows runner was created with an earlier version of ' - 'the template, which is not yet stable.\n\n' - 'Delete the windows/ directory and re-run \'flutter create .\', ' - 're-applying any previous changes.'); - } else if (templateCompareResult > 0) { - throwToolExit('The Windows runner was created with a newer version of the ' - 'template, which is not yet stable.\n\n' - 'Upgrade Flutter and try again.'); - } - // Ensure that necessary emphemeral files are generated and up to date. _writeGeneratedFlutterConfig(windowsProject, buildInfo, target); createPluginSymlinks(windowsProject.parent); @@ -189,25 +175,3 @@ void _writeGeneratedFlutterConfig( } writeGeneratedCmakeConfig(Cache.flutterRoot, windowsProject, environment); } - -// 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(WindowsProject 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', - 'windows.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/windows.tmpl/flutter/.template_version b/packages/flutter_tools/templates/app/windows.tmpl/flutter/.template_version deleted file mode 100644 index 7f8f011eb7..0000000000 --- a/packages/flutter_tools/templates/app/windows.tmpl/flutter/.template_version +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/packages/flutter_tools/templates/template_manifest.json b/packages/flutter_tools/templates/template_manifest.json index f3a1485754..59d87a6784 100644 --- a/packages/flutter_tools/templates/template_manifest.json +++ b/packages/flutter_tools/templates/template_manifest.json @@ -79,7 +79,6 @@ "templates/app/linux.tmpl/my_application.cc.tmpl", "templates/app/linux.tmpl/.gitignore", "templates/app/linux.tmpl/CMakeLists.txt.tmpl", - "templates/app/linux.tmpl/flutter/.template_version", "templates/app/linux.tmpl/flutter/CMakeLists.txt", "templates/app/linux.tmpl/main.cc", "templates/app/linux.tmpl/my_application.cc", @@ -121,7 +120,6 @@ "templates/app/web/manifest.json.tmpl", "templates/app/windows.tmpl/.gitignore", "templates/app/windows.tmpl/CMakeLists.txt.tmpl", - "templates/app/windows.tmpl/flutter/.template_version", "templates/app/windows.tmpl/flutter/CMakeLists.txt", "templates/app/windows.tmpl/runner/CMakeLists.txt", "templates/app/windows.tmpl/runner/flutter_window.cpp", diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart index cbf517dbfd..1b3e276c27 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart @@ -68,26 +68,6 @@ void main() { void setUpMockProjectFilesForBuild({int templateVersion}) { fileSystem.file(buildFilePath).createSync(recursive: true); setUpMockCoreProjectFiles(); - - 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', - 'windows.tmpl', - versionFileSubpath, - )); - sourceTemplateVersionfile.createSync(recursive: true); - sourceTemplateVersionfile.writeAsStringSync(expectedTemplateVersion.toString()); - - final File projectTemplateVersionFile = fileSystem.file( - fileSystem.path.join('windows', versionFileSubpath)); - templateVersion ??= expectedTemplateVersion; - projectTemplateVersionFile.createSync(recursive: true); - projectTemplateVersionFile.writeAsStringSync(templateVersion.toString()); } // Returns the command matching the build_windows call to generate CMake @@ -184,38 +164,6 @@ void main() { FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), }); - testUsingContext('Windows build fails with instructions when template is too old', () async { - final BuildWindowsCommand command = BuildWindowsCommand() - ..visualStudioOverride = mockVisualStudio; - applyMocksToCommand(command); - setUpMockProjectFilesForBuild(templateVersion: 1); - - expect(createTestCommandRunner(command).run( - const ['windows', '--no-pub'] - ), throwsToolExit(message: 'flutter create .')); - }, overrides: { - FileSystem: () => fileSystem, - ProcessManager: () => FakeProcessManager.any(), - Platform: () => windowsPlatform, - FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), - }); - - testUsingContext('Windows build fails with instructions when template is too new', () async { - final BuildWindowsCommand command = BuildWindowsCommand() - ..visualStudioOverride = mockVisualStudio; - applyMocksToCommand(command); - setUpMockProjectFilesForBuild(templateVersion: 999); - - expect(createTestCommandRunner(command).run( - const ['windows', '--no-pub'] - ), throwsToolExit(message: 'Upgrade Flutter')); - }, overrides: { - FileSystem: () => fileSystem, - ProcessManager: () => FakeProcessManager.any(), - Platform: () => windowsPlatform, - FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), - }); - testUsingContext('Windows build does not spew stdout to status logger', () async { final BuildWindowsCommand command = BuildWindowsCommand() ..visualStudioOverride = mockVisualStudio;