From 74ef11d7654fd635535cbf36b70be91097eddbbc Mon Sep 17 00:00:00 2001 From: GuilhermeWerner Date: Thu, 21 Jan 2021 12:39:50 -0300 Subject: [PATCH] Setup Bindings Generation --- .gitignore | 2 +- Config/Bindings.toml | 113 +++++++++++++++++++++++++++++++++++++++ GenerateBindings.bat | 1 + GenerateBindings.command | 3 ++ GenerateBindings.sh | 3 ++ 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Config/Bindings.toml create mode 100644 GenerateBindings.bat create mode 100644 GenerateBindings.command create mode 100644 GenerateBindings.sh diff --git a/.gitignore b/.gitignore index abedf6a..3797f16 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ imgui.ini # Cargo Files Cargo.lock -Engine/Source/Header.h +Source/Library.h # Mac OSX diff --git a/Config/Bindings.toml b/Config/Bindings.toml new file mode 100644 index 0000000..01f6692 --- /dev/null +++ b/Config/Bindings.toml @@ -0,0 +1,113 @@ +# This is a template cbindgen.toml file with all of the default values. +# Some values are commented out because their absence is the real default. +# +# See https://github.com/eqrion/cbindgen/blob/master/docs.md#cbindgentoml +# for detailed documentation of every option here. + +language = "C" + +############## Options for Wrapping the Contents of the Header ################# + +# header = "// Copyright (c) GuilhermeWerner" +# trailer = "/* Text to put at the end of the generated file */" +# include_guard = "my_bindings_h" +pragma_once = true +# autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" +include_version = false +namespace = "Library" +namespaces = [] +using_namespaces = [] +sys_includes = [] +includes = [] +no_includes = false +cpp_compat = true + +# A list of lines to add verbatim after the includes block +#after_includes = "MY_DEFINITION" + +############################ Code Style Options ################################ + +braces = "NextLine" +line_length = 100 +tab_width = 4 +line_endings = "LF" # also "CR", "CRLF", "Native" + +############################# Codegen Options ################################## + +style = "tag" +sort_by = "Name" # default for `fn.sort_by` and `const.sort_by` +usize_is_size_t = true + +[defines] +# "target_os = freebsd" = "DEFINE_FREEBSD" +# "feature = serde" = "DEFINE_SERDE" + +[export] +include = [] +exclude = [] +# prefix = "CAPI_" +item_types = [] +renaming_overrides_prefixing = false + +[export.rename] + +[export.body] + +[export.mangle] + +[fn] +# rename_args = "PascalCase" +# must_use = "MUST_USE_FUNC" +# no_return = "NO_RETURN" +# prefix = "START_FUNC" +# postfix = "END_FUNC" +args = "auto" +sort_by = "Name" + +[struct] +# rename_fields = "PascalCase" +# must_use = "MUST_USE_STRUCT" +derive_constructor = false +derive_eq = false +derive_neq = false +derive_lt = false +derive_lte = false +derive_gt = false +derive_gte = false + +[enum] +# rename_variants = "PascalCase" +# must_use = "MUST_USE_ENUM" +add_sentinel = false +prefix_with_name = false +derive_helper_methods = false +derive_const_casts = false +derive_mut_casts = false +# cast_assert_name = "ASSERT" +derive_tagged_enum_destructor = false +derive_tagged_enum_copy_constructor = false +enum_class = true +private_default_tagged_enum_constructor = false + +[const] +allow_static_const = true +allow_constexpr = false +sort_by = "Name" + +[macro_expansion] +bitflags = false + +############## Options for How Your Rust library Should Be Parsed ############## + +[parse] +parse_deps = false +# include = [] +exclude = [] +clean = false +extra_bindings = [] + +[parse.expand] +crates = [] +all_features = false +default_features = true +features = [] diff --git a/GenerateBindings.bat b/GenerateBindings.bat new file mode 100644 index 0000000..f2257da --- /dev/null +++ b/GenerateBindings.bat @@ -0,0 +1 @@ +cbindgen --config .\Config\Bindings.toml --crate Library --output Source\Library.h diff --git a/GenerateBindings.command b/GenerateBindings.command new file mode 100644 index 0000000..bb11f94 --- /dev/null +++ b/GenerateBindings.command @@ -0,0 +1,3 @@ +#!/bin/zsh + +cbindgen --config ./Config/Bindings.toml --crate Library --output Source/Library.h diff --git a/GenerateBindings.sh b/GenerateBindings.sh new file mode 100644 index 0000000..32583ce --- /dev/null +++ b/GenerateBindings.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cbindgen --config ./Config/Bindings.toml --crate Library --output Source/Library.h