Skip to content
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

Closed
waruqi opened this issue Jul 10, 2024 · 50 comments
Closed

Improve the default installation policy #5325

waruqi opened this issue Jul 10, 2024 · 50 comments

Comments

@waruqi
Copy link
Member

waruqi commented Jul 10, 2024

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.

set_policy("install.targetdeps", true)
set_policy("install.targetdeps.runonly", true) -- default
set_policy("install.targetdeps.all", true)

For example:

app (binary) -> foo (shared) -> bar (static)
xmake install app

Only install the current target without deps

set_policy("install.targetdeps", false)
  • Only Install app binary (add_installfiles, add_packages)
  • Do not install any deps

Only install runonly target files (default)

set_policy("install.targetdeps.runonly", true) -- 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 app binary (add_installfiles, add_packages)
  • Only install foo shared target file and package shared files (without add_headerfiles, add_installfiles)
  • Do not install bar static target

Install target and it's all dep files

set_policy("install.targetdeps.all", true)
  • Install app binary (add_installfiles, add_packages)
  • install foo shared (with add_headerfiles, add_installfiles, add_packages)
  • install bar static (with add_headerfiles, add_installfiles, add_packages)

Enable or disable to install package files

set_policy("install.targetpkgs", true) -- default
set_policy("install.targetpkgs", false)

It is also equivalent to xmake install --nopkgs app

#5308

@waruqi waruqi added this to the v2.9.4 milestone Jul 10, 2024
@waruqi
Copy link
Member Author

waruqi commented Jul 10, 2024

@SirLynix @star-hengxing @Wzshun @xq114 Any idea?

@waruqi waruqi changed the title Improve install policy Improve the default installation policy Jul 10, 2024
@Wzshun
Copy link

Wzshun commented Jul 10, 2024

某些情景下,应用需要部分初始化资源(或者配置文件),才能正常工作。

目前我是这么做的,在target的after_build去拷贝资源到输出目录。

随后为了配合xpack,我又在add_installfiles添加了相应的拷贝逻辑(这个有点重复逻辑了,希望xmake能给个较好的解决方案?)

然后你这里的三个策略,其中默认策略

set_policy("install.targetdeps.runonly", true) -- default

不执行add_installfiles,那么应用还是可能缺少资源而无法运行。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


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

set_policy("install.targetdeps.runonly", true) -- default

If add_installfiles is not executed, the application may still be unable to run due to lack of resources.

@xq114
Copy link
Contributor

xq114 commented Jul 10, 2024

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

add_deps(..., {install = false}) -- do not inherent install files from the dep

@Wzshun
Copy link

Wzshun commented Jul 10, 2024

还有几点:

  1. 某些依赖库可能要被输出到不同的目录,这一点与xpack的交互,好像没法控制?

  2. 依赖的package似乎目前版本不会被安装?或者说这个取决于包的xmake.lua编写问题?
    这个我是测试的opencv。

  3. 部分情况下,package的安装并不如预期,比如opencv我仅用到部分模块,不需要太多opencv库。
    这时候的xpack安装,如何考虑自行安装?或者说拿到本机编译的库路径(这块目前我好像没找到api),自行去编写安装逻辑?

  4. 对于frameworks的安装问题。目前诸如add_rules("qt.widgetapp")这样的qt框架,或者其他框架,都没法正常安装的
    这里我是写了个脚本去部署的,自行调用 windepolyqt。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


A few more points:

  1. Some dependent libraries may be output to different directories. It seems that the interaction with xpack cannot be controlled?

  2. It seems that the current version of the dependent package will not be installed? Or is this a problem with writing xmake.lua that depends on the package?
    I tested this with opencv.

  3. In some cases, the installation of the package is not as expected. For example, I only use some opencv modules and do not need too many opencv libraries.
    How to consider installing xpack by yourself at this time? Or can you get the natively compiled library path (I don’t seem to have found the API for this so far) and write the installation logic by yourself?

  4. Regarding the installation of frameworks. Currently, qt frameworks such as add_rules("qt.widgetapp") or other frameworks cannot be installed normally.
    Here I wrote a script to deploy and call windepolyqt myself.

