Skip to contentSkip to conversation

package/python-protobuf: Allow generating host-python-protobuf

PATCH Superseded Tiago Brusamarello 3 participants 10 messages Jun 30, 2016 – Jul 18, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/python-protobuf: Allow generating host-python-protobuf

This change allows use of python-protobuf libraries on the host, so 'protoc-gen-lua' plugin for the 'protoc' tool can be run on host.

---
 package/python-protobuf/python-protobuf.mk | 1 +
 1 file changed, 1 insertion(+)
package/python-protobuf/python-protobuf.mk +1 -0
index d8be76d..b328e3e 100644
@@ -14,3 +14,4 @@ PYTHON_PROTOBUF_SETUP_TYPE = setuptools
 PYTHON_PROTOBUF_SUBDIR = python
 
 $(eval $(python-package))
+$(eval $(host-python-package))
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 package/protoc-gen-lua: new package

This package adds support to compile Google's Protocol buffers for use with Lua scripts. This tool is needed to allow use of the 'protobuf-lua' package.

---
 package/Config.in                        |  1 +
 package/protoc-gen-lua/Config.in         |  6 ++++++
 package/protoc-gen-lua/protoc-gen-lua.mk | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 package/protoc-gen-lua/Config.in
 create mode 100644 package/protoc-gen-lua/protoc-gen-lua.mk
package/Config.in +1 -0
index e5ddc3e..715f8ab 100644
@@ -1299,6 +1299,7 @@ endif
 	source "package/poco/Config.in"
 	source "package/protobuf/Config.in"
 	source "package/protobuf-c/Config.in"
+	source "package/protoc-gen-lua/Config.in"
 	source "package/qhull/Config.in"
 	source "package/qlibc/Config.in"
 	source "package/startup-notification/Config.in"
package/protoc-gen-lua/Config.in new file +6 -0
new file mode 100644
index 0000000..9c71216
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PROTOC_GEN_LUA
+	bool "protoc-gen-lua"
+	help
+		Code generator plugin to use Protocol Buffers from Lua scripts
+
+		https://github.com/djungelorm/protobuf-lua
package/protoc-gen-lua/protoc-gen-lua.mk new file +19 -0
new file mode 100644
index 0000000..315f581
@@ -0,0 +1,19 @@
+################################################################################
+#
+# protoc-gen-lua
+#
+################################################################################
+
+PROTOC_GEN_LUA_VERSION = v1.1.1
+PROTOC_GEN_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOC_GEN_LUA_VERSION))
+PROTOC_GEN_LUA_DEPENDENCIES = host-python-protobuf
+PROTOC_GEN_LUA_LICENSE = BSD-3c
+PROTOC_GEN_LUA_LICENSE_FILES = LICENSE
+
+define HOST_PROTOC_GEN_LUA_INSTALL_CMDS
+	# install protoc Lua plugin
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin
+endef
+
+$(eval $(host-generic-package))
\ No newline at end of file
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 package/protoc-gen-lua: new package

Hi Tiago,

Le 30/06/2016 ? 14:53, Tiago Brusamarello a ?crit :

Quoted 18 lines

This package adds support to compile Google's Protocol buffers for use with Lua scripts. This tool is needed to allow use of the 'protobuf-lua' package.

---
 package/Config.in                        |  1 +
 package/protoc-gen-lua/Config.in         |  6 ++++++
 package/protoc-gen-lua/protoc-gen-lua.mk | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 package/protoc-gen-lua/Config.in
 create mode 100644 package/protoc-gen-lua/protoc-gen-lua.mk
package/Config.in +0 -0
index e5ddc3e..715f8ab 100644

package/Config.in endif · line 1302

Quoted 4 lines
package/Config.in +1 -0
@@ -1299,6 +1299,7 @@ endif
 	source "package/poco/Config.in"
 	source "package/protobuf/Config.in"
 	source "package/protobuf-c/Config.in"
+	source "package/protoc-gen-lua/Config.in"

protoc-gen-lua is a host package, so it mustn't be listed here.

package/protoc-gen-lua/Config.in

Quoted 8 lines
package/Config.in +0 -0
 	source "package/qhull/Config.in"
 	source "package/qlibc/Config.in"
 	source "package/startup-notification/Config.in"
