mirror of
https://github.com/cimgui/cimgui.git
synced 2025-10-09 03:11:40 +01:00
Merge pull request #165 from frink/flags
Adding CFLAGS to generator.lua
This commit is contained in:
@@ -31,6 +31,7 @@ Notes:
|
|||||||
|
|
||||||
# using generator
|
# using generator
|
||||||
|
|
||||||
|
```
|
||||||
* this is only needed (before compilation) if you want an imgui version different from the one provided, otherwise generation is already done.
|
* this is only needed (before compilation) if you want an imgui version different from the one provided, otherwise generation is already done.
|
||||||
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
||||||
* you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
|
* you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
|
||||||
@@ -40,6 +41,7 @@ Notes:
|
|||||||
* edit config_generator.lua for adding includes needed by your chosen backends (vulkan needs that).
|
* edit config_generator.lua for adding includes needed by your chosen backends (vulkan needs that).
|
||||||
* Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
|
* Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
|
||||||
* as a result some files are generated: `cimgui.cpp`, `cimgui.h` and `cimgui_impl.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the backends info.
|
* as a result some files are generated: `cimgui.cpp`, `cimgui.h` and `cimgui_impl.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the backends info.
|
||||||
|
* You can pass compiler flags to generator.sh or generator.bat at the end of the call to further specify the compiler behavior. (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||||
|
|
||||||
# generate binding
|
# generate binding
|
||||||
* C interface is exposed by cimgui.h when you define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
* C interface is exposed by cimgui.h when you define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
|
@@ -17,7 +17,7 @@ set PATH=%PATH%;C:\anima;C:\mingws\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\min
|
|||||||
:: arg[1] compiler name gcc, clang or cl
|
:: arg[1] compiler name gcc, clang or cl
|
||||||
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
||||||
:: examples: "" "internal" "internal freetype"
|
:: examples: "" "internal" "internal freetype"
|
||||||
:: arg[3..n] name of implementations to generate
|
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||||
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
||||||
|
|
||||||
::leave console open
|
::leave console open
|
||||||
|
@@ -8,12 +8,28 @@ local script_args = {...}
|
|||||||
local COMPILER = script_args[1]
|
local COMPILER = script_args[1]
|
||||||
local INTERNAL_GENERATION = script_args[2]:match("internal") and true or false
|
local INTERNAL_GENERATION = script_args[2]:match("internal") and true or false
|
||||||
local FREETYPE_GENERATION = script_args[2]:match("freetype") and true or false
|
local FREETYPE_GENERATION = script_args[2]:match("freetype") and true or false
|
||||||
|
local CFLAGS = ""
|
||||||
local CPRE,CTEST
|
local CPRE,CTEST
|
||||||
|
--get implementations
|
||||||
|
local implementations = {}
|
||||||
|
for i=3,#script_args do
|
||||||
|
if script_args[i]:match(COMPILER == cl and "^/" or "^%-") then
|
||||||
|
local key, value = script_args[i]:match("^(.+)=(.+)$")
|
||||||
|
if key and value then
|
||||||
|
CFLAGS = CFLAGS .. " " .. key .. "=\"" .. value:gsub("\"", "\\\"") .. "\"";
|
||||||
|
else
|
||||||
|
CFLAGS = CFLAGS .. " " .. script_args[i]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(implementations,script_args[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if COMPILER == "gcc" or COMPILER == "clang" then
|
if COMPILER == "gcc" or COMPILER == "clang" then
|
||||||
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]]
|
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||||
CTEST = COMPILER.." --version"
|
CTEST = COMPILER.." --version"
|
||||||
elseif COMPILER == "cl" then
|
elseif COMPILER == "cl" then
|
||||||
CPRE = COMPILER..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_API="" /DIMGUI_IMPL_API="" ]]
|
CPRE = COMPILER..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_API="" /DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||||
CTEST = COMPILER
|
CTEST = COMPILER
|
||||||
else
|
else
|
||||||
print("Working without compiler ")
|
print("Working without compiler ")
|
||||||
@@ -42,10 +58,6 @@ assert(HAVE_COMPILER,"gcc, clang or cl needed to run script")
|
|||||||
print("HAVE_COMPILER",HAVE_COMPILER)
|
print("HAVE_COMPILER",HAVE_COMPILER)
|
||||||
print("INTERNAL_GENERATION",INTERNAL_GENERATION)
|
print("INTERNAL_GENERATION",INTERNAL_GENERATION)
|
||||||
print("FREETYPE_GENERATION",FREETYPE_GENERATION)
|
print("FREETYPE_GENERATION",FREETYPE_GENERATION)
|
||||||
--get implementations
|
|
||||||
local implementations = {}
|
|
||||||
for i=3,#script_args do table.insert(implementations,script_args[i]) end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
--this table has the functions to be skipped in generation
|
--this table has the functions to be skipped in generation
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
@@ -124,7 +136,8 @@ local func_implementation = cpp2ffi.func_implementation
|
|||||||
-------------------functions for getting and setting defines
|
-------------------functions for getting and setting defines
|
||||||
local function get_defines(t)
|
local function get_defines(t)
|
||||||
if COMPILER == "cl" then print"can't get defines with cl compiler"; return {} end
|
if COMPILER == "cl" then print"can't get defines with cl compiler"; return {} end
|
||||||
local pipe,err = io.popen(COMPILER..[[ -E -dM -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
print(COMPILER..[[ -E -dM -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]] .. CFLAGS)
|
||||||
|
local pipe,err = io.popen(COMPILER..[[ -E -dM -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]] .. CFLAGS,"r")
|
||||||
local defines = {}
|
local defines = {}
|
||||||
while true do
|
while true do
|
||||||
local line = pipe:read"*l"
|
local line = pipe:read"*l"
|
||||||
@@ -336,7 +349,6 @@ print("IMGUI_VERSION",imgui_version)
|
|||||||
--get some defines----------------------------
|
--get some defines----------------------------
|
||||||
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
||||||
|
|
||||||
|
|
||||||
--funtion for parsing imgui headers
|
--funtion for parsing imgui headers
|
||||||
local function parseImGuiHeader(header,names)
|
local function parseImGuiHeader(header,names)
|
||||||
--prepare parser
|
--prepare parser
|
||||||
|
@@ -15,5 +15,5 @@
|
|||||||
# arg[1] compiler name gcc, clang, or cl
|
# arg[1] compiler name gcc, clang, or cl
|
||||||
# arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
# arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
||||||
# examples: "" "internal" "internal freetype"
|
# examples: "" "internal" "internal freetype"
|
||||||
# arg[3..n] name of implementations to generate
|
# arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||||
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
||||||
|
Reference in New Issue
Block a user