Commits

Jason Perkins  committed b5a39cd

Make GCC include dir flags project relative

  • Participants
  • Parent commits e08600c

Comments (0)

Files changed (4)

File src/actions/make/make_cpp.lua

 
 	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
 

File src/tools/gcc.lua

 -- 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

File src/tools/snc.lua

 
 	premake.tools.snc = {}
 	local snc = premake.tools.snc
+	local gcc = premake.tools.gcc
 	local config = premake5.config
 	
 
 
 
 --
--- 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
 
 
 

File tests/tools/test_gcc.lua

 		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
+