package/protoc-gen-lua/Config.in new file +0 -0
new file mode 100644
index 0000000..9c71216

For the same reason, Config.in must be removed.
Config.in is intended for target packages only.

Quoted 23 lines
package/protoc-gen-lua/Config.in new file +6 -0
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PROTOC_GEN_LUA
+	bool "protoc-gen-lua"
+	help
+		Code generator plugin to use Protocol Buffers from Lua scripts
+
+		https://github.com/djungelorm/protobuf-lua
package/protoc-gen-lua/protoc-gen-lua.mk new file +10 -0
new file mode 100644
index 0000000..315f581
@@ -0,0 +1,19 @@
+################################################################################
+#
+# protoc-gen-lua
+#
+################################################################################
+
+PROTOC_GEN_LUA_VERSION = v1.1.1
+PROTOC_GEN_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOC_GEN_LUA_VERSION))
+PROTOC_GEN_LUA_DEPENDENCIES = host-python-protobuf
+PROTOC_GEN_LUA_LICENSE = BSD-3c

package/protoc-gen-lua/protoc-gen-lua.mk line 19

Quoted 10 lines
package/protoc-gen-lua/protoc-gen-lua.mk new file +9 -0
+PROTOC_GEN_LUA_LICENSE_FILES = LICENSE
+
+define HOST_PROTOC_GEN_LUA_INSTALL_CMDS
+	# install protoc Lua plugin
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin
+endef
+
+$(eval $(host-generic-package))
\ No newline at end of file

Please add a new line here.

Also, provide a hash file.

Best regards,
Romain

Quoted 1 line
#3 lore raw

PATCH 2/3 package/protoc-gen-lua: new package

In reply to Tiago Brusamarello

Hello,

package/protoc-gen-lua/protoc-gen-lua.mk line 14

Quoted 2 lines · Tiago Brusamarello
package/protoc-gen-lua/protoc-gen-lua.mk new file +2 -0
+define HOST_PROTOC_GEN_LUA_INSTALL_CMDS
+	# install protoc Lua plugin

Please put this comment above the variable definition.

package/protoc-gen-lua/protoc-gen-lua.mk line 16

Quoted 2 lines
package/protoc-gen-lua/protoc-gen-lua.mk new file +2 -0
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin
+	$(INSTALL) -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin

Please use:

	$(INSTALL) -D -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin/protoc-gen-lua

(for both files)

I.e: use the -D option, and specify a full destination path.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 3/3 package/protobuf-lua: new package

In reply to Tiago Brusamarello

This package adds support to use Google's Protocol buffers from Lua scripts.

The original package from GitHub supports deployment as a LuaRocks package, but the module name as set to 'protobuf' and not 'protobuf-lua' which causes naming problems when building it in Buildroot so the 'generick-package' method was used instead.

This package depends on the 'protoc-gen-lua' plugin package for generation of Protobuf messages types in Lua format.

---
 package/Config.in                    |  1 +
 package/protobuf-lua/Config.in       |  7 +++++
 package/protobuf-lua/protobuf-lua.mk | 60 ++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 package/protobuf-lua/Config.in
 create mode 100644 package/protobuf-lua/protobuf-lua.mk
package/Config.in +1 -0
index 715f8ab..dc32465 100644
@@ -548,6 +548,7 @@ menu "Lua libraries/modules"
 	source "package/luvi/Config.in"
 	source "package/lzlib/Config.in"
 	source "package/orbit/Config.in"
+	source "package/protobuf-lua/Config.in"
 	source "package/rings/Config.in"
 	source "package/turbolua/Config.in"
 	source "package/wsapi/Config.in"
package/protobuf-lua/Config.in new file +7 -0
new file mode 100644
index 0000000..e602111
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_PROTOBUF_LUA
+	bool "protobuf-lua"
+	depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2
+	help
+		Runtime libraries to use Protocol Buffers from Lua scripts.
+
+		https://github.com/djungelorm/protobuf-lua
package/protobuf-lua/protobuf-lua.mk new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH 3/3 package/protobuf-lua: new package

Hi Tiago,

Le 30/06/2016 ? 14:53, Tiago Brusamarello a ?crit :

Quoted 7 lines

This package adds support to use Google's Protocol buffers from Lua scripts.

The original package from GitHub supports deployment as a LuaRocks package, but the module name as set to 'protobuf' and not 'protobuf-lua' which causes naming problems when building it in Buildroot so the 'generick-package' method

s/generik/generic/

Quoted 32 lines

was used instead.

This package depends on the 'protoc-gen-lua' plugin package for generation of Protobuf messages types in Lua format.

---
 package/Config.in                    |  1 +
 package/protobuf-lua/Config.in       |  7 +++++
 package/protobuf-lua/protobuf-lua.mk | 60 ++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 package/protobuf-lua/Config.in
 create mode 100644 package/protobuf-lua/protobuf-lua.mk
package/Config.in +1 -0
index 715f8ab..dc32465 100644
@@ -548,6 +548,7 @@ menu "Lua libraries/modules"
 	source "package/luvi/Config.in"
 	source "package/lzlib/Config.in"
 	source "package/orbit/Config.in"
+	source "package/protobuf-lua/Config.in"
 	source "package/rings/Config.in"
 	source "package/turbolua/Config.in"
 	source "package/wsapi/Config.in"
package/protobuf-lua/Config.in new file +0 -0
new file mode 100644
index 0000000..e602111

package/protobuf-lua/Config.in line 3

Quoted 3 lines
package/protobuf-lua/Config.in new file +3 -0
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_PROTOBUF_LUA
+	bool "protobuf-lua"
+	depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2

Why protobuf-lua depends on lua 5.1 and 5.2 only ? What was the issue ?

Also, is protobuf-lua can be used with luajit ?
If yes, maybe you can use "depends on BR2_PACKAGE_HAS_LUAINTERPRETER" instead.

package/protobuf-lua/Config.in line 7

Quoted 4 lines
package/protobuf-lua/Config.in new file +4 -0
+	help
+		Runtime libraries to use Protocol Buffers from Lua scripts.
+
+		https://github.com/djungelorm/protobuf-lua

Indent with one tab and two space.

package/protobuf-lua/protobuf-lua.mk line 7

Quoted 13 lines
package/protobuf-lua/protobuf-lua.mk new file +7 -0
new file mode 100644
index 0000000..1a6c693
@@ -0,0 +1,60 @@
+################################################################################
+#
+# protobuf-lua
+#
+################################################################################
+
+

remove one empty line

package/protobuf-lua/protobuf-lua.mk line 10

Quoted 3 lines
package/protobuf-lua/protobuf-lua.mk new file +3 -0
+PROTOBUF_LUA_VERSION = v1.1.1
+PROTOBUF_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION))
+PROTOBUF_LUA_DEPENDENCIES = luainterpreter host-protoc-gen-lua

There is a missing dependency on host-protobuf which provide protoc

package/protobuf-lua/protobuf-lua.mk line 21

Quoted 11 lines
package/protobuf-lua/protobuf-lua.mk new file +11 -0
+PROTOBUF_LUA_LICENSE = BSD-3c
+PROTOBUF_LUA_LICENSE_FILES = LICENSE
+
+define PROTOBUF_LUA_BUILD_CMDS
+	# build Lua Protobuf shared lib
+	$(TARGET_CC) -Os -shared -std=gnu99 -fPIC $(@D)/protobuf/pb.c -o $(@D)/protobuf/pb.so
+
+	# build Protobuf examples
+	PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example --proto_path=$(@D)/example \
+		$(@D)/example/person.proto
+endef

protoc-gen-lua doesn't work with any host-python version:

host-python3:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 15, in <module>
from cStringIO import StringIO
ImportError: No module named 'cStringIO'
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

host-python2:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 17, in <module>
import plugin_pb2
File "output/host/usr/bin/plugin_pb2.py", line 3, in <module>
from google.protobuf import descriptor
ImportError: No module named google.protobuf
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

So, I've marked your patch as Changes Requested in patchwork. Feel free to submit an updated version that takes into account the comments and fixed the build issue.

Thanks!

Best regards,
Romain

