Make GCC include dir flags project relative

This commit is contained in:
Jason Perkins 2012-06-28 14:17:19 -04:00
parent b1a2f8918d
commit 1119afdc08
4 changed files with 20 additions and 6 deletions

View File

@ -206,13 +206,13 @@
function cpp.flags(cfg, toolset)
_p(' DEFINES += %s', table.concat(toolset.getdefines(cfg.defines), " "))
_p(' INCLUDES += %s', table.concat(make.esc(toolset.getincludedirs(cfg.includedirs), " ")))
_p(' INCLUDES += %s', table.concat(make.esc(toolset.getincludedirs(cfg, cfg.includedirs), " ")))
_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(toolset.getcppflags(cfg), " "))
_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(toolset.getcflags(cfg), cfg.buildoptions), " "))
_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(toolset.getcxxflags(cfg), " "))
_p(' LDFLAGS += %s', table.concat(table.join(toolset.getldflags(cfg), cfg.linkoptions), " "))
local resflags = table.join(toolset.getdefines(cfg.resdefines), toolset.getincludedirs(cfg.resincludedirs), cfg.resoptions)
local resflags = table.join(toolset.getdefines(cfg.resdefines), toolset.getincludedirs(cfg, cfg.resincludedirs), cfg.resoptions)
_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s', table.concat(resflags, " "))
end

View File

@ -149,10 +149,10 @@
-- Decorate include file search paths for the GCC command line.
--
function gcc.getincludedirs(dirs)
function gcc.getincludedirs(cfg, dirs)
local result = {}
for _, dir in ipairs(dirs) do
table.insert(result, "-I" .. dir)
table.insert(result, "-I" .. project.getrelative(cfg.project, dir))
end
return result
end

View File

@ -6,6 +6,7 @@
premake.tools.snc = {}
local snc = premake.tools.snc
local gcc = premake.tools.gcc
local config = premake5.config
@ -81,10 +82,12 @@
--
-- The linking behavior is the same as GCC.
-- These are the same as GCC
--
snc.getlinks = premake.tools.gcc.getlinks
snc.getdefines = gcc.getdefines
snc.getincludedirs = gcc.getincludedirs
snc.getlinks = gcc.getlinks

View File

@ -233,3 +233,14 @@
test.isequal({ "generated.o" }, gcc.getlinks(cfg))
end
--
-- Include directories should be made project relative.
--
function suite.includeDirsAreRelative()
includedirs { "../include", "src/include" }
prepare()
test.isequal({ "-I../include", "-Isrc/include" }, gcc.getincludedirs(cfg, cfg.includedirs))
end