Merge pull request #76 from starkos/vstudio-system-includes
Add system include and library search paths
This commit is contained in:
commit
d16b2f952f
@ -828,6 +828,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api.register {
|
||||||
|
name = "sysincludedirs",
|
||||||
|
scope = "config",
|
||||||
|
kind = "list:directory",
|
||||||
|
tokens = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
api.register {
|
||||||
|
name = "syslibdirs",
|
||||||
|
scope = "config",
|
||||||
|
kind = "list:directory",
|
||||||
|
tokens = true,
|
||||||
|
}
|
||||||
|
|
||||||
api.register {
|
api.register {
|
||||||
name = "system",
|
name = "system",
|
||||||
scope = "config",
|
scope = "config",
|
||||||
|
@ -394,7 +394,7 @@
|
|||||||
|
|
||||||
|
|
||||||
function make.includes(cfg, toolset)
|
function make.includes(cfg, toolset)
|
||||||
local includes = premake.esc(toolset.getincludedirs(cfg, cfg.includedirs))
|
local includes = premake.esc(toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
||||||
_p(' INCLUDES +=%s', make.list(includes))
|
_p(' INCLUDES +=%s', make.list(includes))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -194,6 +194,8 @@
|
|||||||
m.intDir,
|
m.intDir,
|
||||||
m.targetName,
|
m.targetName,
|
||||||
m.targetExt,
|
m.targetExt,
|
||||||
|
m.includePath,
|
||||||
|
m.libraryPath,
|
||||||
m.imageXexOutput,
|
m.imageXexOutput,
|
||||||
m.generateManifest,
|
m.generateManifest,
|
||||||
m.extensionsToDeleteOnClean,
|
m.extensionsToDeleteOnClean,
|
||||||
@ -1248,6 +1250,14 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function m.includePath(cfg)
|
||||||
|
local dirs = vstudio.path(cfg, cfg.sysincludedirs)
|
||||||
|
if #dirs > 0 then
|
||||||
|
p.x('<IncludePath>%s;$(IncludePath)</IncludePath>', table.concat(dirs, ";"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function m.intDir(cfg)
|
function m.intDir(cfg)
|
||||||
local objdir = vstudio.path(cfg, cfg.objdir)
|
local objdir = vstudio.path(cfg, cfg.objdir)
|
||||||
_x(2,'<IntDir>%s\\</IntDir>', objdir)
|
_x(2,'<IntDir>%s\\</IntDir>', objdir)
|
||||||
@ -1293,6 +1303,14 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function m.libraryPath(cfg)
|
||||||
|
local dirs = vstudio.path(cfg, cfg.syslibdirs)
|
||||||
|
if #dirs > 0 then
|
||||||
|
p.x('<LibraryPath>%s;$(LibraryPath)</LibraryPath>', table.concat(dirs, ";"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.linkIncremental(cfg)
|
function m.linkIncremental(cfg)
|
||||||
if cfg.kind ~= premake.STATICLIB then
|
if cfg.kind ~= premake.STATICLIB then
|
||||||
|
@ -131,10 +131,10 @@
|
|||||||
-- An array of symbols with the appropriate flag decorations.
|
-- An array of symbols with the appropriate flag decorations.
|
||||||
--
|
--
|
||||||
|
|
||||||
function clang.getincludedirs(cfg, dirs)
|
function clang.getincludedirs(cfg, dirs, sysdirs)
|
||||||
|
|
||||||
-- Just pass through to GCC for now
|
-- Just pass through to GCC for now
|
||||||
local flags = gcc.getincludedirs(cfg, dirs)
|
local flags = gcc.getincludedirs(cfg, dirs, sysdirs)
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
--
|
---
|
||||||
-- gcc.lua
|
-- gcc.lua
|
||||||
-- Provides GCC-specific configuration strings.
|
-- Provides GCC-specific configuration strings.
|
||||||
-- Copyright (c) 2002-2014 Jason Perkins and the Premake project
|
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
|
||||||
--
|
---
|
||||||
|
|
||||||
premake.tools.gcc = {}
|
local p = premake
|
||||||
local gcc = premake.tools.gcc
|
|
||||||
local project = premake.project
|
p.tools.gcc = {}
|
||||||
local config = premake.config
|
local gcc = p.tools.gcc
|
||||||
|
|
||||||
|
local project = p.project
|
||||||
|
local config = p.config
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -165,12 +168,16 @@
|
|||||||
-- Decorate include file search paths for the GCC command line.
|
-- Decorate include file search paths for the GCC command line.
|
||||||
--
|
--
|
||||||
|
|
||||||
function gcc.getincludedirs(cfg, dirs)
|
function gcc.getincludedirs(cfg, dirs, sysdirs)
|
||||||
local result = {}
|
local result = {}
|
||||||
for _, dir in ipairs(dirs) do
|
for _, dir in ipairs(dirs) do
|
||||||
dir = project.getrelative(cfg.project, dir)
|
dir = project.getrelative(cfg.project, dir)
|
||||||
table.insert(result, '-I' .. premake.quoted(dir))
|
table.insert(result, '-I' .. premake.quoted(dir))
|
||||||
end
|
end
|
||||||
|
for _, dir in ipairs(sysdirs or {}) do
|
||||||
|
dir = project.getrelative(cfg.project, dir)
|
||||||
|
table.insert(result, '-isystem ' .. premake.quoted(dir))
|
||||||
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -232,13 +239,14 @@
|
|||||||
local flags = config.mapFlags(cfg, gcc.libraryDirectories)
|
local flags = config.mapFlags(cfg, gcc.libraryDirectories)
|
||||||
|
|
||||||
-- Scan the list of linked libraries. If any are referenced with
|
-- Scan the list of linked libraries. If any are referenced with
|
||||||
-- paths, add those to the list of library search paths
|
-- paths, add those to the list of library search paths. The call
|
||||||
|
-- config.getlinks() all includes cfg.libdirs.
|
||||||
for _, dir in ipairs(config.getlinks(cfg, "system", "directory")) do
|
for _, dir in ipairs(config.getlinks(cfg, "system", "directory")) do
|
||||||
table.insert(flags, '-L' .. premake.quoted(dir))
|
table.insert(flags, '-L' .. premake.quoted(dir))
|
||||||
end
|
end
|
||||||
|
|
||||||
if cfg.flags.RelativeLinks then
|
if cfg.flags.RelativeLinks then
|
||||||
for _, dir in ipairs(premake.config.getlinks(cfg, "siblings", "directory")) do
|
for _, dir in ipairs(config.getlinks(cfg, "siblings", "directory")) do
|
||||||
local libFlag = "-L" .. premake.project.getrelative(cfg.project, dir)
|
local libFlag = "-L" .. premake.project.getrelative(cfg.project, dir)
|
||||||
if not table.contains(flags, libFlag) then
|
if not table.contains(flags, libFlag) then
|
||||||
table.insert(flags, libFlag)
|
table.insert(flags, libFlag)
|
||||||
@ -246,6 +254,10 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _, dir in ipairs(cfg.syslibdirs) do
|
||||||
|
table.insert(flags, '-L' .. premake.quoted(dir))
|
||||||
|
end
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -260,7 +272,7 @@
|
|||||||
|
|
||||||
if not systemonly then
|
if not systemonly then
|
||||||
if cfg.flags.RelativeLinks then
|
if cfg.flags.RelativeLinks then
|
||||||
local libFiles = premake.config.getlinks(cfg, "siblings", "basename")
|
local libFiles = config.getlinks(cfg, "siblings", "basename")
|
||||||
for _, link in ipairs(libFiles) do
|
for _, link in ipairs(libFiles) do
|
||||||
if string.find(link, "lib") == 1 then
|
if string.find(link, "lib") == 1 then
|
||||||
link = link:sub(4)
|
link = link:sub(4)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
--
|
---
|
||||||
-- msc.lua
|
-- msc.lua
|
||||||
-- Interface for the MS C/C++ compiler.
|
-- Interface for the MS C/C++ compiler.
|
||||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
-- Author Jason Perkins
|
||||||
--
|
-- Modified by Manu Evans
|
||||||
|
-- Copyright (c) 2009-2015 Jason Perkins and the Premake project
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
premake.tools.msc = {}
|
premake.tools.msc = {}
|
||||||
@ -160,8 +162,9 @@
|
|||||||
-- Decorate include file search paths for the MSVC command line.
|
-- Decorate include file search paths for the MSVC command line.
|
||||||
--
|
--
|
||||||
|
|
||||||
function msc.getincludedirs(cfg, dirs)
|
function msc.getincludedirs(cfg, dirs, sysdirs)
|
||||||
local result = {}
|
local result = {}
|
||||||
|
dirs = table.join(dirs, sysdirs)
|
||||||
for _, dir in ipairs(dirs) do
|
for _, dir in ipairs(dirs) do
|
||||||
dir = project.getrelative(cfg.project, dir)
|
dir = project.getrelative(cfg.project, dir)
|
||||||
table.insert(result, '-I' .. premake.quoted(dir))
|
table.insert(result, '-I' .. premake.quoted(dir))
|
||||||
@ -214,7 +217,8 @@
|
|||||||
|
|
||||||
function msc.getLibraryDirectories(cfg)
|
function msc.getLibraryDirectories(cfg)
|
||||||
local flags = {}
|
local flags = {}
|
||||||
for i, dir in ipairs(cfg.libdirs) do
|
local dirs = table.join(cfg.libdirs, cfg.syslibdirs)
|
||||||
|
for i, dir in ipairs(dirs) do
|
||||||
dir = project.getrelative(cfg.project, dir)
|
dir = project.getrelative(cfg.project, dir)
|
||||||
table.insert(flags, '/LIBPATH:"' .. dir .. '"')
|
table.insert(flags, '/LIBPATH:"' .. dir .. '"')
|
||||||
end
|
end
|
||||||
|
@ -253,3 +253,38 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Check the handling of the VC++ Directories.
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.onSystemIncludeDirs()
|
||||||
|
sysincludedirs { "$(DXSDK_DIR)/Include" }
|
||||||
|
prepare()
|
||||||
|
test.capture [[
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>.\</OutDir>
|
||||||
|
<IntDir>obj\Debug\</IntDir>
|
||||||
|
<TargetName>MyProject</TargetName>
|
||||||
|
<TargetExt>.exe</TargetExt>
|
||||||
|
<IncludePath>$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.onSystemLibraryDirs()
|
||||||
|
syslibdirs { "$(DXSDK_DIR)/lib/x86" }
|
||||||
|
prepare()
|
||||||
|
test.capture [[
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>.\</OutDir>
|
||||||
|
<IntDir>obj\Debug\</IntDir>
|
||||||
|
<TargetName>MyProject</TargetName>
|
||||||
|
<TargetExt>.exe</TargetExt>
|
||||||
|
<LibraryPath>$(DXSDK_DIR)\lib\x86;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
@ -476,3 +476,20 @@
|
|||||||
prepare()
|
prepare()
|
||||||
test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=3" }, gcc.getcflags(cfg))
|
test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=3" }, gcc.getcflags(cfg))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Check handling of system search paths.
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.includeDirs_onSysIncludeDirs()
|
||||||
|
sysincludedirs { "/usr/local/include" }
|
||||||
|
prepare()
|
||||||
|
test.contains("-isystem /usr/local/include", gcc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.libDirs_onSysLibDirs()
|
||||||
|
syslibdirs { "/usr/local/lib" }
|
||||||
|
prepare()
|
||||||
|
test.contains("-L/usr/local/lib", gcc.getLibraryDirectories(cfg))
|
||||||
|
end
|
||||||
|
@ -302,3 +302,20 @@
|
|||||||
prepare()
|
prepare()
|
||||||
test.contains("/clr:pure", msc.getcflags(cfg))
|
test.contains("/clr:pure", msc.getcflags(cfg))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Check handling of system search paths.
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.includeDirs_onSysIncludeDirs()
|
||||||
|
sysincludedirs { "/usr/local/include" }
|
||||||
|
prepare()
|
||||||
|
test.contains("-I/usr/local/include", msc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.libDirs_onSysLibDirs()
|
||||||
|
syslibdirs { "/usr/local/lib" }
|
||||||
|
prepare()
|
||||||
|
test.contains('/LIBPATH:"/usr/local/lib"', msc.getLibraryDirectories(cfg))
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user