@waruqi
Copy link
Member Author

waruqi commented Jul 10, 2024

还有几点:

  1. 某些依赖库可能要被输出到不同的目录,这一点与xpack的交互,好像没法控制?

这个需要对 target 添加 set_bindir, set_libdir, set_includedir, set_prefixdir 才行

  1. 依赖的package似乎目前版本不会被安装?或者说这个取决于包的xmake.lua编写问题?
    这个我是测试的opencv。
  2. 部分情况下,package的安装并不如预期,比如opencv我仅用到部分模块,不需要太多opencv库。

默认会装,但仅仅装 shared 的 package 文件,静态库不会,默认没有配置 add_requires("xxx", {configs = {shared = true}}) ,那就是默认静态库,不会装

这时候的xpack安装,如何考虑自行安装?或者说拿到本机编译的库路径(这块目前我好像没找到api),自行去编写安装逻辑?

after_installcmd, 时候,自己去 copy 安装

  1. 对于frameworks的安装问题。目前诸如add_rules("qt.widgetapp")这样的qt框架,或者其他框架,都没法正常安装的
    这里我是写了个脚本去部署的,自行调用 windepolyqt。

qt 的 windepolyqt 目前仅支持 xmake install ,不支持 xpack

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


A few more points:

  1. Some dependent libraries may be output to different directories. It seems that the interaction with xpack cannot be controlled?

This requires adding set_bindir, set_libdir, set_includedir, set_prefixdir to the target.

  1. It seems that the current version of the dependent package will not be installed? Or is this a problem with xmake.lua writing that depends on the package?
    I tested this with opencv.
  2. In some cases, the installation of the package is not as expected. For example, I only use some opencv modules and do not need too many opencv libraries.

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 add_requires("xxx", {configs = {shared = true}}), which is the default static library and will not be installed.

How to consider installing xpack by yourself at this time? Or can you get the natively compiled library path (I don’t seem to have found the API for this so far) and write the installation logic by yourself?

after_installcmd, copy and install by yourself

  1. Regarding the installation of frameworks. Currently, qt frameworks such as add_rules("qt.widgetapp") or other frameworks cannot be installed normally.
    Here I wrote a script to deploy and call windepolyqt by myself.

Qt's windepolyqt currently only supports xmake install and does not support xpack

@waruqi
Copy link
Member Author

waruqi commented Jul 10, 2024

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

add_deps(..., {install = false}) -- do not inherent install files from the dep

不执行add_installfiles,那么应用还是可能缺少资源而无法运行。

那就 set_policy("install.targetdeps.runonly", true) 这种策略,仅仅用于控制依赖的 target file 的自身安装。。

而 installfiles/headerfiles ,全部走 {public, insterface, private} 控制,不受上面的 policy 影响。

@waruqi
Copy link
Member Author

waruqi commented Jul 10, 2024

不过用策略确实没法细粒度控制每个依赖的安装,修改版:

Only install the current target without deps

add_deps(..., {install = false})

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 files

add_installfiles(..., {public = true})

Control installation directories for target

set_bindir -- (default: "bin")
set_libdir -- (default: "lib")
set_includedir -- (default: "include")
set_prefixdir -- (default: "")
set_installdir -- installation root directory (xmake install -o installdir)

result:

installdir/prefixdir
  - bindir
  - libdir
  - includedir

@xq114
Copy link
Contributor

xq114 commented Jul 10, 2024

  1. 部分情况下,package的安装并不如预期,比如opencv我仅用到部分模块,不需要太多opencv库。

默认会装,但仅仅装 shared 的 package 文件,静态库不会,默认没有配置 add_requires("xxx", {configs = {shared = true}}) ,那就是默认静态库,不会装

他意思是opencv里面有很多dll,并不是每个dll都需要用到。qt也有类似情况,不是所有qt模块的dll都要用到,可能只用到Qt6Base.dll Qt6Gui.dll 结果把 Qt6Network.dll 也打包进来了。windeployqt.exe就没考虑这点,导致打包的程序包太大。这种情况可以提供个 utils.symbols.depend 模块,输出一个exe依赖的所有dll文件(调用dumpbin.exe /dependent xxx.exe再parse就行),在after_install script里面删掉不要的dll

@waruqi
Copy link
Member Author

waruqi commented Jul 11, 2024

  1. 部分情况下,package的安装并不如预期,比如opencv我仅用到部分模块,不需要太多opencv库。

默认会装,但仅仅装 shared 的 package 文件,静态库不会,默认没有配置 add_requires("xxx", {configs = {shared = true}}) ,那就是默认静态库,不会装

他意思是opencv里面有很多dll,并不是每个dll都需要用到。qt也有类似情况,不是所有qt模块的dll都要用到,可能只用到Qt6Base.dll Qt6Gui.dll 结果把 Qt6Network.dll 也打包进来了。windeployqt.exe就没考虑这点,导致打包的程序包太大。这种情况可以提供个 utils.symbols.depend 模块,输出一个exe依赖的所有dll文件(调用dumpbin.exe /dependent xxx.exe再parse就行),在after_install script里面删掉不要的dll

这个想法是挺好,就是要全平台处理稳定,不少东西需要处理。。#5330

@waruqi waruqi mentioned this issue Jul 11, 2024
20 tasks
@waruqi
Copy link
Member Author

waruqi commented Jul 19, 2024

某些依赖库可能要被输出到不同的目录,这一点与xpack的交互,好像没法控制?

如果 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 中去通过 set_prefixdir("/", {bindir = , libdir = }) 修改总的加载依赖的动态库路径。

而如果在 foo target 中配置 set_prefixdir("/", {bindir = , libdir = }) ,是没法影响 app 安装时候的依赖库路径的。。xmake install app

只要当 xmake install foo 单独安装 foo 库的时候,才会生效。。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Some dependent libraries may be output to different directories. It seems that the interaction with xpack cannot be controlled?

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 set_prefixdir("/", {bindir = , libdir = }) in the app target.

And if you configure set_prefixdir("/", {bindir = , libdir = }) in foo target, it will not affect the dependency library path during app installation. . xmake install app

This will only take effect when xmake install foo installs the foo library separately. .

@waruqi
Copy link
Member Author

waruqi commented Jul 19, 2024

所以 #5335 的 patch, 在 xpack 里面,如果仅仅配置 add_targets("app") 就会自动安装 app 的所有依赖库,不需要添加 foo target,但是 foo target 的安装子路径跟随的是 app 的 set_prefixdir 设置。。

如果想要单独安装 foo ,就配置 add_targets("foo") ,就会跟随 foo target 的 set_prefixdir 设置。。

你可以试下这个 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")

@waruqi
Copy link
Member Author

waruqi commented Jul 19, 2024

依赖的package似乎目前版本不会被安装?或者说这个取决于包的xmake.lua编写问题?
这个我是测试的opencv。
部分情况下,package的安装并不如预期,比如opencv我仅用到部分模块,不需要太多opencv库。
这时候的xpack安装,如何考虑自行安装?或者说拿到本机编译的库路径(这块目前我好像没找到api),自行去编写安装逻辑?

包的动态库安装,我也改进过了,会根据 utils.binary.deplibs dump 出来的依赖库,自动过滤掉不需要的 so 库安装

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It seems that the current version of the dependent package will not be installed? Or is this a problem with writing xmake.lua that depends on the package?
I tested this with opencv.
In some cases, the installation of the package is not as expected. For example, I only use some opencv modules and do not need too many opencv libraries.
How to consider installing xpack by yourself at this time? Or can you get the natively compiled library path (I don’t seem to have found the API for this so far) and write the installation logic by yourself?

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.

