summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-17 20:02:00 +0800
committerruki <[email protected]>2017-02-17 20:02:00 +0800
commit6fcb7f953c4c397b7e08bf577f37195508663260 (patch)
tree72d63622b2c4a84079d88c3d2f40aab86f032156
parentbd54ed5a6c59f75ad768d4d37843262314dd1aa1 (diff)
build go project ok
-rw-r--r--xmake/core/tool/builder.lua7
-rw-r--r--xmake/core/tool/compiler.lua5
-rw-r--r--xmake/core/tool/linker.lua7
-rwxr-xr-xxmake/languages/golang/xmake.lua16
-rw-r--r--xmake/platforms/macosx/check.lua34
-rw-r--r--xmake/tools/ar.lua14
-rwxr-xr-xxmake/tools/gcc.lua6
-rwxr-xr-xxmake/tools/go.lua32
-rwxr-xr-xxmake/tools/link.lua6
9 files changed, 65 insertions, 62 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index f8edcd12d..f1335df68 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -52,6 +52,13 @@ function builder:_nameflags()
return self._NAMEFLAGS
end
+-- get the target kind
+function builder:_targetkind()
+
+ -- get it
+ return self._TARGETKIND
+end
+
-- map gcc flag to the given builder flag
function builder:_mapflag(flag, mapflags)
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 7d6d133be..b932a9ed3 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -91,8 +91,11 @@ function compiler.load(sourcekind)
end
instance._LANGUAGE = result
+ -- init target kind
+ instance._TARGETKIND = "object"
+
-- init name flags
- instance._NAMEFLAGS = result:nameflags()["object"]
+ instance._NAMEFLAGS = result:nameflags()[instance:_targetkind()]
-- init flag kinds
instance._FLAGKINDS = table.wrap(result:sourceflags()[sourcekind])
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 50ac0db7e..d438eb54a 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -122,6 +122,9 @@ function linker.load(targetkind, sourcekinds)
end
instance._NAMEFLAGS = nameflags
+ -- init target kind
+ instance._TARGETKIND = targetkind
+
-- init flag kinds
instance._FLAGKINDS = {linkerinfo.flag}
@@ -136,14 +139,14 @@ end
function linker:link(objectfiles, targetfile, target)
-- link it
- return sandbox.load(self:_tool().link, table.concat(table.wrap(objectfiles), " "), targetfile, (self:linkflags(target)))
+ return sandbox.load(self:_tool().link, table.concat(table.wrap(objectfiles), " "), self:_targetkind(), targetfile, (self:linkflags(target)))
end
-- get the link command
function linker:linkcmd(objectfiles, targetfile, target)
-- get it
- return self:_tool().linkcmd(table.concat(table.wrap(objectfiles), " "), targetfile, (self:linkflags(target)))
+ return self:_tool().linkcmd(table.concat(table.wrap(objectfiles), " "), self:_targetkind(), targetfile, (self:linkflags(target)))
end
-- get the link flags
diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua
index 691f89be0..04f915e5e 100755
--- a/xmake/languages/golang/xmake.lua
+++ b/xmake/languages/golang/xmake.lua
@@ -32,10 +32,10 @@ language("golang")
set_sourceflags {go = "goflags"}
-- set target kinds
- set_targetkinds {binary = "go", static = "go", shared = "go"}
+ set_targetkinds {binary = "go-ld", static = "go-ar"}
-- set target flags
- set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"}
+ set_targetflags {binary = "go-ldflags", static = "go-arflags"}
-- on load
on_load("load")
@@ -102,16 +102,12 @@ language("golang")
, {nil, "goflags", "kv", nil, "The Golang Compiler Flags" }
, {}
- , {nil, "ld", "kv", nil, "The Linker" }
- , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
+ , {nil, "go-ld", "kv", nil, "The Linker" }
+ , {nil, "go-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, "go-ar", "kv", nil, "The Static Library Linker" }
+ , {nil, "go-arflags", "kv", nil, "The Static Library Linker Flags" }
, {}
, {nil, "links", "kv", nil, "The Link Libraries" }
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 4e216d4d9..43c17f7b3 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -60,22 +60,24 @@ function _check_toolchains(config)
checker.check_toolchain(config, "dd", "xcrun -sdk macosx ", "lldb", "the debugger")
-- check without xcrun
- checker.check_toolchain(config, "cc", "", "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", "", "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", "", "clang++", "the c++ compiler")
- 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, "go", "", "go", "the golang 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")
- checker.check_toolchain(config, "ar", "", "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", "", "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", "", "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", "", "clang", "the shared library linker")
- checker.check_toolchain(config, "dd", "", "lldb", "the debugger")
+ checker.check_toolchain(config, "cc", "", "clang", "the c compiler")
+ checker.check_toolchain(config, "cxx", "", "clang", "the c++ compiler")
+ checker.check_toolchain(config, "cxx", "", "clang++", "the c++ compiler")
+ 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, "go", "", "go", "the golang compiler")
+ checker.check_toolchain(config, "go-ar","", "go", "the golang archiver")
+ checker.check_toolchain(config, "go-ld","", "go", "the golang linker")
+ 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")
+ checker.check_toolchain(config, "ar", "", "ar", "the static library archiver")
+ checker.check_toolchain(config, "ex", "", "ar", "the static library extractor")
+ checker.check_toolchain(config, "sh", "", "clang++", "the shared library linker")
+ checker.check_toolchain(config, "sh", "", "clang", "the shared library linker")
+ checker.check_toolchain(config, "dd", "", "lldb", "the debugger")
end
-- check it
diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua
index dfecc9340..4c82a7c5b 100644
--- a/xmake/tools/ar.lua
+++ b/xmake/tools/ar.lua
@@ -61,20 +61,26 @@ function strip(level)
end
-- make the link command
-function linkcmd(objectfiles, targetfile, flags)
+function linkcmd(objectfiles, targetkind, targetfile, flags)
+
+ -- check
+ assert(targetkind == "static")
-- make it
return format("%s %s %s %s", _g.shellname, flags, targetfile, objectfiles)
end
-- link the library file
-function link(objectfiles, targetfile, flags)
+function link(objectfiles, targetkind, targetfile, flags)
+
+ -- check
+ assert(targetkind == "static", "the target kind: %s is not support for ar", targetkind)
-- ensure the target directory
os.mkdir(path.directory(targetfile))
-- link it
- os.run(linkcmd(objectfiles, targetfile, flags))
+ os.run(linkcmd(objectfiles, targetkind, targetfile, flags))
end
-- extract the static library to object directory
@@ -125,7 +131,7 @@ function check(flags)
compiler.compile(sourcefile, objectfile)
-- check it
- link(objectfile, libraryfile, arflags)
+ link(objectfile, "static", libraryfile, arflags)
-- remove files
os.rm(objectfile)
diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua
index 2283a08e2..281064a2b 100755
--- a/xmake/tools/gcc.lua
+++ b/xmake/tools/gcc.lua
@@ -245,20 +245,20 @@ function nf_framework(framework)
end
-- make the link command
-function linkcmd(objectfiles, targetfile, flags)
+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, targetfile, flags)
+function link(objectfiles, targetkind, targetfile, flags)
-- ensure the target directory
os.mkdir(path.directory(targetfile))
-- link it
- os.run(linkcmd(objectfiles, targetfile, flags))
+ os.run(linkcmd(objectfiles, targetkind, targetfile, flags))
end
-- make the complie command
diff --git a/xmake/tools/go.lua b/xmake/tools/go.lua
index da777bdd9..578a49f6a 100755
--- a/xmake/tools/go.lua
+++ b/xmake/tools/go.lua
@@ -38,7 +38,7 @@ function init(shellname, kind)
_g.kind = kind
-- init arflags
- _g.arflags = { "grc" }
+ _g["go-arflags"] = { "grc" }
-- init the file formats
_g.formats = {}
@@ -73,37 +73,24 @@ function nf_linkdir(dir)
end
-- make the link command
-function linkcmd(objectfiles, targetfile, flags)
+function linkcmd(objectfiles, targetkind, targetfile, flags)
-- make it
- return format("%s tool link %s -o %s %s", _g.shellname, flags, targetfile, objectfiles)
-end
-
--- make the archive command
-function archivecmd(objectfiles, targetfile, flags)
-
- -- make it
- return format("%s tool pack %s %s %s", _g.shellname, flags, targetfile, objectfiles)
+ if targetkind == "static" then
+ return format("%s tool pack %s %s %s", _g.shellname, flags, targetfile, objectfiles)
+ else
+ return format("%s tool link %s -o %s %s", _g.shellname, flags, targetfile, objectfiles)
+ end
end
-- link the target file
-function link(objectfiles, targetfile, flags)
-
- -- ensure the target directory
- os.mkdir(path.directory(targetfile))
-
- -- link it
- os.run(linkcmd(objectfiles, targetfile, flags))
-end
-
--- archive the library file
-function archive(objectfiles, targetfile, flags)
+function link(objectfiles, targetkind, targetfile, flags)
-- ensure the target directory
os.mkdir(path.directory(targetfile))
-- link it
- os.run(archivecmd(objectfiles, targetfile, flags))
+ os.run(linkcmd(objectfiles, targetkind, targetfile, flags))
end
-- make the complie command
@@ -140,4 +127,3 @@ function check(flags)
os.rm(objectfile)
os.rm(sourcefile)
end
-
diff --git a/xmake/tools/link.lua b/xmake/tools/link.lua
index c6413b04f..822bc3f0f 100755
--- a/xmake/tools/link.lua
+++ b/xmake/tools/link.lua
@@ -103,7 +103,7 @@ function nf_linkdir(dir)
end
-- make the link command
-function linkcmd(objectfiles, targetfile, flags)
+function linkcmd(objectfiles, targetkind, targetfile, flags)
-- make it
local cmd = format("%s %s -out:%s %s", _g.shellname, flags, targetfile, objectfiles)
@@ -120,13 +120,13 @@ function linkcmd(objectfiles, targetfile, flags)
end
-- link the target file
-function link(objectfiles, targetfile, flags)
+function link(objectfiles, targetkind, targetfile, flags)
-- ensure the target directory
os.mkdir(path.directory(targetfile))
-- link it
- os.run(linkcmd(objectfiles, targetfile, flags))
+ os.run(linkcmd(objectfiles, targetkind, targetfile, flags))
end
-- check the given flags