diff mbox series

[v2,2/2] grpc: new package

Message ID 20181118211942.28839-2-robertroyrose@gmail.com
State Superseded
Headers show
Series [v2,1/2] c-ares: support host build | expand

Commit Message

robert rose Nov. 18, 2018, 9:19 p.m. UTC
Signed-off-by: Robert Rose <robertroyrose@gmail.com>
---
 DEVELOPERS                                    |  3 ++
 package/Config.in                             |  1 +
 .../0001-target-build-using-host-plugin.patch | 26 ++++++++++++++
 package/grpc/Config.in                        | 11 ++++++
 package/grpc/grpc.hash                        |  3 ++
 package/grpc/grpc.mk                          | 36 +++++++++++++++++++
 6 files changed, 80 insertions(+)
 create mode 100644 package/grpc/0001-target-build-using-host-plugin.patch
 create mode 100644 package/grpc/Config.in
 create mode 100644 package/grpc/grpc.hash
 create mode 100644 package/grpc/grpc.mk

Comments

Thomas Petazzoni Nov. 24, 2018, 2:12 p.m. UTC | #1
Hello Robert,

Thanks for this contribution!

On Sun, 18 Nov 2018 13:19:42 -0800, Robert Rose wrote:
> Signed-off-by: Robert Rose <robertroyrose@gmail.com>
> ---
>  DEVELOPERS                                    |  3 ++
>  package/Config.in                             |  1 +
>  .../0001-target-build-using-host-plugin.patch | 26 ++++++++++++++
>  package/grpc/Config.in                        | 11 ++++++
>  package/grpc/grpc.hash                        |  3 ++
>  package/grpc/grpc.mk                          | 36 +++++++++++++++++++
>  6 files changed, 80 insertions(+)
>  create mode 100644 package/grpc/0001-target-build-using-host-plugin.patch
>  create mode 100644 package/grpc/Config.in
>  create mode 100644 package/grpc/grpc.hash
>  create mode 100644 package/grpc/grpc.mk

I wanted to apply your patch, but unfortunately, it fails to build for
me in host-grpc:

-- Configuring done
CMake Error at CMakeLists.txt:193 (add_custom_command):
  Error evaluating generator expression:

    $<IF:$<BOOL:>,,$<TARGET_FILE:grpc_cpp_plugin>>

  Expression did not evaluate to a known generator expression
Call Stack (most recent call first):
  CMakeLists.txt:3852 (protobuf_generate_grpc_cpp)


CMake Error at CMakeLists.txt:193 (add_custom_command):
  Error evaluating generator expression:

    $<IF:$<BOOL:>,,$<TARGET_FILE:grpc_cpp_plugin>>

  Expression did not evaluate to a known generator expression
Call Stack (most recent call first):
  CMakeLists.txt:4811 (protobuf_generate_grpc_cpp)


CMake Error at CMakeLists.txt:193 (add_custom_command):
  Error evaluating generator expression:

    $<IF:$<BOOL:>,,$<TARGET_FILE:grpc_cpp_plugin>>

  Expression did not evaluate to a known generator expression
Call Stack (most recent call first):
  CMakeLists.txt:3722 (protobuf_generate_grpc_cpp)


-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_DOC
    BUILD_DOCS
    BUILD_EXAMPLE
    BUILD_EXAMPLES
    BUILD_TEST
    BUILD_TESTING
    BUILD_TESTS
    CMAKE_ASM_COMPILER


-- Build files have been written to: /home/thomas/buildroot/buildroot/output/build/host-grpc-v1.16.0
package/pkg-generic.mk:219: recipe for target '/home/thomas/buildroot/buildroot/output/build/host-grpc-v1.16.0/.stamp_configured' failed
make[1]: *** [/home/thomas/buildroot/buildroot/output/build/host-grpc-v1.16.0/.stamp_configured] Error 1
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2

Could you have a look into this ?

Note that I did a number of fixes/cleanups in your patches, so it would
be nice if you could restart from the two patches I have pushed at
https://git.bootlin.com/users/thomas-petazzoni/buildroot/log/?h=grpc.

Thanks!

Thomas
Thomas Petazzoni Nov. 24, 2018, 8:45 p.m. UTC | #2
Hello Robert,