@waruqi
Copy link
Member Author

waruqi commented Jul 19, 2024

对于frameworks的安装问题。目前诸如add_rules("qt.widgetapp")这样的qt框架,或者其他框架,都没法正常安装的
这里我是写了个脚本去部署的,自行调用 windepolyqt。

xmake install 原本就会自动调用 windeployqt , 之前就支持。

os.vrunv(windeployqt, argv, {envs = envs})

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


For frameworks installation issues. Currently, qt frameworks such as add_rules("qt.widgetapp") or other frameworks cannot be installed normally.
Here I wrote a script to deploy and call windepolyqt myself.

xmake install will automatically call windeployqt, which was supported before.

os.vrunv(windeployqt, argv, {envs = envs})

@waruqi
Copy link
Member Author

waruqi commented Jul 19, 2024

另外,当前 patch 新增了 add_rpathdirs("..", {installonly = true})install.rpath policy 配置,可以配置修改 install 阶段的 rpath,它会自动去掉 build 时候的 rpath ,加上 install rpath。。

@Wzshun
Copy link

Wzshun commented Jul 19, 2024

非常感谢,下周我尝试一下。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Thanks a lot, I'll give it a try next week.

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

非常感谢,下周我尝试一下。

可以了么

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Thanks a lot, I'll give it a try next week.

Is it ok?

@Wzshun
Copy link

Wzshun commented Jul 22, 2024

我这边是,用的opencv的package,没有看到opencv 相关的库,在xpack输出位置那。

工程如下

add_rules("mode.debug", "mode.release")

set_languages("c++14")
set_runtimes(is_mode("debug") and "MDd" or "MD")
set_exceptions("cxx")
set_encodings("utf-8")

add_repositories("local-repo src/3rd-party")

add_requires("opencv", {configs = {shared = true,
                        quirc = false, protobuf = false, tiff = false, opengl = false, webp = false, ffmpeg = false, eigen = false, ['1394'] = false}})

target("opencvTest")
    add_rules("qt.widgetapp")
    add_headerfiles("src/*.h")
    add_files("src/*.cpp")
    add_files("src/mainwindow.ui")
    -- add files with Q_OBJECT meta (only for qt.moc)
    add_files("src/mainwindow.h")
    --deps
    add_packages("opencv")
-- 打包
includes("@builtin/xpack")

xpack("opencvTestPack")
    add_targets("opencvTest")
    set_formats("zip")

有没有可能是opencv的包描述没很好的安装?

或者说我之前也尝试使用编写过,参照table.warp(pkg:get("libfiles"))的写法,去遍历要安装的库,但是这里的local filename = path.filename(libfile),opencv这里的返回都是xxxx.lib,完全没有和dll后缀相关的。
batchcmds

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

我这 mac 下可以的么

