Message ID | 1467291218-7710-3-git-send-email-tiago.brusamarello@datacom.ind.br |
---|---|
State | Superseded |
Headers | show |
Hi Tiago, Le 30/06/2016 à 14:53, Tiago Brusamarello a écrit : > 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/ > was used instead. > > This package depends on the 'protoc-gen-lua' plugin package > for generation of Protobuf messages types in Lua format. > > Signed-off-by: Tiago Brusamarello <tiago.brusamarello@datacom.ind.br> > --- > 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 > > diff --git a/package/Config.in b/package/Config.in > index 715f8ab..dc32465 100644 > --- a/package/Config.in > +++ b/package/Config.in > @@ -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" > diff --git a/package/protobuf-lua/Config.in b/package/protobuf-lua/Config.in > new file mode 100644 > index 0000000..e602111 > --- /dev/null > +++ b/package/protobuf-lua/Config.in > @@ -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. > + help > + Runtime libraries to use Protocol Buffers from Lua scripts. > + > + https://github.com/djungelorm/protobuf-lua Indent with one tab and two space. > diff --git a/package/protobuf-lua/protobuf-lua.mk b/package/protobuf-lua/protobuf-lua.mk > new file mode 100644 > index 0000000..1a6c693 > --- /dev/null > +++ b/package/protobuf-lua/protobuf-lua.mk > @@ -0,0 +1,60 @@ > +################################################################################ > +# > +# protobuf-lua > +# > +################################################################################ > + > + remove one empty line > +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 > +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 > + > +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)) >
Hello, On Thu, 30 Jun 2016 09:53:38 -0300, Tiago Brusamarello wrote: > +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. > + $(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/ > + $(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 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 ) > + # 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
Hi Romain. Em 16-07-2016 07:25, Romain Naour escreveu: > Hi Tiago, > > Le 30/06/2016 à 14:53, Tiago Brusamarello a écrit : >> 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/ > >> was used instead. >> >> This package depends on the 'protoc-gen-lua' plugin package >> for generation of Protobuf messages types in Lua format. >> >> Signed-off-by: Tiago Brusamarello<tiago.brusamarello@datacom.ind.br> >> --- >> 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 >> >> diff --git a/package/Config.in b/package/Config.in >> index 715f8ab..dc32465 100644 >> --- a/package/Config.in >> +++ b/package/Config.in >> @@ -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" >> diff --git a/package/protobuf-lua/Config.in b/package/protobuf-lua/Config.in >> new file mode 100644 >> index 0000000..e602111 >> --- /dev/null >> +++ b/package/protobuf-lua/Config.in >> @@ -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. > 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. >> + help >> + Runtime libraries to use Protocol Buffers from Lua scripts. >> + >> + https://github.com/djungelorm/protobuf-lua > Indent with one tab and two space. > >> diff --git a/package/protobuf-lua/protobuf-lua.mk b/package/protobuf-lua/protobuf-lua.mk >> new file mode 100644 >> index 0000000..1a6c693 >> --- /dev/null >> +++ b/package/protobuf-lua/protobuf-lua.mk >> @@ -0,0 +1,60 @@ >> +################################################################################ >> +# >> +# protobuf-lua >> +# >> +################################################################################ >> + >> + > remove one empty line > >> +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 > >> +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. I guess it will not work whit Python 3 because the missing 'cStringIO '. > 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'. > 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 > > >> + >> +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)) >> Best Regards, Tiago.
Hi Tiago, Le 18/07/2016 à 19:31, Tiago Brusamarello a écrit : > Hi Romain. > > Em 16-07-2016 07:25, Romain Naour escreveu: >> Hi Tiago, >> >> Le 30/06/2016 à 14:53, Tiago Brusamarello a écrit : >>> 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/ >> >>> was used instead. >>> >>> This package depends on the 'protoc-gen-lua' plugin package >>> for generation of Protobuf messages types in Lua format. >>> >>> Signed-off-by: Tiago Brusamarello<tiago.brusamarello@datacom.ind.br> >>> --- >>> 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 >>> >>> diff --git a/package/Config.in b/package/Config.in >>> index 715f8ab..dc32465 100644 >>> --- a/package/Config.in >>> +++ b/package/Config.in >>> @@ -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" >>> diff --git a/package/protobuf-lua/Config.in b/package/protobuf-lua/Config.in >>> new file mode 100644 >>> index 0000000..e602111 >>> --- /dev/null >>> +++ b/package/protobuf-lua/Config.in >>> @@ -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. Then, can you add a comment about pd.so? > >> 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. >>> + help >>> + Runtime libraries to use Protocol Buffers from Lua scripts. >>> + >>> + https://github.com/djungelorm/protobuf-lua >> Indent with one tab and two space. >> >>> diff --git a/package/protobuf-lua/protobuf-lua.mk >>> b/package/protobuf-lua/protobuf-lua.mk >>> new file mode 100644 >>> index 0000000..1a6c693 >>> --- /dev/null >>> +++ b/package/protobuf-lua/protobuf-lua.mk >>> @@ -0,0 +1,60 @@ >>> +################################################################################ >>> >>> +# >>> +# protobuf-lua >>> +# >>> +################################################################################ >>> >>> + >>> + >> remove one empty line >> >>> +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 >> >>> +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. > 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 >> 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'. 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 > >> 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 >> >> >>> + >>> +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)) >>> > Best Regards, > > Tiago.
diff --git a/package/Config.in b/package/Config.in index 715f8ab..dc32465 100644 --- a/package/Config.in +++ b/package/Config.in @@ -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" diff --git a/package/protobuf-lua/Config.in b/package/protobuf-lua/Config.in new file mode 100644 index 0000000..e602111 --- /dev/null +++ b/package/protobuf-lua/Config.in @@ -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 diff --git a/package/protobuf-lua/protobuf-lua.mk b/package/protobuf-lua/protobuf-lua.mk new file mode 100644 index 0000000..1a6c693 --- /dev/null +++ b/package/protobuf-lua/protobuf-lua.mk @@ -0,0 +1,60 @@ +################################################################################ +# +# protobuf-lua +# +################################################################################ + + +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 +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 + +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))
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. Signed-off-by: Tiago Brusamarello <tiago.brusamarello@datacom.ind.br> --- 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