Closed madhurajith closed 2 years ago
you can update to dev and add add_rules("protobuf.cpp")
xmake update -s dev
Switched to dev branch but I can still see the issue.
It's quite strange now. Running XMake: UpdateIntellisense from vscode multiple times leads to different outputs. Sometimes protobuf include path is there. Other times it is not there. Some in-deterministic stuff going on.
It works for me. I cannot reproduce it
you can run xmake project -k compile_commands
to test it.
Issue is still there. I'll make a video to show what is happening.
Attached video shows what I get when i run xmake project -k compile_commands
multiple times in my ubuntu machine,
Run | Time | lib.cpp has protobuf include | main.cpp has protobuf include |
---|---|---|---|
1 | 5s | Yes | No |
2 | 10s | No | Yes |
3 | 15s | No | No |
4 | 20s | No | Yes |
5 | 25s | Yes | No |
6 | 30s | Yes | Yes |
This is an unedited video. No tricks. Exact behaviour I get.
In this case I'm using add_files("proto/*.proto", {rules="protobuf.cpp", proto_public=true})
therefore I expect the output in run 6 to be the output in each run
please add add_rules("protobuf.cpp")
That fixed the issue of protobuf gens folder missing out.
However there is a duplicate entry for test.pb.cc
add_rules("mode.debug", "mode.release")
add_requires("protobuf-cpp")
target("proto_lib")
set_kind("static")
add_installfiles("include/lib.hpp")
add_includedirs("include", {public=true})
add_files("src/lib.cpp")
add_files("proto/*.proto", {rules="protobuf.cpp", proto_public=true})
--add_files("proto/*.proto", {rules="protobuf.cpp"})
add_packages("protobuf-cpp")
add_rules("protobuf.cpp")
target("proto_lib_test")
set_kind("binary")
add_files("src/main.cpp")
add_deps("proto_lib")
[
{
"directory": "/home/namal/Temp/proto_lib",
"arguments": ["/usr/bin/ccache", "/usr/bin/gcc", "-c", "-m64", "-g", "-O0", "-Iinclude", "-Ibuild/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto", "-o", "build/.objs/proto_lib_test/linux/x86_64/debug/src/main.cpp.o", "src/main.cpp"],
"file": "src/main.cpp"
},
{
"directory": "/home/namal/Temp/proto_lib",
"arguments": ["/usr/bin/ccache", "/usr/bin/gcc", "-c", "-m64", "-g", "-O0", "-Iinclude", "-I", "/home/namal/.xmake/packages/p/protobuf-cpp/3.19.4/b2115fa005c149c3a814138eccc0044e/include", "-std=c++11", "-Ibuild/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto", "-o", "build/.objs/proto_lib/linux/x86_64/debug/gens/rules/protobuf/proto/test.pb.cc.o", "build/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto/test.pb.cc"],
"file": "build/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto/test.pb.cc"
},
{
"directory": "/home/namal/Temp/proto_lib",
"arguments": ["/usr/bin/ccache", "/usr/bin/gcc", "-c", "-m64", "-g", "-O0", "-Iinclude", "-I", "/home/namal/.xmake/packages/p/protobuf-cpp/3.19.4/b2115fa005c149c3a814138eccc0044e/include", "-std=c++11", "-Ibuild/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto", "-o", "build/.objs/proto_lib/linux/x86_64/debug/gens/rules/protobuf/proto/test.pb.cc.o", "build/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto/test.pb.cc"],
"file": "build/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto/test.pb.cc"
},
{
"directory": "/home/namal/Temp/proto_lib",
"arguments": ["/usr/bin/ccache", "/usr/bin/gcc", "-c", "-m64", "-g", "-O0", "-Iinclude", "-Ibuild/.gens/proto_lib/linux/x86_64/debug/rules/protobuf/proto", "-I", "/home/namal/.xmake/packages/p/protobuf-cpp/3.19.4/b2115fa005c149c3a814138eccc0044e/include", "-o", "build/.objs/proto_lib/linux/x86_64/debug/src/lib.cpp.o", "src/lib.cpp"],
"file": "src/lib.cpp"
}]
add_files("proto/*.proto", {rules="protobuf.cpp", proto_public=true})
remove rules
add_files("proto/*.proto", {proto_public=true})
That fixed the issue. Thanks
Xmake Version
2.6.4
Operating System Version and Architecture
Ubuntu
Describe Bug
If proto_public=true is set for protobuf.cpp rule, then the source files in the same target lose the protobuf gens folder from the compile_commands.json args,
e.g. The compile command,
/usr/bin/ccache /usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Iinclude -Ibuild/.gens/proto_lib/linux/x86_64/release/rules/protobuf/proto -isystem /home/user/.xmake/packages/p/protobuf-cpp/3.19.4/b2115fa005c149c3a814138eccc0044e/include -DNDEBUG -o build/.objs/proto_lib/linux/x86_64/release/src/lib.cpp.o src/lib.cpp
Corresponding compile_commands.json entry,
The .gens folder is lost only from the compilation units of the same target. The target that consumes the library still get the correct include path.
Expected Behavior
Protobuf gens folder should always be in the same target arguments in the compile_commands.json.
Project Configuration
To reproduce,
To see the correct behaviour, switch the protobuf.cpp rule without proto_public=true and do the same steps and check the compile_commands.json file.
Switching from one config to the other and generating the compile_commands.json is bit in-deterministic. Please repeat the process several times if you don't see the issue in the first try.
proto_lib.zip
Additional Information and Error Logs
No response