Add os.ios option in xcode4

This commit is contained in:
tempura-sukiyaki 2018-10-18 18:52:35 +09:00
parent ca5e62bce7
commit 5cffdc4f6b
7 changed files with 104 additions and 17 deletions

View File

@ -6,6 +6,25 @@
local p = premake local p = premake
--
-- Register the ios extension
--
local osoption = p.option.get("os")
if type(osoption) == "table" then
local ios = false
table.foreachi(osoption.allowed, function(allowed)
ios = ios or allowed[1] == "ios"
end)
if not ios then
table.insert(osoption.allowed, { "ios", "iOS" })
end
end
-- add system tags for ios.
if not os.systemTags[p.IOS] then
os.systemTags[p.IOS] = { "ios", "mobile" }
end
-- --
-- Register new Xcode-specific project fields. -- Register new Xcode-specific project fields.

View File

@ -126,6 +126,19 @@
end end
function suite.PBXFileReference_ListsIOSWindowedTarget()
_TARGET_OS = "ios"
kind "WindowedApp"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.app:product] /* MyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MyProject.app; path = MyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsStaticLibTarget() function suite.PBXFileReference_ListsStaticLibTarget()
kind "StaticLib" kind "StaticLib"
prepare() prepare()
@ -138,6 +151,19 @@
end end
function suite.PBXFileReference_ListsIOSStaticLibTarget()
_TARGET_OS = "ios"
kind "StaticLib"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[libMyProject.a:product] /* libMyProject.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libMyProject.a; path = libMyProject.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsSharedLibTarget() function suite.PBXFileReference_ListsSharedLibTarget()
kind "SharedLib" kind "SharedLib"
prepare() prepare()
@ -150,6 +176,19 @@
end end
function suite.PBXFileReference_ListsIOSSharedLibTarget()
_TARGET_OS = "ios"
kind "SharedLib"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[libMyProject.dylib:product] /* libMyProject.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; name = libMyProject.dylib; path = libMyProject.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsOSXBundleTarget() function suite.PBXFileReference_ListsOSXBundleTarget()
kind "SharedLib" kind "SharedLib"
sharedlibtype "OSXBundle" sharedlibtype "OSXBundle"
@ -163,6 +202,20 @@
end end
function suite.PBXFileReference_ListsIOSOSXBundleTarget()
_TARGET_OS = "ios"
kind "SharedLib"
sharedlibtype "OSXBundle"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.bundle:product] /* MyProject.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.bundle; path = MyProject.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsOSXFrameworkTarget() function suite.PBXFileReference_ListsOSXFrameworkTarget()
kind "SharedLib" kind "SharedLib"
sharedlibtype "OSXFramework" sharedlibtype "OSXFramework"
@ -176,6 +229,21 @@
end end
function suite.PBXFileReference_ListsIOSOSXFrameworkTarget()
_TARGET_OS = "ios"
kind "SharedLib"
sharedlibtype "OSXFramework"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.framework:product] /* MyProject.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = MyProject.framework; path = MyProject.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end
function suite.PBXFileReference_ListsSourceFiles() function suite.PBXFileReference_ListsSourceFiles()
files { "source.c" } files { "source.c" }
prepare() prepare()

View File

@ -1761,17 +1761,17 @@
-- Add variations for other Posix-like systems. -- Add variations for other Posix-like systems.
filter { "system:MacOSX", "kind:WindowedApp" } filter { "system:macosx or ios", "kind:WindowedApp" }
targetextension ".app" targetextension ".app"
filter { "system:MacOSX", "kind:SharedLib" } filter { "system:macosx or ios", "kind:SharedLib" }
targetextension ".dylib" targetextension ".dylib"
filter { "system:MacOSX", "kind:SharedLib", "sharedlibtype:OSXBundle" } filter { "system:macosx or ios", "kind:SharedLib", "sharedlibtype:OSXBundle" }
targetprefix "" targetprefix ""
targetextension ".bundle" targetextension ".bundle"
filter { "system:MacOSX", "kind:SharedLib", "sharedlibtype:OSXFramework" } filter { "system:macosx or ios", "kind:SharedLib", "sharedlibtype:OSXFramework" }
targetprefix "" targetprefix ""
targetextension ".framework" targetextension ".framework"
@ -1797,7 +1797,7 @@
filter { "kind:SharedLib", "system:not Windows" } filter { "kind:SharedLib", "system:not Windows" }
pic "On" pic "On"
filter { "system:macosx" } filter { "system:macosx or ios" }
toolset "clang" toolset "clang"
filter {} filter {}

View File

@ -48,7 +48,7 @@
local bundlename = "" local bundlename = ""
local bundlepath = "" local bundlepath = ""
if cfg.system == p.MACOSX and (kind == p.WINDOWEDAPP or (kind == p.SHAREDLIB and cfg.sharedlibtype)) then if (cfg.system == p.MACOSX or cfg.system == p.IOS) and (kind == p.WINDOWEDAPP or (kind == p.SHAREDLIB and cfg.sharedlibtype)) then
bundlename = basename .. extension bundlename = basename .. extension
bundlepath = path.join(bundlename, iif(kind == p.SHAREDLIB and cfg.sharedlibtype == "OSXFramework", "Versions/A", "Contents/MacOS")) bundlepath = path.join(bundlename, iif(kind == p.SHAREDLIB and cfg.sharedlibtype == "OSXFramework", "Versions/A", "Contents/MacOS"))
end end

View File

@ -69,7 +69,7 @@
elseif os.istarget("haiku") then elseif os.istarget("haiku") then
path = os.getenv("LIBRARY_PATH") or "" path = os.getenv("LIBRARY_PATH") or ""
else else
if os.istarget("macosx") then if os.istarget("macosx") or os.istarget("ios") then
path = os.getenv("DYLD_LIBRARY_PATH") or "" path = os.getenv("DYLD_LIBRARY_PATH") or ""
else else
path = os.getenv("LD_LIBRARY_PATH") or "" path = os.getenv("LD_LIBRARY_PATH") or ""
@ -90,7 +90,7 @@
path = path or "" path = path or ""
local archpath = "/lib:/usr/lib:/usr/local/lib" local archpath = "/lib:/usr/lib:/usr/local/lib"
if os.is64bit() and not os.istarget("macosx") then if os.is64bit() and not (os.istarget("macosx") or os.istarget("ios")) then
archpath = "/lib64:/usr/lib64/:usr/local/lib64" .. ":" .. archpath archpath = "/lib64:/usr/lib64/:usr/local/lib64" .. ":" .. archpath
end end
if (#path > 0) then if (#path > 0) then
@ -116,7 +116,7 @@
elseif os.istarget("haiku") then elseif os.istarget("haiku") then
formats = { "lib%s.so", "%s.so" } formats = { "lib%s.so", "%s.so" }
else else
if os.istarget("macosx") then if os.istarget("macosx") or os.istarget("ios") then
formats = { "lib%s.dylib", "%s.dylib" } formats = { "lib%s.dylib", "%s.dylib" }
else else
formats = { "lib%s.so", "%s.so" } formats = { "lib%s.so", "%s.so" }

View File

@ -210,7 +210,7 @@
table.insert(r, '-Wl,--out-implib="' .. cfg.linktarget.relpath .. '"') table.insert(r, '-Wl,--out-implib="' .. cfg.linktarget.relpath .. '"')
elseif cfg.system == p.LINUX then elseif cfg.system == p.LINUX then
table.insert(r, '-Wl,-soname=' .. p.quoted(cfg.linktarget.name)) table.insert(r, '-Wl,-soname=' .. p.quoted(cfg.linktarget.name))
elseif cfg.system == p.MACOSX then elseif cfg.system == p.MACOSX or cfg.system == p.IOS then
table.insert(r, '-Wl,-install_name,' .. p.quoted('@rpath/' .. cfg.linktarget.name)) table.insert(r, '-Wl,-install_name,' .. p.quoted('@rpath/' .. cfg.linktarget.name))
end end
return r return r

View File

@ -259,7 +259,7 @@
function gcc.getrunpathdirs(cfg, dirs) function gcc.getrunpathdirs(cfg, dirs)
local result = {} local result = {}
if not ((cfg.system == p.MACOSX) if not ((cfg.system == p.MACOSX) or (cfg.system == p.IOS)
or (cfg.system == p.LINUX)) then or (cfg.system == p.LINUX)) then
return result return result
end end
@ -286,7 +286,7 @@
end end
for _, rpath in ipairs(rpaths) do for _, rpath in ipairs(rpaths) do
if (cfg.system == p.MACOSX) then if (cfg.system == p.MACOSX) or (cfg.system == p.IOS) then
rpath = "@loader_path/" .. rpath rpath = "@loader_path/" .. rpath
elseif (cfg.system == p.LINUX) then elseif (cfg.system == p.LINUX) then
rpath = iif(rpath == ".", "", "/" .. rpath) rpath = iif(rpath == ".", "", "/" .. rpath)
@ -303,7 +303,7 @@
-- get the right output flag. -- get the right output flag.
-- --
function gcc.getsharedlibarg(cfg) function gcc.getsharedlibarg(cfg)
if cfg.system == p.MACOSX then if cfg.system == p.MACOSX or cfg.system == p.IOS then
if cfg.sharedlibtype == "OSXBundle" then if cfg.sharedlibtype == "OSXBundle" then
return "-bundle" return "-bundle"
elseif cfg.sharedlibtype == "OSXFramework" then elseif cfg.sharedlibtype == "OSXFramework" then
@ -323,7 +323,7 @@
function gcc.ldsymbols(cfg) function gcc.ldsymbols(cfg)
-- OS X has a bug, see http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html -- OS X has a bug, see http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html
return iif(cfg.system == p.MACOSX, "-Wl,-x", "-s") return iif(cfg.system == p.MACOSX or cfg.system == p.IOS, "-Wl,-x", "-s")
end end
gcc.ldflags = { gcc.ldflags = {
@ -341,7 +341,7 @@
table.insert(r, '-Wl,--out-implib="' .. cfg.linktarget.relpath .. '"') table.insert(r, '-Wl,--out-implib="' .. cfg.linktarget.relpath .. '"')
elseif cfg.system == p.LINUX then elseif cfg.system == p.LINUX then
table.insert(r, '-Wl,-soname=' .. p.quoted(cfg.linktarget.name)) table.insert(r, '-Wl,-soname=' .. p.quoted(cfg.linktarget.name))
elseif cfg.system == p.MACOSX then elseif cfg.system == p.MACOSX or cfg.system == p.IOS then
table.insert(r, '-Wl,-install_name,' .. p.quoted('@rpath/' .. cfg.linktarget.name)) table.insert(r, '-Wl,-install_name,' .. p.quoted('@rpath/' .. cfg.linktarget.name))
end end
return r return r
@ -374,14 +374,14 @@
architecture = { architecture = {
x86 = function (cfg) x86 = function (cfg)
local r = {} local r = {}
if cfg.system ~= p.MACOSX then if cfg.system ~= p.MACOSX and cfg.system ~= p.IOS then
table.insert (r, "-L/usr/lib32") table.insert (r, "-L/usr/lib32")
end end
return r return r
end, end,
x86_64 = function (cfg) x86_64 = function (cfg)
local r = {} local r = {}
if cfg.system ~= p.MACOSX then if cfg.system ~= p.MACOSX and cfg.system ~= p.IOS then
table.insert (r, "-L/usr/lib64") table.insert (r, "-L/usr/lib64")
end end
return r return r