Enables wchar32
This commit is contained in:
parent
f933cfed13
commit
f5ed86c136
12 changed files with 82 additions and 35 deletions
12
README.md
12
README.md
|
|
@ -41,18 +41,24 @@ Update `build.zig.zon`, and then if the headers changed, regenerate them into `s
|
|||
|
||||
Here's how to build `cimgui.h`:
|
||||
```sh
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py -o src/cached/cimgui $DEAR_IMGUI_PATH/imgui.h
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py --imconfig-path src/include/zimconfig.h -o src/cached/dcimgui $DEAR_IMGUI_PATH/imgui.h
|
||||
```
|
||||
|
||||
Here's how to build `cimgui_internal.h`:
|
||||
```sh
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py -o src/cached/cimgui_internal --include $DEAR_IMGUI_PATH/imgui.h $DEAR_IMGUI_PATH/imgui_internal.h
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py --imconfig-path src/include/zimconfig.h -o src/cached/dcimgui_internal --include $DEAR_IMGUI_PATH/imgui.h $DEAR_IMGUI_PATH/imgui_internal.h
|
||||
```
|
||||
|
||||
Here's how to build a backend, using Vulkan as an example:
|
||||
|
||||
```sh
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py --backend --imconfig-path $DEAR_IMGUI_PATH/imconfig.h -o src/cached/cimgui_impl_vulkan $DEAR_IMGUI_PATH/backends/imgui_impl_vulkan.h
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py --backend --imconfig-path src/include/zimconfig.h -o src/cached/cimgui_impl_vulkan $DEAR_IMGUI_PATH/backends/imgui_impl_vulkan.h
|
||||
```
|
||||
|
||||
And here's SDL3:
|
||||
|
||||
```sh
|
||||
python3 $DEAR_BINDINGS_PATH/dear_bindings.py --backend --imconfig-path src/include/zimconfig.h -o src/cached/dcimgui_impl_sdl3 $DEAR_IMGUI_PATH/backends/imgui_impl_sdl3.h
|
||||
```
|
||||
|
||||
If `generator.zig` fails, you may need to add missing values to the enumeration. `std.json` does not provide helpful errors at the time of writing, the easiest way to debug this is to comment out the actual generation code, and all fields in `Header`, adding them back until you figure out which are causing the issue.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
const std = @import("std");
|
||||
|
||||
const flags: []const []const u8 = &.{
|
||||
pub const flags: []const []const u8 = &.{
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-fno-threadsafe-statics",
|
||||
"-DIMGUI_USER_CONFIG=\"imconfig_zig.h\"",
|
||||
};
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
|
|
@ -34,6 +35,8 @@ pub fn build(b: *std.Build) void {
|
|||
}),
|
||||
});
|
||||
dear_imgui_lib.addIncludePath(upstream.path(""));
|
||||
dear_imgui_lib.addIncludePath(b.path("src/include"));
|
||||
dear_imgui_lib.installHeadersDirectory(b.path("src/include"), "", .{});
|
||||
dear_imgui_lib.installHeadersDirectory(upstream.path("."), "", .{});
|
||||
dear_imgui_lib.linkLibC();
|
||||
dear_imgui_lib.addCSourceFiles(.{
|
||||
|
|
@ -68,6 +71,7 @@ pub fn build(b: *std.Build) void {
|
|||
dear_imgui_vulkan_lib.linkLibrary(dear_imgui_lib);
|
||||
dear_imgui_vulkan_lib.addCSourceFile(.{ .file = upstream.path("backends/imgui_impl_vulkan.cpp"), .flags = flags });
|
||||
dear_imgui_vulkan_lib.addCSourceFile(.{ .file = b.path("src/cached/dcimgui_impl_vulkan.cpp"), .flags = flags });
|
||||
dear_imgui_vulkan_lib.addIncludePath(b.path("src/include"));
|
||||
dear_imgui_vulkan_lib.addIncludePath(upstream.path(""));
|
||||
dear_imgui_vulkan_lib.addIncludePath(upstream.path("backends"));
|
||||
const vulkan_headers = b.dependency("Vulkan-Headers", .{});
|
||||
|
|
@ -88,13 +92,12 @@ pub fn build(b: *std.Build) void {
|
|||
dear_imgui_sdl3_lib.linkLibrary(dear_imgui_lib);
|
||||
dear_imgui_sdl3_lib.addCSourceFile(.{ .file = upstream.path("backends/imgui_impl_sdl3.cpp"), .flags = flags });
|
||||
dear_imgui_sdl3_lib.addCSourceFile(.{ .file = b.path("src/cached/dcimgui_impl_sdl3.cpp"), .flags = flags });
|
||||
dear_imgui_sdl3_lib.addIncludePath(b.path("src/include"));
|
||||
dear_imgui_sdl3_lib.addIncludePath(upstream.path(""));
|
||||
dear_imgui_sdl3_lib.addIncludePath(upstream.path("backends"));
|
||||
const sdl = b.dependency("sdl", .{});
|
||||
dear_imgui_sdl3_lib.addIncludePath(sdl.path("include"));
|
||||
// dear_imgui_sdl3_lib.root_module.addCMacro("IMGUI_IMPL_VULKAN_NO_PROTOTYPES", "1"); // Assumed in generator // XXX: ...
|
||||
dear_imgui_sdl3_lib.installHeadersDirectory(upstream.path("backends"), "", .{});
|
||||
// dear_imgui_sdl3_lib.installHeadersDirectory(vulkan_headers.path("include"), "", .{}); // XXX: ...
|
||||
b.installArtifact(dear_imgui_sdl3_lib);
|
||||
|
||||
// Compile the generator
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"defines": [],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"defines": [],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
16
src/cached/dcimgui_impl_sdl3_zimconfig.json
Normal file
16
src/cached/dcimgui_impl_sdl3_zimconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"defines": [
|
||||
{
|
||||
"name": "DIMGUI_USE_WCHAR32",
|
||||
"is_internal": false,
|
||||
"source_location": {
|
||||
"filename": "zimconfig.h",
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"defines": [],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
16
src/cached/dcimgui_impl_vulkan_zimconfig.json
Normal file
16
src/cached/dcimgui_impl_vulkan_zimconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"defines": [
|
||||
{
|
||||
"name": "DIMGUI_USE_WCHAR32",
|
||||
"is_internal": false,
|
||||
"source_location": {
|
||||
"filename": "zimconfig.h",
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"defines": [],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
16
src/cached/dcimgui_internal_zimconfig.json
Normal file
16
src/cached/dcimgui_internal_zimconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"defines": [
|
||||
{
|
||||
"name": "DIMGUI_USE_WCHAR32",
|
||||
"is_internal": false,
|
||||
"source_location": {
|
||||
"filename": "zimconfig.h",
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
16
src/cached/dcimgui_zimconfig.json
Normal file
16
src/cached/dcimgui_zimconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"defines": [
|
||||
{
|
||||
"name": "DIMGUI_USE_WCHAR32",
|
||||
"is_internal": false,
|
||||
"source_location": {
|
||||
"filename": "zimconfig.h",
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"enums": [],
|
||||
"typedefs": [],
|
||||
"structs": [],
|
||||
"functions": []
|
||||
}
|
||||
|
|
@ -961,10 +961,10 @@ fn skip(conditionals: []const Header.Conditional) bool {
|
|||
if (std.mem.eql(u8, conditional.expression, "IMGUI_ENABLE_STB_TRUETYPE")) break :b true;
|
||||
if (std.mem.eql(u8, conditional.expression, "IMGUI_ENABLE_FREETYPE")) break :b true;
|
||||
if (std.mem.eql(u8, conditional.expression, "IMGUI_ENABLE_TEST_ENGINE")) break :b true;
|
||||
if (std.mem.eql(u8, conditional.expression, "IMGUI_USE_WCHAR32")) break :b true;
|
||||
|
||||
// False conditionals
|
||||
if (std.mem.eql(u8, conditional.expression, "IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT")) break :b false;
|
||||
if (std.mem.eql(u8, conditional.expression, "IMGUI_USE_WCHAR32")) break :b false;
|
||||
if (std.mem.eql(u8, conditional.expression, "ImTextureID")) break :b false;
|
||||
if (std.mem.eql(u8, conditional.expression, "ImDrawIdx")) break :b false;
|
||||
if (std.mem.eql(u8, conditional.expression, "ImDrawCallback")) break :b false;
|
||||
|
|
|
|||
2
src/include/imconfig_zig.h
Normal file
2
src/include/imconfig_zig.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#pragma once
|
||||
#define IMGUI_USE_WCHAR32
|
||||
Loading…
Add table
Add a link
Reference in a new issue