Replies: 1 comment 13 replies
-
In order to generate bindings this tool requires some knowledge of the project written in form of JSON configuration description. It tells the tool basic information about the source code to work on - where to look for extra headers, which compiler flags to use, and macro definitions that are often used as a basic conditional compilation and affects what symbols are present or omitted. Let's first look at the most basic configuration: (more info can be found at QuickStart) basic.json: {
"version": 1,
"input": {
"std": "c++11",
"paths": ["../include"],
"includes": ["../include/"],
"system": [],
"defines": [],
"cflags": []
},
"output": {
"path": "generated.d",
"target": "dlang",
"attr-nogc": false
}
} This configuration provides knowledge about the source code for which bindings needs to be generated. It defines an input(C++ source) and (produced) output. InputInput entry describes a set of headers("includes"), "system" headers (STL and compiler specific's, optional), macro defines and compiler flags (cflags). "includes" tells the generator where to look for both project and 3rd party headers, it often have the same folder as paths as the root. "defines" category takes macro definitions used by C++ preprocessor, it takes array of strings in "name=value" format where value is an optional value for the item, this is very important as it greatly affects resulting configuration, some projects won't even work if some defines is not set (e.g. PhysX with its platform configuration) "cflags" C++ compiler flags (in clang format), in most cases affects compiled code but not definitions and so can be left empty OutputAt this moment there is few options, the most important one is target file "path" that will contain generated bindings. (at the moment of writing only single file output is supported) "target" - currently only "dlang" target is supported There is also set of optional attributes such as "skip-bodies" and "mangle-all" that can be useful in some cases. See QuickStart for more info. Back to WtLet's take a look at Wt source From example folder we see that the core project consists of <Wt/*.h> includes, generally such includes resides in dedicated "include" folder at the project root, adding it to the includes and paths should solve the problem, however Wt in that regard is a bit messy as it keeps everything in one folder. Anyway... In case of Wt public headers is actually directly under src/ folder So the config will look like wt.json: {
"version": 1,
"input": {
"std": "c++11",
"paths": ["../src/Wt"], // Note that for sharing purposes you can use env variables, also note that it is limited to Wt subfolder
"includes": ["../src"]
"system": [],
"defines": [], // <- will likely won't work without set of feature defines (the ones that makes up logical configuration in project)
"cflags": []
},
"output": {
"path": "generated.d",
"target": "dlang",
"attr-nogc": false
}
} It might work as is, however very likely you will have to grab defines from your build system cache and/or including compiler defines(for gcc for example In case of cmake you can dig through example command-line for MSVS compiler
here it adds several defines (staring with /D prefix, -D for other compilers): "_MBCS" "WIN32" "_WINDOWS", it can also has values "CMAKE_INTDIR="Debug"" From a real example, for PhysX I had to put these defines, but later commented out unneeded stuff "defines": [
"_MSC_EXTENSIONS",
"_INTEGRAL_MAX_BITS=64",
//"_MSC_VER=1915",
//"_MSC_FULL_VER=191526726",
//"_MSC_BUILD=0",
"_M_AMD64=100",
"_M_X64=100",
"_WIN64",
"_WIN32",
"_CPPRTTI",
"_MT",
"_CRT_SECURE_NO_DEPRECATE",
"_CRT_NONSTDC_NO_DEPRECATE",
"NDEBUG",
//"PX_VC=15",
//"PX_DEBUG=0",
//"PX_CHECKED=1",
//"PX_NVTX=1",
//"PX_SUPPORT_PVD=1"
], After invoking I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
As referenced in #16, I'm hoping to be able to use this app to generate a Wt binding.
Some things to take note of:
std::unique_ptr
with a fewstd::string
s and such thrown in. Probably nothing that can't be worked around withcore.stdcpp
.First off, I need to figure out how the configuration file is set up.
Beta Was this translation helpful? Give feedback.
All reactions