Skip to content

Commit

Permalink
Merge pull request #510 from evo-lua/reorganize-ffi-bindings
Browse files Browse the repository at this point in the history
Reorganize the directory structure for the FFI bindings
  • Loading branch information
rdw-software authored Feb 19, 2024
2 parents 3661c7d + 19583f7 commit 60d7032
Show file tree
Hide file tree
Showing 70 changed files with 59 additions and 46 deletions.
28 changes: 14 additions & 14 deletions .cppcheck
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ unknownMacro:Runtime/luajit_repl.c
// Debug functions left in on purpose
unusedFunction:Runtime/LuaVirtualMachine.cpp
// Callback-based interface (hooks that will be called by RML)
unusedFunction:Runtime/Bindings/RmlUi_Renderer_WebGPU.cpp
unusedFunction:Runtime/Bindings/FFI/RmlUi_Renderer_WebGPU.cpp

// FFI exports used from Lua, which cppcheck can't see
unusedStructMember:Runtime/Bindings/crypto_exports.hpp
unusedStructMember:Runtime/Bindings/glfw_exports.hpp
unusedStructMember:Runtime/Bindings/iconv_exports.hpp
unusedStructMember:Runtime/Bindings/interop_exports.hpp
unusedStructMember:Runtime/Bindings/labsound_exports.hpp
unusedStructMember:Runtime/Bindings/rml_exports.hpp
unusedStructMember:Runtime/Bindings/runtime_exports.hpp
unusedStructMember:Runtime/Bindings/stbi_exports.hpp
unusedStructMember:Runtime/Bindings/stduuid_exports.hpp
unusedStructMember:Runtime/Bindings/uws_exports.hpp
unusedStructMember:Runtime/Bindings/webgpu_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/crypto/crypto_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/glfw/glfw_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/iconv/iconv_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/interop/interop_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/labsound/labsound_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/rml/rml_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/runtime/runtime_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/stbi/stbi_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/stduuid/stduuid_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/uws/uws_exports.hpp
unusedStructMember:Runtime/Bindings/FFI/webgpu/webgpu_exports.hpp

// PerSocketData is actually used, but cppcheck can't see it
unusedStructMember:Runtime/Bindings/WebServer.hpp
unusedStructMember:Runtime/Bindings/FFI/WebServer.hpp
// The internal types are used by miniz, of course...
unusedStructMember:Runtime/Bindings/lminiz.hpp

