Closed TOMO-CAT closed 3 weeks ago
你 package 定义里面啥 add_deps 都没加,等于没依赖,当然不生效了。。
xmake 不会去自动解析 你工程里面的 xmake.lua ,你得自己配置上 add_deps
你 package 定义里面啥 add_deps 都没加,等于没依赖,当然不生效了。。
xmake 不会去自动解析 你工程里面的 xmake.lua ,你得自己配置上 add_deps
不是自己定义的 package zpnc 缺少依赖,是 zsim package 找不到 zpnc package,zsim 里是带了 zpnc 的:
package("zsim", function()
...
add_deps("zpnc", ...)
end)
Bot detected the issue body's language is not English, translate it automatically.
Title: Locally defined packages cannot replace indirect dependencies
Bot detected the issue body's language is not English, translate it automatically.
You haven't added any add_deps in your package definition, which means there are no dependencies, and of course it won't take effect. .
xmake will not automatically parse xmake.lua in your project, you have to configure add_deps yourself.
Bot detected the issue body's language is not English, translate it automatically.
You have not added any add_deps in your package definition, which means there is no dependency, and of course it will not take effect. .
xmake will not automatically parse xmake.lua in your project. You have to configure add_deps yourself.
It’s not that the self-defined package zpnc lacks dependencies, it’s that the zsim package cannot find the zpnc package, and zsim contains zpnc:
package("zsim", function()
...
add_deps("zpnc", ...)
end)
既然你是 zsim 依赖 zpnc 。。为啥你配置的确是 add_requireconfs("**.zsim")
? 不应该是 zsim.zpnc 或者 **.zpnc
么。。
Bot detected the issue body's language is not English, translate it automatically.
Since you are zsim depends on zpnc . . Why is your configuration indeed
add_requireconfs("**.zsim")
? Shouldn't it be zsim.zpnc or**.zpnc
. .
是这样的,这部分代码是自动生成的,一开始长这样,定义了所有直接依赖和间接依赖的版本: 然后 zpnc 需要用本地库做本地仿真,就注释掉了 zpnc 的 add_requires:
其中 zsim 依赖 zpnc,改完后 zsim 会报错找不到 zpnc
Bot detected the issue body's language is not English, translate it automatically.
Yes, this part of the code is automatically generated. It looks like this at the beginning, and defines the versions of all direct dependencies and indirect dependencies: Then zpnc needs to use the local library for local simulation, so we comment out the add_requires of zpnc:
Among them, zsim depends on zpnc. After the change, zsim will report an error that zpnc cannot be found.
看不懂你的配置和需求,还是不知道你在干什么。
Bot detected the issue body's language is not English, translate it automatically.
I don’t understand your configuration and requirements, or I still don’t know what you are doing.
看不懂你的配置和需求,还是不知道你在干什么。
举个例子说明就是,我现在有一个库,就叫仿真库吧 simulation,它依赖 A、B 两个库。然后 B 又依赖 A。
正常线上代码是直接在 simulation 里 add_requires("A version_a") add_requires("B version_b") 然后再通过 add_requireconfs("B.A") 把 B 依赖的 A 库版本也写死成 version_a。
现在我本地仿真需要将 A 和 B.A 都替换成 local package 里定义的,但是此时编译 B 找不到依赖库 A 的 latest 版本。
如果我哪里还是讲的不明白的话,我可以写个 demo 说明下。
Bot detected the issue body's language is not English, translate it automatically.
I don’t understand your configuration and requirements, or I still don’t know what you are doing.
For example, I now have a library called simulation library, which depends on two libraries, A and B. Then B depends on A.
The normal online code is to add_requires("A version_a") add_requires("B version_b") directly in the simulation, and then use add_requireconfs("B.A") to hard-code the A library version that B depends on to version_a.
Now my local simulation needs to replace both A and B.A with those defined in the local package, but when compiling B, the latest version of the dependent library A cannot be found.
If I still don’t understand something, I can write a demo to explain.
举个例子说明就是,我现在有一个库,就叫仿真库吧 simulation,它依赖 A、B 两个库。然后 B 又依赖 A。
说白了就是
simulation -> B -> A
-> A
呗。
正常线上代码是直接在 simulation 里 add_requires("A version_a") add_requires("B version_b") 然后再通过 add_requireconfs("B.A") 把 B 依赖的 A 库版本也写死成 version_a。
其实你 simulation 里,只需要 add_requires("B version_b")
就行了,B 会把 A 带进来。。没必要再去加 add_requires("A version_a")
现在我本地仿真需要将 A 和 B.A 都替换成 local package 里定义的,但是此时编译 B 找不到依赖库 A 的 latest 版本。
你 local package 里的 A 如果是 zpnc 的话,我也没看到你加任何 add_versions
配置,那当然找不到了。
Bot detected the issue body's language is not English, translate it automatically.
For example, I now have a library called simulation library, which depends on two libraries A and B. Then B depends on A.
To put it bluntly, it is
simulation -> B -> A
-> A
chant.
The normal online code is to add_requires("A version_a") add_requires("B version_b") directly in the simulation, and then use add_requireconfs("B.A") to hard-code the A library version that B depends on to version_a.
In fact, in your simulation, you only need add_requires("B version_b")
, and B will bring A in. . There is no need to add add_requires("A version_a")
Now my local simulation needs to replace both A and B.A with those defined in the local package, but when compiling B, the latest version of the dependent library A cannot be found.
If A in your local package is zpnc, I haven't seen you add any add_versions
configuration, so of course it can't be found.
add_requires("B version_b")
但是 A 和 B 也都是 simulation 的直接依赖,所以都得带上
Bot detected the issue body's language is not English, translate it automatically.
add_requires("B version_b")
But A and B are also direct dependencies of simulation, so they must be brought
add_requires("B version_b")
但是 A 和 B 也都是 simulation 的直接依赖,所以都得带上
这个随你,效果一样。。跟现在的问题无关,你现在的问题是 local package 没有 add_versions
Bot detected the issue body's language is not English, translate it automatically.
add_requires("B version_b")
But A and B are also direct dependencies of simulation, so they must be brought
It's up to you, the effect is the same. . It has nothing to do with the current problem. Your current problem is that local package does not have add_versions.
add_requires("B version_b")
但是 A 和 B 也都是 simulation 的直接依赖,所以都得带上
这个随你,效果一样。。跟现在的问题无关,你现在的问题是 local package 没有 add_versions
add_versions("latest") 吗,还是加什么 version 呢,用的是本地的代码
Bot detected the issue body's language is not English, translate it automatically.
add_requires("B version_b")
But A and B are also direct dependencies of simulation, so they must be brought
This is up to you, the effect is the same. . It has nothing to do with the current problem. Your current problem is that local package does not have add_versions.
add_versions("latest"), or add some version, use local code
既然你 add_requireconfs 指定了 version,就把对应 version 加进去,反正至少有一个 add_versions
Bot detected the issue body's language is not English, translate it automatically.
Since you specify version in add_requireconfs, add the corresponding version. Anyway, there is at least one add_versions
既然你 add_requireconfs 指定了 version,就把对应 version 加进去,反正至少有一个 add_versions
但是我对 zpnc 没有指定 version,我把那两行都注释了。 报错也是 zsim 找不到 zpnc 的 latest version,不应该直接依赖我的 local package 吗?
Bot detected the issue body's language is not English, translate it automatically.
Since you specify version in add_requireconfs, add the corresponding version. Anyway, there is at least one add_versions
But I did not specify version for zpnc, I commented out both lines. The error reported is that zsim cannot find the latest version of zpnc. Shouldn't it rely directly on my local package?
报错也是 zsim 找不到 zpnc 的 latest version,不应该直接依赖我的 local package 吗?
就是因为已经用了你的 local package ,才会报错。。你的 local package 配置啥也没有,add_versions 没有。。。on_install 也没有,当然报错了。。
要是没用你的 local package ,用的线上有效的包,反而不会报错。。
这不是可以的么
package("zlib")
set_sourcedir("src")
add_versions("1.0", "xxxx")
on_install(function (package)
end)
package_end()
add_requires("libpng", {system = false})
add_requireconfs("libpng.zlib", {system = false})
note: install or modify (m) these packages (pass -y to skip confirm)?
-> zlib 1.0 [from:libpng]
in xmake-repo:
-> libpng v1.6.43
报错也是 zsim 找不到 zpnc 的 latest version,不应该直接依赖我的 local package 吗?
就是因为已经用了你的 local package ,才会报错。。你的 local package 配置啥也没有,add_versions 没有。。。on_install 也没有,当然报错了。。
要是没用你的 local package ,用的线上有效的包,反而不会报错。。
这不是可以的么
package("zlib") set_sourcedir("src") add_versions("1.0", "xxxx") on_install(function (package) end) package_end() add_requires("libpng", {system = false}) add_requireconfs("libpng.zlib", {system = false})
note: install or modify (m) these packages (pass -y to skip confirm)? -> zlib 1.0 [from:libpng] in xmake-repo: -> libpng v1.6.43
好的感谢我试试,我琢磨下啥原理。
我猜是因为我定义 zpnc 的时候没有 add_versions(),只是通过版本号构造对应的 url,所以添加 local repo 的时候就走到了 xmake-repo 里定义的 zpnc(因为它没有定义 versions 所以包含了所有的 version?)。
Bot detected the issue body's language is not English, translate it automatically.
I guess it's because I didn't add_versions() when I defined zpnc, I just constructed the corresponding URL through the version number, so when I added the local repo, I went to the zpnc defined in xmake-repo (because it didn't define versions, it included all version?).
不是,既然找到了你的包,就不会再用 xmake-repo 的包,但是你的包 没写 add_versions ,当然报错找不到 latest versions 了
Bot detected the issue body's language is not English, translate it automatically.
No, now that I have found your package, I will no longer use the xmake-repo package. However, your package does not include add_versions. Of course, an error is reported that the latest versions cannot be found.
可以这样使用本地包: zip包名称为:cJSON-1.7.15.zip,跟xmake.lua在同一个目录下
package("cjson")
set_homepage("https://github.com/DaveGamble/cJSON")
set_description("Ultralightweight JSON parser in ANSI C.")
set_license("MIT")
set_urls(os.scriptdir() .. "\\cJSON-$(version).zip")
add_versions("1.7.10", "80a0584410656c8d8da2ba703744f44d7535fc4f0778d8bf4f980ce77c6a9f65")
add_versions("1.7.14", "d797b4440c91a19fa9c721d1f8bab21078624aa9555fc64c5c82e24aa2a08221")
add_versions("1.7.15", "c55519316d940757ef93a779f1db1ca809dbf979c551861f339d35aaea1c907c")
add_deps("cmake")
on_install("windows", "macosx", "linux", "iphoneos", "android", function (package)
local configs = {"-DENABLE_CJSON_TEST=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("cJSON_malloc", {includes = "cjson/cJSON.h"}))
end)
只需要照着包仓库里面的改,将set_urls里面改成对应的本地路径就行了
Bot detected the issue body's language is not English, translate it automatically.
Just follow the changes in the package warehouse and change set_urls to the corresponding local path.
不过这里的路径是Windows格式的(很久之前写的了)
set_urls(os.scriptdir() .. "\\cJSON-$(version).zip")
如果要跨操作系统兼容的话建议改成:
set_urls(path.translate(os.scriptdir() .. "/cJSON-$(version).zip"))
或者
set_urls(path.translate("$(scriptdir)/cJSON-$(version).zip"))
Bot detected the issue body's language is not English, translate it automatically.
But the path here is in Windows format (written a long time ago)
set_urls(os.scriptdir() .. "\\cJSON-$(version).zip")
If you want cross-operating system compatibility, it is recommended to change it to:
set_urls(path.translate(os.scriptdir() .. "/cJSON-$(version).zip"))
or
set_urls(path.translate("$(scriptdir)/cJSON-$(version).zip"))
Xmake 版本
v2.9.2
操作系统版本和架构
Linux 720ce3a659a2 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
描述问题
背景是本地仿真需要用本地库替换掉某个库,比如我这里定义了 pnc 引用本地库,但是这里 sim 也依赖了 pnc,在安装 sim 时会报错:`package(zpnc): version(latest) not found!
期待的结果
能影响到间接 package。
工程配置
无
附加信息和错误日志
无