Quoted 40 lines
package/protobuf-lua/protobuf-lua.mk new file +39 -0
+
+define PROTOBUF_LUA_INSTALL_TARGET_CMDS
+	# install Lua Protobuf support
+	mkdir -p $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/pb.so \
+		$(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/containers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/decoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/descriptor.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/encoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/init.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/listener.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/text_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/wire_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+
+	# install example files
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/person_pb.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/person.proto \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/test.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+endef
+
+$(eval $(generic-package))
#6 lore raw

PATCH 3/3 package/protobuf-lua: new package

Hi Romain.

Em 16-07-2016 07:25, Romain Naour escreveu:

Quoted 41 lines

Hi Tiago,

Le 30/06/2016 ? 14:53, Tiago Brusamarello a ?crit :

Quoted 7 lines

This package adds support to use Google's Protocol buffers from Lua scripts.

The original package from GitHub supports deployment as a LuaRocks package, but the module name as set to 'protobuf' and not 'protobuf-lua' which causes naming problems when building it in Buildroot so the 'generick-package' method

s/generik/generic/

Quoted 29 lines

was used instead.

This package depends on the 'protoc-gen-lua' plugin package for generation of Protobuf messages types in Lua format.

---
  package/Config.in                    |  1 +
  package/protobuf-lua/Config.in       |  7 +++++
  package/protobuf-lua/protobuf-lua.mk | 60 ++++++++++++++++++++++++++++++++++++
  3 files changed, 68 insertions(+)

create mode 100644 package/protobuf-lua/Config.in create mode 100644 package/protobuf-lua/protobuf-lua.mk

package/Config.in +1 -0
index 715f8ab..dc32465 100644
@@ -548,6 +548,7 @@ menu "Lua libraries/modules"
  	source "package/luvi/Config.in"
  	source "package/lzlib/Config.in"
  	source "package/orbit/Config.in"
+	source "package/protobuf-lua/Config.in"
  	source "package/rings/Config.in"
  	source "package/turbolua/Config.in"
  	source "package/wsapi/Config.in"
package/protobuf-lua/Config.in new file +0 -0
new file mode 100644
index 0000000..e602111
Quoted 8 lines

package/protobuf-lua/Config.in line 3

Quoted 6 lines
package/protobuf-lua/Config.in new file +3 -0
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_PROTOBUF_LUA
+	bool "protobuf-lua"
+	depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2

Why protobuf-lua depends on lua 5.1 and 5.2 only ? What was the issue ?

It seems that the shared library 'pb.so' built by the package is only compatible
with Lua 5.2 and Lua 5.2.

Quoted 2 lines

Also, is protobuf-lua can be used with luajit ?
If yes, maybe you can use "depends on BR2_PACKAGE_HAS_LUAINTERPRETER" instead.

I can't tell you if it's compatible with 'luajit' or not.

Quoted 39 lines

package/protobuf-lua/Config.in line 7

Quoted 4 lines
package/protobuf-lua/Config.in new file +4 -0
+	help
+		Runtime libraries to use Protocol Buffers from Lua scripts.
+
+		https://github.com/djungelorm/protobuf-lua

Indent with one tab and two space.

package/protobuf-lua/protobuf-lua.mk line 7

Quoted 13 lines
package/protobuf-lua/protobuf-lua.mk new file +7 -0
new file mode 100644
index 0000000..1a6c693
@@ -0,0 +1,60 @@
+################################################################################
+#
+# protobuf-lua
+#
+################################################################################
+
+

remove one empty line

package/protobuf-lua/protobuf-lua.mk line 10

Quoted 3 lines
package/protobuf-lua/protobuf-lua.mk new file +3 -0
+PROTOBUF_LUA_VERSION = v1.1.1
+PROTOBUF_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION))
+PROTOBUF_LUA_DEPENDENCIES = luainterpreter host-protoc-gen-lua

There is a missing dependency on host-protobuf which provide protoc

package/protobuf-lua/protobuf-lua.mk line 21

