summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-18 22:58:22 +0800
committerruki <[email protected]>2020-05-18 11:50:13 +0800
commit3c304c6ae85fe66c2f2144e447d31a68b45cf349 (patch)
tree1df81107a08fcff86f53556949479489c6ab62ed
parent93db858087c1bdeba2585f2de409e53a8d8e8fbd (diff)
improve to check iphoneos and watchos
-rw-r--r--xmake/platforms/iphoneos/check.lua89
-rw-r--r--xmake/platforms/macosx/check.lua123
-rw-r--r--xmake/platforms/watchos/check.lua105
3 files changed, 11 insertions, 306 deletions
diff --git a/xmake/platforms/iphoneos/check.lua b/xmake/platforms/iphoneos/check.lua
index 1a7fbd4e3..ad0110b39 100644
--- a/xmake/platforms/iphoneos/check.lua
+++ b/xmake/platforms/iphoneos/check.lua
@@ -22,95 +22,8 @@
import("core.project.config")
import("private.platform.check_arch")
---[[
-import("core.base.singleton")
-import("private.platform.toolchain")
-import("private.platform.check_xcode")
-import("private.platform.check_toolchain")
-
--- get toolchains
-function _toolchains()
-
- -- init architecture
- local arch = config.get("arch") or os.arch()
- local simulator = (arch == "i386" or arch == "x86_64")
-
- -- init cross
- local cross = simulator and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos "
-
- -- init toolchains
- local cc = toolchain("the c compiler")
- local cpp = toolchain("the c preprocessor")
- local cxx = toolchain("the c++ compiler")
- local ld = toolchain("the linker")
- local sh = toolchain("the shared library linker")
- local ar = toolchain("the static library archiver")
- local ex = toolchain("the static library extractor")
- local strip = toolchain("the symbols stripper")
- local dsymutil = toolchain("the symbols generator")
- local mm = toolchain("the objc compiler")
- local mxx = toolchain("the objc++ compiler")
- local as = toolchain("the assember")
- local sc = toolchain("the swift compiler")
- local sc_ld = toolchain("the swift linker")
- local sc_sh = toolchain("the swift shared library linker")
- local toolchains = {cc = cc, cpp = cpp, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil,
- mm = mm, mxx = mxx, sc = sc, ["scld"] = sc_ld, ["scsh"] = sc_sh}
-
- -- init the c compiler
- cc:add({name = "clang", cross = cross})
-
- -- init the c preprocessor
- cpp:add({name = "clang -arch " .. arch .. " -E", cross = cross})
-
- -- init the c++ compiler
- cxx:add({name = "clang", cross = cross})
- cxx:add({name = "clang++", cross = cross})
-
- -- init the assember
- if simulator then
- as:add({name = "clang", cross = cross})
- else
- as:add({name = "clang", cross = path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. cross)})
- end
-
- -- init the linker
- ld:add({name = "clang++", cross = cross})
- ld:add({name = "clang", cross = cross})
-
- -- init the shared library linker
- sh:add({name = "clang++", cross = cross})
- sh:add({name = "clang", cross = cross})
-
- -- init the static library archiver
- ar:add({name = "ar", cross = cross})
-
- -- init the static library extractor
- ex:add({name = "ar", cross = cross})
-
- -- init the symbols stripper
- strip:add({name = "strip", cross = cross})
-
- -- init the symbols generator
- dsymutil:add({name = "dsymutil", cross = cross})
-
- -- init the objc compiler
- mm:add({name = "clang", cross = cross})
-
- -- init the objc++ compiler
- mxx:add({name = "clang", cross = cross})
- mxx:add({name = "clang++", cross = cross})
-
- -- init the swift compiler and linker
- sc:add({name = "swiftc", cross = cross})
- sc_ld:add({name = "swiftc", cross = cross})
- sc_sh:add({name = "swiftc", cross = cross})
-
- return toolchains
-end]]
-
-- check it
-function main(platform, name)
+function main(platform)
-- check arch
check_arch(config, "arm64")
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 1166c3205..df2f072ec 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -22,129 +22,6 @@
import("core.project.config")
import("private.platform.check_arch")
---[[
-import("core.base.singleton")
-import("private.platform.toolchain")
-import("private.platform.check_xcode")
-import("private.platform.check_toolchain")
-
--- get toolchains
-function _toolchains()
-
- -- init cross
- local cross = "xcrun -sdk macosx "
-
- -- init toolchains
- local cc = toolchain("the c compiler")
- local cxx = toolchain("the c++ compiler")
- local ld = toolchain("the linker")
- local sh = toolchain("the shared library linker")
- local ar = toolchain("the static library archiver")
- local ex = toolchain("the static library extractor")
- local strip = toolchain("the symbols stripper")
- local dsymutil = toolchain("the symbols generator")
- local mm = toolchain("the objc compiler")
- local mxx = toolchain("the objc++ compiler")
- local as = toolchain("the assember")
- local sc = toolchain("the swift compiler")
- local sc_ld = toolchain("the swift linker")
- local sc_sh = toolchain("the swift shared library linker")
- local gc = toolchain("the golang compiler")
- local gc_ld = toolchain("the golang linker")
- local gc_ar = toolchain("the golang static library archiver")
- local dc = toolchain("the dlang compiler")
- local dc_ld = toolchain("the dlang linker")
- local dc_sh = toolchain("the dlang shared library linker")
- local dc_ar = toolchain("the dlang static library archiver")
- local rc = toolchain("the rust compiler")
- local rc_ld = toolchain("the rust linker")
- local rc_sh = toolchain("the rust shared library linker")
- local rc_ar = toolchain("the rust static library archiver")
- local cu = toolchain("the cuda compiler")
- local cu_ld = toolchain("the cuda linker")
- local cu_ccbin = toolchain("the cuda host c++ compiler")
- local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil,
- mm = mm, mxx = mxx, sc = sc, ["scld"] = sc_ld, ["scsh"] = sc_sh,
- gc = gc, ["gcld"] = gc_ld, ["gcar"] = gc_ar,
- dc = dc, ["dcld"] = dc_ld, ["dcsh"] = dc_sh, ["dcar"] = dc_ar,
- rc = rc, ["rcld"] = rc_ld, ["rcsh"] = rc_sh, ["rcar"] = rc_ar,
- cu = cu, ["cu-ld"] = cu_ld, ["cu-ccbin"] = cu_ccbin}
-
- -- init the c compiler
- cc:add("$(env CC)", {name = "clang", cross = cross}, "clang", "gcc")
-
- -- init the c++ compiler
- cxx:add("$(env CXX)")
- cxx:add({name = "clang", cross = cross})
- cxx:add({name = "clang++", cross = cross})
- cxx:add("clang", "clang++", "gcc", "g++")
-
- -- init the assember
- as:add("$(env AS)", {name = "clang", cross = cross}, "clang", "gcc")
-
- -- init the linker
- ld:add("$(env LD)", "$(env CXX)")
- ld:add({name = "clang++", cross = cross})
- ld:add({name = "clang", cross = cross})
- ld:add("clang++", "g++", "clang", "gcc")
-
- -- init the shared library linker
- sh:add("$(env SH)", "$(env CXX)")
- sh:add({name = "clang++", cross = cross})
- sh:add({name = "clang", cross = cross})
- sh:add("clang++", "g++", "clang", "gcc")
-
- -- init the static library archiver
- ar:add("$(env AR)", {name = "ar", cross = cross}, "ar")
-
- -- init the static library extractor
- ex:add({name = "ar", cross = cross}, "ar")
-
- -- init the symbols stripper
- strip:add({name = "strip", cross = cross}, "strip")
-
- -- init the symbols generator
- dsymutil:add({name = "dsymutil", cross = cross}, "dsymutil")
-
- -- init the objc compiler
- mm:add("$(env MM)", {name = "clang", cross = cross}, "clang", "gcc")
-
- -- init the objc++ compiler
- mxx:add("$(env MXX)")
- mxx:add({name = "clang", cross = cross})
- mxx:add({name = "clang++", cross = cross})
- mxx:add("clang", "clang++", "gcc", "g++")
-
- -- init the swift compiler and linker
- sc:add("$(env SC)", {name = "swiftc", cross = cross}, "swiftc")
- sc_ld:add("$(env SC)", {name = "swiftc", cross = cross}, "swiftc")
- sc_sh:add("$(env SC)", {name = "swiftc", cross = cross}, "swiftc")
-
- -- init the golang compiler and linker
- gc:add("$(env GC)", "go", "gccgo")
- gc_ld:add("$(env GC)", "go", "gccgo")
- gc_ar:add("$(env GC)", "go", "gccgo")
-
- -- init the dlang compiler and linker
- dc:add("$(env DC)", "dmd", "ldc2", "gdc")
- dc_ld:add("$(env DC)", "dmd", "ldc2", "gdc")
- dc_sh:add("$(env DC)", "dmd", "ldc2", "gdc")
- dc_ar:add("$(env DC)", "dmd", "ldc2", "gdc")
-
- -- init the rust compiler and linker
- rc:add("$(env RC)", "rustc")
- rc_ld:add("$(env RC)", "rustc")
- rc_sh:add("$(env RC)", "rustc")
- rc_ar:add("$(env RC)", "rustc")
-
- -- init the cuda compiler and linker
- cu:add("nvcc", "clang")
- cu_ld:add("nvcc")
- cu_ccbin:add("$(env CXX)", "$(env CC)", "clang", "gcc")
-
- return toolchains
-end]]
-
-- check it
function main(platform)
diff --git a/xmake/platforms/watchos/check.lua b/xmake/platforms/watchos/check.lua
index 89086d74c..e4e36f092 100644
--- a/xmake/platforms/watchos/check.lua
+++ b/xmake/platforms/watchos/check.lua
@@ -20,105 +20,20 @@
-- imports
import("core.project.config")
-import("core.base.singleton")
-import("private.platform.toolchain")
import("private.platform.check_arch")
-import("private.platform.check_xcode")
-import("private.platform.check_toolchain")
-
--- get toolchains
-function _toolchains()
-
- -- init architecture
- local arch = config.get("arch")
- local simulator = (arch == "i386")
-
- -- init cross
- local cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos "
-
- -- init toolchains
- local cc = toolchain("the c compiler")
- local cxx = toolchain("the c++ compiler")
- local ld = toolchain("the linker")
- local sh = toolchain("the shared library linker")
- local ar = toolchain("the static library archiver")
- local ex = toolchain("the static library extractor")
- local strip = toolchain("the symbols stripper")
- local dsymutil = toolchain("the symbols generator")
- local mm = toolchain("the objc compiler")
- local mxx = toolchain("the objc++ compiler")
- local as = toolchain("the assember")
- local sc = toolchain("the swift compiler")
- local sc_ld = toolchain("the swift linker")
- local sc_sh = toolchain("the swift shared library linker")
- local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil,
- mm = mm, mxx = mxx, sc = sc, ["scld"] = sc_ld, ["scsh"] = sc_sh}
-
- -- init the c compiler
- cc:add({name = "clang", cross = cross})
-
- -- init the c++ compiler
- cxx:add({name = "clang", cross = cross})
- cxx:add({name = "clang++", cross = cross})
-
- -- init the assember
- if simulator then
- as:add({name = "clang", cross = cross})
- else
- as:add({name = "clang", cross = path.join(os.programdir(), "scripts", "gas-preprocessor.pl " .. cross)})
- end
-
- -- init the linker
- ld:add({name = "clang++", cross = cross})
- ld:add({name = "clang", cross = cross})
-
- -- init the shared library linker
- sh:add({name = "clang++", cross = cross})
- sh:add({name = "clang", cross = cross})
-
- -- init the static library archiver
- ar:add({name = "ar", cross = cross})
-
- -- init the static library extractor
- ex:add({name = "ar", cross = cross})
-
- -- init the symbols stripper
- strip:add({name = "strip", cross = cross})
-
- -- init the symbols generator
- dsymutil:add({name = "dsymutil", cross = cross})
-
- -- init the objc compiler
- mm:add({name = "clang", cross = cross})
-
- -- init the objc++ compiler
- mxx:add({name = "clang", cross = cross})
- mxx:add({name = "clang++", cross = cross})
-
- -- init the swift compiler and linker
- sc:add({name = "swiftc", cross = cross})
- sc_ld:add({name = "swiftc", cross = cross})
- sc_sh:add({name = "swiftc", cross = cross})
-
- return toolchains
-end
-- check it
-function main(platform, name)
-
- -- only check the given config name?
- if name then
- local toolchain = singleton.get("watchos.toolchains", _toolchains)[name]
- if toolchain then
- check_toolchain(config, name, toolchain)
- end
- else
+function main(platform)
- -- check arch
- check_arch(config, "armv7k")
+ -- check arch
+ check_arch(config, "armv7k")
- -- check xcode
- check_xcode(config)
+ -- check toolchains
+ local toolchains = platform:toolchains()
+ for idx, toolchain in irpairs(toolchains) do
+ if not toolchain:check() then
+ table.remove(toolchains, idx)
+ end
end
+ assert(#toolchains > 0, "toolchains not found!")
end
-