diff options
| author | ruki <[email protected]> | 2025-08-10 22:13:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-10 22:13:07 +0800 |
| commit | 8d49fda3521f20b8d0e6d0b01d416f06e5f1239c (patch) | |
| tree | 200e884b198f253d7f2bc6bf16673c5b94961fbe | |
| parent | 74f61a33d6af99e80bf55fee60c3acea09f4e1d8 (diff) | |
improve to install targets
| -rw-r--r-- | xmake/actions/install/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/package/tools/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/main.lua | 81 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/main.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/pack/batchcmds.lua | 3 |
5 files changed, 54 insertions, 41 deletions
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua index 3fa870061..a18b11214 100644 --- a/xmake/actions/install/xmake.lua +++ b/xmake/actions/install/xmake.lua @@ -37,7 +37,11 @@ task("install") " xmake install -g test_*", " xmake install --group=benchmark/*" }, {'a', "all", "k", nil , "Install all targets." }, - {nil, "nopkgs", "k", nil , "Only install targets without packages." }, + {nil, "binaries", "kv", true , "Enable or disable install binary files." }, + {nil, "headers", "kv", true , "Enable or disable install header files." }, + {nil, "libraries", "kv", true , "Enable or disable install library files." }, + {nil, "packages", "kv", true , "Enable or disable install package files." }, + {}, {nil, "admin", "k", nil , "Try to request administrator permission to install"}, {}, {nil, "target", "v", nil , "The target name. It will install all default targets if this parameter is not specified.", diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index 17cf48a2e..b572c2fec 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -543,7 +543,7 @@ function install(package, configs, opt) os.vrunv(os.programfile(), argv, {envs = envs, curdir = opt.curdir}) -- do install - argv = {"install", "-y", "--nopkgs", "-o", package:installdir()} + argv = {"install", "-y", "--packages=n", "-o", package:installdir()} _set_builtin_argv(package, argv) local targets = table.wrap(opt.targets or opt.target) if #targets ~= 0 then diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua index d9faa80ad..3e8e1e62e 100644 --- a/xmake/modules/target/action/install/main.lua +++ b/xmake/modules/target/action/install/main.lua @@ -50,7 +50,7 @@ function _get_target_includedir(target, opt) end function _get_target_package_libfiles(target, opt) - if option.get("nopkgs") then + if not option.get("packages") then return {} end opt = opt or {} @@ -204,57 +204,72 @@ end -- install binary function _install_binary(target, opt) - local bindir = _get_target_bindir(target, opt) - os.mkdir(bindir) - os.vcp(target:targetfile(), bindir) - os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile()))) - _install_shared_libraries(target, opt) - _update_install_rpath(target, opt) + if option.get("libraries") then + _install_shared_libraries(target, opt) + end + if option.get("binaries") then + local bindir = _get_target_bindir(target, opt) + os.mkdir(bindir) + os.vcp(target:targetfile(), bindir) + os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile()))) + _update_install_rpath(target, opt) + end end -- install shared library function _install_shared(target, opt) - local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(target, opt) or _get_target_libdir(target, opt) - os.mkdir(bindir) - local targetfile = target:targetfile() + if option.get("libraries") then + local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(target, opt) or _get_target_libdir(target, opt) + os.mkdir(bindir) + local targetfile = target:targetfile() - if target:is_plat("windows", "mingw") then - -- install *.lib for shared/windows (*.dll) target - -- @see https://github.com/xmake-io/xmake/issues/714 - os.vcp(target:targetfile(), bindir) - local libdir = _get_target_libdir(target, opt) - local implibfile = target:artifactfile("implib") - if os.isfile(implibfile) then - os.mkdir(libdir) - os.vcp(implibfile, libdir) + if target:is_plat("windows", "mingw") then + -- install *.lib for shared/windows (*.dll) target + -- @see https://github.com/xmake-io/xmake/issues/714 + os.vcp(target:targetfile(), bindir) + local libdir = _get_target_libdir(target, opt) + local implibfile = target:artifactfile("implib") + if os.isfile(implibfile) then + os.mkdir(libdir) + os.vcp(implibfile, libdir) + end + else + -- install target with soname and symlink + _copy_file_with_symlinks(targetfile, bindir) end - else - -- install target with soname and symlink - _copy_file_with_symlinks(targetfile, bindir) + os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile()))) + _install_shared_libraries(target, opt) + end + if option.get("headers") then + _install_headers(target, opt) end - os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile()))) - - _install_headers(target, opt) - _install_shared_libraries(target, opt) end -- install static library function _install_static(target, opt) - local libdir = _get_target_libdir(target, opt) - os.mkdir(libdir) - os.vcp(target:targetfile(), libdir) - os.trycp(target:symbolfile(), path.join(libdir, path.filename(target:symbolfile()))) - _install_headers(target, opt) + if option.get("libraries") then + local libdir = _get_target_libdir(target, opt) + os.mkdir(libdir) + os.vcp(target:targetfile(), libdir) + os.trycp(target:symbolfile(), path.join(libdir, path.filename(target:symbolfile()))) + end + if option.get("headers") then + _install_headers(target, opt) + end end -- install headeronly library function _install_headeronly(target, opt) - _install_headers(target, opt) + if option.get("headers") then + _install_headers(target, opt) + end end -- install moduleonly library function _install_moduleonly(target, opt) - _install_headers(target, opt) + if option.get("headers") then + _install_headers(target, opt) + end end function main(target, opt) diff --git a/xmake/modules/target/action/uninstall/main.lua b/xmake/modules/target/action/uninstall/main.lua index 2273ff76d..26ea33530 100644 --- a/xmake/modules/target/action/uninstall/main.lua +++ b/xmake/modules/target/action/uninstall/main.lua @@ -50,9 +50,6 @@ function _get_target_includedir(target, opt) end function _get_target_package_libfiles(target, opt) - if option.get("nopkgs") then - return {} - end opt = opt or {} local libfiles = {} for _, pkg in ipairs(target:orderpkgs(opt)) do diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua index 2418f39ac..b67d66b5b 100644 --- a/xmake/plugins/pack/batchcmds.lua +++ b/xmake/plugins/pack/batchcmds.lua @@ -63,9 +63,6 @@ function _get_target_installdir(package, target) end function _get_target_package_libfiles(target, opt) - if option.get("nopkgs") then - return {} - end opt = opt or {} local libfiles = {} for _, pkg in ipairs(target:orderpkgs(opt)) do |
