简体   繁体   English

如何在自己的Yocto软件包中访问protoc编译器并参考gRPC库

[英]How to access protoc compiler in own Yocto package and reference to gRPC libs

I have some problems to build my own package "grpcSandbox", which depends on gRPC and protobuf. 我在构建自己的软件包“ grpcSandbox”时遇到了一些问题,该软件包依赖于gRPC和protobuf。 There already exists recipes for gRPC and protobuf which builds well. 已经存在gRPC和protobuf构建良好的配方。

The problem is: cmake project of grpcSandbox requires the directory of gRPC header/libs and protobuf header/libs + protobuf-compiler (protoc). 问题是:grpcSandbox的cmake项目需要gRPC标头/ lib和protobuf标头/ libs + protobuf-compiler(protoc)的目录。

I do not really understand how to link from my grpcSandbox package to the shared libs from gRPC and how to execute the meta-compiler "protoc" which is provided by protobuf. 我不太了解如何从grpcSandbox软件包链接到gRPC的共享库,以及如何执行protobuf提供的元编译器“ protoc”。

All I have done is to add dependencies to the two packages in my recipe. 我要做的就是将依赖关系添加到配方中的两个软件包中。

# 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}"

When I start a devshell with "bitbake -c devshell grpcsandbox", the command "protoc" is not available and I cannot find the gRPC libs/headers in the sysroot of package grpcsandbox (which I thought they should be there, since I listed them as dependency for grpcSandbox). 当我使用“ bitbake -c devshell grpcsandbox”启动devshell时,命令“ protoc”不可用,并且我在grpcsandbox软件包的sysroot中找不到gRPC libs / header(我认为它们应该在那里,因为我列出了它们)作为grpcSandbox的依赖项)。

What am I doing wrong? 我究竟做错了什么?

I've not used protobuf in Yocto so can't tell you exactly how it's designed to be used but I can point out some issues in the recipe: 我没有在Yocto中使用protobuf,因此无法确切地告诉您它是如何设计的,但是我可以指出配方中的一些问题:

# This depends on gRPC and protobuf (gRPC depends on protobuf)
RDEPENDS_${PN} += " grpc protobuf nativesdk-protobuf"

RDEPENDS is about runtime dependencies. RDEPENDS与运行时相关性有关。 It's unlikely that you would want to depend on a nativesdk- package here and I'm doubtful about protobuf itself too -- is protobuf needed at runtime on the target? 您不太可能希望在此处依赖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 is about build time dependencies and is not package-specific: you should just say DEPENDS = ... . DEPENDS与构建时间相关,并且不是特定于软件包的:您应该只说DEPENDS = ... Fixing this should put the protoc binary into the native sysroot so it's available during build. 修复此问题后,应将protoc二进制文件放入本机sysroot中,以便在构建过程中可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM