diff options
| author | ruki <[email protected]> | 2022-07-26 23:36:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-07-26 23:36:52 +0800 |
| commit | ce7ea0db01c9ec430c98dd37e27c956043ea2c5d (patch) | |
| tree | 06e25867800cd2adcfc329e24c763504190a6f34 | |
| parent | 9caa7031050dfa0b2122f41d54c30fd06e900872 (diff) | |
improve to install headerfiles #2577
| -rw-r--r-- | xmake/core/project/target.lua | 21 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/unix.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/windows.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/unix.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/windows.lua | 2 |
5 files changed, 22 insertions, 7 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 81f79cbae..b00cbe15a 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1440,7 +1440,7 @@ end -- TODO get the header files, get("headers") (deprecated) function _instance:headers(outputdir) - return self:headerfiles(outputdir, true) + return self:headerfiles(outputdir, {only_deprecated = true}) end -- get the header files @@ -1448,14 +1448,29 @@ end -- default: get("headers") + get("headerfiles") -- only_deprecated: get("headers") -- -function _instance:headerfiles(outputdir, only_deprecated) +function _instance:headerfiles(outputdir, opt) -- get header files? + opt = opt or {} local headers = self:get("headers") -- TODO deprecated + local only_deprecated = opt.only_deprecated if not only_deprecated then headers = table.join(headers or {}, self:get("headerfiles")) + -- add_headerfiles("src/*.h", {install = false}) + -- @see https://github.com/xmake-io/xmake/issues/2577 + if opt.installonly then + local installfiles = {} + for _, headerfile in ipairs(table.wrap(headers)) do + if self:extraconf("headerfiles", headerfile, "install") ~= false then + table.insert(installfiles, headerfile) + end + end + headers = installfiles + end + end + if not headers then + return end - if not headers then return end -- get the installed header directory local headerdir = outputdir diff --git a/xmake/modules/target/action/install/unix.lua b/xmake/modules/target/action/install/unix.lua index af641e5bc..126191c0e 100644 --- a/xmake/modules/target/action/install/unix.lua +++ b/xmake/modules/target/action/install/unix.lua @@ -22,7 +22,7 @@ function _install_headers(target, opt) local includedir = path.join(target:installdir(), opt and opt.includedir or "include") os.mkdir(includedir) - local srcheaders, dstheaders = target:headerfiles(includedir) + local srcheaders, dstheaders = target:headerfiles(includedir, {installonly = true}) if srcheaders and dstheaders then local i = 1 for _, srcheader in ipairs(srcheaders) do diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua index dfbcad11f..d508623be 100644 --- a/xmake/modules/target/action/install/windows.lua +++ b/xmake/modules/target/action/install/windows.lua @@ -25,7 +25,7 @@ import("lib.detect.find_file") function _install_headers(target, opt) local includedir = path.join(target:installdir(), opt and opt.includedir or "include") os.mkdir(includedir) - local srcheaders, dstheaders = target:headerfiles(includedir) + local srcheaders, dstheaders = target:headerfiles(includedir, {installonly = true}) if srcheaders and dstheaders then local i = 1 for _, srcheader in ipairs(srcheaders) do diff --git a/xmake/modules/target/action/uninstall/unix.lua b/xmake/modules/target/action/uninstall/unix.lua index e11446dd4..128d24977 100644 --- a/xmake/modules/target/action/uninstall/unix.lua +++ b/xmake/modules/target/action/uninstall/unix.lua @@ -21,7 +21,7 @@ -- uninstall headers function _uninstall_headers(target, opt) local includedir = path.join(target:installdir(), opt and opt.includedir or "include") - local _, dstheaders = target:headerfiles(includedir) + local _, dstheaders = target:headerfiles(includedir, {installonly = true}) for _, dstheader in ipairs(dstheaders) do os.vrm(dstheader) end diff --git a/xmake/modules/target/action/uninstall/windows.lua b/xmake/modules/target/action/uninstall/windows.lua index ed6923567..93d7df4be 100644 --- a/xmake/modules/target/action/uninstall/windows.lua +++ b/xmake/modules/target/action/uninstall/windows.lua @@ -21,7 +21,7 @@ -- uninstall headers function _uninstall_headers(target, opt) local includedir = path.join(target:installdir(), opt and opt.includedir or "include") - local _, dstheaders = target:headerfiles(includedir) + local _, dstheaders = target:headerfiles(includedir, {installonly = true}) for _, dstheader in ipairs(dstheaders) do os.vrm(dstheader) end |