ruki-2:test3 ruki$ unzip -l  build/xpack/opencvTestPack/opencvTestPack.zip
Archive:  build/xpack/opencvTestPack/opencvTestPack.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
    34600  07-22-2024 15:39   bin/opencvTest
   169880  07-22-2024 15:39   lib/libopencv_saliency.410.dylib
  1055720  07-22-2024 15:39   lib/libopencv_xphoto.410.dylib
   357936  07-22-2024 15:39   lib/libopencv_surface_matching.4.10.0.dylib
   464240  07-22-2024 15:39   lib/libopencv_mcc.410.dylib
  3883584  07-22-2024 15:39   lib/libopencv_dnn.410.dylib
  5323312  07-22-2024 15:39   lib/libopencv_gapi.4.10.0.dylib
  1305344  07-22-2024 15:39   lib/libopencv_objdetect.4.10.0.dylib
    71472  07-22-2024 15:39   lib/libopencv_aruco.4.10.0.dylib
   179728  07-22-2024 15:39   lib/libopencv_shape.410.dylib
  6195600  07-22-2024 15:39   lib/libopencv_imgproc.4.10.0.dylib
   326840  07-22-2024 15:39   lib/libopencv_ccalib.410.dylib
    91480  07-22-2024 15:39   lib/libopencv_dnn_superres.410.dylib
   273624  07-22-2024 15:39   lib/libopencv_bioinspired.410.dylib
   169880  07-22-2024 15:39   lib/libopencv_saliency.4.10.0.dylib
   722216  07-22-2024 15:39   lib/libopencv_photo.410.dylib
    89576  07-22-2024 15:39   lib/libopencv_quality.4.10.0.dylib
    57992  07-22-2024 15:39   lib/libopencv_plot.4.10.0.dylib
   223080  07-22-2024 15:39   lib/libopencv_highgui.4.10.0.dylib
  4136624  07-22-2024 15:39   lib/libopencv_core.4.10.0.dylib
   212104  07-22-2024 15:39   lib/libopencv_line_descriptor.4.10.0.dylib
   132568  07-22-2024 15:39   lib/libopencv_bgsegm.410.dylib
   132568  07-22-2024 15:39   lib/libopencv_bgsegm.4.10.0.dylib
    64048  07-22-2024 15:39   lib/libopencv_phase_unwrapping.4.10.0.dylib
   172872  07-22-2024 15:39   lib/libopencv_superres.4.10.0.dylib
  2076384  07-22-2024 15:39   lib/libopencv_tracking.4.10.0.dylib
    98448  07-22-2024 15:39   lib/libopencv_img_hash.410.dylib
  1289256  07-22-2024 15:39   lib/libopencv_rgbd.410.dylib
   212104  07-22-2024 15:39   lib/libopencv_line_descriptor.410.dylib
  1478736  07-22-2024 15:39   lib/libopencv_ximgproc.410.dylib
   608304  07-22-2024 15:39   lib/libopencv_wechat_qrcode.410.dylib
   223080  07-22-2024 15:39   lib/libopencv_highgui.410.dylib
   550456  07-22-2024 15:39   lib/libopencv_text.4.10.0.dylib
   218288  07-22-2024 15:39   lib/libopencv_videostab.410.dylib
   351552  07-22-2024 15:39   lib/libopencv_videoio.410.dylib
    91480  07-22-2024 15:39   lib/libopencv_dnn_superres.4.10.0.dylib
   451640  07-22-2024 15:39   lib/libopencv_datasets.410.dylib
   218288  07-22-2024 15:39   lib/libopencv_videostab.4.10.0.dylib
  1323272  07-22-2024 15:39   lib/libopencv_imgcodecs.410.dylib
  1305344  07-22-2024 15:39   lib/libopencv_objdetect.410.dylib
   609880  07-22-2024 15:39   lib/libopencv_video.410.dylib
   722216  07-22-2024 15:39   lib/libopencv_photo.4.10.0.dylib
  3016912  07-22-2024 15:39   lib/libopencv_xfeatures2d.410.dylib
   273624  07-22-2024 15:39   lib/libopencv_bioinspired.4.10.0.dylib
   172872  07-22-2024 15:39   lib/libopencv_superres.410.dylib
    73432  07-22-2024 15:39   lib/libopencv_dnn_objdetect.4.10.0.dylib
  1289256  07-22-2024 15:39   lib/libopencv_rgbd.4.10.0.dylib
    71472  07-22-2024 15:39   lib/libopencv_aruco.410.dylib
   123888  07-22-2024 15:39   lib/libopencv_reg.4.10.0.dylib
   218792  07-22-2024 15:39   lib/libopencv_stereo.4.10.0.dylib
  2435528  07-22-2024 15:39   lib/libopencv_calib3d.4.10.0.dylib
   123888  07-22-2024 15:39   lib/libopencv_reg.410.dylib
   859224  07-22-2024 15:39   lib/libopencv_features2d.4.10.0.dylib
  1323272  07-22-2024 15:39   lib/libopencv_imgcodecs.4.10.0.dylib
    35408  07-22-2024 15:39   lib/libopencv_intensity_transform.4.10.0.dylib
   106216  07-22-2024 15:39   lib/libopencv_xobjdetect.410.dylib
   401752  07-22-2024 15:39   lib/libopencv_optflow.4.10.0.dylib
  4136624  07-22-2024 15:39   lib/libopencv_core.410.dylib
  2435528  07-22-2024 15:39   lib/libopencv_calib3d.410.dylib
   589984  07-22-2024 15:39   lib/libopencv_ml.410.dylib
    64048  07-22-2024 15:39   lib/libopencv_phase_unwrapping.410.dylib
   135296  07-22-2024 15:39   lib/libopencv_dpm.4.10.0.dylib
   609688  07-22-2024 15:39   lib/libopencv_stitching.410.dylib
   609688  07-22-2024 15:39   lib/libopencv_stitching.4.10.0.dylib
    73432  07-22-2024 15:39   lib/libopencv_dnn_objdetect.410.dylib
    83288  07-22-2024 15:39   lib/libopencv_rapid.410.dylib
   550456  07-22-2024 15:39   lib/libopencv_text.410.dylib
    75792  07-22-2024 15:39   lib/libopencv_fuzzy.410.dylib
  3016912  07-22-2024 15:39   lib/libopencv_xfeatures2d.4.10.0.dylib
   218792  07-22-2024 15:39   lib/libopencv_stereo.410.dylib
   106216  07-22-2024 15:39   lib/libopencv_xobjdetect.4.10.0.dylib
    89576  07-22-2024 15:39   lib/libopencv_quality.410.dylib
  5323312  07-22-2024 15:39   lib/libopencv_gapi.410.dylib
   859224  07-22-2024 15:39   lib/libopencv_features2d.410.dylib
   105456  07-22-2024 15:39   lib/libopencv_structured_light.4.10.0.dylib
   326840  07-22-2024 15:39   lib/libopencv_ccalib.4.10.0.dylib
  1478736  07-22-2024 15:39   lib/libopencv_ximgproc.4.10.0.dylib
    75792  07-22-2024 15:39   lib/libopencv_fuzzy.4.10.0.dylib
  2076384  07-22-2024 15:39   lib/libopencv_tracking.410.dylib
  3883584  07-22-2024 15:39   lib/libopencv_dnn.4.10.0.dylib
   509400  07-22-2024 15:39   lib/libopencv_face.410.dylib
   135296  07-22-2024 15:39   lib/libopencv_dpm.410.dylib
   102944  07-22-2024 15:39   lib/libopencv_hfs.4.10.0.dylib
   589984  07-22-2024 15:39   lib/libopencv_ml.4.10.0.dylib
   105456  07-22-2024 15:39   lib/libopencv_structured_light.410.dylib
   464240  07-22-2024 15:39   lib/libopencv_mcc.4.10.0.dylib
   608304  07-22-2024 15:39   lib/libopencv_wechat_qrcode.4.10.0.dylib
   401752  07-22-2024 15:39   lib/libopencv_optflow.410.dylib
   551112  07-22-2024 15:39   lib/libopencv_flann.4.10.0.dylib
    83288  07-22-2024 15:39   lib/libopencv_rapid.4.10.0.dylib
   357936  07-22-2024 15:39   lib/libopencv_surface_matching.410.dylib
   179728  07-22-2024 15:39   lib/libopencv_shape.4.10.0.dylib
   102944  07-22-2024 15:39   lib/libopencv_hfs.410.dylib
  6195600  07-22-2024 15:39   lib/libopencv_imgproc.410.dylib
   509400  07-22-2024 15:39   lib/libopencv_face.4.10.0.dylib
   609880  07-22-2024 15:39   lib/libopencv_video.4.10.0.dylib
    98448  07-22-2024 15:39   lib/libopencv_img_hash.4.10.0.dylib
   451640  07-22-2024 15:39   lib/libopencv_datasets.4.10.0.dylib
    57992  07-22-2024 15:39   lib/libopencv_plot.410.dylib
   351552  07-22-2024 15:39   lib/libopencv_videoio.4.10.0.dylib
   551112  07-22-2024 15:39   lib/libopencv_flann.410.dylib
    35408  07-22-2024 15:39   lib/libopencv_intensity_transform.410.dylib
  1055720  07-22-2024 15:39   lib/libopencv_xphoto.4.10.0.dylib
