Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More verbose "Log Exclusions" Option? #532

Open
kkukshtel opened this issue Feb 29, 2024 · 2 comments
Open

More verbose "Log Exclusions" Option? #532

kkukshtel opened this issue Feb 29, 2024 · 2 comments

Comments

@kkukshtel
Copy link
Contributor

I'm having a hell of a time trying to generate bindings for https://github.com/memononen/fontstash, and all more normal ways of flipping defines and such aren't working. It could very well be my own cause of define stuff but with a mostly normal config nothing is being generated. However even with log-exclusions set I'm not seeing any information about functions that were visited and why they were or weren't emitted to the bindgen. Here's my rsp:

--config
latest-codegen
single-file
generate-aggressive-inlining
generate-file-scoped-namespaces
log-exclusions
log-potential-typedef-remappings
log-visited-files
generate-cpp-attributes
--additional
-Wno-ignored-attributes
-Wno-nullability-completeness
-Wunused-function

--include-directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/
./libs/sokol/src/sokol
./libs/sokol/src/
--define-macro
SOKOL_DLL
SOKOL_NO_ENTRY
SOKOL_TRACE_HOOKS
--namespace
Dinghy.Internal.Sokol
--libraryPath
sokol
--file
./libs/sokol/fontstash.h
--methodClassName
Fontstash
--output
../Dinghy.Core/src/generated/lib/sokol/Sokol.Fontstash.cs
--prefixStrip
sfons_
--traverse
./libs/sokol/fontstash.h

I get unused function warnings on stb_truetype (included from fontstash.h) but nothing from fontstash.h, even though nothing is emitted from fontash.h. Any indication from ClangSharp as to why would be great.

@kkukshtel
Copy link
Contributor Author

Bumping this again as I'm trying to generate for Box2D and getting no good information on why functions are being skipped:

Zinc.Bootstrapper: C:\Users\kylek\.dotnet\tools\ClangSharpPInvokeGenerator.EXE @box2d.rsp
Diagnostics for './libs/box2d/bindgen/box2d_bindgen_helper.h':
    ./libs/box2d/bindgen/box2d_bindgen_helper.h:1:26: warning: ISO C99 requires whitespace after the macro name [-Wc99-extensions]
    ./libs/box2d/bindgen\../src/box2d/include/box2d\base.h:16:10: warning: 'BOX2D_EXPORT' macro redefined [-Wmacro-redefined]
    ./libs/box2d/bindgen\../src/box2d/include/box2d\base.h:27:10: warning: 'B2_API' macro redefined [-Wmacro-redefined]
Processing './libs/box2d/bindgen/box2d_bindgen_helper.h'
Diagnostics for binding generation of ./libs/box2d/bindgen/box2d_bindgen_helper.h:
    Info: Visiting
    Info: Visiting C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/include/vadefs.h
    Info: Visiting C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/include/vcruntime.h
    Info: Visiting C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/include/stdint.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/base.h
    Info: Visiting C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt.h
    Info: Visiting C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/float.h
    Info: Visiting C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_math.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/math_functions.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/collision.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/id.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/types.h
    Info: Visiting ./libs/box2d/bindgen/../src/box2d/include/box2d/box2d.h

the rsp file:

--config
latest-codegen
single-file
exclude-funcs-with-body
generate-aggressive-inlining
log-exclusions
log-potential-typedef-remappings
log-visited-files
generate-cpp-attributes
--additional
-Wno-ignored-attributes
-Wno-nullability-completeness
-Wunused-function

--include-directory
C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt
./libs/box2d/src/include/box2d/
--define-macro
BOX2D_DLL
--namespace
Zinc.Internal.Box2D
--libraryPath
box2d

--file
./libs/box2d/bindgen/box2d_bindgen_helper.h
--methodClassName
Box2D
--output
./out/bindings/box2d/Box2D.cs
--traverse
./libs/box2d/src/include/box2d/box2d.h

@tannergooding
Copy link
Member

There's not really much additional that can be logged here. The next best thing would be to debug into the code and view the actual AST produced by Clang.

My general recommendation is, due to the way that Clang itself handles files, you should try to make this as "simple" as possible and avoid relative paths or the like.

In the case of TerraFX.Interop.Windows, for example, you'll note that there is a folder per header that needs to be processed: https://github.com/terrafx/terrafx.interop.windows/tree/main/generation/DirectX/d3d12

Within each folder is then 3 files:

  1. The generate.rsp file that actually contains the various options passed to clang
  2. A header.txt containing the license info to add to the generated files
  3. A *.h file that includes the file that I actually want to traverse, in addition to any other shared configuration options (like include prerequisites, defines, etc)

I think have the shared settings and shared import header as the only "relative" files, which helps ensure Clang produces consistent paths and traversal diagnostics. -- Other setups can lead to weird paths that may not match the expected relative path, and which therefore won't match the configuration passed in even if you attempt to normalize them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants