如何在自己的 Yocto 包中访问 protoc 编译器并引用 gRPC 库
How to access protoc compiler in own Yocto package and reference to gRPC libs
我在构建自己的包时遇到了一些问题 "grpcSandbox",它依赖于 gRPC 和 protobuf。已经存在构建良好的 gRPC 和 protobuf 的配方。
问题是:grpcSandbox的cmake工程需要gRPC目录header/libs和protobuf目录header/libs + protobuf-compiler(protoc).
我真的不明白如何从我的 grpcSandbox 包 link 到 gRPC 的共享库,以及如何执行 protobuf 提供的元编译器 "protoc"。
我所做的就是为我的食谱中的两个包添加依赖项。
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=79bfc140d04e521d1032e65eef60cfa8"
SRC_URI = "***"
# Modify these as desired
PV = "1.1+git${SRCPV}"
SRCREV = "***"
S = "${WORKDIR}/git"
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
# NOTE: unable to map the following CMake package dependencies: Protobuf GRPC
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
# Pass the path of sysroot to the cmake compiler script. Required to find headers of protobuf/protoc
EXTRA_OECMAKE = "-DOE_SYSROOT:STRING=${STAGING_DIR_HOST}"
当我使用 "bitbake -c devshell grpcsandbox" 启动 devshell 时,命令 "protoc" 不可用,我在 grpcsandbox 包的 sysroot 中找不到 gRPC libs/headers(我认为它们应该在那里,因为我将它们列为 grpcSandbox 的依赖项)。
我做错了什么?
我没有在 Yocto 中使用过 protobuf,所以无法确切地告诉你它是如何设计使用的,但我可以指出配方中的一些问题:
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
RDEPENDS 是关于 运行时 依赖项。您不太可能希望在这里依赖 nativesdk- 包,我也对 protobuf 本身表示怀疑——目标运行时是否需要 protobuf?
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
DEPENDS 是关于构建时间依赖性的,而不是 package-specific:你应该只说 DEPENDS = ...
。解决这个问题应该将 protoc 二进制文件放入本机 sysroot 中,以便在构建期间可用。
我在构建自己的包时遇到了一些问题 "grpcSandbox",它依赖于 gRPC 和 protobuf。已经存在构建良好的 gRPC 和 protobuf 的配方。
问题是:grpcSandbox的cmake工程需要gRPC目录header/libs和protobuf目录header/libs + protobuf-compiler(protoc).
我真的不明白如何从我的 grpcSandbox 包 link 到 gRPC 的共享库,以及如何执行 protobuf 提供的元编译器 "protoc"。
我所做的就是为我的食谱中的两个包添加依赖项。
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=79bfc140d04e521d1032e65eef60cfa8"
SRC_URI = "***"
# Modify these as desired
PV = "1.1+git${SRCPV}"
SRCREV = "***"
S = "${WORKDIR}/git"
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
# NOTE: unable to map the following CMake package dependencies: Protobuf GRPC
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
# Pass the path of sysroot to the cmake compiler script. Required to find headers of protobuf/protoc
EXTRA_OECMAKE = "-DOE_SYSROOT:STRING=${STAGING_DIR_HOST}"
当我使用 "bitbake -c devshell grpcsandbox" 启动 devshell 时,命令 "protoc" 不可用,我在 grpcsandbox 包的 sysroot 中找不到 gRPC libs/headers(我认为它们应该在那里,因为我将它们列为 grpcSandbox 的依赖项)。
我做错了什么?
我没有在 Yocto 中使用过 protobuf,所以无法确切地告诉你它是如何设计使用的,但我可以指出配方中的一些问题:
# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"
RDEPENDS 是关于 运行时 依赖项。您不太可能希望在这里依赖 nativesdk- 包,我也对 protobuf 本身表示怀疑——目标运行时是否需要 protobuf?
#protobuf-native makes the protoc (protobuf compiler) at build time accessible (host version)
#Need to check if this works, since it will convert proto-files to cpp/hpp files
DEPENDS_${PN} += " protobuf protobuf-native grpc"
DEPENDS 是关于构建时间依赖性的,而不是 package-specific:你应该只说 DEPENDS = ...
。解决这个问题应该将 protoc 二进制文件放入本机 sysroot 中,以便在构建期间可用。