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

Export include directories from protobuf rule #1453

Closed
madhurajith opened this issue Jun 9, 2021 · 4 comments
Closed

Export include directories from protobuf rule #1453

madhurajith opened this issue Jun 9, 2021 · 4 comments

Comments

@madhurajith
Copy link

rule("protobuf.cpp") add the _gens/** folder to the target's include directories.

However there is no easy way of declaring the _gens/** directory as a public include directory.

This is required for libraries with protobuf files in them.

It would be great if there was an option in the rule to export the include directory.

@waruqi waruqi added this to the v2.5.5 milestone Jun 9, 2021
@waruqi
Copy link
Member

waruqi commented Jun 9, 2021

you can update to dev, xmake update -s dev

and try {proto_public = true}

    add_files("src/**.proto", {rules = "protobuf.c", proto_public = true})

@waruqi
Copy link
Member

waruqi commented Jun 10, 2021

Does it work?

@madhurajith
Copy link
Author

Yes, I can confirm it compiles now.

One small issue though. Protobuf include path does not appear in the compile_commands.json generated by vscode. Is that something easy to fix?

@waruqi
Copy link
Member

waruqi commented Jun 12, 2021

{
"directory": "/Users/ruki/projects/personal/xmake/tests/projects/c/protobuf",
"arguments": ["/usr/local/bin/ccache", "/usr/bin/xcrun", "-sdk", "macosx", "clang", "-c", "-Qun
used-arguments", "-arch", "x86_64", "-mmacosx-version-min=10.15", "-isysroot", "/Applications/Xco
de.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk", "-fvisibilit
y=hidden", "-O3", "-Ibuild/.gens/test/macosx/x86_64/release/rules/protobuf/src", "-I", "/Users/ru
ki/.xmake/packages/p/protobuf-c/1.3.1/f025d1e2f6944ee8a7b62ad011126f67/include", "-I", "/Users/ru
ki/.xmake/packages/p/protobuf-cpp/3.15.5/6c4662c08c5f4cee8a4a04ec43f24434/include", "-DNDEBUG", "
-o", "build/.objs/test/macosx/x86_64/release/src/main.c.o", "src/main.c"],
"file": "src/main.c"
}]

It works for me.

"-Ibuild/.gens/test/macosx/x86_64/release/rules/protobuf/src",

@waruqi waruqi closed this as completed Jun 23, 2021
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

2 participants