package/python-protobuf: Allow generating host-python-protobuf
PATCH v2 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
@@ -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
PATCH v2 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.
---
Changes v1 -> v2:
- Removed Config.in (suggested by Romain Naour)
- Added new line at end of the .mk file (suggested by Romain Naour)
--- package/protoc-gen-lua/protoc-gen-lua.hash | 2 ++ package/protoc-gen-lua/protoc-gen-lua.mk | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 package/protoc-gen-lua/protoc-gen-lua.hash create mode 100644 package/protoc-gen-lua/protoc-gen-lua.mk
package/protoc-gen-lua/protoc-gen-lua.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Locally computed +sha256 bccdd9c65970c42fd29b87084db83777cad75780a67c5107b68f96603b5788a8 protoc-gen-lua-v1.1.1.tar.gz
package/protoc-gen-lua/protoc-gen-lua.mk new file +18 -0
@@ -0,0 +1,18 @@ +################################################################################ +# +# 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) -D -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin + $(INSTALL) -D -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin +endef + +$(eval $(host-generic-package))
Signature · 1 line
1.9.1
PATCH v2 2/3 package/protoc-gen-lua: new package
Hi Tiago,
Le 19/07/2016 ? 14:31, Tiago Brusamarello a ?crit :
Quoted 4 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.
Thanks for this new version!
Sorry but it still doesn't work here for the same reason:
ImportError: No module named google.protobuf
I have not idea...
Best regards,
Romain
Quoted 48 lines
Signed-off-by Tiago Brusamarello <[email protected]>---
Changes v1 -> v2:
- Removed Config.in (suggested by Romain Naour)
- Added new line at end of the .mk file (suggested by Romain Naour)Signed-off-by Tiago Brusamarello <[email protected]>--- package/protoc-gen-lua/protoc-gen-lua.hash | 2 ++ package/protoc-gen-lua/protoc-gen-lua.mk | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 package/protoc-gen-lua/protoc-gen-lua.hash create mode 100644 package/protoc-gen-lua/protoc-gen-lua.mkpackage/protoc-gen-lua/protoc-gen-lua.hash new file +2
-0@@ -0,0 +1,2 @@ +# Locally computed +sha256 bccdd9c65970c42fd29b87084db83777cad75780a67c5107b68f96603b5788a8 protoc-gen-lua-v1.1.1.tar.gzpackage/protoc-gen-lua/protoc-gen-lua.mk new file +18
-0@@ -0,0 +1,18 @@ +################################################################################ +# +# 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) -D -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin + $(INSTALL) -D -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin +endef + +$(eval $(host-generic-package))
PATCH v2 2/3 package/protoc-gen-lua: new package
In reply to Tiago BrusamarelloHello,
package/protoc-gen-lua/protoc-gen-lua.mk line 8
Quoted 2 lines · Tiago Brusamarello
package/protoc-gen-lua/protoc-gen-lua.mk new file +2
-0+PROTOC_GEN_LUA_VERSION = v1.1.1 +PROTOC_GEN_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOC_GEN_LUA_VERSION))
This has the exact same source as the protobuf-lua package you propose in PATCH 3/3:
+PROTOBUF_LUA_VERSION = v1.1.1
+PROTOBUF_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION))
So, we clearly don't want two packages in this case: we want a single package. The host variant of the package will just install plugin_pb2.py and protoc-gen-lua like your protoc-gen-lua package is doing today. And the target package will do what your protobuf-lua package is doing.
package/protoc-gen-lua/protoc-gen-lua.mk line 15
Quoted 3 lines
package/protoc-gen-lua/protoc-gen-lua.mk new file +3
-0+define HOST_PROTOC_GEN_LUA_INSTALL_CMDS + $(INSTALL) -D -m 0755 $(@D)/protoc-plugin/plugin_pb2.py $(HOST_DIR)/usr/bin + $(INSTALL) -D -m 0755 $(@D)/protoc-plugin/protoc-gen-lua $(HOST_DIR)/usr/bin
Full destination paths please.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 3/3 package/protobuf-lua: new package
In reply to Tiago BrusamarelloThis 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 builds a shared library named 'pb.so' thats is only supported on Lua versions 5.1 and 5.2. So this package will be available only when one of these two version is selected.
This package depends on the 'host-protoc-gen-lua' plugin to be used with the 'protoc' tool from the Google's Protobuf package to generate Protobuf messages types in Lua format. It's a Python script and is currently only supported on Python version 2.x.
---
Changes v1 -> v2:
- Added '-D' option on each 'install' command invocation (suggested by Thomas Petazzoni)
- Lua files were listed in a variable and installed with a 'foreach' loop (suggested by Thomas Petazzoni)
- Examples are not deployed to the target anymore (suggested by Thomas Petazzoni)
- Added comment about the 'pb.so' compatibility issue (suggested by Romain Naour)
- Removed empty line from the start of the '.mk' file (suggested by Romain Naour)
- Added dependency to the 'host-protobuf' package (suggested by Romain Naour)
--- package/Config.in | 1 + package/protobuf-lua/Config.in | 10 ++++++++++ package/protobuf-lua/protobuf-lua.hash | 2 ++ package/protobuf-lua/protobuf-lua.mk | 36 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 package/protobuf-lua/Config.in create mode 100644 package/protobuf-lua/protobuf-lua.hash create mode 100644 package/protobuf-lua/protobuf-lua.mk
package/Config.in +1 -0
@@ -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 +10 -0
@@ -0,0 +1,10 @@ +config BR2_PACKAGE_PROTOBUF_LUA + bool "protobuf-lua" + depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2 + depends on !BR2_PACKAGE_PYTHON3 + help + Runtime libraries to use Protocol Buffers from Lua scripts. + This package requires 'host-protoc-gen-lua' which depends on + Python version 2.x to work. + + https://github.com/djungelorm/protobuf-lua
package/protobuf-lua/protobuf-lua.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Locally computed +sha256 bccdd9c65970c42fd29b87084db83777cad75780a67c5107b68f96603b5788a8 protobuf-lua-v1.1.1.tar.gz
package/protobuf-lua/protobuf-lua.mk new file +36 -0
@@ -0,0 +1,36 @@ +################################################################################ +# +# protobuf-lua +# +################################################################################ + +PROTOBUF_LUA_VERSION = v1.1.1 +PROTOBUF_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION)) +PROTOBUF_LUA_DEPENDENCIES = luainterpreter host-protobuf host-protoc-gen-lua +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 Lua Protobuf examples + PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example --proto_path=$(@D)/example \ + $(@D)/example/person.proto +endef + +PROTOBUF_LUA_FILES = \ + containers decoder descriptor encoder init listener \ + text_format type_checkers wire_format + +define PROTOBUF_LUA_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/protobuf/pb.so \ + $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so + + $(foreach f,$(PROTOBUF_LUA_FILES),\ + $(INSTALL) -D -m 0755 $(@D)/protobuf/$(f).lua \ + $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/$(f).lua + ) +endef + +$(eval $(generic-package))
Signature · 1 line
1.9.1
PATCH v2 3/3 package/protobuf-lua: new package
Hello,
Quoted 5 lines · Tiago Brusamarello
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.
Again, I already suggested that the naming conflict is not a good enough reason, and can be resolved.
package/protobuf-lua/Config.in line 4
Quoted 10 lines
package/protobuf-lua/Config.in new file +4
-0@@ -0,0 +1,10 @@ +config BR2_PACKAGE_PROTOBUF_LUA + bool "protobuf-lua" + depends on BR2_PACKAGE_LUA_5_1 || BR2_PACKAGE_LUA_5_2 + depends on !BR2_PACKAGE_PYTHON3
depends on BR2_PACKAGE_PYTHON would be better here
package/protobuf-lua/Config.in
Quoted 13 lines
package/protobuf-lua/Config.in new file +13
-0+PROTOBUF_LUA_VERSION = v1.1.1 +PROTOBUF_LUA_SITE = $(call github,djungelorm,protobuf-lua,$(PROTOBUF_LUA_VERSION)) +PROTOBUF_LUA_DEPENDENCIES = luainterpreter host-protobuf host-protoc-gen-lua +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 Lua Protobuf examples + PATH=$(BR_PATH) $(HOST_DIR)/usr/bin/protoc --lua_out=$(@D)/example --proto_path=$(@D)/example \ + $(@D)/example/person.proto
Why do you build examples? We generally don't care about building example code in Buildroot.
Quoted 17 lines
package/protobuf-lua/Config.in new file +17
-0+endef + +PROTOBUF_LUA_FILES = \ + containers decoder descriptor encoder init listener \ + text_format type_checkers wire_format + +define PROTOBUF_LUA_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/protobuf/pb.so \ + $(TARGET_DIR)/usr/lib/lua/$(LUAINTERPRETER_ABIVER)/protobuf/pb.so + + $(foreach f,$(PROTOBUF_LUA_FILES),\ + $(INSTALL) -D -m 0755 $(@D)/protobuf/$(f).lua \ + $(TARGET_DIR)/usr/share/lua/$(LUAINTERPRETER_ABIVER)/protobuf/$(f).lua + ) +endef + +$(eval $(generic-package))
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com