From 4cce5bd56c7d0df41c85f98a075f85ca150753f1 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 31 Oct 2024 08:04:40 -0700 Subject: [PATCH] [ci] use env for format and support arm64 hosts --- ci/bin/format.dart | 21 ++++++++++----------- ci/format.sh | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ci/bin/format.dart b/ci/bin/format.dart index b165dd5a7854c..88390bd826256 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -6,6 +6,7 @@ // // Run with --help for usage. +import 'dart:ffi'; import 'dart:io'; import 'package:args/args.dart'; @@ -312,17 +313,15 @@ class ClangFormatChecker extends FormatChecker { super.allFiles, super.messageCallback, }) { - /*late*/ String clangOs; - if (Platform.isLinux) { - clangOs = 'linux-x64'; - } else if (Platform.isMacOS) { - clangOs = 'mac-x64'; - } else if (Platform.isWindows) { - clangOs = 'windows-x64'; - } else { - throw FormattingException( - "Unknown operating system: don't know how to run clang-format here."); - } + final clangOs = switch (Abi.current()) { + Abi.linuxArm64 => 'linux-arm64', + Abi.linuxX64 => 'linux-x64', + Abi.macosArm64 => 'mac-arm64', + Abi.macosX64 => 'mac-x64', + Abi.windowsX64 => 'windows-x64', + (_) => throw FormattingException( + "Unknown operating system: don't know how to run clang-format here.") + }; clangFormat = File( path.join( srcDir.absolute.path, diff --git a/ci/format.sh b/ci/format.sh index 8bdd9424d010f..c402102d6c8a8 100755 --- a/ci/format.sh +++ b/ci/format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be