Skip to content

Commit

Permalink
Update binding generator to output native getter functions for extern…
Browse files Browse the repository at this point in the history
… variables
  • Loading branch information
BeanCheeseBurrito committed Oct 30, 2024
1 parent 710c8b8 commit aade97e
Show file tree
Hide file tree
Showing 7 changed files with 1,302 additions and 615 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "submodules/flecs"]
path = submodules/flecs
[submodule "native/flecs"]
path = native/flecs
url = https://github.com/SanderMertens/flecs
branch = master
2 changes: 1 addition & 1 deletion src/Flecs.NET.Bindgen/Flecs.NET.Bindgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bindgen.NET" Version="0.1.14"/>
<PackageReference Include="Bindgen.NET" Version="0.1.15"/>
<PackageReference Include="Vezel.Zig.Toolsets.$(HostRuntime)" Version="0.13.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
27 changes: 13 additions & 14 deletions src/Flecs.NET.Bindgen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,42 @@

DllImportPath = "flecs",

DllFilePaths =
{
"flecs",
"libflecs",
"runtimes/linux-x64/native/libflecs",
"runtimes/linux-arm64/native/libflecs",
"runtimes/osx-x64/native/libflecs",
"runtimes/osx-arm64/native/libflecs",
"runtimes/win-x64/native/flecs",
"runtimes/win-arm64/native/flecs"
},

SuppressedWarnings = { "CS8981" },

SystemIncludeDirectories = { Path.Combine(BuildConstants.ZigLibPath, "include") },

InputFile = GetFlecsHeaderPath(),
OutputFile = GetBindingsOutputPath(),
NativeOutputFile = GetBindingsHelperOutputPath(),

GenerateMacros = true,
GenerateExternVariables = true,
GenerateStructEqualityFunctions = true
GenerateStructEqualityFunctions = true,

Ignored = {"FLECS_IDEcsPipelineQueryID_"}
};

if (OperatingSystem.IsMacOS())
bindingOptions.SystemIncludeDirectories.Add(Path.Combine(BuildConstants.ZigLibPath, "libc", "include", "any-macos-any"));

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
BindingGenerator.Generate(bindingOptions);
Console.WriteLine(stopwatch.Elapsed);

return;

string GetFlecsHeaderPath([CallerFilePath] string filePath = "")
{
return Path.GetFullPath(Path.Combine(filePath, "..", "..", "..", "submodules", "flecs", "distr", "flecs.h"));
return Path.GetFullPath(Path.Combine(filePath, "..", "..", "..", "native", "flecs", "distr", "flecs.h"));
}

string GetBindingsOutputPath([CallerFilePath] string filePath = "")
{
return Path.GetFullPath(Path.Combine(filePath, "..", "..", "Flecs.NET.Bindings", "Flecs.g.cs"));
}

string GetBindingsHelperOutputPath([CallerFilePath] string filePath = "")
{
return Path.GetFullPath(Path.Combine(filePath, "..", "..", "..", "native", "flecs_helpers.c"));
}
Loading

0 comments on commit aade97e

Please sign in to comment.