---------                     -------
 89234936                     103 files

,opencv这里的返回都是xxxx.lib,完全没有和dll后缀相关的。

这是包的问题,跟当前 install 的逻辑无关

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

因为这个包 win 下,dll 是默认安装在 x64\vc17\bin 的。。但是 libfiles 的提取,目前只能从 bin 下找。。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Because this package is under win, the dll is installed in x64\vc17\bin by default. . However, the extraction of libfiles can only be found from bin. .

@Wzshun
Copy link

Wzshun commented Jul 22, 2024

是啊,我就觉得奇怪。。

程序调试运行是可以跑通的,说明xmake和对应的包处理,在调试运行环境变量里加入了包的编译安装目录(包被本地编译的情况下)。

目前看来,两种做法?:
a. 在包描述中,规范包的输出(输出哪些库、输出到哪里)?或者都需要定义bin目录?
b. xmake install 或 xpack相关的安装,需要自行从包给到的环境变量,找包。

其实这两点,也是我看xmake 的包描述里,非常模糊的几点。。官方文档介绍里,仅很好的介绍了基于xmake的工程的包描述生成xmake package,但是一些关于package定义的xmake.lua是需要输出哪些内容、规范是怎么样的都没提及,这对于一些预编译好的二进制库使用就需要自行摸索之类的。。

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