On Sat, 24 Nov 2018 12:09:36 -0800, robert rose wrote:

> tar xf ~/Downloads/buildroot-2018.08.2.tar.gz
> cd buildroot-2018.08.2
> patch -p1 < ~/buildroot/outgoing/v2-0001-c-ares-support-host-build.patch
> patch -p1 < ~/buildroot/outgoing/v2-0002-grpc-new-package.patch
> make raspberrypi3_defconfig
> make

If you do just this, you don't build gprc, you at least need to do
"make menuconfig" and enable gprc.

> And it worked.  I don't have cmake on my machine, so buildroot
> built cmake-3.8.2
> What version of cmake do you use?

I have a cmake installed system-wide, so I'm not using the one built by
Buildroot. My cmake version is:

$ cmake --version
cmake version 3.12.1

Best regards,

Thomas
robert rose Nov. 24, 2018, 10 p.m. UTC | #3
I just did the make menuconfig, added grpc and it still worked.  I just
installed cmake 3.12.1 and doing a build from scratch (with grpc :)
Let you know in a couple hours how it works.
Try doing
make V=1
and see if you can find anything wrong.

-robert

On Sat, Nov 24, 2018 at 12:45 PM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:

> Hello Robert,
>
> On Sat, 24 Nov 2018 12:09:36 -0800, robert rose wrote:
>
> > tar xf ~/Downloads/buildroot-2018.08.2.tar.gz
> > cd buildroot-2018.08.2
> > patch -p1 < ~/buildroot/outgoing/v2-0001-c-ares-support-host-build.patch
> > patch -p1 < ~/buildroot/outgoing/v2-0002-grpc-new-package.patch
> > make raspberrypi3_defconfig
> > make
>
> If you do just this, you don't build gprc, you at least need to do
> "make menuconfig" and enable gprc.
>
> > And it worked.  I don't have cmake on my machine, so buildroot
> > built cmake-3.8.2
> > What version of cmake do you use?
>
> I have a cmake installed system-wide, so I'm not using the one built by
> Buildroot. My cmake version is:
>
> $ cmake --version
> cmake version 3.12.1
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
<div dir="ltr">I just did the make menuconfig, added grpc and it still worked.  I just installed cmake 3.12.1 and doing a build from scratch (with grpc :)<div>Let you know in a couple hours how it works.</div><div>Try doing</div><div>make V=1</div><div>and see if you can find anything wrong.</div><div><br></div><div>-robert</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 24, 2018 at 12:45 PM Thomas Petazzoni &lt;<a href="mailto:thomas.petazzoni@bootlin.com">thomas.petazzoni@bootlin.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Robert,<br>
<br>
On Sat, 24 Nov 2018 12:09:36 -0800, robert rose wrote:<br>
<br>
&gt; tar xf ~/Downloads/buildroot-2018.08.2.tar.gz<br>
&gt; cd buildroot-2018.08.2<br>
&gt; patch -p1 &lt; ~/buildroot/outgoing/v2-0001-c-ares-support-host-build.patch<br>
&gt; patch -p1 &lt; ~/buildroot/outgoing/v2-0002-grpc-new-package.patch<br>
&gt; make raspberrypi3_defconfig<br>
&gt; make<br>
<br>
If you do just this, you don&#39;t build gprc, you at least need to do<br>
&quot;make menuconfig&quot; and enable gprc.<br>
<br>
&gt; And it worked.  I don&#39;t have cmake on my machine, so buildroot<br>
&gt; built cmake-3.8.2<br>
&gt; What version of cmake do you use?<br>
<br>
I have a cmake installed system-wide, so I&#39;m not using the one built by<br>
Buildroot. My cmake version is:<br>
<br>
$ cmake --version<br>
cmake version 3.12.1<br>
<br>
Best regards,<br>
<br>
Thomas<br>
-- <br>
Thomas Petazzoni, CTO, Bootlin<br>
Embedded Linux and Kernel engineering<br>
<a href="https://bootlin.com" rel="noreferrer" target="_blank">https://bootlin.com</a><br>
</blockquote></div>
robert rose Nov. 24, 2018, 11:57 p.m. UTC | #4
I just ran with native cmake 3.12.1.
Everything worked and yes I did build grpc.
I am using Fedora 29 and everything is up to date.
After the make fails, do make V=1 and send me the output.  I will try and
help you debug it.

