mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Made clang tidy use arm64 if on an arm64 mac. (flutter/engine#47494)
fixes https://github.com/flutter/flutter/issues/137260 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --------- Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
This commit is contained in:
parent
eb6c33cee1
commit
52fcefb32a
@ -46,6 +46,11 @@ else
|
||||
fix_flag="--fix --lint-all"
|
||||
fi
|
||||
|
||||
# Determine wether to use x64 or arm64.
|
||||
if command -v arch &> /dev/null && [[ $(arch) == "arm64" ]]; then
|
||||
CLANG_TIDY_PATH="buildtools/mac-arm64/clang/bin/clang-tidy"
|
||||
fi
|
||||
|
||||
COMPILE_COMMANDS="$SRC_DIR/out/host_debug/compile_commands.json"
|
||||
if [ ! -f "$COMPILE_COMMANDS" ]; then
|
||||
(cd "$SRC_DIR"; ./flutter/tools/gn)
|
||||
@ -58,6 +63,7 @@ cd "$SCRIPT_DIR"
|
||||
--disable-dart-dev \
|
||||
"$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \
|
||||
--src-dir="$SRC_DIR" \
|
||||
${CLANG_TIDY_PATH:+--clang-tidy="$SRC_DIR/$CLANG_TIDY_PATH"} \
|
||||
$fix_flag \
|
||||
"$@" && true # errors ignored
|
||||
clang_tidy_return=$?
|
||||
|
||||
@ -177,6 +177,7 @@ std::unique_ptr<Shell> Shell::Create(
|
||||
auto resource_cache_limit_calculator =
|
||||
std::make_shared<ResourceCacheLimitCalculator>(
|
||||
settings.resource_cache_max_bytes_threshold);
|
||||
|
||||
return CreateWithSnapshot(platform_data, //
|
||||
task_runners, //
|
||||
/*parent_thread_merger=*/nullptr, //
|
||||
|
||||
@ -146,8 +146,9 @@ class Command {
|
||||
'--',
|
||||
];
|
||||
args.addAll(tidyArgs.split(' '));
|
||||
final String clangTidyPath = options.clangTidyPath?.path ?? tidyPath;
|
||||
return WorkerJob(
|
||||
<String>[tidyPath, ...args],
|
||||
<String>[clangTidyPath, ...args],
|
||||
workingDirectory: directory,
|
||||
name: 'clang-tidy on $filePath',
|
||||
printOutput: options.verbose,
|
||||
|
||||
@ -38,6 +38,7 @@ class Options {
|
||||
this.shardCommandsPaths = const <io.File>[],
|
||||
this.enableCheckProfile = false,
|
||||
StringSink? errSink,
|
||||
this.clangTidyPath,
|
||||
}) : checks = checksArg.isNotEmpty ? '--checks=$checksArg' : null,
|
||||
_errSink = errSink ?? io.stderr;
|
||||
|
||||
@ -69,6 +70,7 @@ class Options {
|
||||
StringSink? errSink,
|
||||
required List<io.File> shardCommandsPaths,
|
||||
int? shardId,
|
||||
io.File? clangTidyPath,
|
||||
}) {
|
||||
final LintTarget lintTarget;
|
||||
if (options.wasParsed('lint-all') || io.Platform.environment['FLUTTER_LINT_ALL'] != null) {
|
||||
@ -92,6 +94,7 @@ class Options {
|
||||
shardCommandsPaths: shardCommandsPaths,
|
||||
shardId: shardId,
|
||||
enableCheckProfile: options['enable-check-profile'] as bool,
|
||||
clangTidyPath: clangTidyPath,
|
||||
);
|
||||
}
|
||||
|
||||
@ -138,12 +141,16 @@ class Options {
|
||||
if (shardId != null && (shardId > shardCommands.length || shardId < 0)) {
|
||||
return Options._error('Invalid shard-id value: $shardId.', errSink: errSink);
|
||||
}
|
||||
final io.File? clangTidyPath = ((String? path) => path == null
|
||||
? null
|
||||
: io.File(path))(argResults['clang-tidy'] as String?);
|
||||
return Options._fromArgResults(
|
||||
argResults,
|
||||
buildCommandsPath: buildCommands,
|
||||
errSink: errSink,
|
||||
shardCommandsPaths: shardCommands,
|
||||
shardId: shardId,
|
||||
clangTidyPath: clangTidyPath,
|
||||
);
|
||||
}
|
||||
|
||||
@ -227,6 +234,10 @@ class Options {
|
||||
'string, indicating all checks should be performed.',
|
||||
defaultsTo: '',
|
||||
)
|
||||
..addOption('clang-tidy',
|
||||
help:
|
||||
'Path to the clang-tidy executable. Defaults to deriving the path\n'
|
||||
'from compile_commands.json.')
|
||||
..addFlag(
|
||||
'enable-check-profile',
|
||||
help: 'Enable per-check timing profiles and print a report to stderr.',
|
||||
@ -276,6 +287,10 @@ class Options {
|
||||
|
||||
final StringSink _errSink;
|
||||
|
||||
/// Override for which clang-tidy to use. If it is null it will be derived
|
||||
/// instead.
|
||||
final io.File? clangTidyPath;
|
||||
|
||||
/// Print command usage with an additional message.
|
||||
void printUsage({String? message, required Engine? engine}) {
|
||||
if (message != null) {
|
||||
|
||||
@ -214,6 +214,23 @@ Future<int> main(List<String> args) async {
|
||||
});
|
||||
});
|
||||
|
||||
test('clang-tidy specified', () async {
|
||||
_withTempFile('shard-id-valid', (String path) {
|
||||
final Options options = Options.fromCommandLine( <String>[
|
||||
'--clang-tidy=foo/bar',
|
||||
],);
|
||||
expect(options.clangTidyPath, isNotNull);
|
||||
expect(options.clangTidyPath!.path, equals('foo/bar'));
|
||||
});
|
||||
});
|
||||
|
||||
test('clang-tidy unspecified', () async {
|
||||
_withTempFile('shard-id-valid', (String path) {
|
||||
final Options options = Options.fromCommandLine( <String>[],);
|
||||
expect(options.clangTidyPath, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
test('shard-id invalid', () async {
|
||||
_withTempFile('shard-id-valid', (String path) {
|
||||
final StringBuffer errBuffer = StringBuffer();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user