a. 在包描述中,规范包的输出(输出哪些库、输出到哪里)?或者都需要定义bin目录?
b. xmake install 或 xpack相关的安装,需要自行从包给到的环境变量,找包。

目前不支持,但找 dll 我刚改进过了,可以更新下 install 分支,重装下 opencv 再试试

其实这两点,也是我看xmake 的包描述里,非常模糊的几点。。官方文档介绍里,仅很好的介绍了基于xmake的工程的包描述生成xmake package,但是一些关于package定义的xmake.lua是需要输出哪些内容、规范是怎么样的都没提及,这对于一些预编译好的二进制库使用就需要自行摸索之类的。。

没时间写

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


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? :
a. In the package description, standardize the output of the package (which libraries are output and where are they output)? Or do you need to define the bin directory?
b. For xmake install or xpack related installations, you need to find the package by yourself from the environment variables given by the package.

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 xmake package, but there is no mention of what the xmake.lua of the package definition needs to output and what the specifications are. , which requires you to explore by yourself when using some precompiled binary libraries. .

@Wzshun
Copy link

Wzshun commented Jul 22, 2024

可以了,并且也只安装了程序使用到的库。

但还是有些欠缺的地方,这也不是xmake的问题了。

  1. package本身模块的依赖库,没被输出。
    例如我这里的:
    1721643185153
    但这个完整的依赖是这样的:
    1721643225172

  2. qt的库 安装问题。这个我打算在xpack的before_install 自行编写了。。

但这也非常感谢了,离一键完整部署更进一步了。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


a. In the package description, standardize the output of the package (which libraries are output and where are they output)? Or do you need to define the bin directory?
b. For xmake install or xpack related installations, you need to find the package by yourself from the environment variables given by the package.

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.

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 xmake-based project to generate the xmake package, but there is no mention of what content xmake.lua needs to output and what the specifications are for the package definition. This is not mentioned for some To use the precompiled binary library, you need to explore it yourself. .

