Skip to content

Commit

Permalink
[ffigen] Add compiler option -Wno-nullability-completeness by defau…
Browse files Browse the repository at this point in the history
…lt (#1074)
  • Loading branch information
dcharkes authored Apr 10, 2024
1 parent cf4f974 commit 695c065
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkgs/ffigen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
`ffi-native` option.
- Add `retainAndReturnPointer` method to ObjC objects and blocks, and add
`castFromPointer` method to blocks.
- Add `-Wno-nullability-completeness` as default compiler option for MacOS.

## 11.0.0

Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/example/libclang-example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ headers:
compiler-opts:
- '-I../../third_party/libclang/include'
- '-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/'
- '-Wno-nullability-completeness'
functions:
include:
- 'clang_.*' # Can be a regexp, '.' matches any character.
Expand Down
10 changes: 5 additions & 5 deletions pkgs/ffigen/lib/src/config_provider/config_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ class CompilerOptsAuto {

/// Extracts compiler options based on OS and config.
List<String> extractCompilerOpts() {
if (Platform.isMacOS && macIncludeStdLib) {
return getCStandardLibraryHeadersForMac();
}

return [];
return [
if (Platform.isMacOS && macIncludeStdLib)
...getCStandardLibraryHeadersForMac(),
if (Platform.isMacOS) '-Wno-nullability-completeness',
];
}
}

Expand Down
9 changes: 8 additions & 1 deletion pkgs/ffigen/test/config_tests/compiler_opts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 'dart:io';

import 'package:ffigen/ffigen.dart';
import 'package:ffigen/src/config_provider/spec_utils.dart';
import 'package:ffigen/src/strings.dart' as strings;
Expand Down Expand Up @@ -40,7 +42,12 @@ ${strings.compilerOptsAuto}:
${strings.macos}:
${strings.includeCStdLib}: false
''');
expect(config.compilerOpts.isEmpty, true);
expect(
config.compilerOpts,
equals([
if (Platform.isMacOS) '-Wno-nullability-completeness',
]),
);
});
});
}
1 change: 0 additions & 1 deletion pkgs/ffigen/test/native_test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ headers:
include-directives:
- '**native_test.c'

compiler-opts: '-Wno-nullability-completeness'
preamble: |
// ignore_for_file: camel_case_types, non_constant_identifier_names
1 change: 0 additions & 1 deletion pkgs/ffigen/tool/libclang_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ description: Holds bindings to LibClang.
output: '../lib/src/header_parser/clang_bindings/clang_bindings.dart'
compiler-opts:
- '-Ithird_party/libclang/include'
- '-Wno-nullability-completeness'
headers:
entry-points:
- '../third_party/libclang/include/clang-c/Index.h'
Expand Down

0 comments on commit 695c065

Please sign in to comment.