Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4a7daa5

Browse files
[ci] use env for format and support arm64 hosts (#56268)
Fixes running x64 binaries on arm64 hosts, this fixes systems like Raspberry Pi's, Apple Silicon, and Ampere. Before, I would get something like: ``` Checking GN formatting... Completed checking 0 GN files with no formatting problems. Checking Java formatting... No Java files with changes, skipping Java format check. Checking Python formatting... All python files formatted correctly. Checking for trailing whitespace on 1 source file... No trailing whitespace found. No header files with changes, skipping header guard check. Checking C++/ObjC/Shader formatting... ERROR: Formatter command '/home/ross/flutter-engine/src/flutter/buildtools/linux-x64/clang/bin/clang-format --style=file shell/platform/linux/fl_application_test.cc' failed with exit code 255. Command output follows: qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory Completed checking 0 C++/ObjC/Shader files with no formatting problems ``` Now it just works, I also changed the shell script to use env since `/bin/bash` doesn't exist on NixOS so using env is a more portable solution. *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 1e562dd commit 4a7daa5

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

ci/bin/format.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
// Run with --help for usage.
88

9+
import 'dart:ffi';
910
import 'dart:io';
1011

1112
import 'package:args/args.dart';
@@ -312,17 +313,15 @@ class ClangFormatChecker extends FormatChecker {
312313
super.allFiles,
313314
super.messageCallback,
314315
}) {
315-
/*late*/ String clangOs;
316-
if (Platform.isLinux) {
317-
clangOs = 'linux-x64';
318-
} else if (Platform.isMacOS) {
319-
clangOs = 'mac-x64';
320-
} else if (Platform.isWindows) {
321-
clangOs = 'windows-x64';
322-
} else {
323-
throw FormattingException(
324-
"Unknown operating system: don't know how to run clang-format here.");
325-
}
316+
final clangOs = switch (Abi.current()) {
317+
Abi.linuxArm64 => 'linux-arm64',
318+
Abi.linuxX64 => 'linux-x64',
319+
Abi.macosArm64 => 'mac-arm64',
320+
Abi.macosX64 => 'mac-x64',
321+
Abi.windowsX64 => 'windows-x64',
322+
(_) => throw FormattingException(
323+
"Unknown operating system: don't know how to run clang-format here.")
324+
};
326325
clangFormat = File(
327326
path.join(
328327
srcDir.absolute.path,

ci/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
33
# Copyright 2013 The Flutter Authors. All rights reserved.
44
# Use of this source code is governed by a BSD-style license that can be

0 commit comments

Comments
 (0)