add_rules("protobuf.cpp") 应该以 host 方式编译 并使用 protoc
你在什么场景下需要该功能?
目前的版本,交叉编译时,protoc 也交叉编译了,造成交叉编译时不会基于 proto文件生成 .pb.cc 和 .pb.h
描述可能的解决方案
add_rules("protobuf.cpp") 应该以 host 方式编译 并使用 protoc
描述你认为的候选方案
No response
其他信息
No response
Bot detected the issue body's language is not English, translate it automatically.
Title: add_rules("protobuf.cpp") should be compiled in host mode and use protoc
In what scenario do you need this feature?
In the current version, when cross-compiling, protoc is also cross-compiled, causing .pb.cc and .pb.h to not be generated based on the proto file during cross-compilation.
Describe possible solutions
add_rules("protobuf.cpp") should be compiled in host mode and use protoc
Describe your alternatives
No response
other information
No response
目前这个包原本就还不支持交叉编译。你可以提 pr 过来改进这个包。
https://github.com/xmake-io/xmake-repo/blob/3a7bd844fd0f9d9702b9bbd11710d1fa685c99e8/packages/p/protobuf-cpp/xmake.lua#L54
Bot detected the issue body's language is not English, translate it automatically.
Currently, this package does not originally support cross-compilation. You can submit a PR to improve this package.
https://github.com/xmake-io/xmake-repo/blob/3a7bd844fd0f9d9702b9bbd11710d1fa685c99e8/packages/p/protobuf-cpp/xmake.lua#L54
我改进了一下 protoc 包,原来是直接下载预编译二进制,现在是 binary package,永远只会构建 host tool。 因为 protobuf-cpp 没有单独构建 protoc 的选项,所以 protoc 的实现很简单,直接用 protobuf-cpp 作为依赖。
package("protoc")
set_kind("binary")
add_deps("protobuf-cpp")
on_install(function (package) end)
on_test(function (package)
os.vrun("protoc --version")
end)
protoc 的版本需要用 add_requireconfs 指定。
add_requires("protoc", "protobuf-cpp")
add_requireconfs("protoc.protobuf-cpp", {version = "1.0.0"})
add_packages("protoc", "protobuf-cpp")
如果不用 protoc 包,交叉编译就这样:
add_requires("protobuf-cpp~host", {host = true, alias = "protoc"})
add_requires("protobuf-cpp")
add_packages("protoc", {links = {}})
add_packages("protobuf-cpp")
我改进了一下 protoc 包,原来是直接下载预编译二进制,现在是 binary package,永远只会构建 host tool。 因为 protobuf-cpp 没有单独构建 protoc 的选项,所以 protoc 的实现很简单,直接用 protobuf-cpp 作为依赖。
package("protoc") set_kind("binary") add_deps("protobuf-cpp") on_install(function (package) end) on_test(function (package) os.vrun("protoc --version") end)protoc 的版本需要用 add_requireconfs 指定。
add_requires("protoc", "protobuf-cpp") add_requireconfs("protoc.protobuf-cpp", {version = "1.0.0"}) add_packages("protoc", "protobuf-cpp")如果不用 protoc 包,交叉编译就这样:
add_requires("protobuf-cpp~host", {host = true, alias = "protoc"}) add_requires("protobuf-cpp") add_packages("protoc", {links = {}}) add_packages("protobuf-cpp")
如果用法变了,最好同步下 tests example 和相关文档
https://github.com/xmake-io/xmake/blob/dev/tests/projects/c%2B%2B/protobuf/xmake.lua