From 98a14ff6248a83ca888e6ef5963d217042eaab7a Mon Sep 17 00:00:00 2001 From: Sam Surtees Date: Thu, 31 Aug 2017 02:55:00 +1000 Subject: [PATCH] Added basic iOS support to XCode4 --- modules/xcode/_preload.lua | 17 ++- modules/xcode/tests/test_header_footer.lua | 1 + modules/xcode/tests/test_xcode4_project.lua | 1 + modules/xcode/tests/test_xcode4_workspace.lua | 1 + .../xcode/tests/test_xcode_dependencies.lua | 1 + modules/xcode/tests/test_xcode_project.lua | 118 ++++++++++++++++++ modules/xcode/xcode_common.lua | 21 ++++ src/_premake_init.lua | 1 + src/base/_foundation.lua | 1 + 9 files changed, 161 insertions(+), 1 deletion(-) diff --git a/modules/xcode/_preload.lua b/modules/xcode/_preload.lua index d6b1faf4..fb8fd8c1 100644 --- a/modules/xcode/_preload.lua +++ b/modules/xcode/_preload.lua @@ -23,6 +23,22 @@ kind = "list", } + p.api.register { + name = "xcodecodesigningidentity", + scope = "config", + kind = "string", + } + + p.api.register { + name = "iosfamily", + scope = "config", + kind = "string", + allowed = { + "iPhone/iPod touch", + "iPad", + "Universal", + } + } -- -- Register the Xcode exporters. @@ -35,7 +51,6 @@ -- Xcode always uses Mac OS X path and naming conventions - targetos = "macosx", toolset = "clang", -- The capabilities of this action diff --git a/modules/xcode/tests/test_header_footer.lua b/modules/xcode/tests/test_header_footer.lua index 9635f10b..73dcbda6 100644 --- a/modules/xcode/tests/test_header_footer.lua +++ b/modules/xcode/tests/test_header_footer.lua @@ -17,6 +17,7 @@ local wks function suite.setup() + _TARGET_OS = "macosx" p.action.set('xcode4') wks = test.createWorkspace() end diff --git a/modules/xcode/tests/test_xcode4_project.lua b/modules/xcode/tests/test_xcode4_project.lua index 1d6350bc..6b2fcff0 100644 --- a/modules/xcode/tests/test_xcode4_project.lua +++ b/modules/xcode/tests/test_xcode4_project.lua @@ -49,6 +49,7 @@ end function suite.setup() + _TARGET_OS = "macosx" p.action.set('xcode4') io.eol = "\n" xcode.used_ids = { } -- reset the list of generated IDs diff --git a/modules/xcode/tests/test_xcode4_workspace.lua b/modules/xcode/tests/test_xcode4_workspace.lua index cd937253..77336c10 100644 --- a/modules/xcode/tests/test_xcode4_workspace.lua +++ b/modules/xcode/tests/test_xcode4_workspace.lua @@ -18,6 +18,7 @@ local wks, prj function suite.setup() + _TARGET_OS = "macosx" p.action.set('xcode4') wks = test.createWorkspace() end diff --git a/modules/xcode/tests/test_xcode_dependencies.lua b/modules/xcode/tests/test_xcode_dependencies.lua index 6046fc16..d4204c32 100644 --- a/modules/xcode/tests/test_xcode_dependencies.lua +++ b/modules/xcode/tests/test_xcode_dependencies.lua @@ -23,6 +23,7 @@ end function suite.setup() + _TARGET_OS = "macosx" p.action.set('xcode4') xcode.used_ids = { } -- reset the list of generated IDs diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index d153df80..f643310b 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -20,6 +20,7 @@ end function suite.setup() + _TARGET_OS = "macosx" p.action.set('xcode4') p.eol("\n") xcode.used_ids = { } -- reset the list of generated IDs @@ -1095,6 +1096,123 @@ ]] end + function suite.XCBuildConfigurationTarget_OnIOS() + _TARGET_OS = "ios" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + [MyProject:Debug] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = bin/Debug; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = MyProject; + SDKROOT = iphoneos; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationTarget_OnIOSMinVersion() + _TARGET_OS = "ios" + systemversion "8.3" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + [MyProject:Debug] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = bin/Debug; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + PRODUCT_NAME = MyProject; + SDKROOT = iphoneos; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationTarget_OnIOSMinMaxVersion() + _TARGET_OS = "ios" + systemversion "8.3:9.1" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + [MyProject:Debug] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = bin/Debug; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + PRODUCT_NAME = MyProject; + SDKROOT = iphoneos; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationTarget_OnIOSCodeSigningIdentity() + _TARGET_OS = "ios" + xcodecodesigningidentity "Premake Developers" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + [MyProject:Debug] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Premake Developers"; + CONFIGURATION_BUILD_DIR = bin/Debug; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = MyProject; + SDKROOT = iphoneos; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationTarget_OnIOSFamily() + _TARGET_OS = "ios" + iosfamily "Universal" + prepare() + xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1]) + test.capture [[ + [MyProject:Debug] /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CONFIGURATION_BUILD_DIR = bin/Debug; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = MyProject; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + ]] + end + --------------------------------------------------------------------------- -- XCBuildConfiguration_Project tests diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index a95b3177..b677d7e3 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -943,6 +943,27 @@ settings['EXCLUDED_SOURCE_FILE_NAMES'] = fileNameList end settings['PRODUCT_NAME'] = cfg.buildtarget.basename + + if os.istarget(p.IOS) then + settings['SDKROOT'] = 'iphoneos' + + settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = cfg.xcodecodesigningidentity or 'iPhone Developer' + + local minOSVersion = project.systemversion(cfg) + if minOSVersion ~= nil then + settings['IPHONEOS_DEPLOYMENT_TARGET'] = minOSVersion + end + + local families = { + ['iPhone/iPod touch'] = '1', + ['iPad'] = '2', + ['Universal'] = '1,2', + } + local family = families[cfg.iosfamily] + if family then + settings['TARGETED_DEVICE_FAMILY'] = family + end + end --ms not by default ...add it manually if you need it --settings['COMBINE_HIDPI_IMAGES'] = 'YES' diff --git a/src/_premake_init.lua b/src/_premake_init.lua index ec7492d2..fe0ede97 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1105,6 +1105,7 @@ "aix", "bsd", "haiku", + "ios", "linux", "macosx", "solaris", diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index 2c8019bc..10d370b3 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -34,6 +34,7 @@ premake.CSHARP = "C#" premake.GCC = "gcc" premake.HAIKU = "haiku" + premake.IOS = "ios" premake.LINUX = "linux" premake.MACOSX = "macosx" premake.MAKEFILE = "Makefile"