macOS deployment target support for gcc and clang
Use the value of systemversion to set the Apple-specific gcc/clang option -mmacosx-version-min=<version>, equivalent of the Xcode setting MACOSX_DEPLOYMENT_TARGET add tests for gcc and clang
This commit is contained in:
parent
2c42771f3f
commit
c923e04486
@ -75,7 +75,7 @@
|
||||
local cflags = config.mapFlags(cfg, clang.cflags)
|
||||
|
||||
local flags = table.join(shared, cflags)
|
||||
flags = table.join(flags, clang.getwarnings(cfg))
|
||||
flags = table.join(flags, clang.getwarnings(cfg), clang.getsystemversionflags(cfg))
|
||||
|
||||
return flags
|
||||
end
|
||||
@ -84,6 +84,23 @@
|
||||
return gcc.getwarnings(cfg)
|
||||
end
|
||||
|
||||
--
|
||||
-- Returns C/C++ system version related build flags
|
||||
--
|
||||
|
||||
function clang.getsystemversionflags(cfg)
|
||||
local flags = {}
|
||||
|
||||
if cfg.system == p.MACOSX or cfg.system == p.IOS then
|
||||
local minVersion = p.project.systemversion(cfg)
|
||||
if (type (minVersion) == "string") and (string.match(minVersion, "^%d+%.%d+") ~= nil) then
|
||||
local name = iif(cfg.system == p.MACOSX, "macosx", "iphoneos")
|
||||
table.insert (flags, "-m" .. name .. "-version-min=" .. p.project.systemversion(cfg))
|
||||
end
|
||||
end
|
||||
|
||||
return flags
|
||||
end
|
||||
|
||||
--
|
||||
-- Build a list of C++ compiler flags corresponding to the settings
|
||||
@ -103,7 +120,7 @@
|
||||
local shared = config.mapFlags(cfg, clang.shared)
|
||||
local cxxflags = config.mapFlags(cfg, clang.cxxflags)
|
||||
local flags = table.join(shared, cxxflags)
|
||||
flags = table.join(flags, clang.getwarnings(cfg))
|
||||
flags = table.join(flags, clang.getwarnings(cfg), clang.getsystemversionflags(cfg))
|
||||
return flags
|
||||
end
|
||||
|
||||
|
@ -144,7 +144,7 @@
|
||||
function gcc.getcflags(cfg)
|
||||
local shared_flags = config.mapFlags(cfg, gcc.shared)
|
||||
local cflags = config.mapFlags(cfg, gcc.cflags)
|
||||
local flags = table.join(shared_flags, cflags)
|
||||
local flags = table.join(shared_flags, cflags, gcc.getsystemversionflags(cfg))
|
||||
flags = table.join(flags, gcc.getwarnings(cfg))
|
||||
return flags
|
||||
end
|
||||
@ -163,6 +163,23 @@
|
||||
return result
|
||||
end
|
||||
|
||||
--
|
||||
-- Returns C/C++ system version build flags
|
||||
--
|
||||
|
||||
function gcc.getsystemversionflags(cfg)
|
||||
local flags = {}
|
||||
|
||||
if cfg.system == p.MACOSX then
|
||||
local minVersion = p.project.systemversion(cfg)
|
||||
if (type (minVersion) == "string") and (string.match(minVersion, "^%d+%.%d+") ~= nil) then
|
||||
table.insert (flags, "-mmacosx-version-min=" .. minVersion)
|
||||
end
|
||||
end
|
||||
|
||||
return flags
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns list of C++ compiler flags for a configuration.
|
||||
@ -213,7 +230,7 @@
|
||||
local shared_flags = config.mapFlags(cfg, gcc.shared)
|
||||
local cxxflags = config.mapFlags(cfg, gcc.cxxflags)
|
||||
local flags = table.join(shared_flags, cxxflags)
|
||||
flags = table.join(flags, gcc.getwarnings(cfg))
|
||||
flags = table.join(flags, gcc.getwarnings(cfg), gcc.getsystemversionflags(cfg))
|
||||
return flags
|
||||
end
|
||||
|
||||
|
@ -61,5 +61,6 @@ return {
|
||||
-- -- Toolset tests
|
||||
"tools/test_dotnet.lua",
|
||||
"tools/test_gcc.lua",
|
||||
"tools/test_clang.lua",
|
||||
"tools/test_msc.lua",
|
||||
}
|
||||
|
72
tests/tools/test_clang.lua
Normal file
72
tests/tools/test_clang.lua
Normal file
@ -0,0 +1,72 @@
|
||||
--
|
||||
-- tests/test_clang.lua
|
||||
-- Automated test suite for the GCC toolset interface.
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("tools_clang")
|
||||
|
||||
local clang = p.tools.clang
|
||||
local project = p.project
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local wks, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
wks, prj = test.createWorkspace()
|
||||
system "Linux"
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = test.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check Mac OS X deployment target flags
|
||||
--
|
||||
|
||||
function suite.cflags_macosx_systemversion()
|
||||
system "MacOSX"
|
||||
systemversion "10.9"
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, clang.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cxxflags_macosx_systemversion()
|
||||
system "MacOSX"
|
||||
systemversion "10.9"
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, clang.getcxxflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cxxflags_macosx_systemversion_invalid()
|
||||
system "MacOSX"
|
||||
systemversion "weird"
|
||||
prepare()
|
||||
test.excludes({ "-mmacosx-version-min=10.9" }, clang.getcxxflags(cfg))
|
||||
end
|
||||
|
||||
--
|
||||
-- Check iOS deployment target flags
|
||||
--
|
||||
|
||||
function suite.cflags_ios_systemversion()
|
||||
system "iOS"
|
||||
systemversion "12.1"
|
||||
prepare()
|
||||
test.contains({ "-miphoneos-version-min=12.1" }, clang.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cxxflags_ios_systemversion()
|
||||
system "iOS"
|
||||
systemversion "5.0"
|
||||
prepare()
|
||||
test.contains({ "-miphoneos-version-min=5.0" }, clang.getcxxflags(cfg))
|
||||
end
|
||||
|
@ -381,6 +381,31 @@
|
||||
prepare()
|
||||
test.contains({ "-dynamiclib" }, gcc.getldflags(cfg))
|
||||
end
|
||||
|
||||
--
|
||||
-- Check Mac OS X deployment target flags
|
||||
--
|
||||
|
||||
function suite.cflags_macosx_systemversion()
|
||||
system "MacOSX"
|
||||
systemversion "10.9"
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cxxflags_macosx_systemversion()
|
||||
system "MacOSX"
|
||||
systemversion "10.9:10.15"
|
||||
prepare()
|
||||
test.contains({ "-mmacosx-version-min=10.9" }, gcc.getcxxflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cxxflags_macosx_systemversion_invalid()
|
||||
system "MacOSX"
|
||||
systemversion "strange"
|
||||
prepare()
|
||||
test.excludes({ "-mmacosx-version-min=10.9" }, gcc.getcxxflags(cfg))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
|
Reference in New Issue
Block a user