-robert

On Sat, Nov 24, 2018 at 2:00 PM robert rose <robertroyrose@gmail.com> wrote:

> I just did the make menuconfig, added grpc and it still worked.  I just
> installed cmake 3.12.1 and doing a build from scratch (with grpc :)
> Let you know in a couple hours how it works.
> Try doing
> make V=1
> and see if you can find anything wrong.
>
> -robert
>
> On Sat, Nov 24, 2018 at 12:45 PM Thomas Petazzoni <
> thomas.petazzoni@bootlin.com> wrote:
>
>> Hello Robert,
>>
>> On Sat, 24 Nov 2018 12:09:36 -0800, robert rose wrote:
>>
>> > tar xf ~/Downloads/buildroot-2018.08.2.tar.gz
>> > cd buildroot-2018.08.2
>> > patch -p1 < ~/buildroot/outgoing/v2-0001-c-ares-support-host-build.patch
>> > patch -p1 < ~/buildroot/outgoing/v2-0002-grpc-new-package.patch
>> > make raspberrypi3_defconfig
>> > make
>>
>> If you do just this, you don't build gprc, you at least need to do
>> "make menuconfig" and enable gprc.
>>
>> > And it worked.  I don't have cmake on my machine, so buildroot
>> > built cmake-3.8.2
>> > What version of cmake do you use?
>>
>> I have a cmake installed system-wide, so I'm not using the one built by
>> Buildroot. My cmake version is:
>>
>> $ cmake --version
>> cmake version 3.12.1
>>
>> Best regards,
>>
>> Thomas
>> --
>> Thomas Petazzoni, CTO, Bootlin
>> Embedded Linux and Kernel engineering
>> https://bootlin.com
>>
>
<div dir="ltr">I just ran with native cmake 3.12.1.<div>Everything worked and yes I did build grpc.</div><div>I am using Fedora 29 and everything is up to date.</div><div>After the make fails, do make V=1 and send me the output.  I will try and help you debug it.</div><div><br></div><div>-robert</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 24, 2018 at 2:00 PM robert rose &lt;<a href="mailto:robertroyrose@gmail.com">robertroyrose@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I just did the make menuconfig, added grpc and it still worked.  I just installed cmake 3.12.1 and doing a build from scratch (with grpc :)<div>Let you know in a couple hours how it works.</div><div>Try doing</div><div>make V=1</div><div>and see if you can find anything wrong.</div><div><br></div><div>-robert</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 24, 2018 at 12:45 PM Thomas Petazzoni &lt;<a href="mailto:thomas.petazzoni@bootlin.com" target="_blank">thomas.petazzoni@bootlin.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Robert,<br>
<br>
On Sat, 24 Nov 2018 12:09:36 -0800, robert rose wrote:<br>
<br>
&gt; tar xf ~/Downloads/buildroot-2018.08.2.tar.gz<br>
&gt; cd buildroot-2018.08.2<br>
&gt; patch -p1 &lt; ~/buildroot/outgoing/v2-0001-c-ares-support-host-build.patch<br>
&gt; patch -p1 &lt; ~/buildroot/outgoing/v2-0002-grpc-new-package.patch<br>
&gt; make raspberrypi3_defconfig<br>
&gt; make<br>
<br>
If you do just this, you don&#39;t build gprc, you at least need to do<br>
&quot;make menuconfig&quot; and enable gprc.<br>
<br>
&gt; And it worked.  I don&#39;t have cmake on my machine, so buildroot<br>
&gt; built cmake-3.8.2<br>
&gt; What version of cmake do you use?<br>
<br>
I have a cmake installed system-wide, so I&#39;m not using the one built by<br>
Buildroot. My cmake version is:<br>
<br>
$ cmake --version<br>
cmake version 3.12.1<br>
<br>
Best regards,<br>
<br>
Thomas<br>
-- <br>
Thomas Petazzoni, CTO, Bootlin<br>
Embedded Linux and Kernel engineering<br>
<a href="https://bootlin.com" rel="noreferrer" target="_blank">https://bootlin.com</a><br>
</blockquote></div>
</blockquote></div>
Thomas Petazzoni Nov. 26, 2018, 9:58 p.m. UTC | #5
Hello Robert,

On Sat, 24 Nov 2018 15:57:07 -0800, robert rose wrote:
> I just ran with native cmake 3.12.1.
> Everything worked and yes I did build grpc.
> I am using Fedora 29 and everything is up to date.
> After the make fails, do make V=1 and send me the output.  I will try and
> help you debug it.

So in fact, I was wrong: I told you the CMake version that my Fedora 29
system uses, but on this system, it builds fine. The build failure
occurred on an older Ubuntu system, which has:

$ cmake --version
cmake version 3.5.1

The full build log is at:

  http://code.bulix.org/h552dy-513207

And the host-grpc build with make V=1 is at:

  http://code.bulix.org/qy4r3g-513210

Thanks!

Thomas
Arnout Vandecappelle Nov. 27, 2018, 5:17 p.m. UTC | #6
Regarding the CMake issue that Thomas found...

On 18/11/2018 22:19, Robert Rose wrote:
> diff --git a/package/grpc/0001-target-build-using-host-plugin.patch b/package/grpc/0001-target-build-using-host-plugin.patch
> new file mode 100644
> index 0000000000..379464916a
> --- /dev/null
> +++ b/package/grpc/0001-target-build-using-host-plugin.patch
> @@ -0,0 +1,26 @@
> +From f7e70f03167834ce5e221c7dbca936edb1662274 Mon Sep 17 00:00:00 2001
> +From: Robert Rose <robertroyrose@gmail.com>
> +Date: Sun, 18 Nov 2018 12:55:49 -0800
> +Subject: [PATCH 1/1] target build using host plugin
> +
> +Signed-off-by: Robert Rose <robertroyrose@gmail.com>
> +---
> + CMakeLists.txt | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index ab1802e..1b44c3c 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -199,7 +199,7 @@ function(protobuf_generate_grpc_cpp)
> +       COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
> +       ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
> +            --cpp_out=${_gRPC_PROTO_GENS_DIR}
> +-           --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
> ++           --plugin=protoc-gen-grpc=$<IF:$<BOOL:${gRPC_NATIVE_CPP_PLUGIN}>,${gRPC_NATIVE_CPP_PLUGIN},$<TARGET_FILE:grpc_cpp_plugin>>

 The $<IF:...> generator was apparently introduced in CMake 3.8. So if you use
it, the patch should also update the minimal CMake version at the beginning of
the file, *and* the Buildroot minimum version should be updated from current 3.1
to 3.8 in support/dependencies/check-host-cmake.mk.

 Since that is not very nice, maybe a better alternative is to allow
grpc_cpp_plugin to be an imported target instead of an executable. That way you
can still simply use the $<TARGET_FILE> generator. Of course, importing a target
is a little bit more complicated...

 I think the latter would also be easier to accept for upstream.

> +            ${_protobuf_include_path}
> +            ${REL_FIL}
> +       DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
> +-- 
> +2.19.1
> +


 BTW, there's also a 1.16.1 release out.

 Regards,
 Arnout
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 53467da489..437614c190 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1772,6 +1772,9 @@  F:	package/subversion/
 N:	RJ Ascani <rj.ascani@gmail.com>
 F:	package/azmq/
 
+N:	Robert Rose <robertroyrose@gmail.com>
+F:	package/grpc
+
 N:	Rodrigo Rebello <rprebello@gmail.com>
 F:	package/chocolate-doom/
 F:	package/irssi/
diff --git a/package/Config.in b/package/Config.in
index b60e7700ad..2d0cc51797 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1495,6 +1495,7 @@  menu "Networking"
 	source "package/freeradius-client/Config.in"
 	source "package/geoip/Config.in"
 	source "package/glib-networking/Config.in"
+	source "package/grpc/Config.in"
 	source "package/gssdp/Config.in"
 	source "package/gupnp/Config.in"
 	source "package/gupnp-av/Config.in"
