diff options
| author | ruki <[email protected]> | 2023-08-09 00:45:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-08-09 00:45:21 +0800 |
| commit | d56fd4e78dd1d5a64409df3b8c889a54a4f740eb (patch) | |
| tree | fa70ae50d2aca8f0b198a7d4c3ad3360da8acfee /xmake/modules | |
| parent | 04ff2a200ba3be2334827b3fe0385038aee9c090 (diff) | |
use arch to select target
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/package/manager/cargo/install_package.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/xmake/modules/package/manager/cargo/install_package.lua b/xmake/modules/package/manager/cargo/install_package.lua index 60c059f40..7d58553e6 100644 --- a/xmake/modules/package/manager/cargo/install_package.lua +++ b/xmake/modules/package/manager/cargo/install_package.lua @@ -52,6 +52,15 @@ function main(name, opt) require_version = "*" end + -- get target + -- e.g. x86_64-pc-windows-msvc, aarch64-unknown-none + -- @see https://github.com/xmake-io/xmake/issues/4049 + local target + local arch = opt.arch + if arch and #arch:split("%-") > 1 then + target = arch + end + -- generate Cargo.toml local sourcedir = path.join(opt.cachedir, "source") local cargotoml = path.join(sourcedir, "Cargo.toml") @@ -88,11 +97,11 @@ function main(name, opt) -- generate .cargo/config.toml local configtoml = path.join(sourcedir, ".cargo", "config.toml") - if configs.build_target then + if target then io.writefile(configtoml, format([[ [build] target = "%s" -]], configs.build_target)) +]], target)) end -- generate main.rs @@ -132,9 +141,8 @@ target = "%s" -- do install local installdir = opt.installdir os.tryrm(path.join(installdir, "lib")) - local cross = get_config("cross") - if cross then - os.vcp(path.join(sourcedir, "target", cross, opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib")) + if target then + os.vcp(path.join(sourcedir, "target", target, opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib")) else os.vcp(path.join(sourcedir, "target", opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib")) end |
