From 1119afdc087053fd48eb052b1660b59f70e07680 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 28 Jun 2012 14:17:19 -0400 Subject: [PATCH] Make GCC include dir flags project relative --- src/actions/make/make_cpp.lua | 4 ++-- src/tools/gcc.lua | 4 ++-- src/tools/snc.lua | 7 +++++-- tests/tools/test_gcc.lua | 11 +++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index fdb12965..4a8d756f 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -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 diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 90cc57c0..85a272ac 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -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 diff --git a/src/tools/snc.lua b/src/tools/snc.lua index 17ec2a5b..539839a1 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -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 diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 860d5ede..a3f6c8bb 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -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 +