summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-12-06 00:38:11 +0800
committerruki <[email protected]>2015-12-06 00:38:11 +0800
commitb7a0ed4cd24fbd421715dad7376ae691871ca126 (patch)
treeade15aaefe06cdfad6ee4fb81289c0b0e21f278d /xmake/scripts
parent55baf72274c1aeefceb125f49a4da77e1d49bf40 (diff)
auto configure if makefile not exists
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/action/_build.lua18
-rw-r--r--xmake/scripts/base/makefile.lua22
-rw-r--r--xmake/scripts/base/rule.lua11
-rw-r--r--xmake/scripts/platform/windows/tools/lib.lua15
4 files changed, 47 insertions, 19 deletions
diff --git a/xmake/scripts/action/_build.lua b/xmake/scripts/action/_build.lua
index 7fea4be22..4b4b72687 100644
--- a/xmake/scripts/action/_build.lua
+++ b/xmake/scripts/action/_build.lua
@@ -80,6 +80,24 @@ function _build.done()
end
end
+ -- check makefile
+ if not os.isfile(rule.makefile()) then
+
+ -- make the configure file for the given target
+ if not project.makeconf(options.target) then
+ -- error
+ utils.error("make configure failed!")
+ return false
+ end
+
+ -- make makefile
+ if not makefile.make() then
+ -- error
+ utils.error("make makefile failed!")
+ return false
+ end
+ end
+
-- build target for makefile
if not makefile.build(target_name) then
-- error
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua
index 9dbf1ae35..b35ac8412 100644
--- a/xmake/scripts/base/makefile.lua
+++ b/xmake/scripts/base/makefile.lua
@@ -98,7 +98,8 @@ function makefile._make_object_for_static(file, target, srcfile, objfile)
else mode = "" end
-- make command
- local cmd = string.format("xmake l -P %s -f %s dispatcher ex extract %s %s > %s 2>&1", xmake._PROJECT_DIR, xmake._PROJECT_FILE, srcfile:encode(), objfile:encode(), makefile._LOGFILE)
+-- local cmd = string.format("xmake l -P %s -f %s dispatcher ex extract %s %s > %s 2>&1", xmake._PROJECT_DIR, xmake._PROJECT_FILE, srcfile:encode(), objfile:encode(), makefile._LOGFILE)
+ local cmd = string.format("xmake l -P %s -f %s dispatcher ex extract %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, srcfile:encode(), objfile:encode())
-- make head
file:write(string.format("%s:", objfile))
@@ -343,17 +344,6 @@ function makefile._make_targets(file)
return true
end
--- get the makefile path
-function makefile.path()
-
- -- get the build directory
- local buildir = config.get("buildir")
- assert(buildir)
-
- -- get it
- return path.translate(buildir .. "/makefile")
-end
-
-- make makefile in the build directory
function makefile.make()
@@ -372,7 +362,7 @@ function makefile.make()
assert(logfile)
-- open the makefile
- local path = makefile.path()
+ local path = rule.makefile()
local file = io.openmk(path)
if not file then
-- error
@@ -409,10 +399,6 @@ function makefile.build(target)
-- check
assert(target and type(target) == "string")
- -- get the build directory
- local buildir = config.get("buildir")
- assert(buildir)
-
-- load make
local make = tools.get("make")
if not make then
@@ -421,7 +407,7 @@ function makefile.build(target)
end
-- done make
- return make:main(buildir .. "/makefile", target)
+ return make:main(rule.makefile(), target)
end
-- return module: makefile
diff --git a/xmake/scripts/base/rule.lua b/xmake/scripts/base/rule.lua
index e165c6533..e6e724cff 100644
--- a/xmake/scripts/base/rule.lua
+++ b/xmake/scripts/base/rule.lua
@@ -55,6 +55,17 @@ function rule.filename(name, kind)
return format[1] .. name .. format[2]
end
+-- get the makefile path
+function rule.makefile()
+
+ -- get the build directory
+ local buildir = config.get("buildir")
+ assert(buildir)
+
+ -- get it
+ return path.translate(buildir .. "/makefile")
+end
+
-- get configure file for the given target
function rule.config_h(target)
diff --git a/xmake/scripts/platform/windows/tools/lib.lua b/xmake/scripts/platform/windows/tools/lib.lua
index 8fcd682e5..e56e4c195 100644
--- a/xmake/scripts/platform/windows/tools/lib.lua
+++ b/xmake/scripts/platform/windows/tools/lib.lua
@@ -25,6 +25,7 @@ local lib = lib or {}
-- load modules
local io = require("base/io")
+local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
@@ -77,11 +78,23 @@ function lib.extract(self, ...)
-- extrace all object files
for line in file:lines() do
+ print(line)
-- is object file?
if line:find("%.obj") then
-- init command
- local cmd = string.format("%s -nologo -extract:%s -out:%s\\%s %s", self.name, line, objdir, path.filename(line), libfile)
+ local out = path.translate(string.format("%s\\%s", objdir, path.filename(line)))
+
+ -- repeat? rename it
+ if os.isfile(out) then
+ for i = 0, 10 do
+ out = path.translate(string.format("%s\\%d_%s", objdir, i, path.filename(line)))
+ if not os.isfile(out) then break end
+ end
+ end
+
+ -- init command
+ local cmd = string.format("%s -nologo -extract:%s -out:%s %s", self.name, line, out, libfile)
-- extract it
if 0 ~= os.execute(cmd) then