summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-15 20:45:27 +0800
committerruki <[email protected]>2017-02-15 20:45:27 +0800
commitb98e6978cd6514169c7f0fea4ab6ba63a093754c (patch)
tree087de92610444ebe2eb2153219974c563924a192
parentdfce526796ade25d4da69c2542929e9c4662402a (diff)
modify targetfile
-rw-r--r--xmake/core/platform/platform.lua6
-rw-r--r--xmake/core/project/target.lua26
-rw-r--r--xmake/core/tool/builder.lua6
-rwxr-xr-xxmake/tools/go.lua10
4 files changed, 24 insertions, 24 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index c090744cc..ac2f87a0a 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -293,13 +293,13 @@ function platform.tooldirs(plat)
return platform.get("tooldirs", plat)
end
--- get the given format
-function platform.format(kind)
+-- get the format of the given target kind for platform
+function platform.format(targetkind)
-- get formats
local formats = platform.get("formats")
if formats then
- return formats[kind]
+ return formats[targetkind]
end
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 35b98c4eb..0975e4eac 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -37,17 +37,17 @@ local compiler = require("tool/compiler")
local platform = require("platform/platform")
local language = require("language/language")
--- get the filename from the given name and kind
-function target.filename(name, kind)
+-- get the filename from the given target name and kind
+function target.filename(targetname, targetkind, targetformat)
-- check
- assert(name and kind)
+ assert(targetname and targetkind)
-- get format
- local format = platform.format(kind) or {"", ""}
+ local format = targetformat or platform.format(targetkind) or {"", ""}
-- make it
- return format[1] .. name .. format[2]
+ return format[1] .. targetname .. format[2]
end
-- get the target info
@@ -76,7 +76,7 @@ function target:linker()
end
-- get the linker instance
- local instance, errors = linker.load(self:get("kind"), self:sourcekinds())
+ local instance, errors = linker.load(self:targetkind(), self:sourcekinds())
if not instance then
os.raise(errors)
end
@@ -148,6 +148,13 @@ function target:objectdir()
return objectdir
end
+-- get the target kind
+function target:targetkind()
+
+ -- get it
+ return self:get("kind")
+end
+
-- get the target file
function target:targetfile()
@@ -158,8 +165,11 @@ function target:targetfile()
local targetdir = self:get("targetdir") or config.get("buildir")
assert(targetdir and type(targetdir) == "string")
- -- the target file name
- local filename = target.filename(self:name(), self:get("kind"))
+ -- get target kind
+ local targetkind = self:targetkind()
+
+ -- make the target file name and attempt to use the format of linker first
+ local filename = target.filename(self:name(), targetkind, self:linker():format(targetkind))
assert(filename)
-- make the target file path
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index 19d462551..f8edcd12d 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -225,13 +225,13 @@ function builder:get(name)
return self:_tool().get(name)
end
--- get the format of the given file kind
-function builder:format(kind)
+-- get the format of the given target kind
+function builder:format(targetkind)
-- get formats
local formats = self:get("formats")
if formats then
- return formats[kind]
+ return formats[targetkind]
end
end
diff --git a/xmake/tools/go.lua b/xmake/tools/go.lua
index 154676e89..da777bdd9 100755
--- a/xmake/tools/go.lua
+++ b/xmake/tools/go.lua
@@ -86,16 +86,6 @@ function archivecmd(objectfiles, targetfile, flags)
return format("%s tool pack %s %s %s", _g.shellname, flags, targetfile, objectfiles)
end
--- archive the library file
-function archive(objectfiles, targetfile, flags)
-
- -- ensure the target directory
- os.mkdir(path.directory(targetfile))
-
- -- link it
- os.run(archivecmd(objectfiles, targetfile, flags))
-end
-
-- link the target file
function link(objectfiles, targetfile, flags)