// Let's just hope we don't have to descent into the depths of Objective C hell ever again
cstyleCast:Runtime/Bindings/webview_mac.hpp
cstyleCast:Runtime/Bindings/FFI/webview/webview_mac.hpp
69 changes: 41 additions & 28 deletions BuildTools/Targets/EvoBuildTarget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ local EvoBuildTarget = {
"Runtime/API/Networking/HttpServer.lua",
"Runtime/API/Networking/WebSocketTestClient.lua",
"Runtime/API/Networking/WebSocketServer.lua",
"Runtime/Bindings/crypto.lua",
"Runtime/Bindings/glfw.lua",
"Runtime/Bindings/iconv.lua",
"Runtime/Bindings/interop.lua",
"Runtime/Bindings/labsound.lua",
"Runtime/Bindings/runtime.lua",
"Runtime/Bindings/rml.lua",
"Runtime/Bindings/stbi.lua",
"Runtime/Bindings/stduuid.lua",
"Runtime/Bindings/uws.lua",
"Runtime/Bindings/webgpu.lua",
"Runtime/Bindings/webview.lua",
"Runtime/Bindings/FFI/crypto/crypto.lua",
"Runtime/Bindings/FFI/glfw/glfw.lua",
"Runtime/Bindings/FFI/iconv/iconv.lua",
"Runtime/Bindings/FFI/interop/interop.lua",
"Runtime/Bindings/FFI/labsound/labsound.lua",
"Runtime/Bindings/FFI/runtime/runtime.lua",
"Runtime/Bindings/FFI/rml/rml.lua",
"Runtime/Bindings/FFI/stbi/stbi.lua",
"Runtime/Bindings/FFI/stduuid/stduuid.lua",
"Runtime/Bindings/FFI/uws/uws.lua",
"Runtime/Bindings/FFI/webgpu/webgpu.lua",
"Runtime/Bindings/FFI/webview/webview.lua",
"Runtime/Extensions/debugx.lua",
"Runtime/Extensions/jsonx.lua",
"Runtime/Extensions/stringx.lua",
Expand All @@ -62,36 +62,49 @@ local EvoBuildTarget = {
},
cSources = {
"Runtime/luajit_repl.c",
"Runtime/Bindings/glfw_webgpu.c",
"Runtime/Bindings/FFI/glfw_webgpu.c",
"Runtime/Bindings/lutf8.c",
},
cppSources = {
"Runtime/main.cpp",
"Runtime/Bindings/crypto_argon2.cpp",
"Runtime/Bindings/crypto_ffi.cpp",
"Runtime/Bindings/glfw_ffi.cpp",
"Runtime/Bindings/iconv_ffi.cpp",
"Runtime/Bindings/interop_ffi.cpp",
"Runtime/Bindings/labsound_ffi.cpp",
"Runtime/Bindings/FFI/crypto/crypto_argon2.cpp",
"Runtime/Bindings/FFI/crypto/crypto_ffi.cpp",
"Runtime/Bindings/FFI/glfw/glfw_ffi.cpp",
"Runtime/Bindings/FFI/iconv/iconv_ffi.cpp",
"Runtime/Bindings/FFI/interop/interop_ffi.cpp",
"Runtime/Bindings/FFI/labsound/labsound_ffi.cpp",
"Runtime/Bindings/lpeg.cpp",
"Runtime/Bindings/lminiz.cpp",
"Runtime/Bindings/RmlUi_Renderer_WebGPU.cpp",
"Runtime/Bindings/rml_ffi.cpp",
"Runtime/Bindings/runtime_ffi.cpp",
"Runtime/Bindings/stbi_ffi.cpp",
"Runtime/Bindings/stduuid_ffi.cpp",
"Runtime/Bindings/uws_ffi.cpp",
"Runtime/Bindings/webgpu_ffi.cpp",
"Runtime/Bindings/webview_ffi.cpp",
"Runtime/Bindings/FFI/RmlUi_Renderer_WebGPU.cpp",
"Runtime/Bindings/FFI/rml/rml_ffi.cpp",
"Runtime/Bindings/FFI/runtime/runtime_ffi.cpp",
"Runtime/Bindings/FFI/stbi/stbi_ffi.cpp",
"Runtime/Bindings/FFI/stduuid/stduuid_ffi.cpp",
"Runtime/Bindings/FFI/uws/uws_ffi.cpp",
"Runtime/Bindings/FFI/webgpu/webgpu_ffi.cpp",
"Runtime/Bindings/FFI/webview/webview_ffi.cpp",
"Runtime/Bindings/lrexlib.cpp",
"Runtime/Bindings/lzlib.cpp",
"Runtime/Bindings/WebServer.cpp",
"Runtime/Bindings/FFI/WebServer.cpp",
"Runtime/LuaVirtualMachine.cpp",
},
includeDirectories = {
NinjaBuildTools.DEFAULT_BUILD_DIRECTORY_NAME, -- For auto-generated headers (e.g., PCRE2)
"Runtime",
"Runtime/Bindings",
"Runtime/Bindings/FFI",
"Runtime/Bindings/FFI/crypto",
"Runtime/Bindings/FFI/glfw",
"Runtime/Bindings/FFI/iconv",
"Runtime/Bindings/FFI/interop",
"Runtime/Bindings/FFI/labsound",
"Runtime/Bindings/FFI/rml",
"Runtime/Bindings/FFI/runtime",
"Runtime/Bindings/FFI/stbi",
"Runtime/Bindings/FFI/stduuid",
"Runtime/Bindings/FFI/uws",
"Runtime/Bindings/FFI/webgpu",
"Runtime/Bindings/FFI/webview",
"deps",
"deps/eliemichel/glfw3webgpu",
"deps/gfx-rs/wgpu-native/ffi",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions synchronize-cdefs.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local transform = require("transform")

local bindingsDirectory = path.join("Runtime", "Bindings")
local bindingsDirectory = path.join("Runtime", "Bindings", "FFI")

local function discoverBindings(dir)
local files = C_FileSystem.ReadDirectoryTree(dir)
Expand All @@ -26,7 +26,7 @@ local function string_explode_with_newlines(fileContents)
end

local function updateTypeDefinitions(binding)
local fileSystemPath = path.join(bindingsDirectory, binding .. ".lua")
local fileSystemPath = path.join(bindingsDirectory, binding, binding .. ".lua")
printf("Updating cdefs for %s (package name: %s)", transform.green(fileSystemPath), transform.blue(binding))
local moduleFileContents = C_FileSystem.ReadFile(fileSystemPath)

Expand All @@ -52,9 +52,9 @@ local function updateTypeDefinitions(binding)
cdefsEnd - cdefsStart - 2
)

local aliasedDefinitionsPath = path.join(bindingsDirectory, binding .. "_aliases.h")
local aliasedDefinitionsPath = path.join(bindingsDirectory, binding, binding .. "_aliases.h")
local hasAliases = C_FileSystem.Exists(aliasedDefinitionsPath)
local exportDefinitionsPath = path.join(bindingsDirectory, binding .. "_exports.h")
local exportDefinitionsPath = path.join(bindingsDirectory, binding, binding .. "_exports.h")

local updatedAliases = hasAliases and C_FileSystem.ReadFile(aliasedDefinitionsPath) or ""
local updatedDefinitions = C_FileSystem.ReadFile(exportDefinitionsPath)
Expand Down

0 comments on commit 60d7032

Please sign in to comment.