Open Charusso opened 5 years ago
@Charusso I think #2092 solved your problem. Could you please try it out?
@Charusso since UE2.24 you can actually use the UnrealBuildTool to generate the compile_commands.json. You just need to run "<path_to_ue4.24>/Engine/Binaries/DotNet/UnrealBuildTool.exe
-mode=GenerateClangDatabase -project"
Currently I am using it for the CCLS languag server for code checking in editor, however it doesn't seem to work fully as still several errors appear, but it may be enough for your usecase.
Here is an ongoing thread in the forums where it's being discussed as well, and includes further references to the documentation that mentions it in release notes https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1525128-linux-rdm-compile_commands-json
@axsaucedo Is this working in Linux? I'm trying to do the same but when I run:
/home/user/Programs/UnrealEngine/Engine/Build/BatchFiles/Linux/Build.sh/Build.sh -project=/home/user/Documents/Unreal/MyProject/MyProject.uproject -mode=GenerateClangDatabase UE4Game Linux Development
I get an error complaining that clang is not installed, but it is:
clang --version
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
There is a comment in the mentioned forum discussion about the same problem, that the Build.sh script can not generate a compile command database file right now on linux.
10-11-2020, 01:47 PM Same situation here, not able to use -mode=GenerateClangDatabase it complaints about not finding clang, which is insatlled.
What you were trying to do.
make
Unreal Engine 4 from source to createcompile_commands.json
.The version number of CodeChecker c0664e3 (6.9.1)
What behaviour was expected instead of what happened.
As usual I tried the following to produce the database:
CodeChecker log -b "make -j13" -o compile_commands.json
Outcome:
Build failed
.2.1. I have followed the advice by
Timothee "TTimo" Besset
withBear
:Sourcetrail
:compile_commands.json
.2.2. I wanted to use that
Bear
-madecompile_commands.json
:The usual command:
CodeChecker analyze compile_commands.json -o ...
Outcome: Other software like
Sourcetrail
works perfectly with that, butCodeChecker
is not:Copied the tricky build command from
TTimo
toCodeChecker
:CodeChecker log -b "./Engine/Build/BatchFiles/Linux/Build.sh UE4Game Linux Development -disableunity -nopch" -o compile_commands.json
Outcome: successfully built, but the
compile_commands.json
was empty, so failed.I have hard-coded the arguments into
Build.sh
and the outcome was the same so the parsing is cool I think.Tried out the hack made by
TTimo
combined with his build command withCodeChecker
:export CC_LOGGER_GCC_LIKE="gcc:g++:clang:cc1"
cc1plus
may would be involved so I tried"gcc:g++:clang:cc1:cc1plus"
as well.CodeChecker log -b "./Engine/Build/BatchFiles/Linux/Build.sh UE4Game Linux Development -disableunity -nopch" -o compile_commands.json
3.
: successfully built, but thecompile_commands.json
was empty, so failed.Additional information
compile_commands.json
withninja
it immediately run into a trouble:Argument list too long
.There is two workaround to split the overhead:
If you check out the
CMakeLists.txt
is has the following (mentioned in the first link):The UE4 is that heavy it has that workaround here by default.
Note:
ninja
cannot handle it as well: If you try to build it hackingCMakeLists.txt
with the above trick:set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "")
, it tries to compile 8412 compilation unit, but after a while there is too much error and it give up.How to reproduce the environment
Before
make
create a copy of theUnrealEngine
folder because there is nomake clear
.The environment
./Engine/Binaries/Linux/UE4Editor
to check if it is working the folder is 78 GB.Building is about 5120 compilation unit with the tricky command.
The tricky command explained
/Engine/Build/BatchFiles/Linux/Build.sh UE4Game Linux Development -disableunity -nopch
disableunity
: process every compilation unit separately (5th post bygmpreussner
):nopch
: no pre-compiled header (2nd post byExtraLifeMatt
):Summary
I cannot decide if we would
2.)
use hackedBear
-madecompile_commands.json
likeSourcetrail
does,4.)
supportcc1
/(cc1plus
?) hooks better,5.)
supportCMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS/INCLUDES
better.The best would be just a simple
CodeChecker log -b "make -j13" -o compile_commands.json
.