0

我在构建自己的包“grpcSandbox”时遇到了一些问题,它依赖于 gRPC 和 protobuf。已经存在构建良好的 gRPC 和 protobuf 配方。

问题是:grpcSandbox的cmake项目需要gRPC header/libs和protobuf header/libs + protobuf-compiler(protoc)目录。

我真的不明白如何从我的 grpcSandbox 包链接到来自 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}"

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).

What am I doing wrong?

4

1 回答 1

1

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:

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

RDEPENDS is about runtime dependencies. 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?

#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 = ... . Fixing this should put the protoc binary into the native sysroot so it's available during build.

于 2019-07-24T08:53:31.827 回答