From 79166dfe17a2493b0b772b37c86fb33581dd861a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Mon, 18 May 2020 12:04:31 +0800 Subject: [PATCH] Allow passing config macros from env (#2147) --- scripts/bgfx.lua | 4 +--- scripts/genie.lua | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index 1667f4840..b19f40c77 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -79,9 +79,7 @@ function bgfxProjectBase(_kind, _defines) path.join(BIMG_DIR, "include"), } - defines { - _defines, - } + defines (_defines) links { "bx", diff --git a/scripts/genie.lua b/scripts/genie.lua index 14446c1fc..cabb088f9 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -498,7 +498,22 @@ end dofile "bgfx.lua" group "libs" -bgfxProject("", "StaticLib", {}) + +local function userdefines() + local defines = {} + local BGFX_CONFIG = os.getenv("BGFX_CONFIG") + if BGFX_CONFIG then + for def in BGFX_CONFIG:gmatch "[^%s:]+" do + table.insert(defines, "BGFX_CONFIG_" .. def) + end + end + + return defines +end + +BGFX_CONFIG = userdefines() + +bgfxProject("", "StaticLib", BGFX_CONFIG) dofile(path.join(BX_DIR, "scripts/bx.lua")) dofile(path.join(BIMG_DIR, "scripts/bimg.lua")) @@ -575,7 +590,7 @@ end if _OPTIONS["with-shared-lib"] then group "libs" - bgfxProject("-shared-lib", "SharedLib", {}) + bgfxProject("-shared-lib", "SharedLib", BGFX_CONFIG) end if _OPTIONS["with-tools"] then