summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-23 20:32:47 +0800
committerruki <[email protected]>2016-04-23 20:32:47 +0800
commit9abcba01a96905368c9204269c1e3062dedf7e84 (patch)
tree5a2457dc7f3d44d33588f2c9b3731d322a66a525
parenta40e8b5d84255edae664fab9b7192d15fedf92ba (diff)
add iphonesimulator platform
-rw-r--r--xmake/platforms/iphonesimulator/checker.lua77
-rwxr-xr-xxmake/platforms/iphonesimulator/xmake.lua129
2 files changed, 206 insertions, 0 deletions
diff --git a/xmake/platforms/iphonesimulator/checker.lua b/xmake/platforms/iphonesimulator/checker.lua
new file mode 100644
index 000000000..a0f269ab3
--- /dev/null
+++ b/xmake/platforms/iphonesimulator/checker.lua
@@ -0,0 +1,77 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file checker.lua
+--
+
+-- imports
+import("core.tool.tool")
+import("platforms.checker", {rootdir = os.programdir()})
+
+-- check the toolchains
+function _check_toolchains(config)
+
+ -- done
+ checker.check_toolchain(config, "cc", "xcrun -sdk iphonesimulator ", "clang", "the c compiler")
+ checker.check_toolchain(config, "cxx", "xcrun -sdk iphonesimulator ", "clang", "the c++ compiler")
+ checker.check_toolchain(config, "cxx", "xcrun -sdk iphonesimulator ", "clang++", "the c++ compiler")
+ checker.check_toolchain(config, "mm", "xcrun -sdk iphonesimulator ", "clang", "the objc compiler")
+ checker.check_toolchain(config, "mxx", "xcrun -sdk iphonesimulator ", "clang++", "the objc++ compiler")
+ checker.check_toolchain(config, "mxx", "xcrun -sdk iphonesimulator ", "clang", "the objc++ compiler")
+ checker.check_toolchain(config, "as", "xcrun -sdk iphonesimulator ", "clang", "the assember")
+ checker.check_toolchain(config, "ld", "xcrun -sdk iphonesimulator ", "clang++", "the linker")
+ checker.check_toolchain(config, "ld", "xcrun -sdk iphonesimulator ", "clang", "the linker")
+ checker.check_toolchain(config, "ar", "xcrun -sdk iphonesimulator ", "ar", "the static library linker")
+ checker.check_toolchain(config, "sh", "xcrun -sdk iphonesimulator ", "clang++", "the shared library linker")
+ checker.check_toolchain(config, "sh", "xcrun -sdk iphonesimulator ", "clang", "the shared library linker")
+ checker.check_toolchain(config, "sc", "xcrun -sdk iphonesimulator ", "swiftc", "the swift compiler")
+ checker.check_toolchain(config, "lipo", "xcrun -sdk iphonesimulator ", "lipo", "the universal files creater")
+end
+
+-- init it
+function init()
+
+ -- init the check list of config
+ _g.config =
+ {
+ { checker.check_arch, "x86_64" }
+ , checker.check_xcode
+ , checker.check_xcode_sdkver
+ , checker.check_target_minver
+ , checker.check_make
+ , checker.check_ccache
+ , _check_toolchains
+ }
+
+ -- init the check list of global
+ _g.global =
+ {
+ checker.check_xcode
+ , checker.check_ccache
+ }
+
+end
+
+-- get the property
+function get(name)
+
+ -- get it
+ return _g[name]
+end
+
diff --git a/xmake/platforms/iphonesimulator/xmake.lua b/xmake/platforms/iphonesimulator/xmake.lua
new file mode 100755
index 000000000..fad40dddb
--- /dev/null
+++ b/xmake/platforms/iphonesimulator/xmake.lua
@@ -0,0 +1,129 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define platform
+platform("iphonesimulator")
+
+ -- set os
+ set_platform_os("ios")
+
+ -- set hosts
+ set_platform_hosts("macosx")
+
+ -- set archs
+ set_platform_archs("i386", "x86_64")
+
+ -- set checker
+ set_platform_checker("checker")
+
+ -- on load
+ on_platform_load(function ()
+
+ -- imports
+ import("core.project.config")
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".dylib"}
+
+ -- init the tools
+ _g.tools = {}
+ _g.tools.make = config.get("make")
+ _g.tools.ccache = config.get("__ccache")
+ _g.tools.cc = config.get("cc")
+ _g.tools.cxx = config.get("cxx")
+ _g.tools.mm = config.get("mm")
+ _g.tools.mxx = config.get("mxx")
+ _g.tools.as = config.get("as")
+ _g.tools.ld = config.get("ld")
+ _g.tools.ar = config.get("ar")
+ _g.tools.sh = config.get("sh")
+ _g.tools.ex = config.get("ar")
+ _g.tools.sc = config.get("sc")
+ _g.tools.lipo = config.get("lipo")
+
+ -- init flags for architecture
+ local arch = config.get("arch")
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.mxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.asflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphonesimulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphonesimulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator")
+
+ end)
+
+ -- set menu
+ set_platform_menu({
+ config =
+ {
+ {}
+ , {nil, "mm", "kv", nil, "the objc compiler" }
+ , {nil, "mxx", "kv", nil, "the objc++ compiler" }
+ , {nil, "mflags", "kv", nil, "the objc compiler flags" }
+ , {nil, "mxflags", "kv", nil, "the objc/c++ compiler flags" }
+ , {nil, "mxxflags", "kv", nil, "the objc++ compiler flags" }
+ , {}
+ , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" }
+ , {nil, "xcode_sdkver", "kv", "auto", "the sdk version for xcode" }
+ , {nil, "target_minver", "kv", "auto", "the target minimal version" }
+ , {}
+ , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" }
+ , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" }
+ , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" }
+ }
+
+ , global =
+ {
+ {}
+ , {nil, "xcode_dir", "kv", "auto", "the xcode application directory" }
+ , {}
+ , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" }
+ , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" }
+ , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" }
+ }
+ })
+
+
+
+
+
+