Quoted 11 lines
package/protobuf-lua/protobuf-lua.mk new file +11 -0
+PROTOBUF_LUA_LICENSE = BSD-3c
+PROTOBUF_LUA_LICENSE_FILES = LICENSE
+
+define PROTOBUF_LUA_BUILD_CMDS
+	# build Lua Protobuf shared lib
+	$(TARGET_CC) -Os -shared -std=gnu99 -fPIC $(@D)/protobuf/pb.c -o $(@D)/protobuf/pb.so
+
+	# build Protobuf examples
+	PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example --proto_path=$(@D)/example \
+		$(@D)/example/person.proto
+endef

protoc-gen-lua doesn't work with any host-python version:

Quoted 7 lines

host-python3:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 15, in <module>
from cStringIO import StringIO
ImportError: No module named 'cStringIO'
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

I guess it will not work whit Python 3 because the missing 'cStringIO '.

Quoted 9 lines

host-python2:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 17, in <module>
import plugin_pb2
File "output/host/usr/bin/plugin_pb2.py", line 3, in <module>
from google.protobuf import descriptor
ImportError: No module named google.protobuf
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

I've tested it with Python 2.7.11 and it worked well for me. Maybe this error is caused
by the missing dependency to 'host-protobuf'.

Quoted 42 lines

So, I've marked your patch as Changes Requested in patchwork. Feel free to submit an updated version that takes into account the comments and fixed the build issue.

Thanks!

Best regards,
Romain

Quoted 32 lines
package/protobuf-lua/protobuf-lua.mk new file +32 -0
+
+define PROTOBUF_LUA_INSTALL_TARGET_CMDS
+	# install Lua Protobuf support
+	mkdir -p $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/pb.so \
+		$(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/containers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/decoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/descriptor.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/encoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/init.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/listener.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/text_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/wire_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+
+	# install example files
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/person_pb.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
Quoted 8 lines

package/protobuf-lua/protobuf-lua.mk line 60

Quoted 8 lines
package/protobuf-lua/protobuf-lua.mk new file +7 -0
+	$(INSTALL) -m 0755 $(@D)/example/person.proto \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/test.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+endef
+
+$(eval $(generic-package))

Best Regards,

Tiago.

#7 lore raw

PATCH 3/3 package/protobuf-lua: new package

Hi Tiago,

Le 18/07/2016 ? 19:31, Tiago Brusamarello a ?crit :

Quoted 52 lines

Hi Romain.

Em 16-07-2016 07:25, Romain Naour escreveu:

Quoted 41 lines

Hi Tiago,

Le 30/06/2016 ? 14:53, Tiago Brusamarello a ?crit :

Quoted 7 lines

This package adds support to use Google's Protocol buffers from Lua scripts.

The original package from GitHub supports deployment as a LuaRocks package, but the module name as set to 'protobuf' and not 'protobuf-lua' which causes naming problems when building it in Buildroot so the 'generick-package' method

s/generik/generic/

Quoted 29 lines

was used instead.

This package depends on the 'protoc-gen-lua' plugin package for generation of Protobuf messages types in Lua format.

---
  package/Config.in                    |  1 +
  package/protobuf-lua/Config.in       |  7 +++++
  package/protobuf-lua/protobuf-lua.mk | 60 ++++++++++++++++++++++++++++++++++++
  3 files changed, 68 insertions(+)

create mode 100644 package/protobuf-lua/Config.in create mode 100644 package/protobuf-lua/protobuf-lua.mk

package/Config.in +1 -0
index 715f8ab..dc32465 100644
@@ -548,6 +548,7 @@ menu "Lua libraries/modules"
      source "package/luvi/Config.in"
      source "package/lzlib/Config.in"
      source "package/orbit/Config.in"
+    source "package/protobuf-lua/Config.in"
      source "package/rings/Config.in"
      source "package/turbolua/Config.in"
      source "package/wsapi/Config.in"
package/protobuf-lua/Config.in new file +0 -0
new file mode 100644
index 0000000..e602111
Quoted 8 lines

package/protobuf-lua/Config.in line 3

Quoted 6 lines
package/protobuf-lua/Config.in new file +3 -0
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_PROTOBUF_LUA
+    bool "protobuf-lua"
+    depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2

Why protobuf-lua depends on lua 5.1 and 5.2 only ? What was the issue ?

Quoted 2 lines

It seems that the shared library 'pb.so' built by the package is only compatible with Lua 5.2 and Lua 5.2.

Then, can you add a comment about pd.so?

Quoted 4 lines
Quoted 3 lines

Also, is protobuf-lua can be used with luajit ?
If yes, maybe you can use "depends on BR2_PACKAGE_HAS_LUAINTERPRETER" instead.

I can't tell you if it's compatible with 'luajit' or not.

It's ok to disable luajit support now and if someone want to use it, it can be enabled later with a followup patch.

Quoted 45 lines
Quoted 45 lines

package/protobuf-lua/Config.in line 7

Quoted 4 lines
package/protobuf-lua/Config.in new file +4 -0
+    help
+        Runtime libraries to use Protocol Buffers from Lua scripts.
+
+        https://github.com/djungelorm/protobuf-lua

Indent with one tab and two space.

Quoted 7 lines
package/protobuf-lua/protobuf-lua.mk new file +0 -0
new file mode 100644
index 0000000..1a6c693

package/protobuf-lua/protobuf-lua.mk line 7

Quoted 9 lines
package/protobuf-lua/protobuf-lua.mk new file +7 -0
@@ -0,0 +1,60 @@
+################################################################################
 
+#
+# protobuf-lua
+#
+################################################################################
 
+
+

remove one empty line

Quoted 4 lines
package/protobuf-lua/protobuf-lua.mk new file +2 -0
+PROTOBUF_LUA_VERSION = v1.1.1
+PROTOBUF_LUA_SITE = $(call

github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION)) +PROTOBUF_LUA_DEPENDENCIES = luainterpreter host-protoc-gen-lua

