diff --git a/packages/pigeon/tool/shared/test_suites.dart b/packages/pigeon/tool/shared/test_suites.dart index fe86925792aa..2707076c94a8 100644 --- a/packages/pigeon/tool/shared/test_suites.dart +++ b/packages/pigeon/tool/shared/test_suites.dart @@ -409,6 +409,15 @@ Future _runLinuxUnitTests({bool ciMode = false}) async { return compileCode; } + // Depending on the Flutter version, the build output path may be different. + // To handle both master and stable, and to future-proof against the changes + // that will happen in https://github.com/flutter/flutter/issues/114349 + // - Try arm64, to future-proof against arm64 support. + // - Try x64, to cover pre-arm64 support on arm64 hosts, as well as x64 hosts. + // TODO(gustl22): Remove all this when these tests no longer need to + // support a version of Flutter without + // https://github.com/flutter/flutter/issues/114349, and just construct the + // version of the path with the current architecture. const buildDirBase = '$examplePath/build/linux'; const buildRelativeBinaryPath = 'debug/plugins/test_plugin/test_plugin_test'; const arm64Path = '$buildDirBase/arm64/$buildRelativeBinaryPath'; diff --git a/script/tool/lib/src/common/cmake.dart b/script/tool/lib/src/common/cmake.dart index 841d3f25be23..8084f9aee87a 100644 --- a/script/tool/lib/src/common/cmake.dart +++ b/script/tool/lib/src/common/cmake.dart @@ -20,7 +20,7 @@ class CMakeProject { required this.buildMode, this.processRunner = const ProcessRunner(), this.platform = const LocalPlatform(), - this.arch, + required this.arch, }); /// The directory of a Flutter project to run Gradle commands in. @@ -33,13 +33,11 @@ class CMakeProject { final Platform platform; /// The architecture subdirectory of the build. - // TODO(stuartmorgan): Make this non-nullable once Flutter 3.13 is no longer - // supported, since at that point there will always be a subdirectory. - final String? arch; + final String arch; /// The build mode (e.g., Debug, Release). /// - /// This is a constructor paramater because on Linux many properties depend + /// This is a constructor parameter because on Linux many properties depend /// on the build mode since it uses a single-configuration generator. final String buildMode; @@ -52,10 +50,8 @@ class CMakeProject { Directory get buildDirectory { Directory buildDir = flutterProject .childDirectory('build') - .childDirectory(_platformDirName); - if (arch != null) { - buildDir = buildDir.childDirectory(arch!); - } + .childDirectory(_platformDirName) + .childDirectory(arch); if (platform.isLinux) { // Linux uses a single-config generator, so the base build directory // includes the configuration. diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index a944b95b87bc..7d5001c2671f 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -678,50 +678,35 @@ this command. var hasMissingBuild = false; var buildFailed = false; String? arch; - const x64DirName = 'x64'; - const arm64DirName = 'arm64'; if (platform.isWindows) { - arch = _abi == Abi.windowsX64 ? x64DirName : arm64DirName; + arch = switch (_abi) { + Abi.windowsX64 => 'x64', + Abi.windowsArm64 => 'arm64', + _ => null, + }; } else if (platform.isLinux) { // TODO(stuartmorgan): Support arm64 if that ever becomes a supported // CI configuration for the repository. + // See: https://github.com/flutter/flutter/issues/114349 arch = 'x64'; } + + if (arch == null) { + return _PlatformResult( + RunState.failed, + error: + 'Testing on platform and architecture "$_abi" as CMakeProjects is not supported.', + ); + } + for (final RepositoryPackage example in plugin.getExamples()) { - var project = CMakeProject( + final project = CMakeProject( example.directory, buildMode: buildMode, processRunner: processRunner, platform: platform, arch: arch, ); - if (platform.isWindows) { - if (arch == arm64DirName && !project.isConfigured()) { - // Check for x64, to handle builds newer than 3.13, but that don't yet - // have https://github.com/flutter/flutter/issues/129807. - // TODO(stuartmorgan): Remove this when CI no longer supports a - // version of Flutter without the issue above fixed. - project = CMakeProject( - example.directory, - buildMode: buildMode, - processRunner: processRunner, - platform: platform, - arch: x64DirName, - ); - } - if (!project.isConfigured()) { - // Check again without the arch subdirectory, since 3.13 doesn't - // have it yet. - // TODO(stuartmorgan): Remove this when CI no longer supports Flutter - // 3.13. - project = CMakeProject( - example.directory, - buildMode: buildMode, - processRunner: processRunner, - platform: platform, - ); - } - } if (!project.isConfigured()) { printError( 'ERROR: Run "flutter build" on ${example.displayName}, '