summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-03 14:11:09 +0800
committerruki <[email protected]>2016-07-03 14:11:09 +0800
commitbde33e64c9c036589c6f13d94bf577509fceb28d (patch)
tree69b0a2f3bf30e376cb73e19d315a22fb1335791b
parent383c46c282fe0fcd82e2bc8a2d227cd0528af262 (diff)
fix check ar failed for windows
-rwxr-xr-xxmake/actions/build/builder.lua4
-rw-r--r--xmake/core/project/option.lua8
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua7
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/linker.lua7
-rw-r--r--xmake/core/tool/compiler.lua12
-rw-r--r--xmake/core/tool/linker.lua12
-rwxr-xr-xxmake/plugins/project/makefile.lua4
-rw-r--r--xmake/tools/ar.lua28
8 files changed, 58 insertions, 24 deletions
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua
index ee4c7eb5f..9ecbd4b25 100755
--- a/xmake/actions/build/builder.lua
+++ b/xmake/actions/build/builder.lua
@@ -92,7 +92,7 @@ function _build_object(target, index)
end
-- make command
- local command = compiler.command(target, sourcefile, objectfile)
+ local command = compiler.compcmd(sourcefile, objectfile, target)
-- uses ccache
local ccache = nil
@@ -194,7 +194,7 @@ function _build_target(target)
-- make the command for linking target
local targetfile = target:targetfile()
- local command = linker.command(target)
+ local command = linker.linkcmd(target:objectfiles(), targetfile, target)
-- trace
print("[%02d%%]: linking.$(mode) %s", _g.targetindex * 100 / _g.targetcount, path.filename(targetfile))
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index 6d1b86f06..b1b1e13fd 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -52,7 +52,7 @@ function option:_check_link(sourcefile, objectfile, targetfile)
end
-- attempt to run this command
- local ok, errors = instance:run(instance:command(self, objectfile, targetfile))
+ local ok, errors = instance:run(instance:linkcmd(objectfile, targetfile, self))
if not ok and option_.get("verbose") then
print(errors)
end
@@ -94,7 +94,7 @@ function option:_check_include(include, srcpath, objpath)
end
-- attempt to run this command
- local ok, errors = instance:run(instance:command(self, srcpath, objpath))
+ local ok, errors = instance:run(instance:compcmd(srcpath, objpath, self))
if not ok and option_.get("verbose") then
print(errors)
end
@@ -150,7 +150,7 @@ function option:_check_function(interface, srcpath, objpath)
srcfile:close()
-- execute the compile command
- local ok, errors = instance:run(instance:command(self, srcpath, objpath))
+ local ok, errors = instance:run(instance:compcmd(srcpath, objpath, self))
if not ok and option_.get("verbose") then
print(errors)
end
@@ -204,7 +204,7 @@ function option:_check_typedef(typedef, srcpath, objpath)
srcfile:close()
-- execute the compile command
- local ok, errors = instance:run(instance:command(self, srcpath, objpath))
+ local ok, errors = instance:run(instance:compcmd(srcpath, objpath, self))
if not ok and option_.get("verbose") then
print(errors)
end
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index 1eb4603e6..bf231f7b4 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -25,19 +25,20 @@ local sandbox_core_tool_compiler = sandbox_core_tool_compiler or {}
-- load modules
local platform = require("platform/platform")
+local compiler = require("tool/compiler")
local raise = require("sandbox/modules/raise")
-- make command for compiling source file
-function sandbox_core_tool_compiler.command(target, sourcefile, objectfile, logfile)
+function sandbox_core_tool_compiler.compcmd(sourcefile, objectfile, target)
-- get the compiler instance
- local instance, errors = target:compiler(sourcefile)
+ local instance, errors = compiler.load(compiler.kind_of_file(sourcefile))
if not instance then
raise(errors)
end
-- make command
- return instance:command(target, sourcefile, objectfile, logfile)
+ return instance:compcmd(sourcefile, objectfile, target)
end
-- return module
diff --git a/xmake/core/sandbox/modules/import/core/tool/linker.lua b/xmake/core/sandbox/modules/import/core/tool/linker.lua
index 1e1249832..9f42a04e7 100644
--- a/xmake/core/sandbox/modules/import/core/tool/linker.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/linker.lua
@@ -25,19 +25,20 @@ local sandbox_core_tool_linker = sandbox_core_tool_linker or {}
-- load modules
local platform = require("platform/platform")
+local linker = require("tool/linker")
local raise = require("sandbox/modules/raise")
-- make command for linking target file
-function sandbox_core_tool_linker.command(target)
+function sandbox_core_tool_linker.linkcmd(objectfiles, targetfile, target)
-- get the linker instance
- local instance, errors = target:linker()
+ local instance, errors = linker.load(target:get("kind"))
if not instance then
raise(errors)
end
-- make command
- return instance:command(target, target:objectfiles(), target:targetfile())
+ return instance:linkcmd(objectfiles, targetfile, target)
end
-- return module
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index f2a3c6147..7d867a6d2 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -398,11 +398,17 @@ function compiler:get(name)
return self:_tool().get(name)
end
--- get the command
-function compiler:command(target, srcfile, objfile, logfile)
+-- get the compile command
+function compiler:compcmd(srcfile, objfile, target)
+
+ -- get flags
+ local flags = nil
+ if target then
+ flags = self:_flags(target)
+ end
-- get it
- return self:_tool().compcmd(srcfile, objfile, self:_flags(target), logfile)
+ return self:_tool().compcmd(srcfile, objfile, flags or "")
end
-- make the define flag
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 52d1e7b72..e0959702c 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -332,11 +332,17 @@ function linker:get(name)
return self:_tool().get(name)
end
--- get the command
-function linker:command(target, objfiles, targetfile, logfile)
+-- get the link command
+function linker:linkcmd(objfiles, targetfile, target)
+
+ -- get flags
+ local flags = nil
+ if target then
+ flags = self:_flags(target)
+ end
-- get it
- return self:_tool().linkcmd(table.concat(table.wrap(objfiles), " "), targetfile, self:_flags(target), logfile)
+ return self:_tool().linkcmd(table.concat(table.wrap(objfiles), " "), targetfile, flags or "")
end
-- make the link flag
diff --git a/xmake/plugins/project/makefile.lua b/xmake/plugins/project/makefile.lua
index 2fe7ffd93..60455ca6d 100755
--- a/xmake/plugins/project/makefile.lua
+++ b/xmake/plugins/project/makefile.lua
@@ -78,7 +78,7 @@ function _make_object(makefile, target, srcfile, objfile)
-- make command
local ccache = tool.shellname("ccache")
- local command = compiler.command(target, srcfile, objfile)
+ local command = compiler.compcmd(srcfile, objfile, target)
if ccache then
command = ccache:append(command, " ")
end
@@ -140,7 +140,7 @@ function _make_target(makefile, target)
makefile:print("")
-- make the command
- local command = linker.command(target)
+ local command = linker.linkcmd(target:objectfiles, targetfile, target)
-- make body
makefile:print("\t@echo linking.$(mode) %s", path.filename(targetfile))
diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua
index 64161a901..df9325763 100644
--- a/xmake/tools/ar.lua
+++ b/xmake/tools/ar.lua
@@ -20,6 +20,9 @@
-- @file ar.lua
--
+-- imports
+import("core.tool.compiler")
+
-- init it
function init(shellname, kind)
@@ -100,9 +103,26 @@ end
-- check the given flags
function check(flags)
- -- check it
- local ok = os.execute("%s %s > %s 2>&1", _g.shellname, ifelse(flags, flags, ""), os.nuldev())
- if ok ~= 0 and ok ~= 256 then
- raise("not found!")
+ -- make an stub source file
+ local libfile = path.join(os.tmpdir(), "xmake.ar.a")
+ local objfile = path.join(os.tmpdir(), "xmake.ar.o")
+ local srcfile = path.join(os.tmpdir(), "xmake.ar.c")
+ io.write(srcfile, "int test(void)\n{return 0;}")
+
+ -- make flags
+ local arflags = table.concat(_g.arflags, " ")
+ if flags then
+ arflags = arflags .. " " .. flags
end
+
+ -- make the compile command
+ os.run(compiler.compcmd(srcfile, objfile))
+
+ -- check it
+ os.run(linkcmd(objfile, libfile, arflags))
+
+ -- remove files
+ os.rm(objfile)
+ os.rm(srcfile)
+ os.rm(libfile)
end