diff options
| author | ruki <[email protected]> | 2016-05-24 20:42:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-24 20:42:12 +0800 |
| commit | 487eda865797da4fc81ba8ba8ec932dc2fb64cec (patch) | |
| tree | a731cdefc5607d65e03219d1e1625f62518eb52c | |
| parent | e932acd1440734e5977bd23176c9ac7a133f6b53 (diff) | |
impl extractor using ar
| -rwxr-xr-x | xmake/actions/build/builder.lua | 12 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 6 | ||||
| -rw-r--r-- | xmake/platforms/windows/checker.lua | 2 | ||||
| -rw-r--r-- | xmake/tools/ar.lua | 36 |
4 files changed, 47 insertions, 9 deletions
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua index 9027b5737..33a1e47d2 100755 --- a/xmake/actions/build/builder.lua +++ b/xmake/actions/build/builder.lua @@ -49,8 +49,16 @@ end -- build the object for the *.[a|lib] source file function _build_object_for_static(target, sourcefile, objectfile, percent) - raise("not implemented") - -- TODO + -- trace + print("[%02d%%]: inserting.$(mode) %s", percent, sourcefile) + + -- trace verbose info + if option.get("verbose") then + print("ex %s %s", sourcefile, objectfile) + end + + -- extract the static library to object directory + tool.run("ex", sourcefile, path.directory(objectfile)) end -- build object diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index 07f022a62..3846dc499 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -122,7 +122,7 @@ function tool._find(root, name) end -- load the given tool from the given shell name -function tool._load(shellname) +function tool._load(shellname, kind) -- get it directly from cache dirst tool._TOOLS = tool._TOOLS or {} @@ -166,7 +166,7 @@ function tool._load(shellname) -- init the tool module if module.init then - module.init(shellname) + module.init(shellname, kind) end -- save tool to the cache @@ -220,7 +220,7 @@ function tool.load(kind) end -- load it - return tool._load(shellname) + return tool._load(shellname, kind) end -- check the tool and return the absolute path if exists diff --git a/xmake/platforms/windows/checker.lua b/xmake/platforms/windows/checker.lua index edb3b246d..7b185f252 100644 --- a/xmake/platforms/windows/checker.lua +++ b/xmake/platforms/windows/checker.lua @@ -157,7 +157,7 @@ function _check_toolchains(config) checker.check_toolchain(config, "ld", "", "link.exe", "the linker") checker.check_toolchain(config, "ar", "", "link.exe -lib", "the static library linker") checker.check_toolchain(config, "sh", "", "link.exe -dll", "the shared library linker") - checker.check_toolchain(config, "ex", "", "lib.exe", "the library extractor") + checker.check_toolchain(config, "ex", "", "lib.exe", "the static library extractor") -- leave environment environment.leave("toolchains") 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 |