There is a missing dependency on host-protobuf which provide protoc

package/protobuf-lua/protobuf-lua.mk line 21

Quoted 13 lines
package/protobuf-lua/protobuf-lua.mk new file +6 -0
+PROTOBUF_LUA_LICENSE = BSD-3c
+PROTOBUF_LUA_LICENSE_FILES = LICENSE
+
+define PROTOBUF_LUA_BUILD_CMDS
+    # build Lua Protobuf shared lib
+    $(TARGET_CC) -Os -shared -std=gnu99 -fPIC $(@D)/protobuf/pb.c -o

$(@D)/protobuf/pb.so

package/protobuf-lua/protobuf-lua.mk new file +5 -1
+
+    # build Protobuf examples
+    PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example
--proto_path=$(@D)/example \
+        $(@D)/example/person.proto
+endef

protoc-gen-lua doesn't work with any host-python version:

Quoted 8 lines
Quoted 7 lines

host-python3:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 15, in <module>
from cStringIO import StringIO
ImportError: No module named 'cStringIO'
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

I guess it will not work whit Python 3 because the missing 'cStringIO '.

It seems you're right "The StringIO and cStringIO modules are gone."
http://stackoverflow.com/questions/28200366/python-3-4-0-email-package-install-importerror-no-module-named-cstringio

Quoted 9 lines
Quoted 9 lines

host-python2:

Traceback (most recent call last):
File "output/host/usr/bin/protoc-gen-lua", line 17, in <module>
import plugin_pb2
File "output/host/usr/bin/plugin_pb2.py", line 3, in <module>
from google.protobuf import descriptor
ImportError: No module named google.protobuf
--lua_out: protoc-gen-lua: Plugin failed with status code 1.

Quoted 3 lines

I've tested it with Python 2.7.11 and it worked well for me. Maybe this error is caused
by the missing dependency to 'host-protobuf'.

Well, I tried to build it with host-protobuf dependency fixed... not sure what's going on.

I can retry when you send a new patch version.

Best regards,
Romain

Quoted 55 lines
Quoted 44 lines

So, I've marked your patch as Changes Requested in patchwork. Feel free to submit an updated version that takes into account the comments and fixed the build issue.

Thanks!

Best regards,
Romain

Quoted 33 lines
package/protobuf-lua/protobuf-lua.mk new file +30 -0
+
+define PROTOBUF_LUA_INSTALL_TARGET_CMDS
+    # install Lua Protobuf support
+    mkdir -p $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/pb.so \
+        $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so
+    mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/containers.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/decoder.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/descriptor.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/encoder.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/init.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/listener.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/text_format.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+    $(INSTALL) -m 0755 $(@D)/protobuf/wire_format.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+
+    # install example files
+    mkdir -p

