xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.2k stars 789 forks source link

add_deps 和 import("package.tools.msbuild") 配合时没有正确传递头文件路径和链接依赖 #5892

Closed heheda123123 closed 1 hour ago

heheda123123 commented 2 hours ago

Xmake 版本

v2.9.6+dev.ad8324471

操作系统版本和架构

windows 11

描述问题

https://github.com/xmake-io/xmake-repo/issues/5846

期待的结果

加上依赖的头文件路径,链接依赖

工程配置

已提供

附加信息和错误日志

已提供

Issues-translate-bot commented 2 hours ago

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


Title: add_deps and import("package.tools.msbuild") are combined, the header file path and link dependencies are not correctly passed

waruqi commented 2 hours ago

跟 msbuild 有啥关系,只跟是否安装在 include 目录,以及 add_includedirs , package library kind 有关。。其他没任何关系

Issues-translate-bot commented 2 hours ago

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


It has nothing to do with msbuild. It only depends on whether it is installed in the include directory, as well as add_includedirs and package library kind. . Nothing else matters

heheda123123 commented 2 hours ago

如果add_deps了,package 构建的时候会自动加上对应的头文件路径吧 phnt包的include目录是正常的,有h文件

或者说看下那个链接里的包描述为啥出错了?是我哪里写错 了?

Issues-translate-bot commented 2 hours ago

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


If add_deps is added, the corresponding header file path will be automatically added when the package is built. The include directory of the phnt package is normal and there is an h file.

heheda123123 commented 1 hour ago

解决了,另外写了个xmake.lua https://github.com/xmake-io/xmake-repo/pull/5847

waruqi commented 1 hour ago

如果add_deps了,package 构建的时候会自动加上对应的头文件路径吧 phnt包的include目录是正常的,有h文件

或者说看下那个链接里的包描述为啥出错了?是我哪里写错 了?

不知道,我没空看,反正头文件找不到,只能是上面我说的几种可能性,或者路径不对。。跟 msbuild没有半毛钱关系

Issues-translate-bot commented 1 hour ago

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


If add_deps is added, the corresponding header file path will be automatically added when the package is built. The include directory of the phnt package is normal and has an h file.

Or take a look at why the package description in that link is wrong? Did I write something wrong somewhere?

I don’t know, I don’t have time to look. Anyway, the header file cannot be found. It can only be the possibilities I mentioned above, or the path is wrong. . It has nothing to do with msbuild

heheda123123 commented 1 hour ago

如果add_deps了,package 构建的时候会自动加上对应的头文件路径吧 phnt包的include目录是正常的,有h文件 或者说看下那个链接里的包描述为啥出错了?是我哪里写错 了?

不知道,我没空看,反正头文件找不到,只能是上面我说的几种可能性,或者路径不对。。跟 msbuild没有半毛钱关系

。。。我也没说和msbuild有关系,那不能是package.tools.msbuild的问题吗

Issues-translate-bot commented 1 hour ago

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


If add_deps is added, the corresponding header file path will be automatically added when the package is built. The include directory of the phnt package is normal, and there is an h file. Or take a look at why the package description in that link is wrong? Did I write something wrong somewhere?

I don’t know, I don’t have time to look. Anyway, the header file cannot be found. It can only be a few possibilities as I mentioned above, or the path is wrong. . It has nothing to do with msbuild

. . . I didn’t say it had anything to do with msbuild, so couldn’t it be a problem with package.tools.msbuild?

waruqi commented 1 hour ago

如果add_deps了,package 构建的时候会自动加上对应的头文件路径吧 phnt包的include目录是正常的,有h文件 或者说看下那个链接里的包描述为啥出错了?是我哪里写错 了?

不知道,我没空看,反正头文件找不到,只能是上面我说的几种可能性,或者路径不对。。跟 msbuild没有半毛钱关系

。。。我也没说和msbuild有关系,那不能是package.tools.msbuild的问题吗

我指的就是跟 package.tools.msbuild 无关。。你都自己在 on_install 里面去 os.cp 到 include 了。对用户导出头文件,只看 installdir/include 目录,以及 package 的 add_includedirs 配置,还有 package 的 kind,我上面说过了。。

跟 package.tools.msbuild 没有任何关系。你只用了 package.tools.msbuild 的 build function ,原本就不会去 copy headers。如果里面还去 copy headers 了,到还能扯上些关系

heheda123123 commented 1 hour ago

关键是还没执行到os.cp那一步去,还在构建库本身的阶段,执行import("package.tools.msbuild").build(package, configs)还没成功。 我发的报错就在执行import("package.tools.msbuild").build(package, configs)构建这个库本身的时候, 下面的编译命令里面就没有带 add_deps的phnt和detours相关的头文件路径

 C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\CL.exe /c /I"C:\vcpkg\installed\x64-windows\include" /Zi /nologo /W3 /WX- /diagnostics:
         column /sdl /O2 /Oi /GL /D _MEMORY_MODULE /D _HAS_AUTO_INITIALIZE /D NDEBUG /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permiss
         ive- /Fo"x64\Release\\" /Fd"C:\Users\Administrator\AppData\Local\.xmake\cache\packages\2411\m\memorymodulepp\2024.11.7\source\memorymodulepp\x64\Release\MemoryModule.pdb" /external:W3 /G
         d /TP /FC /errorReport:queue ..\3rdparty\Detours\creatwth.cpp ..\3rdparty\Detours\detours.cpp ..\3rdparty\Detours\disasm.cpp ..\3rdparty\Detours\disolarm.cpp ..\3rdparty\Detours\disolarm
         64.cpp ..\3rdparty\Detours\disolia64.cpp ..\3rdparty\Detours\disolx64.cpp ..\3rdparty\Detours\disolx86.cpp ..\3rdparty\Detours\image.cpp ..\3rdparty\Detours\modules.cpp ImportTable.cpp I
         nitialize.cpp LoadDllMemoryApi.cpp MemoryModule.cpp MmpDotNet.cpp MmpTlsFiber.cpp MmpLdrpTls.cpp MmpTls.cpp Loader.cpp InvertedFunctionTable.cpp LdrEntry.cpp BaseAddressIndex.cpp Utils.c
