diff options
| author | ruki <[email protected]> | 2017-02-22 00:04:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-02-22 00:04:47 +0800 |
| commit | 07090c9dcd4c9deb42b2f8aa47072a9f8c518d85 (patch) | |
| tree | b29b649000e0404927d67c9a68545eb4cb2d0ab5 | |
| parent | 06e5d287750d029f1458f2fa2f88733238cf93eb (diff) | |
improve swfitc tool
| -rwxr-xr-x | xmake/languages/golang/xmake.lua | 2 | ||||
| -rwxr-xr-x | xmake/languages/swift/xmake.lua | 31 | ||||
| -rw-r--r-- | xmake/platforms/macosx/check.lua | 13 | ||||
| -rw-r--r-- | xmake/platforms/macosx/load.lua | 3 | ||||
| -rw-r--r-- | xmake/tools/swiftc.lua | 53 |
5 files changed, 69 insertions, 33 deletions
diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua index 2a52e353e..e1939dec7 100755 --- a/xmake/languages/golang/xmake.lua +++ b/xmake/languages/golang/xmake.lua @@ -106,6 +106,6 @@ language("golang") , {nil, "links", "kv", nil, "The Link Libraries" } , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } , {nil, "includedirs","kv", nil, "The Include Search Directories" } - } + } } diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index 4af71bc15..f031069cb 100755 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -32,7 +32,7 @@ language("swift") set_sourceflags {sc = "scflags"} -- set target kinds - set_targetkinds {binary = "ld", static = "ar", shared = "sh"} + set_targetkinds {binary = "sc-ld", static = "ar", shared = "sc-sh"} -- set target flags set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"} @@ -121,27 +121,16 @@ language("swift") set_menu { config = { - {} - , {nil, "sc", "kv", nil, "The Swift Compiler" } - , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" } + { } + , { nil, "sc", "kv", nil, "The Swift Compiler" } + , { nil, "sc-ld", "kv", nil, "The Swift Linker" } + , { nil, "sc-sh", "kv", nil, "The Swift Shared Library Linker" } - , {} - , {nil, "ld", "kv", nil, "The Linker" } - , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" } - - , {} - , {nil, "ar", "kv", nil, "The Static Library Linker" } - , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } - - , {} - , {nil, "sh", "kv", nil, "The Shared Library Linker" } - , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } - - , {} - , {nil, "links", "kv", nil, "The Link Libraries" } - , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } - , {nil, "includedirs","kv", nil, "The Include Search Directories" } - , {nil, "frameworks", "kv", nil, "The Link Frameworks" } + , { } + , { nil, "links", "kv", nil, "The Link Libraries" } + , { nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , { nil, "includedirs","kv", nil, "The Include Search Directories" } + , { nil, "frameworks", "kv", nil, "The Link Frameworks" } } } diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua index a18a83cdf..bd8cd86f3 100644 --- a/xmake/platforms/macosx/check.lua +++ b/xmake/platforms/macosx/check.lua @@ -48,7 +48,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "mm", "xcrun -sdk macosx ", "clang", "the objc compiler") checker.check_toolchain(config, "mxx", "xcrun -sdk macosx ", "clang++", "the objc++ compiler") checker.check_toolchain(config, "mxx", "xcrun -sdk macosx ", "clang", "the objc++ compiler") - checker.check_toolchain(config, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler") checker.check_toolchain(config, "as", "xcrun -sdk macosx ", "clang", "the assember") checker.check_toolchain(config, "ld", "xcrun -sdk macosx ", "clang++", "the linker") checker.check_toolchain(config, "ld", "xcrun -sdk macosx ", "clang", "the linker") @@ -65,7 +64,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "mm", "", "clang", "the objc compiler") checker.check_toolchain(config, "mxx", "", "clang++", "the objc++ compiler") checker.check_toolchain(config, "mxx", "", "clang", "the objc++ compiler") - checker.check_toolchain(config, "sc", "", "swiftc", "the swift compiler") checker.check_toolchain(config, "as", "", "clang", "the assember") checker.check_toolchain(config, "ld", "", "clang++", "the linker") checker.check_toolchain(config, "ld", "", "clang", "the linker") @@ -75,6 +73,17 @@ function _check_toolchains(config) checker.check_toolchain(config, "sh", "", "clang", "the shared library linker") checker.check_toolchain(config, "dg", "", "lldb", "the debugger") + -- check for swift tools + checker.check_toolchain_from_env(config, "sc", "SC", "the swift compiler") + checker.check_toolchain(config, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler") + checker.check_toolchain(config, "sc", "", "swiftc", "the swift compiler") + checker.check_toolchain_from_env(config, "sc-ld", "SC", "the swift linker") + checker.check_toolchain(config, "sc-ld", "xcrun -sdk macosx ", "swiftc", "the swift linker") + checker.check_toolchain(config, "sc-ld", "", "swiftc", "the swift linker") + checker.check_toolchain_from_env(config, "sc-sh", "SC", "the swift shared library linker") + checker.check_toolchain(config, "sc-sh", "xcrun -sdk macosx ", "swiftc", "the swift shared library linker") + checker.check_toolchain(config, "sc-sh", "", "swiftc", "the swift shared library linker") + -- check for golang tools checker.check_toolchain(config, "go", "", "go", "the golang compiler") checker.check_toolchain(config, "go", "", "gccgo", "the golang compiler") diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua index 5496ed844..9cf0711b7 100644 --- a/xmake/platforms/macosx/load.lua +++ b/xmake/platforms/macosx/load.lua @@ -57,7 +57,8 @@ function main() -- init flags for swift (with _g.ldflags and _g.shflags) _g.scflags = { format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx") + _g["sc-shflags"] = {} + _g["sc-ldflags"] = {} -- init flags for golang _g["go-ldflags"] = {} diff --git a/xmake/tools/swiftc.lua b/xmake/tools/swiftc.lua index 74f7e8974..f006b4c14 100644 --- a/xmake/tools/swiftc.lua +++ b/xmake/tools/swiftc.lua @@ -72,18 +72,24 @@ end -- get the property function get(name) - -- init ldflags - if not _g.ldflags then - local swift_linkdirs = config.get("__swift_linkdirs") - if swift_linkdirs then - _g.ldflags = { "-L" .. swift_linkdirs } - end - end - -- get it return _g[name] end +-- make the strip flag +function nf_strip(level) + + -- the maps + local maps = + { + debug = "-Xlinker -S" + , all = "-Xlinker -s" + } + + -- make it + return maps[level] or "" +end + -- make the symbol flag function nf_symbol(level) @@ -180,6 +186,37 @@ function nf_framework(framework) return "-framework" .. framework end +-- make the link flag +function nf_link(lib) + + -- make it + return "-l" .. lib +end + +-- make the linkdir flag +function nf_linkdir(dir) + + -- make it + return "-L" .. dir +end + +-- make the link command +function linkcmd(objectfiles, targetkind, targetfile, flags) + + -- make it + return format("%s -o %s %s %s", _g.shellname, targetfile, objectfiles, flags) +end + +-- link the target file +function link(objectfiles, targetkind, targetfile, flags) + + -- ensure the target directory + os.mkdir(path.directory(targetfile)) + + -- link it + os.run(linkcmd(objectfiles, targetkind, targetfile, flags)) +end + -- make the compile command function _compcmd1(sourcefile, objectfile, flags) |
