-
-
Notifications
You must be signed in to change notification settings - Fork 773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the default installation policy #5325
Comments
@SirLynix @star-hengxing @Wzshun @xq114 Any idea? |
某些情景下,应用需要部分初始化资源(或者配置文件),才能正常工作。 目前我是这么做的,在target的after_build去拷贝资源到输出目录。 随后为了配合xpack,我又在add_installfiles添加了相应的拷贝逻辑(这个有点重复逻辑了,希望xmake能给个较好的解决方案?) 然后你这里的三个策略,其中默认策略
不执行add_installfiles,那么应用还是可能缺少资源而无法运行。 |
In some scenarios, the application needs to partially initialize resources (or configuration files) to work properly. This is what I am currently doing, copying resources to the output directory in the target's after_build. Then in order to cooperate with xpack, I added the corresponding copy logic in add_installfiles (this is a bit repetitive logic, I hope xmake can give a better solution?) Then you have three strategies here, among which the default strategy
If add_installfiles is not executed, the application may still be unable to run due to lack of resources. |
What about add_installfiles(..., {private = true}) -- default
add_installfiles(..., {public = true}) -- propagate the files to dependent binaries
add_installfiles(..., {interface = true}) -- only install the files for dependent binaries or
|
还有几点:
|
A few more points:
|
这个需要对 target 添加
默认会装,但仅仅装 shared 的 package 文件,静态库不会,默认没有配置
after_installcmd, 时候,自己去 copy 安装
qt 的 windepolyqt 目前仅支持 xmake install ,不支持 xpack |
This requires adding
It will be installed by default, but only shared package files will be installed. Static libraries will not be installed. There is no configuration by default
after_installcmd, copy and install by yourself
Qt's windepolyqt currently only supports xmake install and does not support xpack |
那就 而 installfiles/headerfiles ,全部走 |
不过用策略确实没法细粒度控制每个依赖的安装,修改版: Only install the current target without deps
Only install runonly target files (default)We just install the binary that can be run, and all the dynamic libraries needed to ensure that the binary can be run. add_installfiles(...) or add_installfiles(..., {private = true}) Install target and it's all dep filesadd_installfiles(..., {public = true}) Control installation directories for targetset_bindir -- (default: "bin")
set_libdir -- (default: "lib")
set_includedir -- (default: "include")
set_prefixdir -- (default: "")
set_installdir -- installation root directory (xmake install -o installdir) result:
|
他意思是opencv里面有很多dll,并不是每个dll都需要用到。qt也有类似情况,不是所有qt模块的dll都要用到,可能只用到Qt6Base.dll Qt6Gui.dll 结果把 Qt6Network.dll 也打包进来了。windeployqt.exe就没考虑这点,导致打包的程序包太大。这种情况可以提供个 utils.symbols.depend 模块,输出一个exe依赖的所有dll文件(调用 |
这个想法是挺好,就是要全平台处理稳定,不少东西需要处理。。#5330 |
如果 app 依赖 foo 库,那么 app 加载动态库的子路径(prefixdir, bindir, libdir 等),应该是在 app target 去配置,foo target 里面是没法决定的,因为它不知道依赖它的父 target ,到底怎么加载它依赖的库。。 比如 app -> foo , app2 -> foo 。。app/app2 targets 可能加载 foo 的路径需求都不同。 但是在 app target只能配置修改总的 prefixdir, bindir, libdir 。。不可能单独对某个 so deps 去改 libdir,因为它可能还依赖了其他 so 动态库 所以 #5335 我只能做到,在 app target 中去通过 而如果在 foo target 中配置 只要当 |
If the app depends on the foo library, then the subpath of the dynamic library loaded by the app (prefixdir, bindir, libdir, etc.) should be configured in the app target. It cannot be determined in the foo target because it does not know the parent target it depends on. How to load the libraries it depends on. . For example, app -> foo, app2 -> foo. . app/app2 targets may have different path requirements for loading foo. However, only the general prefixdir, bindir, and libdir can be configured and modified in the app target. . It is impossible to change libdir for a certain so deps alone, because it may also depend on other so dynamic libraries So #5335 all I can do is load the dependent dynamic library path through And if you configure This will only take effect when |
所以 #5335 的 patch, 在 xpack 里面,如果仅仅配置 如果想要单独安装 foo ,就配置 你可以试下这个 patch ,改的差不多了。。 完整例子: add_rules("mode.debug", "mode.release")
set_version("1.0.1", {soname = true})
add_requires("libzip", {system = false, configs = {shared = true}})
target("foo")
set_kind("shared")
add_files("src/foo.cpp")
add_packages("libzip", {public = true})
add_headerfiles("src/foo.h", {public = true})
add_installfiles("src/foo.txt", {prefixdir = "assets", public = true})
set_prefixdir("/", {libdir = "foo_lib"})
target("app")
set_kind("binary")
add_deps("foo")
add_files("src/main.cpp")
set_prefixdir("app", {libdir = "app_lib"})
add_rpathdirs("@loader_path/../app_lib", {installonly = true})
includes("@builtin/xpack")
xpack("test")
add_targets("app")
set_formats("zip")
|
包的动态库安装,我也改进过了,会根据 utils.binary.deplibs dump 出来的依赖库,自动过滤掉不需要的 so 库安装 |
I have also improved the dynamic library installation of the package. It will automatically filter out unnecessary so library installation based on the dependent libraries dumped by utils.binary.deplibs. |
xmake/xmake/rules/qt/install/windows.lua Line 115 in 3a8ad70
|
xmake/xmake/rules/qt/install/windows.lua Line 115 in 3a8ad70
|
另外,当前 patch 新增了 |
非常感谢,下周我尝试一下。 |
Thanks a lot, I'll give it a try next week. |
可以了么 |
Is it ok? |
我这边是,用的opencv的package,没有看到opencv 相关的库,在xpack输出位置那。 工程如下
有没有可能是opencv的包描述没很好的安装? 或者说我之前也尝试使用编写过,参照 |
我这 mac 下可以的么
这是包的问题,跟当前 install 的逻辑无关 |
因为这个包 win 下,dll 是默认安装在 |
Because this package is under win, the dll is installed in |
是啊,我就觉得奇怪。。 程序调试运行是可以跑通的,说明xmake和对应的包处理,在调试运行环境变量里加入了包的编译安装目录(包被本地编译的情况下)。 目前看来,两种做法?: 其实这两点,也是我看xmake 的包描述里,非常模糊的几点。。官方文档介绍里,仅很好的介绍了基于xmake的工程的包描述生成 |
目前不支持,但找 dll 我刚改进过了,可以更新下 install 分支,重装下 opencv 再试试
没时间写 |
Yeah, I feel weird. . The debugging and running of the program can be run through, indicating that xmake and the corresponding package processing have added the compilation and installation directory of the package to the debugging and running environment variables (when the package is compiled locally). At present, there are two approaches? : In fact, these two points are also very vague in the package description of xmake. . In the official document introduction, it only gives a good introduction to the package description of the project based on xmake to generate |
It is not supported at the moment, but I have just improved the dll. You can update the install branch, reinstall opencv and try again.
no time to write |
OK, and only the libraries used by the program are installed. But there are still some shortcomings, and this is not a problem with xmake. |
是否考虑给package的fetch信息加一个bindirs?目前都是通过 package:addenv("PATH", xxx) 的形式添加exe路径,但这种形式不适用于从系统fetch的包,并且假设package B 用到package A的exe,目前没有有效的方法确定exe的路径,因为A有可能是从系统发etch到的。如果加入bindirs,其一方便了libfiles的提取,其二对系统包可以在on_fetch里返回exe路径,调用时自动加入PATH中、且可以用find_program严格定位exe路径。 |
这个单独开 feature request 吧,这个 patch 暂时不处理了 |
Have you considered adding a bindir to the fetch information of the package? Currently, the exe path is added in the form of package:addenv("PATH", xxx), but this form is not suitable for packages fetched from the system, and assuming that package B uses the exe of package A, there is currently no effective method to determine The path of the exe, because A may be sent from the system. If bindirs are added, firstly, it facilitates the extraction of libfiles, and secondly, the exe path of the system package can be returned in on_fetch, automatically added to PATH when called, and find_program can be used to strictly locate the exe path. |
Let’s open a separate feature request for this. |
再试试,应该可以了 |
这个目前只有在 所以建议在 xpack 的 after_installcmd 里调用 qtdeploy + batchcmds:cp 做。xpack的 也可以在 xpack 的 before_package/after_package 里去 qtdeploy 然后走 package:add("installfiles") |
Try again, it should work |
这个有效果了么 |
Has this worked? |
可以了,但是我尝试去编写qt安装,在
自己编写的
这里报错
|
after_installcmd 是命令式生成,不是真的执行,一切操作都用 batchcmds |
after_installcmd is generated by command, not actually executed. All operations are done using batchcmds. |
既然依赖库安装可以了,我就先 merge 了,qt deploy 这个跟当前无关,自己处理下就行了 |
Now that the dependent libraries are installed, I will merge first. qt deploy has nothing to do with the current situation. I can just handle it myself. |
qt deploy 回头可以单独开 issues/discussion 讨论 |
After qt deploy, you can open issues/discussion separately. |
Is your feature request related to a problem? Please describe.
The current logic for installing a target and its dependencies is confusing and inflexible.
We need to add an installation policy that gives users the flexibility to configure the installation themselves.
For example:
xmake install app
Only install the current target without deps
Only install runonly target files (default)
We just install the binary that can be run, and all the dynamic libraries needed to ensure that the binary can be run.
Install target and it's all dep files
Enable or disable to install package files
It is also equivalent to
xmake install --nopkgs app
#5308
The text was updated successfully, but these errors were encountered: