diff options
| author | ruki <[email protected]> | 2022-04-05 00:46:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-05 00:46:08 +0800 |
| commit | a42eec83431f69649a349baf35593b39d0c25ca7 (patch) | |
| tree | 68e5066037e90e1414e91c590bd20ded289d5e89 | |
| parent | f42d862991ebb86316d43e747876e5a6cf5b7d2e (diff) | |
improve cargo install package
| -rw-r--r-- | xmake/modules/package/manager/cargo/install_package.lua | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/xmake/modules/package/manager/cargo/install_package.lua b/xmake/modules/package/manager/cargo/install_package.lua index 60c811291..c57a9c0b0 100644 --- a/xmake/modules/package/manager/cargo/install_package.lua +++ b/xmake/modules/package/manager/cargo/install_package.lua @@ -52,17 +52,20 @@ function main(name, opt) require_version = "*" end - -- @note we cannot use local cachedir as sourcedir, because it maybe will conflict with the parent root Cargo.toml - -- @see https://github.com/rust-lang/cargo/issues/10534 - -- local sourcedir = path.join(opt.cachedir, "source") - local sourcedir = path.join(os.tmpfile({ramdisk = true}) .. ".dir", "cargo", "source") - -- generate Cargo.toml + local sourcedir = path.join(opt.cachedir, "source") local cargotoml = path.join(sourcedir, "Cargo.toml") os.tryrm(sourcedir) if configs.cargo_toml then assert(os.isfile(configs.cargo_toml), "%s not found!", configs.cargo_toml) os.cp(configs.cargo_toml, cargotoml) + -- we need add `[workspace]` to prevent cargo from searching up for a parent. + -- https://github.com/rust-lang/cargo/issues/10534#issuecomment-1087631050 + local tomlfile = io.open(cargotoml, "a") + tomlfile:print("") + tomlfile:print("[workspace]") + tomlfile:print("") + tomlfile:close() else local tomlfile = io.open(cargotoml, "w") tomlfile:print("[package]") @@ -71,6 +74,10 @@ function main(name, opt) tomlfile:print("edition = \"2018\"") tomlfile:print("") tomlfile:print("[dependencies]") + tomlfile:print("") + tomlfile:print("[workspace]") + tomlfile:print("") + local features = configs.features if features then features = table.wrap(features) |