$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example

package/protobuf-lua/protobuf-lua.mk new file +2 -0
+    $(INSTALL) -m 0755 $(@D)/example/person_pb.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
Quoted 8 lines

package/protobuf-lua/protobuf-lua.mk line 60

Quoted 8 lines
package/protobuf-lua/protobuf-lua.mk new file +7 -0
+    $(INSTALL) -m 0755 $(@D)/example/person.proto \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+    $(INSTALL) -m 0755 $(@D)/example/test.lua \
+        $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+endef
+
+$(eval $(generic-package))

Best Regards,

Tiago.

#8 lore raw

PATCH 3/3 package/protobuf-lua: new package

In reply to Tiago Brusamarello

Hello,

package/protobuf-lua/protobuf-lua.mk line 25

Quoted 12 lines · Tiago Brusamarello
package/protobuf-lua/protobuf-lua.mk new file +12 -0
+define PROTOBUF_LUA_BUILD_CMDS
+	# build Lua Protobuf shared lib
+	$(TARGET_CC) -Os -shared -std=gnu99 -fPIC $(@D)/protobuf/pb.c -o $(@D)/protobuf/pb.so
+
+	# build Protobuf examples
+	PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example --proto_path=$(@D)/example \
+		$(@D)/example/person.proto
+endef
+
+define PROTOBUF_LUA_INSTALL_TARGET_CMDS
+	# install Lua Protobuf support
+	mkdir -p $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf

Not needed if you use the -D option of $(INSTALL) and specify a full destination path.

package/protobuf-lua/protobuf-lua.mk line 28

Quoted 3 lines
package/protobuf-lua/protobuf-lua.mk new file +3 -0
+	$(INSTALL) -m 0755 $(@D)/protobuf/pb.so \
+		$(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf

Ditto/

Quoted 10 lines
package/protobuf-lua/protobuf-lua.mk new file +10 -0
+	$(INSTALL) -m 0755 $(@D)/protobuf/containers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/decoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/descriptor.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/encoder.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/init.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf

package/protobuf-lua/protobuf-lua.mk line 48

Quoted 10 lines
package/protobuf-lua/protobuf-lua.mk new file +10 -0
+	$(INSTALL) -m 0755 $(@D)/protobuf/listener.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/text_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/type_checkers.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf
+	$(INSTALL) -m 0755 $(@D)/protobuf/wire_format.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf

Could you replace this either with a copy of all *.lua files (if it's OK), or otherwise by something like:

PROTOBUF_LUA_FILES = \
	decoder descriptor encoder \
	init listener ... ... ..

and then:

	$(foreach f,$(PROTOBUF_LUA_FILES),\
		$(INSTALL) -D -m 0755 $(@D)/protobuf/$(f).lua \
			$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/$(f).lua
	)

package/protobuf-lua/protobuf-lua.mk line 57

Quoted 8 lines
package/protobuf-lua/protobuf-lua.mk new file +8 -0
+	# install example files
+	mkdir -p $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/person_pb.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/person.proto \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example
+	$(INSTALL) -m 0755 $(@D)/example/test.lua \
+		$(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/example

We don't normally install examples to the target, so I think you could get rid of those lines.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw

PATCH 1/3 package/python-protobuf: Allow generating host-python-protobuf

In reply to Tiago Brusamarello

Hi Tiago,

Le 30/06/2016 ? 14:53, Tiago Brusamarello a ?crit :

Quoted 2 lines

This change allows use of python-protobuf libraries on the host, so 'protoc-gen-lua' plugin for the 'protoc' tool can be run on host.

Thanks for the improved commit log.

Best regards,
Romain

Quoted 16 lines
---
 package/python-protobuf/python-protobuf.mk | 1 +
 1 file changed, 1 insertion(+)
package/python-protobuf/python-protobuf.mk +1 -0
index d8be76d..b328e3e 100644
@@ -14,3 +14,4 @@ PYTHON_PROTOBUF_SETUP_TYPE = setuptools
 PYTHON_PROTOBUF_SUBDIR = python
 
 $(eval $(python-package))
+$(eval $(host-python-package))