no time to write

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


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.

  1. The dependent libraries of the module of the package itself are not output.
    For example what I have here:
    1721643185153
    But the complete dependency looks like this:
    1721643225172

  2. Qt library installation problem. I plan to write this myself before_install of xpack. .

@xq114
Copy link
Contributor

xq114 commented Jul 22, 2024

因为这个包 win 下,dll 是默认安装在 x64\vc17\bin 的。。但是 libfiles 的提取,目前只能从 bin 下找。。

是否考虑给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路径。

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

因为这个包 win 下,dll 是默认安装在 x64\vc17\bin 的。。但是 libfiles 的提取,目前只能从 bin 下找。。

是否考虑给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 暂时不处理了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Because this package is under win, the dll is installed in x64\vc17\bin by default. . However, the extraction of libfiles can only be found from bin. .

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.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Because this package is under win, the dll is installed in x64\vc17\bin by default. . However, the extraction of libfiles can only be found from bin. .

Have you considered adding a bindirs 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.

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

package本身模块的依赖库,没被输出。

再试试,应该可以了

@waruqi
Copy link
Member Author

waruqi commented Jul 22, 2024

qt的库 安装问题。这个我打算在xpack的before_install 自行编写了。。

这个目前只有在 xmake install 才会执行 qtdeploy,target 里面没有对应 xpack action 的,所以没法内置对 xpack 支持。

所以建议在 xpack 的 after_installcmd 里调用 qtdeploy + batchcmds:cp 做。xpack的 package:targets(), package:target 也是可以访问到所有 add_targets 绑定到 xpack 的 target 的。。

也可以在 xpack 的 before_package/after_package 里去 qtdeploy 然后走 package:add("installfiles")

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


The dependent libraries of the package's own modules are not output.

Try again, it should work

@waruqi
Copy link
Member Author

waruqi commented Jul 23, 2024

package本身模块的依赖库,没被输出。

再试试,应该可以了

这个有效果了么

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


The dependent libraries of the package's own modules are not output.

Try again, it should work

Has this worked?

@Wzshun
Copy link

Wzshun commented Jul 23, 2024

可以了,但是我尝试去编写qt安装,在after_installcmd

-- 打包
includes("@builtin/xpack")

xpack("opencvTestPack")
    add_targets("opencvTest")
    set_formats("zip")
    after_installcmd(function(xpack, batchcmds)
        import("qt.deploy", {alias="qt_install"})
        print("install dir:", xpack:bindir())
        qt_install(xpack:targets()[1], xpack:bindir())
    end)

自己编写的qt.deploy.lua

function main(target, installDir)
    if not target then
        raise("Target is nil.")
    end

    if not os.isdir(installDir) then
        raise("Install dir is not exists.")
    end

    --local baseName = target:basename()
    --local binName = baseName .. ".exe"
    local binName = target:filename()

    -- TODO obtain the qt components for the target and it's deps 
    local components = {}

    -- TODO handle different os platform
    _qtDeploy_windows(binName, components, installDir)
end

这里报错

packing build\xpack\opencvTestPack\opencvTestPack.zip .. 
install dir: build\.xpack\opencvTestPack\installed\zip\bin
error: Install dir is not exists.

xpack:bindir()after_installcmd阶段里是不是还没创建?

@waruqi
Copy link
Member Author

waruqi commented Jul 23, 2024

after_installcmd 是命令式生成,不是真的执行,一切操作都用 batchcmds

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


after_installcmd is generated by command, not actually executed. All operations are done using batchcmds.

@waruqi
Copy link
Member Author

waruqi commented Jul 23, 2024

可以了

既然依赖库安装可以了,我就先 merge 了,qt deploy 这个跟当前无关,自己处理下就行了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


That's it

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.

@waruqi
Copy link
Member Author

waruqi commented Jul 23, 2024

qt deploy 回头可以单独开 issues/discussion 讨论

@waruqi waruqi closed this as completed Jul 23, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After qt deploy, you can open issues/discussion separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants