diff --git a/pkgs/native_toolchain_c/CHANGELOG.md b/pkgs/native_toolchain_c/CHANGELOG.md index 16151e6f64..916abb3089 100644 --- a/pkgs/native_toolchain_c/CHANGELOG.md +++ b/pkgs/native_toolchain_c/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.17.4 + +- Fixed resolution of C compiler and tools on macOS when `swiftly` is installed. +- Broaden compiler tool discovery on macOS. + ## 0.17.3 - Bump `package:hooks` and `package:code_assets`to 1.0.0. diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 9c7eb4c99e..67dcf49619 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:code_assets/code_assets.dart'; + import '../tool/tool.dart'; import '../tool/tool_resolver.dart'; @@ -31,6 +33,10 @@ final Tool appleAr = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ar'), ), + PathToolResolver( + toolName: 'Apple archiver', + executableName: OS.current.executableFileName('ar'), + ), ]), ); @@ -43,6 +49,15 @@ final Tool appleLd = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ld'), ), + PathToolResolver( + toolName: 'Apple linker', + executableName: OS.current.executableFileName('ld'), + ), + RelativeToolResolver( + toolName: 'Apple linker', + wrappedResolver: appleClang.defaultResolver!, + relativePath: Uri.file(OS.current.executableFileName('ld.lld')), + ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 0603703181..84fcdf679e 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -65,8 +65,10 @@ class PathToolResolver extends ToolResolver { if (process.exitCode == 0) { final file = File(LineSplitter.split(process.stdout).first); final uri = File(await file.resolveSymbolicLinks()).uri; - if (uri.pathSegments.last == 'llvm') { + if (uri.pathSegments.last == 'llvm' || + uri.pathSegments.last == 'swiftly') { // https://github.com/dart-lang/native/issues/136 + // https://github.com/dart-lang/native/issues/2792 return file.uri; } return uri; diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index d0f58df9a8..1a3e16f778 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -1,7 +1,7 @@ name: native_toolchain_c description: >- A library to invoke the native C compiler installed on the host machine. -version: 0.17.3 +version: 0.17.4 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c topics: