summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/compiler.lua2
-rw-r--r--xmake/scripts/platform/iphoneos/iphoneos.lua1
-rw-r--r--xmake/scripts/platform/iphoneos/prober.lua1
-rw-r--r--xmake/scripts/platform/iphonesimulator/iphonesimulator.lua1
-rw-r--r--xmake/scripts/platform/iphonesimulator/prober.lua1
-rw-r--r--xmake/scripts/platform/macosx/macosx.lua4
-rw-r--r--xmake/scripts/platform/macosx/prober.lua1
-rw-r--r--xmake/scripts/tools/swiftc.lua120
8 files changed, 131 insertions, 0 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index 184ad0125..f7a9a0c33 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -312,6 +312,7 @@ function compiler._flagnames(name)
elseif name == "mm" then flagnames = { "mxflags", "mflags" }
elseif name == "mxx" then flagnames = { "mxflags", "mxxflags" }
elseif name == "as" then flagnames = { "asflags" }
+ elseif name == "sc" then flagnames = { "scflags" }
else
-- error
utils.error("unknown compiler: %s", name)
@@ -341,6 +342,7 @@ function compiler._kind(srcfile)
elseif filetype == ".m" then kind = "mm"
elseif filetype == ".mm" then kind = "mxx"
elseif filetype == ".s" or filetype == ".asm" then kind = "as"
+ elseif filetype == ".swift" then kind = "sc"
end
-- ok
diff --git a/xmake/scripts/platform/iphoneos/iphoneos.lua b/xmake/scripts/platform/iphoneos/iphoneos.lua
index ff9ddfdc0..282d3fe52 100644
--- a/xmake/scripts/platform/iphoneos/iphoneos.lua
+++ b/xmake/scripts/platform/iphoneos/iphoneos.lua
@@ -57,6 +57,7 @@ function iphoneos.make(configs)
configs.tools.ar = config.get("ar")
configs.tools.sh = config.get("sh")
configs.tools.ex = config.get("ar")
+ configs.tools.sc = config.get("sc")
configs.tools.lipo = config.get("lipo")
-- init flags for architecture
diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua
index ae17a74c9..ac2e45838 100644
--- a/xmake/scripts/platform/iphoneos/prober.lua
+++ b/xmake/scripts/platform/iphoneos/prober.lua
@@ -239,6 +239,7 @@ function prober._probe_toolchains(configs)
if not prober._probe_toolpath(configs, "ld", "xcrun -sdk iphoneos ", "clang++", "the linker") then return false end
if not prober._probe_toolpath(configs, "ar", "xcrun -sdk iphoneos ", "ar", "the static library linker") then return false end
if not prober._probe_toolpath(configs, "sh", "xcrun -sdk iphoneos ", "clang++", "the shared library linker") then return false end
+ if not prober._probe_toolpath(configs, "sc", "xcrun -sdk iphoneos ", "swiftc", "the swift compiler") then return false end
if not prober._probe_toolpath(configs, "lipo", "xcrun -sdk iphoneos ", "lipo", "the universal files creater") then return false end
return true
end
diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
index 3765fbe85..c550a2f97 100644
--- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
+++ b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
@@ -56,6 +56,7 @@ function iphonesimulator.make(configs)
configs.tools.ar = config.get("ar")
configs.tools.sh = config.get("sh")
configs.tools.ex = config.get("ar")
+ configs.tools.sc = config.get("sc")
-- init flags for architecture
local archflags = nil
diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua
index ae9754f81..72671ecfa 100644
--- a/xmake/scripts/platform/iphonesimulator/prober.lua
+++ b/xmake/scripts/platform/iphonesimulator/prober.lua
@@ -239,6 +239,7 @@ function prober._probe_toolchains(configs)
if not prober._probe_toolpath(configs, "ld", "xcrun -sdk iphonesimulator ", "clang++", "the linker") then return false end
if not prober._probe_toolpath(configs, "ar", "xcrun -sdk iphonesimulator ", "ar", "the static library linker") then return false end
if not prober._probe_toolpath(configs, "sh", "xcrun -sdk iphonesimulator ", "clang++", "the shared library linker") then return false end
+ if not prober._probe_toolpath(configs, "sc", "xcrun -sdk iphonesimulator ", "swiftc", "the swift compiler") then return false end
return true
end
diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua
index c7f4eb2c4..699e3e506 100644
--- a/xmake/scripts/platform/macosx/macosx.lua
+++ b/xmake/scripts/platform/macosx/macosx.lua
@@ -56,6 +56,7 @@ function macosx.make(configs)
configs.tools.ar = config.get("ar")
configs.tools.sh = config.get("sh")
configs.tools.ex = config.get("ar")
+ configs.tools.sc = config.get("sc")
-- init flags for architecture
local archflags = nil
@@ -97,6 +98,9 @@ function macosx.menu(action)
, {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" }
, {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" }
, {}
+ , {nil, "sc", "kv", nil, "The Swift Compiler" }
+ , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" }
+ , {}
, {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" }
, {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" }
, }
diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua
index d2c397edc..cc4ac3dfb 100644
--- a/xmake/scripts/platform/macosx/prober.lua
+++ b/xmake/scripts/platform/macosx/prober.lua
@@ -239,6 +239,7 @@ function prober._probe_toolchains(configs)
if not prober._probe_toolpath(configs, "ld", "xcrun -sdk macosx ", "clang++", "the linker") then return false end
if not prober._probe_toolpath(configs, "ar", "xcrun -sdk macosx ", "ar", "the static library linker") then return false end
if not prober._probe_toolpath(configs, "sh", "xcrun -sdk macosx ", "clang++", "the shared library linker") then return false end
+ if not prober._probe_toolpath(configs, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler") then return false end
return true
end
diff --git a/xmake/scripts/tools/swiftc.lua b/xmake/scripts/tools/swiftc.lua
new file mode 100644
index 000000000..379fb764b
--- /dev/null
+++ b/xmake/scripts/tools/swiftc.lua
@@ -0,0 +1,120 @@
+--!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) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file swiftc.lua
+--
+
+-- load modules
+local utils = require("base/utils")
+local table = require("base/table")
+local string = require("base/string")
+local config = require("base/config")
+local platform = require("platform/platform")
+
+-- define module: swiftc
+local swiftc = swiftc or {}
+
+-- the init function
+function swiftc.init(self, name)
+
+ -- save name
+ self.name = name or "swiftc"
+
+ -- init flags map
+ self.mapflags =
+ {
+ -- symbols
+ ["-fvisibility=hidden"] = ""
+
+ -- warnings
+ , ["-w"] = ""
+ , ["-W.*"] = ""
+
+ -- optimize
+ , ["-O0"] = "-Onone"
+ , ["-O.*"] = "-O"
+
+ -- vectorexts
+ , ["-m.*"] = ""
+
+ -- strip
+ , ["-s"] = ""
+ , ["-S"] = ""
+
+ -- others
+ , ["-ftrapv"] = ""
+ , ["-fsanitize=address"] = ""
+ }
+
+ -- -target
+ -- armv7-apple-ios7.1
+ -- x86_64-apple-ios9.0
+ -- x86_64-apple-macosx10.10
+ --
+ -- -sdk
+ -- /xxx/xxx.sdk
+ --
+ -- -enable-objc-interop
+
+end
+
+-- make the compile command
+function swiftc.command_compile(self, srcfile, objfile, flags, logfile)
+
+ -- redirect
+ local redirect = ""
+ if logfile then redirect = string.format(" > %s 2>&1", logfile) end
+
+ -- make it
+ return string.format("%s -c %s -o %s %s%s", self.name, flags, objfile, srcfile, redirect)
+end
+
+-- make the includedir flag
+function swiftc.flag_includedir(self, includedir)
+
+ -- make it
+ return "-Xcc -I" .. includedir
+end
+
+-- make the define flag
+function swiftc.flag_define(self, define)
+
+ -- make it
+ return "-Xcc -D" .. define:gsub("\"", "\\\"")
+end
+
+-- make the undefine flag
+function swiftc.flag_undefine(self, undefine)
+
+ -- make it
+ return "-Xcc -U" .. undefine
+end
+
+-- the main function
+function swiftc.main(self, cmd)
+
+ -- execute it
+ local ok = os.execute(cmd)
+
+ -- ok?
+ return utils.ifelse(ok == 0, true, false)
+end
+
+-- return module: swiftc
+return swiftc