Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/pigeon/tool/shared/test_suites.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,15 @@ Future<int> _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';
Expand Down
14 changes: 5 additions & 9 deletions script/tool/lib/src/common/cmake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand All @@ -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.
Expand Down
47 changes: 16 additions & 31 deletions script/tool/lib/src/native_test_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Copy link
Copy Markdown
Contributor Author

@Gustl22 Gustl22 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this check, to be more explicit and perhaps its easier in the future to unify the handling for Linux and Windows in the same switch statement.

} 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}, '
Expand Down