Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Fixing mac bot by explicitly setting the objective C sysroot (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Jul 1, 2022
1 parent 9dce9c8 commit 544dba6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/src/header_parser/parser.dart
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:ffi';
import 'dart:io';

import 'package:ffi/ffi.dart';
import 'package:ffigen/src/code_generator.dart';
Expand Down Expand Up @@ -65,7 +66,10 @@ List<Binding> parseToBindings() {

/// If the config targets Objective C, add a compiler opt for it.
if (config.language == Language.objc) {
compilerOpts.addAll(strings.clangLangObjC);
compilerOpts.addAll([
...strings.clangLangObjC,
..._findObjectiveCSysroot(),
]);
}

_logger.fine('CompilerOpts used: $compilerOpts');
Expand Down Expand Up @@ -119,3 +123,15 @@ List<Binding> parseToBindings() {
clang.clang_disposeIndex(index);
return bindings.toList();
}

List<String> _findObjectiveCSysroot() {
final result = Process.runSync('xcrun', ['--show-sdk-path']);
if (result.exitCode == 0) {
for (final line in (result.stdout as String).split('\n')) {
if (line.isNotEmpty) {
return ['-isysroot', line];
}
}
}
return [];
}

0 comments on commit 544dba6

Please sign in to comment.