From 487eda865797da4fc81ba8ba8ec932dc2fb64cec Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 24 May 2016 20:42:12 +0800 Subject: impl extractor using ar --- xmake/tools/ar.lua | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'xmake/tools/ar.lua') diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua index e100db74a..de220ca88 100644 --- a/xmake/tools/ar.lua +++ b/xmake/tools/ar.lua @@ -21,11 +21,14 @@ -- -- init it -function init(shellname) +function init(shellname, kind) -- save the shell name _g.shellname = shellname or "ar" + -- save the tool kind + _g.kind = kind or "ar" + -- init arflags _g.arflags = { "-cr" } @@ -47,15 +50,42 @@ function linkdir(dir) end -- make the link command -function linkcmd(objfiles, targetfile, flags) +function linkcmd(objectfiles, targetfile, flags) -- make it - return format("%s %s %s %s", _g.shellname, flags, targetfile, objfiles) + return format("%s %s %s %s", _g.shellname, flags, targetfile, objectfiles) +end + +-- extract the static library to object directory +function extract(libraryfile, objectdir) + + -- make the object directory first + os.mkdir(objectdir) + + -- get the absolute path of this library + libraryfile = path.absolute(libraryfile) + + -- enter the object directory + os.cd(objectdir) + + -- extract it + os.run("%s -x %s", _g.shellname, libraryfile) + + -- TODO + -- check repeat object name + + -- leave the object directory + os.cd("-") end -- run command function run(...) + -- extract it + if _g.kind == "ex" then + return extract(...) + end + -- run it os.run(...) end -- cgit v1.3.1