diff options
| author | ruki <[email protected]> | 2020-04-03 23:18:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-03 14:20:20 +0800 |
| commit | b49cfd13fc19b42ecce4ae9077e3ba51a46a5fcb (patch) | |
| tree | ff9ad749278725525951c0d836a018fc416b0ca1 | |
| parent | 9783d272988b51843869af98e0c53fa00cf9c902 (diff) | |
enable symbols.extract for other langs
| -rw-r--r-- | xmake/core/project/target.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/asm/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/c++/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/dlang/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/mode/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/objc++/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/xmake.lua | 30 |
8 files changed, 66 insertions, 14 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 8f6a5220f..4d244ee4f 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1268,7 +1268,7 @@ function _instance:dependfile(objectfile) -- make dependent file -- full file name(not base) to avoid name-clash of original file - return path.join(self:dependir(), relativedir, path.basename(originfile) .. ".d") + return path.join(self:dependir(), relativedir, path.filename(originfile) .. ".d") end -- get the dependent include files diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 70c72b11e..84a8b99d9 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -101,7 +101,7 @@ function is_changed(dependinfo, opt) for _, file in ipairs(files) do -- get and cache the file mtime - local mtime = files_mtime[file] or (os.isfile(file) and os.mtime(file) or nil) + local mtime = files_mtime[file] or os.mtime(file) files_mtime[file] = mtime -- source and header files have been changed? diff --git a/xmake/rules/asm/xmake.lua b/xmake/rules/asm/xmake.lua index 4bf5ae0d3..33823b412 100644 --- a/xmake/rules/asm/xmake.lua +++ b/xmake/rules/asm/xmake.lua @@ -25,4 +25,13 @@ rule("asm.build") -- define rule: asm rule("asm") - add_deps("asm.build", "utils.merge.object", "utils.merge.archive") + + -- add build rules + add_deps("asm.build") + + -- support `add_files("src/*.o")` and `add_files("src/*.a")` to merge object and archive files to target + add_deps("utils.merge.object", "utils.merge.archive") + + -- we attempt to extract symbols to the independent file and + -- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled + add_deps("utils.symbols.extract") diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua index 1693b38ac..1e9af0266 100644 --- a/xmake/rules/c++/xmake.lua +++ b/xmake/rules/c++/xmake.lua @@ -44,4 +44,13 @@ rule("c++.build") -- define rule: cpp rule("c++") - add_deps("c++.build", "c.build", "utils.merge.object", "utils.merge.archive") + + -- add build rules + add_deps("c++.build", "c.build") + + -- support `add_files("src/*.o")` and `add_files("src/*.a")` to merge object and archive files to target + add_deps("utils.merge.object", "utils.merge.archive") + + -- we attempt to extract symbols to the independent file and + -- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled + add_deps("utils.symbols.extract") diff --git a/xmake/rules/dlang/xmake.lua b/xmake/rules/dlang/xmake.lua index 0027b71a6..e28fbb2d5 100644 --- a/xmake/rules/dlang/xmake.lua +++ b/xmake/rules/dlang/xmake.lua @@ -25,4 +25,13 @@ rule("dlang.build") -- define rule: dlang rule("dlang") - add_deps("dlang.build", "utils.merge.object", "utils.merge.archive") + + -- add build rules + add_deps("dlang.build") + + -- support `add_files("src/*.o")` and `add_files("src/*.a")` to merge object and archive files to target + add_deps("utils.merge.object", "utils.merge.archive") + + -- we attempt to extract symbols to the independent file and + -- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled + add_deps("utils.symbols.extract") diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 7214e23f8..6dfa4b0f2 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -39,8 +39,6 @@ rule("mode.debug") -- define rule: release mode rule("mode.release") - -- we attempt to extract symbols to the independent file and strip self-target binary if `symbols/debug` is enabled - add_deps("utils.symbols.extract") after_load(function (target) -- is release mode now? xmake f -m release diff --git a/xmake/rules/objc++/xmake.lua b/xmake/rules/objc++/xmake.lua index 9f649a834..248745b86 100644 --- a/xmake/rules/objc++/xmake.lua +++ b/xmake/rules/objc++/xmake.lua @@ -32,4 +32,13 @@ rule("objc++.build") -- define rule: objc rule("objc++") - add_deps("objc++.build", "objc.build", "utils.merge.object", "utils.merge.archive") + + -- add build rules + add_deps("objc++.build", "objc.build") + + -- support `add_files("src/*.o")` and `add_files("src/*.a")` to merge object and archive files to target + add_deps("utils.merge.object", "utils.merge.archive") + + -- we attempt to extract symbols to the independent file and + -- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled + add_deps("utils.symbols.extract") diff --git a/xmake/rules/utils/symbols/xmake.lua b/xmake/rules/utils/symbols/xmake.lua index 1e5369a58..e6c9ecfb8 100644 --- a/xmake/rules/utils/symbols/xmake.lua +++ b/xmake/rules/utils/symbols/xmake.lua @@ -39,6 +39,7 @@ rule("utils.symbols.extract") -- imports import("core.base.option") import("core.theme.theme") + import("core.project.depend") import("core.platform.platform") -- get strip @@ -56,8 +57,16 @@ rule("utils.symbols.extract") end end - -- trace progress info + -- need re-generate this symbol file? local symbolfile = target:symbolfile() + local targetfile = target:targetfile() + local dependfile = target:dependfile(symbolfile) + local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) + if not depend.is_changed(dependinfo, {lastmtime = os.mtime(symbolfile)}) then + return + end + + -- trace progress info local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then cprint(progress_prefix .. "${dim color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile)) @@ -65,8 +74,13 @@ rule("utils.symbols.extract") cprint(progress_prefix .. "${color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile)) end + -- we remove the previous symbol file to ensure that it will be re-generated and it's mtime will be changed. + local dryrun = option.get("dry-run") + if not dryrun then + os.tryrm(symbolfile) + end + -- generate symbols file - local targetfile = target:targetfile() if dsymutil then local dsymutil_argv = {} local arch = get_config("arch") @@ -77,9 +91,9 @@ rule("utils.symbols.extract") table.insert(dsymutil_argv, targetfile) table.insert(dsymutil_argv, "-o") table.insert(dsymutil_argv, symbolfile) - os.vrunv(dsymutil, dsymutil_argv, {dryrun = option.get("dry-run")}) - else - os.vcp(targetfile, target:symbolfile()) + os.vrunv(dsymutil, dsymutil_argv, {dryrun = dryrun}) + elseif not dryrun then + os.vcp(targetfile, symbolfile) end -- strip it @@ -97,6 +111,10 @@ rule("utils.symbols.extract") table.insert(strip_argv, "-s") end table.insert(strip_argv, targetfile) - os.vrunv(strip, strip_argv, {dryrun = option.get("dry-run")}) + os.vrunv(strip, strip_argv, {dryrun = dryrun}) + + -- update files and values to the dependent file + dependinfo.files = {targetfile} + depend.save(dependinfo, dependfile) end) |
