-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Hi,
I just tried out flutter's FFI plugin tutorial under https://docs.flutter.dev/development/packages-and-plugins/developing-packages#plugin-ffi.
There the bindings are supposed to get generated using the following command:
flutter pub run ffigen --config ffigen.yaml
However, the file remains mainly empty only containing the following:
// ignore_for_file: always_specify_types
// ignore_for_file: camel_case_types
// ignore_for_file: non_constant_identifier_names
// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
import 'dart:ffi' as ffi;
running the command in verbose mode shows that the functions in the header file are (not-included) despite the entry under "include-directives":
[FINEST] : rootCursorVisitor:(not included) (Cursor) spelling: sum, kind: 8, kindSpelling: FunctionDecl, type: 111, typeSpelling: intptr_t (intptr_t, intptr_t), usr: c:@F@sum
[FINEST] : rootCursorVisitor:(not included) (Cursor) spelling: sum_long_running, kind: 8, kindSpelling: FunctionDecl, type: 111, typeSpelling: intptr_t (intptr_t, intptr_t), usr: c:@F@sum_long_running
and removing the following lines from the config file results in the functions being generated, but also all the other methods hidden in other header files that I don't want to get generated:
include-directives:
- 'src/test_ffi.h'
test_ffi.h:
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#if _WIN32
#include <windows.h>
#else
#include <pthread.h>
#include <unistd.h>
#endif
#if _WIN32
#define FFI_PLUGIN_EXPORT __declspec(dllexport)
#else
#define FFI_PLUGIN_EXPORT
#endif
// A very short-lived native function.
//
// For very short-lived functions, it is fine to call them on the main isolate.
// They will block the Dart execution while running the native function, so
// only do this for native functions which are guaranteed to be short-lived.
FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b);
// A longer lived native function, which occupies the thread calling it.
//
// Do not call these kind of native functions in the main isolate. They will
// block Dart execution. This will cause dropped frames in Flutter applications.
// Instead, call these native functions on a separate isolate.
FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b);
// FFI_PLUGIN_EXPORT int test(char * out );
System: Win 10
tested with both ffigen version 6.0.0 and 4.1.2