blob: 7ba17c548b5c0749fbaee619b55c36be9c947a71 [file] [log] [blame]
// Copyright (c) 2020, 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 'package:ffigen/src/config_provider/config.dart';
import 'package:ffigen/src/header_parser.dart';
import 'package:ffigen/src/strings.dart' as strings;
import 'package:logging/logging.dart';
import 'package:test/test.dart';
import 'package:yaml/yaml.dart';
import '../test_utils.dart';
void main() {
group('example_test', () {
setUpAll(() {
logWarnings(Level.SEVERE);
});
test('libclang-example', () {
final config = Config.fromYaml(loadYaml('''
${strings.output}: 'generated_bindings.dart'
${strings.headers}:
${strings.entryPoints}:
- third_party/libclang/include/clang-c/Index.h
${strings.includeDirectives}:
- '**CXString.h'
- '**Index.h'
${strings.compilerOpts}: '-Ithird_party/libclang/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ -Wno-nullability-completeness'
${strings.functions}:
${strings.include}:
- 'clang_.*'
${strings.symbolAddress}:
${strings.include}:
- 'clang_.*'
${strings.structs}:
${strings.include}:
- 'CX.*'
${strings.enums}:
${strings.include}:
- 'CXTypeKind'
- 'CXGlobalOptFlags'
${strings.typedefmap}:
'size_t': 'IntPtr'
'time_t': 'Int64'
${strings.name}: 'LibClang'
${strings.description}: 'Holds bindings to LibClang.'
${strings.comments}:
${strings.style}: ${strings.doxygen}
${strings.length}: ${strings.full}
${strings.preamble}: |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM
// Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// ignore_for_file: camel_case_types, non_constant_identifier_names
''') as YamlMap);
final library = parse(config);
matchLibraryWithExpected(
library,
['test', 'debug_generated', 'example_libclang.dart'],
['example', 'libclang-example', config.output],
);
});
});
}