xmake-io / xmake

šŸ”„ A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.87k stars 776 forks source link

unity_build recursion with xmake test #5288

Closed charlesseizilles closed 2 months ago

charlesseizilles commented 2 months ago

Xmake Version

2.9.3

Operating System Version and Architecture

Windows 10 Pro version 22H2

Describe Bug

When calling xmake test and having a dep target that uses unity_build, the compilation fails.

Expected Behavior

It should compile

Project Configuration

xmake.zip

Additional Information and Error Logs

> xmake test -vD
checking for platform ... windows
checking for architecture ... x64
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.38.33133
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for link.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
generating.unityfile build\.gens\foobar\windows\unity_build\unity_1.cpp
[ 37%]: compiling.release build\.gens\foobar\windows\unity_build\unity_1.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x64\\cl.exe" -c -nologo /EHsc -Fobuild\.objs\foobar\windows\x64\release\build\.gens\foobar\windows\unity_build\unity_1.cpp.obj build\.gens\foobar\windows\unity_build\unity_1.cpp
[ 50%]: compiling.release test.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x64\\cl.exe" -c -nologo /EHsc -Fobuild\.objs\test\windows\x64\release\test.cpp.obj test.cpp
checking for C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
> cl.exe "/sourceDependencies" "C:\Users\Charles\AppData\Local\Temp\.xmake\240701\_42ED3810F25F4140841BDBE0E98490B0.json" "-nologo"
error: @programdir\core\main.lua:329: @programdir\actions\build\main.lua:148: @programdir\modules\async\runjobs.lua:325: @programdir\modules\private\action\build\object.lua:91: @programdir\modules\core\tools\cl.lua:728: unity_1.cpp
C:\Users\Charles\Documents\work\test\xmake\build\.gens\foobar\windows\unity_build\unity_1.cpp(1): fatal error C1014: too many include files: depth = 1024

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [@programdir\modules\core\tools\cl.lua:728]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [@programdir\modules\core\tools\cl.lua:667]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]:
    [@programdir\core\tool\compiler.lua:278]: in function 'compile'
    [@programdir\modules\private\action\build\object.lua:91]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:122]: in function 'build_object'
    [@programdir\modules\private\action\build\object.lua:147]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:241]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:223]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:973: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

With the build\.gens\foobar\windows\unity_build\unity_1.cpp file containing only:

#include "unity_1.cpp"
waruqi commented 2 months ago

try it again. https://github.com/xmake-io/xmake/pull/5291

xmake update -s dev
charlesseizilles commented 2 months ago

It works, thanks