Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -315,7 +315,7 @@ else -- Support GLOOX_CONFIG for overriding the default (pkg-config --cflags gloox) -- i.e. on OSX where it gets set in update-workspaces.sh - pkgconfig.add_includes("gloox", os.getenv("GLOOX_CONFIG")) + pkgconfig.find_system("gloox", os.getenv("GLOOX_CONFIG")).add_includes() end end, link_settings = function() @@ -326,7 +326,7 @@ no_delayload = 1, }) else - pkgconfig.add_links("gloox", os.getenv("GLOOX_CONFIG")) + pkgconfig.find_system("gloox", os.getenv("GLOOX_CONFIG")).add_links() if os.istarget("macosx") then -- Manually add gnutls dependencies, those are not present in gloox's pkg-config @@ -383,7 +383,7 @@ else -- Support ICU_CONFIG for overriding the default (pkg-config --cflags icu-i18n) -- i.e. on OSX where it gets set in update-workspaces.sh - pkgconfig.add_includes("icu-i18n", os.getenv("ICU_CONFIG"), "--cppflags") + pkgconfig.find_system("icu-i18n", os.getenv("ICU_CONFIG")).add_includes("--cppflags") end end, link_settings = function() @@ -395,7 +395,7 @@ no_delayload = 1, }) else - pkgconfig.add_links("icu-i18n", os.getenv("ICU_CONFIG"), "--ldflags-searchpath --ldflags-libsonly --ldflags-system") + pkgconfig.find_system("icu-i18n", os.getenv("ICU_CONFIG")).add_links("--ldflags-searchpath --ldflags-libsonly --ldflags-system") end end, }, @@ -462,7 +462,7 @@ else -- Support XML2_CONFIG for overriding the default (pkg-config --cflags libxml-2.0) -- i.e. on OSX where it gets set in update-workspaces.sh - pkgconfig.add_includes("libxml-2.0", os.getenv("XML2_CONFIG")) + pkgconfig.find_system("libxml-2.0", os.getenv("XML2_CONFIG")).add_includes() end if os.istarget("macosx") then -- libxml2 needs _REENTRANT or __MT__ for thread support; @@ -479,7 +479,7 @@ links { "libxml2" } filter { } else - pkgconfig.add_links("libxml-2.0", os.getenv("XML2_CONFIG")) + pkgconfig.find_system("libxml-2.0", os.getenv("XML2_CONFIG")).add_links() end end, }, @@ -570,14 +570,14 @@ elseif not _OPTIONS["android"] then -- Support SDL2_CONFIG for overriding the default (pkg-config sdl2) -- i.e. on OSX where it gets set in update-workspaces.sh - pkgconfig.add_includes("sdl2", os.getenv("SDL2_CONFIG")) + pkgconfig.find_system("sdl2", os.getenv("SDL2_CONFIG")).add_includes() end end, link_settings = function() if os.istarget("windows") then add_default_lib_paths("sdl2") elseif not _OPTIONS["android"] then - pkgconfig.add_links("sdl2", os.getenv("SDL2_CONFIG")) + pkgconfig.find_system("sdl2", os.getenv("SDL2_CONFIG")).add_links() end end, }, @@ -585,7 +585,16 @@ compile_settings = function() if _OPTIONS["with-system-mozjs"] then if not _OPTIONS["android"] then - pkgconfig.add_includes("mozjs-78") + -- Many linux distros package icu headers in with spidermonkey headers, but + -- do not provide compatible icu library files to go along with them. + -- + -- Attempting to use the spidermonkey-icu headers with a distro's + -- standard-icu lib files causes linking errors. + -- + -- Therefore, we set the spidermonkey includes directory to be searched + -- *after* the standard system includes so gcc/clang finds and includes + -- compatible icu headers. + pkgconfig.find_system("mozjs-78").add_includes_after_system() end else if os.istarget("windows") then @@ -607,7 +616,7 @@ if _OPTIONS["android"] then links { "mozjs-78" } else - pkgconfig.add_links("mozjs-78") + pkgconfig.find_system("mozjs-78").add_links() end else filter { "Debug", "action:vs*" } @@ -674,7 +683,7 @@ -- wxwidgets does not come with a definition file for pkg-config, -- so we have to use wxwidgets' own config tool wx_config_path = os.getenv("WX_CONFIG") or "wx-config" - pkgconfig.add_includes(nil, wx_config_path, "--unicode=yes --cxxflags") + pkgconfig.find_system(nil, wx_config_path).add_includes("--unicode=yes --cxxflags") end end, link_settings = function() @@ -682,19 +691,19 @@ libdirs { libraries_dir.."wxwidgets/lib/vc_lib" } else wx_config_path = os.getenv("WX_CONFIG") or "wx-config" - pkgconfig.add_links(nil, wx_config_path, "--unicode=yes --libs std,gl") + pkgconfig.find_system(nil, wx_config_path).add_links("--unicode=yes --libs std,gl") end end, }, x11 = { compile_settings = function() if not os.istarget("windows") and not os.istarget("macosx") then - pkgconfig.add_includes("x11") + pkgconfig.find_system("x11").add_includes() end end, link_settings = function() if not os.istarget("windows") and not os.istarget("macosx") then - pkgconfig.add_links("x11") + pkgconfig.find_system("x11").add_links() end end, }, Index: build/premake/pkgconfig/pkgconfig.lua =================================================================== --- build/premake/pkgconfig/pkgconfig.lua +++ build/premake/pkgconfig/pkgconfig.lua @@ -1,11 +1,11 @@ local m = {} -m._VERSION = "1.1.0-dev" +m._VERSION = "1.2.1-dev" local function os_capture(cmd) return io.popen(cmd, 'r'):read('*a'):gsub("\n", " ") end -function m.add_includes(lib, alternative_cmd, alternative_flags) +local function find_includes(lib, alternative_cmd, alternative_flags) local result if not alternative_cmd then result = os_capture("pkg-config --cflags "..lib) @@ -17,9 +17,10 @@ end end - -- Small trick: delete the space after -include so that we can detect - -- which files have to be force-included without difficulty. + -- Small trick: delete the space after -include and -isystem so that + -- we can detect which files have to be included without difficulty. result = result:gsub("%-include +(%g+)", "-include%1") + result = result:gsub("%-isystem +(%g+)", "-isystem%1") local dirs = {} local files = {} @@ -27,6 +28,8 @@ for w in string.gmatch(result, "[^' ']+") do if string.sub(w,1,2) == "-I" then table.insert(dirs, string.sub(w,3)) + elseif string.sub(w,1,8) == "-isystem" then + table.insert(dirs, string.sub(w,9)) elseif string.sub(w,1,8) == "-include" then table.insert(files, string.sub(w,9)) else @@ -34,12 +37,10 @@ end end - sysincludedirs(dirs) - forceincludes(files) - buildoptions(options) + return dirs, files, options end -function m.add_links(lib, alternative_cmd, alternative_flags) +local function find_links(lib, alternative_cmd, alternative_flags) local result if not alternative_cmd then result = os_capture("pkg-config --libs "..lib) @@ -69,9 +70,35 @@ end end - links(libs) - libdirs(dirs) - linkoptions(options) + return libs, dirs, options +end + +function m.find_system(lib, alternative_cmd) + + local meths = {} + + function meths.add_includes(alternative_flags) + local dirs, files, options = find_includes(lib, alternative_cmd, alternative_flags) + sysincludedirs(dirs) + forceincludes(files) + buildoptions(options) + end + + function meths.add_includes_after_system(alternative_flags) + local dirs, files, options = find_includes(lib, alternative_cmd, alternative_flags) + aftersysincludedirs(dirs) + forceincludes(files) + buildoptions(options) + end + + function meths.add_links(alternative_flags) + local libs, dirs, options = find_links(lib, alternative_cmd, alternative_flags) + links(libs) + libdirs(dirs) + linkoptions(options) + end + + return meths end return m Index: build/premake/premake5/modules/gmake/gmake_cpp.lua =================================================================== --- build/premake/premake5/modules/gmake/gmake_cpp.lua +++ build/premake/premake5/modules/gmake/gmake_cpp.lua @@ -521,7 +521,7 @@ function make.includes(cfg, toolset) - local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) + local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.aftersysincludedirs) _p(' INCLUDES +=%s', make.list(includes)) end Index: build/premake/premake5/modules/gmake2/gmake2_cpp.lua =================================================================== --- build/premake/premake5/modules/gmake2/gmake2_cpp.lua +++ build/premake/premake5/modules/gmake2/gmake2_cpp.lua @@ -436,7 +436,7 @@ function cpp.includes(cfg, toolset) - local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) + local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.aftersysincludedirs) p.outln('INCLUDES +=' .. gmake2.list(includes)) end Index: build/premake/premake5/src/_premake_init.lua =================================================================== --- build/premake/premake5/src/_premake_init.lua +++ build/premake/premake5/src/_premake_init.lua @@ -18,6 +18,13 @@ -- ----------------------------------------------------------------------------- + api.register { + name = "aftersysincludedirs", + scope = "config", + kind = "list:directory", + tokens = true, + } + api.register { name = "architecture", scope = "config", Index: build/premake/premake5/src/tools/clang.lua =================================================================== --- build/premake/premake5/src/tools/clang.lua +++ build/premake/premake5/src/tools/clang.lua @@ -168,10 +168,10 @@ -- An array of symbols with the appropriate flag decorations. -- - function clang.getincludedirs(cfg, dirs, sysdirs) + function clang.getincludedirs(cfg, dirs, sysdirs, aftersysdirs) -- Just pass through to GCC for now - local flags = gcc.getincludedirs(cfg, dirs, sysdirs) + local flags = gcc.getincludedirs(cfg, dirs, sysdirs, aftersysdirs) return flags end Index: build/premake/premake5/src/tools/gcc.lua =================================================================== --- build/premake/premake5/src/tools/gcc.lua +++ build/premake/premake5/src/tools/gcc.lua @@ -239,7 +239,7 @@ -- Decorate include file search paths for the GCC command line. -- - function gcc.getincludedirs(cfg, dirs, sysdirs) + function gcc.getincludedirs(cfg, dirs, sysdirs, aftersysdirs) local result = {} for _, dir in ipairs(dirs) do dir = project.getrelative(cfg.project, dir) @@ -249,6 +249,10 @@ dir = project.getrelative(cfg.project, dir) table.insert(result, '-isystem ' .. p.quoted(dir)) end + for _, dir in ipairs(aftersysdirs or {}) do + dir = project.getrelative(cfg.project, dir) + table.insert(result, '-idirafter ' .. p.quoted(dir)) + end return result end Index: build/premake/premake5/src/tools/msc.lua =================================================================== --- build/premake/premake5/src/tools/msc.lua +++ build/premake/premake5/src/tools/msc.lua @@ -217,13 +217,17 @@ -- Decorate include file search paths for the MSVC command line. -- - function msc.getincludedirs(cfg, dirs, sysdirs) + function msc.getincludedirs(cfg, dirs, sysdirs, aftersysdirs) local result = {} dirs = table.join(dirs, sysdirs) for _, dir in ipairs(dirs) do dir = project.getrelative(cfg.project, dir) table.insert(result, '-I' .. p.quoted(dir)) end + for _, dir in ipairs(aftersysdirs) do + dir = project.getrelative(cfg.project, dir) + table.insert(result, '/INCLUDE:"' .. dir .. '"') + end return result end Index: build/premake/premake5/tests/tools/test_gcc.lua =================================================================== --- build/premake/premake5/tests/tools/test_gcc.lua +++ build/premake/premake5/tests/tools/test_gcc.lua @@ -619,6 +619,17 @@ end +-- +-- Check handling of search paths that come after the standard system search paths +-- + + function suite.includeDirs_onAfterSysIncludeDirs() + aftersysincludedirs { "/usr/local/include" } + prepare() + test.contains("-idirafter /usr/local/include", gcc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.aftersysincludedirs)) + end + + -- -- Check handling of link time optimization flag. -- Index: source/scriptinterface/ScriptTypes.h =================================================================== --- source/scriptinterface/ScriptTypes.h +++ source/scriptinterface/ScriptTypes.h @@ -82,7 +82,7 @@ #endif #if MOZJS_MINOR_VERSION != 6 -#error Your compiler is trying to use an untested minor version of the \ +#warning Your compiler is trying to use an untested minor version of the \ SpiderMonkey library. If you are a package maintainer, please make sure \ to check very carefully that this version does not change the behaviour \ of the code executed by SpiderMonkey. Different parts of the game (e.g. \