summaryrefslogtreecommitdiff
path: root/xmake/plugins/project/makefile.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-12 08:46:07 +0800
committerruki <[email protected]>2016-07-12 08:46:07 +0800
commitc4ed00d99526c87e083bcd9e8310fbb759245b7f (patch)
tree9a167100c4386199851e815a428873f0397fafac /xmake/plugins/project/makefile.lua
parent45e1839ea78bdff05460bdfb8d619325419274d6 (diff)
improve to generate makefile
Diffstat (limited to 'xmake/plugins/project/makefile.lua')
-rwxr-xr-xxmake/plugins/project/makefile.lua33
1 files changed, 27 insertions, 6 deletions
diff --git a/xmake/plugins/project/makefile.lua b/xmake/plugins/project/makefile.lua
index 61300eb4c..fe3d5b0eb 100755
--- a/xmake/plugins/project/makefile.lua
+++ b/xmake/plugins/project/makefile.lua
@@ -35,6 +35,30 @@ function _logfile()
return vformat("$(buildir)/.build.log")
end
+-- mkdir directory
+function _mkdir(makefile, dir)
+
+ if config.get("plat") == "windows" then
+ makefile:print("\t-@mkdir %s > /null 2>&1", dir)
+ else
+ makefile:print("\t@mkdir -p %s", dir)
+ end
+end
+
+-- copy file
+function _cp(makefile, srcfile, dstfile)
+
+ -- ensure the destinate directory
+ _mkdir(makefile, path.directory(dstfile))
+
+ -- copy file
+ if config.get("plat") == "windows" then
+ makefile:print("\t@copy /Y %s %s > /null 2>&1", srcfile, dstfile)
+ else
+ makefile:print("\t@cp %s %s", srcfile, dstfile)
+ end
+end
+
-- make the object for the *.[o|obj] source file
function _make_object_for_object(makefile, target, srcfile, objfile)
@@ -49,7 +73,6 @@ function _make_object_for_object(makefile, target, srcfile, objfile)
-- make body
makefile:print("\t@echo inserting.$(mode) %s", srcfile)
- makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", cmd:encode())
makefile:print("\t@%s", cmd)
-- make tail
@@ -89,8 +112,7 @@ function _make_object(makefile, target, srcfile, objfile)
-- make body
makefile:print("\t@echo %scompiling.$(mode) %s", ifelse(config.get("ccache"), "ccache ", ""), srcfile)
- makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", command:encode())
- makefile:print("\t@xmake l mkdir %s", path.directory(objfile))
+ _mkdir(makefile, path.directory(objfile))
makefile:print("\t@%s > %s 2>&1", command, _logfile())
-- make tail
@@ -147,8 +169,7 @@ function _make_target(makefile, target)
-- make body
makefile:print("\t@echo linking.$(mode) %s", path.filename(targetfile))
- makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", command:encode())
- makefile:print("\t@xmake l mkdir %s", path.directory(targetfile))
+ _mkdir(makefile, path.directory(targetfile))
makefile:print("\t@%s > %s 2>&1", command, _logfile())
-- make headers
@@ -158,7 +179,7 @@ function _make_target(makefile, target)
for _, srcheader in ipairs(srcheaders) do
local dstheader = dstheaders[i]
if dstheader then
- makefile:print("\t@xmake l cp %s %s", srcheader, dstheader)
+ _cp(makefile, srcheader, dstheader)
end
i = i + 1
end