diff options
| author | ruki <[email protected]> | 2022-04-02 12:26:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-02 12:26:14 +0800 |
| commit | a9f5e6556fc8ee8584aedb9d4b5b88ab475bef0e (patch) | |
| tree | f25ecd1018f930482b55cbebde81957a415f4fd1 /xmake/modules/package/manager/cargo/install_package.lua | |
| parent | 3261ecb32c7c5c0c4c71e5b78a03b0cd203652f1 (diff) | |
improve to find cargo package
Diffstat (limited to 'xmake/modules/package/manager/cargo/install_package.lua')
| -rw-r--r-- | xmake/modules/package/manager/cargo/install_package.lua | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/xmake/modules/package/manager/cargo/install_package.lua b/xmake/modules/package/manager/cargo/install_package.lua index 9ea709dd7..93ba2c59e 100644 --- a/xmake/modules/package/manager/cargo/install_package.lua +++ b/xmake/modules/package/manager/cargo/install_package.lua @@ -29,6 +29,7 @@ import("lib.detect.find_tool") -- add_requires("cargo::base64") -- add_requires("cargo::base64 0.13.0") -- add_requires("cargo::flate2 1.0.17", {configs = {features = {"zlib"}, ["default-features"] = false}}) +-- add_requires("cargo::xxx", {configs = {cargo_toml = path.join(os.projectdir(), "Cargo.toml")}}) -- -- @param name the package name, e.g. cargo::base64 -- @param opt the options, e.g. { verbose = true, mode = "release", plat = , arch = , require_version = "x.x.x"} @@ -55,21 +56,26 @@ function main(name, opt) local sourcedir = path.join(opt.cachedir, "source") local cargotoml = path.join(sourcedir, "Cargo.toml") os.tryrm(sourcedir) - local tomlfile = io.open(cargotoml, "w") - tomlfile:print("[package]") - tomlfile:print("name = \"cargodeps\"") - tomlfile:print("version = \"0.1.0\"") - tomlfile:print("edition = \"2018\"") - tomlfile:print("") - tomlfile:print("[dependencies]") - local features = configs.features - if features then - features = table.wrap(features) - tomlfile:print("%s = {version = \"%s\", features = [\"%s\"], default-features = %s}", name, require_version, table.concat(features, "\", \""), configs.default_features) + if configs.cargo_toml then + assert(os.isfile(configs.cargo_toml), "%s not found!", configs.cargo_toml) + os.cp(configs.cargo_toml, cargotoml) else - tomlfile:print("%s = \"%s\"", name, require_version) + local tomlfile = io.open(cargotoml, "w") + tomlfile:print("[package]") + tomlfile:print("name = \"cargodeps\"") + tomlfile:print("version = \"0.1.0\"") + tomlfile:print("edition = \"2018\"") + tomlfile:print("") + tomlfile:print("[dependencies]") + local features = configs.features + if features then + features = table.wrap(features) + tomlfile:print("%s = {version = \"%s\", features = [\"%s\"], default-features = %s}", name, require_version, table.concat(features, "\", \""), configs.default_features) + else + tomlfile:print("%s = \"%s\"", name, require_version) + end + tomlfile:close() end - tomlfile:close() -- generate main.rs io.writefile(path.join(sourcedir, "src", "main.rs"), [[ |
