summaryrefslogtreecommitdiff
path: root/xmake/toolchains/xcode
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-18 22:57:44 +0800
committerruki <[email protected]>2020-05-18 11:46:26 +0800
commit93db858087c1bdeba2585f2de409e53a8d8e8fbd (patch)
tree7f696114cd6c2fd15f9dc9fdda7cdc1096366ec6 /xmake/toolchains/xcode
parent9aaf4d1f861acb3167ce101ddbf12a5f57b0392a (diff)
support watchos for xcode toolchain
Diffstat (limited to 'xmake/toolchains/xcode')
-rw-r--r--xmake/toolchains/xcode/load_macosx.lua16
-rw-r--r--xmake/toolchains/xcode/load_watchos.lua59
-rw-r--r--xmake/toolchains/xcode/xmake.lua4
3 files changed, 63 insertions, 16 deletions
diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua
index b735b8d77..5cebd96bb 100644
--- a/xmake/toolchains/xcode/load_macosx.lua
+++ b/xmake/toolchains/xcode/load_macosx.lua
@@ -64,8 +64,6 @@ function main(toolchain)
end
-- init flags for asm
--- toolchain:add("yasm.asflags", arch == "x86_64" and "macho64" or "macho32")
--- toolchain:set("fasm.asflags", "")
toolchain:add("asflags", "-arch " .. arch)
if xcode_sdkdir then
toolchain:add("asflags", "-isysroot " .. xcode_sdkdir)
@@ -77,18 +75,4 @@ function main(toolchain)
toolchain:add("scshflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir)
toolchain:add("scldflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir)
end
-
- --[[
- -- init flags for golang
- toolchain:set("gcldflags", "")
-
- -- init flags for dlang
- local dc_archs = { i386 = "-m32", x86_64 = "-m64" }
- toolchain:add("dcflags", dc_archs[arch] or "")
- toolchain:add("dcshflags", dc_archs[arch] or "")
- toolchain:add("dcldflags", dc_archs[arch] or "" )
-
- -- init flags for rust
- toolchain:set("rcshflags", "")
- toolchain:set("rcldflags", "")]]
end
diff --git a/xmake/toolchains/xcode/load_watchos.lua b/xmake/toolchains/xcode/load_watchos.lua
new file mode 100644
index 000000000..5048f4bb7
--- /dev/null
+++ b/xmake/toolchains/xcode/load_watchos.lua
@@ -0,0 +1,59 @@
+--!A cross-toolchain build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file load_watchos.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- main entry
+function main(toolchain)
+
+ -- init architecture
+ local arch = config.get("arch")
+ local simulator = arch == "i386"
+
+ -- init platform name
+ local platname = simulator and "WatchSimulator" or "WatchOS"
+
+ -- init target minimal version
+ local target_minver = config.get("target_minver")
+ local target_minver_flags = (simulator and "-mwatchos-simulator-version-min=" or "-mwatchos-version-min=") .. target_minver
+
+ -- init the xcode sdk directory
+ local xcode_dir = config.get("xcode")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver)
+
+ -- init flags for c/c++
+ toolchain:add("cxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir)
+ toolchain:add("ldflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir)
+ toolchain:add("shflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir)
+
+ -- init flags for objc/c++
+ toolchain:add("mxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir)
+
+ -- init flags for asm
+ toolchain:add("asflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir)
+
+ -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags)
+ toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir)
+ toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir)
+ toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir)
+end
+
diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua
index 4f45f6d60..f20fabe1f 100644
--- a/xmake/toolchains/xcode/xmake.lua
+++ b/xmake/toolchains/xcode/xmake.lua
@@ -35,6 +35,10 @@ toolchain("xcode")
local arch = get_config("arch") or os.arch()
local simulator = (arch == "i386" or arch == "x86_64")
cross = simulator and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos "
+ elseif is_plat("watchos") then
+ local arch = get_config("arch") or os.arch()
+ local simulator = (arch == "i386")
+ cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos "
else
raise("unknown platform for xcode!")
end