Issues-translate-bot commented 1 hour ago

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


The key is that the os.cp step has not been executed yet. It is still in the stage of building the library itself, and the execution of import("package.tools.msbuild").build(package, configs) has not been successful yet. The error I received was when executing import("package.tools.msbuild").build(package, configs) to build the library itself. There is no header file path related to phnt and detours with add_deps in the following compilation command.

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\CL.exe /c /I"C:\vcpkg\installed\x64-windows\include " /Zi /nologo /W3 /WX- /diagnostics:
column /sdl /O2 /Oi /GL /D _MEMORY_MODULE /D _HAS_AUTO_INITIALIZE /D NDEBUG /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permiss
ive- /Fo"x64\Release\\" /Fd"C:\Users\Administrator\AppData\Local\.xmake\cache\packages\2411\m\memorymodulepp\2024.11.7\source\memorymodulepp\x64\Release\ MemoryModule.pdb" /external:W3 /G
d /TP /FC /errorReport:queue ..\3rdparty\Detours\creatwth.cpp ..\3rdparty\Detours\detours.cpp ..\3rdparty\Detours\disasm.cpp ..\3rdparty\Detours\disolarm.cpp . .\3rdparty\Detours\disolarm
64.cpp ..\3rdparty\Detours\disolia64.cpp ..\3rdparty\Detours\disolx64.cpp ..\3rdparty\Detours\disolx86.cpp ..\3rdparty\Detours\image.cpp ..\3rdparty\Detours\ modules.cpp ImportTable.cpp I
initialize.cpp LoadDllMemoryApi.cpp MemoryModule.cpp MmpDotNet.cpp MmpTlsFiber.cpp MmpLdrpTls.cpp MmpTls.cpp Loader.cpp InvertedFunctionTable.cpp LdrEntry.cpp BaseAddressIndex.cpp Utils.c
heheda123123 commented 1 hour ago

在全局 add_deps("phnt", "microsoft-detours") 在 on_install 内部调用 import("package.tools.msbuild").build(package, configs) 那在构建这个sln的时候,是不是会把依赖phnt的头文件路径加上去呢,这个我也理解错了?

Issues-translate-bot commented 1 hour ago

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


Globally add_deps("phnt", "microsoft-detours") Call import("package.tools.msbuild").build(package, configs) inside on_install Then when building this sln, will the path of the header file that depends on phnt be added? I also understand this wrong?

heheda123123 commented 1 hour ago

比如找个其他用cmake的包,上面add_deps之后,下面用package.tools.cmake 构建这个包的时候,deps里面的头文件路径等等肯定就会加进来 image

waruqi commented 1 hour ago

那你得说清楚,是 msbuild 内部编译没有获取到头文件路径。而不是对用户导出的头文件。

package.tools.msbuild 本身是不会处理这些的,cmake/autoconf 可以,是因为它们支持从 pkg-config 到 deps 里面取。。deps 安装时候,安装了对应的 pc 文件导出了这些信息,cmake 还能额外从 .cmake 中取,走 FindXXX 。。

即使 cmake/autoconf 的 pkg-config/FindXXX 没找到,还可以走 install(package, configs, {cxflags/packagedeps}) 强行打入 include path,那是因为 cmake/autoconf 支持外部传入 cxflags,xmake 有机会传入进去。

msbuild 又没这些东西,怎么取?一不支持 pkg-config,二不支持传参导入 cxflags,xmake 怎么让它知道。这种如果非要裸用 msbuild ,你只能自己走 io.replace 去强行 patch vcproj 文件,给打进去。如果非要原生支持,只能给 ms 提 issues ,让他们支持。

Issues-translate-bot commented 1 hour ago

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


Then you have to make it clear that msbuild's internal compilation did not obtain the header file path. Instead of the header file exported by the user.

package.tools.msbuild itself will not handle these, cmake/autoconf can because they support fetching from pkg-config to deps. . When deps is installed, the corresponding pc file is installed to export this information. cmake can additionally take it from .cmake and use FindXXX. .

Even if pkg-config/FindXXX of cmake/autoconf is not found, you can also use install(package, configs, {cxflags/packagedeps}) to forcibly enter the include path. That is because cmake/autoconf supports external input of cxflags, and xmake has the opportunity to input Go in.

msbuild doesn’t have these things, how can I get them? First, it does not support pkg-config, and second, it does not support passing parameters to import cxflags. How can xmake let it know? If you have to use msbuild naked, you can only use io.replace to forcibly patch the vcproj file and type it in. If you have to support it natively, you can only submit issues to ms and ask them to support it.

heheda123123 commented 1 hour ago

那没问题了,结论就是package.tools.msbuild和 package.tools.cmake行为不一致。这种情况只能write一个xmake.lua

Issues-translate-bot commented 1 hour ago

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


That's no problem. The conclusion is that package.tools.msbuild and package.tools.cmake behave inconsistently.