diff --git a/package/grpc/0001-target-build-using-host-plugin.patch b/package/grpc/0001-target-build-using-host-plugin.patch
new file mode 100644
index 0000000000..379464916a
--- /dev/null
+++ b/package/grpc/0001-target-build-using-host-plugin.patch
@@ -0,0 +1,26 @@ 
+From f7e70f03167834ce5e221c7dbca936edb1662274 Mon Sep 17 00:00:00 2001
+From: Robert Rose <robertroyrose@gmail.com>
+Date: Sun, 18 Nov 2018 12:55:49 -0800
+Subject: [PATCH 1/1] target build using host plugin
+
+Signed-off-by: Robert Rose <robertroyrose@gmail.com>
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ab1802e..1b44c3c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -199,7 +199,7 @@ function(protobuf_generate_grpc_cpp)
+       COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
+       ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
+            --cpp_out=${_gRPC_PROTO_GENS_DIR}
+-           --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
++           --plugin=protoc-gen-grpc=$<IF:$<BOOL:${gRPC_NATIVE_CPP_PLUGIN}>,${gRPC_NATIVE_CPP_PLUGIN},$<TARGET_FILE:grpc_cpp_plugin>>
+            ${_protobuf_include_path}
+            ${REL_FIL}
+       DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
+-- 
+2.19.1
+
diff --git a/package/grpc/Config.in b/package/grpc/Config.in
new file mode 100644
index 0000000000..e4364c2fe6
--- /dev/null
+++ b/package/grpc/Config.in
@@ -0,0 +1,11 @@ 
+config BR2_PACKAGE_GRPC
+	bool "grpc"
+	select BR2_PACKAGE_C_ARES
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_PROTOBUF
+	select BR2_PACKAGE_ZLIB
+	help
+	  A language-neutral, platform-neutral, open source, remote
+	  procedure call (RPC) system initially developed at Google.
+
+	  http://github.com/grpc/grpc
diff --git a/package/grpc/grpc.hash b/package/grpc/grpc.hash
new file mode 100644
index 0000000000..3b1904a883
--- /dev/null
+++ b/package/grpc/grpc.hash
@@ -0,0 +1,3 @@ 
+# Locally computed
+sha256 d99db0b39b490d2469a8ef74197d5f211fa740fc9581dccecbb76c56d080fce1  grpc-v1.16.0.tar.gz
+sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
diff --git a/package/grpc/grpc.mk b/package/grpc/grpc.mk
new file mode 100644
index 0000000000..8ee7781428
--- /dev/null
+++ b/package/grpc/grpc.mk
@@ -0,0 +1,36 @@ 
+################################################################################
+#
+# grpc
+#
+################################################################################
+
+GRPC_VERSION = v1.16.0
+GRPC_SOURCE = grpc-$(GRPC_VERSION).tar.gz
+GRPC_SITE = $(call github,grpc,grpc,$(GRPC_VERSION))
+GRPC_LICENSE = Apache-2.0
+GRPC_LICENSE_FILES = LICENSE
+
+GRPC_INSTALL_STAGING = YES
+
+# Need to use host grpc_cpp_plugin during cross compilation.
+GRPC_DEPENDENCIES = c-ares host-grpc openssl protobuf zlib
+HOST_GRPC_DEPENDENCIES = host-c-ares host-openssl host-protobuf host-zlib
+
+GRPC_CONF_OPTS = \
+         -D_gRPC_CARES_LIBRARIES=cares \
+         -DgRPC_CARES_PROVIDER=none \
+         -DgRPC_PROTOBUF_PROVIDER=package \
+         -DgRPC_SSL_PROVIDER=package \
+         -DgRPC_ZLIB_PROVIDER=package \
+         -DgRPC_NATIVE_CPP_PLUGIN=$(HOST_DIR)/bin/grpc_cpp_plugin
+
+HOST_GRPC_CONF_OPTS = \
+         -D_gRPC_CARES_LIBRARIES=cares \
+         -DgRPC_CARES_PROVIDER=none \
+         -DgRPC_CARES_PROVIDER=none \
+         -DgRPC_PROTOBUF_PROVIDER=package \
+         -DgRPC_SSL_PROVIDER=package \
+         -DgRPC_ZLIB_PROVIDER=package
+
+$(eval $(cmake-package))
+$(eval $(host-cmake-package))