Skip to content

Commit a91b2be

Browse files
committed
address C++ compiler option review feedback
1 parent fd7442f commit a91b2be

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

‎pkgs/ffigen/lib/src/config_provider/config_types.dart‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,18 @@ List<String> defaultCompilerOpts(
384384
Logger logger, {
385385
bool macIncludeStdLib = true,
386386
bool cpp = false,
387-
}) => [
388-
if (Platform.isMacOS && macIncludeStdLib && !cpp)
389-
...getCStandardLibraryHeadersForMac(logger),
390-
if (Platform.isMacOS && !cpp) '-Wno-nullability-completeness',
391-
if (cpp) ...[
392-
'-x',
393-
'c++',
394-
'-std=c++17',
395-
if (Platform.isMacOS) ...['-isysroot', macSdkPath],
396-
],
397-
];
387+
}) => cpp
388+
? [
389+
'-x',
390+
'c++',
391+
'-std=c++17',
392+
if (Platform.isMacOS) ...['-isysroot', macSdkPath],
393+
]
394+
: [
395+
if (Platform.isMacOS && macIncludeStdLib)
396+
...getCStandardLibraryHeadersForMac(logger),
397+
if (Platform.isMacOS) '-Wno-nullability-completeness',
398+
];
398399

399400
/// Handles config for automatically added compiler options.
400401
class CompilerOptsAuto {

‎pkgs/ffigen/lib/src/context.dart‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ class Context {
2727
bool hasSourceErrors = false;
2828
final reportedCommentRanges = <((String, int), (String, int))>{};
2929
final libs = LibraryImports();
30-
late final compilerOpts = config.cpp == null
31-
? config.input.compilerOptions ?? defaultCompilerOpts(logger)
32-
: [
33-
...defaultCompilerOpts(logger, cpp: true),
34-
...?config.input.compilerOptions,
35-
];
30+
late final compilerOpts =
31+
config.input.compilerOptions ??
32+
defaultCompilerOpts(logger, cpp: config.cpp != null);
3633
final Scope rootScope = Scope.createRoot('root');
3734
final Scope rootObjCScope = Scope.createRoot('objc_root');
3835
late final ExtraSymbols extraSymbols;

0 commit comments

Comments
 (0)