Merge pull request #1661 from depinxi/toolset-frameworkdirs

Add frameworkdirs support to gmake and gmake2 with gcc/clang toolsets
This commit is contained in:
starkos 2021-09-14 08:50:47 -04:00 committed by GitHub
commit 0dd9c4bbdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 10 deletions

View File

@ -195,7 +195,7 @@
end end
local toolset = m.getcompiler(cfg) local toolset = m.getcompiler(cfg)
local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs) local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs, cfg.frameworkdirs)
local forceincludes = toolset.getforceincludes(cfg) local forceincludes = toolset.getforceincludes(cfg)
local cxxflags = table.concat(table.join(sysincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";") local cxxflags = table.concat(table.join(sysincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";")
local cflags = table.concat(table.join(sysincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";") local cflags = table.concat(table.join(sysincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";")
@ -225,7 +225,7 @@
end end
local toolset = m.getcompiler(cfg) local toolset = m.getcompiler(cfg)
local flags = table.join(toolset.getldflags(cfg), cfg.linkoptions, toolset.getlinks(cfg)) local flags = table.join(toolset.getldflags(cfg), toolset.getincludedirs(cfg, {}, nil, cfg.frameworkdirs), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), cfg.linkoptions, toolset.getlinks(cfg))
_x(3, '<Linker Required="yes" Options="%s">', table.concat(flags, ";")) _x(3, '<Linker Required="yes" Options="%s">', table.concat(flags, ";"))

View File

@ -521,7 +521,7 @@ end
function make.includes(cfg, toolset) function make.includes(cfg, toolset)
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs)
_p(' INCLUDES +=%s', make.list(includes)) _p(' INCLUDES +=%s', make.list(includes))
end end

View File

@ -386,7 +386,7 @@
function cpp.includes(cfg, toolset) function cpp.includes(cfg, toolset)
local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs)
p.outln('INCLUDES +=' .. gmake2.list(includes)) p.outln('INCLUDES +=' .. gmake2.list(includes))
end end
@ -531,8 +531,8 @@
end end
end end
if fcfg.includedirs or fcfg.sysincludedirs then if fcfg.includedirs or fcfg.sysincludedirs or fcfg.frameworkdirs then
local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.sysincludedirs) local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.sysincludedirs, fcfg.frameworkdirs)
if #includes > 0 then if #includes > 0 then
value = value .. gmake2.list(includes) value = value .. gmake2.list(includes)
end end

View File

@ -186,10 +186,10 @@
-- An array of symbols with the appropriate flag decorations. -- An array of symbols with the appropriate flag decorations.
-- --
function clang.getincludedirs(cfg, dirs, sysdirs) function clang.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
-- Just pass through to GCC for now -- Just pass through to GCC for now
local flags = gcc.getincludedirs(cfg, dirs, sysdirs) local flags = gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
return flags return flags
end end

View File

@ -284,12 +284,20 @@
-- 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, sysdirs) function gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
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' .. p.quoted(dir)) table.insert(result, '-I' .. p.quoted(dir))
end end
if table.contains(os.getSystemTags(cfg.system), "darwin") then
for _, dir in ipairs(frameworkdirs or {}) do
dir = project.getrelative(cfg.project, dir)
table.insert(result, '-F' .. p.quoted(dir))
end
end
for _, dir in ipairs(sysdirs or {}) do for _, dir in ipairs(sysdirs or {}) do
dir = project.getrelative(cfg.project, dir) dir = project.getrelative(cfg.project, dir)
table.insert(result, '-isystem ' .. p.quoted(dir)) table.insert(result, '-isystem ' .. p.quoted(dir))
@ -481,6 +489,13 @@
table.insert(flags, '-L' .. p.quoted(dir)) table.insert(flags, '-L' .. p.quoted(dir))
end end
if table.contains(os.getSystemTags(cfg.system), "darwin") then
for _, dir in ipairs(cfg.frameworkdirs) do
dir = project.getrelative(cfg.project, dir)
table.insert(flags, '-F' .. p.quoted(dir))
end
end
if cfg.flags.RelativeLinks then if cfg.flags.RelativeLinks then
for _, dir in ipairs(config.getlinks(cfg, "siblings", "directory")) do for _, dir in ipairs(config.getlinks(cfg, "siblings", "directory")) do
local libFlag = "-L" .. p.project.getrelative(cfg.project, dir) local libFlag = "-L" .. p.project.getrelative(cfg.project, dir)

View File

@ -231,7 +231,7 @@
-- 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, sysdirs) function msc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs)
local result = {} local result = {}
dirs = table.join(dirs, sysdirs) dirs = table.join(dirs, sysdirs)
for _, dir in ipairs(dirs) do for _, dir in ipairs(dirs) do

View File

@ -674,6 +674,54 @@
test.contains("-L/usr/local/lib", gcc.getLibraryDirectories(cfg)) test.contains("-L/usr/local/lib", gcc.getLibraryDirectories(cfg))
end end
--
-- Check handling of Apple frameworks search paths
--
function suite.includeDirs_notDarwin_onFrameworkDirs()
system "Linux"
frameworkdirs { "/Library/Frameworks" }
prepare()
test.excludes("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
end
function suite.libDirs_notDarwin_onFrameworkDirs()
system "Windows"
frameworkdirs { "/Library/Frameworks" }
prepare()
test.excludes("-F/Library/Frameworks", gcc.getLibraryDirectories(cfg))
end
function suite.includeDirs_macosx_onFrameworkDirs()
system "MacOSX"
location "subdir"
frameworkdirs {
"/Library/Frameworks",
"subdir/Relative/Frameworks"
}
prepare()
test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
test.contains("-FRelative/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
end
function suite.libDirs_macosx_onFrameworkDirs()
system "MacOSX"
location "subdir"
frameworkdirs {
"/Library/Frameworks",
"subdir/Relative/Frameworks"
}
prepare()
test.contains("-F/Library/Frameworks", gcc.getLibraryDirectories(cfg))
test.contains("-FRelative/Frameworks", gcc.getLibraryDirectories(cfg))
end
function suite.includeDirs_ios_onFrameworkDirs()
system "iOS"
frameworkdirs { "/Library/Frameworks" }
prepare()
test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
end
-- --
-- Check handling of link time optimization flag. -- Check handling of link time optimization flag.