blob: 55e4b93665d3d898ce99bd3abc0b553bb64d3338 [file]
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// 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';
FfiGenerator getConfig([Uri? packageRoot]) {
packageRoot ??= Uri.directory(Directory.current.path);
final testDir = packageRoot.resolve('test/native_cpp_test/');
return FfiGenerator(
output: Output(
dart: DartOutput(
path: testDir.resolve('cpp_scoped_struct_test_bindings.dart'),
),
),
input: Input(
entryPoints: [testDir.resolve('cpp_scoped_struct_test.h')],
compilerOptions: [
'-x',
'c++',
'-std=c++17',
if (Platform.isMacOS) ...['-isysroot', macSdkPath],
],
),
visitors: [
Visitor(
struct: (node) => node.isIncluded = {
'GlobalBox',
'GlobalBox::Lid',
'outer::Point',
'outer::inner::Point',
'outer::Palette::Entry',
'other::Point',
}.contains(node.originalName),
union: (node) => node.isIncluded = node.originalName == 'other::Value',
),
],
);
}