Skip to contentSkip to conversation

Add apache thrift

PATCH Superseded Gustavo Zacarias 2 participants 9 messages Oct 30, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add apache thrift

Add the apache thrift runtime and host tool.

Changes for v2:
* Fix indentation in python-thrift cross building
* Explicitly select/depend on zlib in thrift
* Patch Makefile.am instead of Makefile in thrift

Gustavo Zacarias (5):
libevent: add host variant
boost: add host variant
python-thrift: fix cross building
python-thrift: bump to version 0.9.1 and switch to apache
thrift: new package

 package/Config.in                             |  1 +
 package/boost/boost.mk                        | 33 +++++++++++++++
 package/libevent/libevent.mk                  |  1 +
 package/python-thrift/python-thrift.mk        | 21 ++++++----
 package/thrift/Config.in                      | 23 ++++++++++
 package/thrift/thrift-01-libevent-cross.patch | 16 +++++++
 package/thrift/thrift-02-autoreconf.patch     | 22 ++++++++++
 package/thrift/thrift-03-zlib-cross.patch     | 16 +++++++
 package/thrift/thrift.mk                      | 60 +++++++++++++++++++++++++++
 9 files changed, 185 insertions(+), 8 deletions(-)
 create mode 100644 package/thrift/Config.in
 create mode 100644 package/thrift/thrift-01-libevent-cross.patch
 create mode 100644 package/thrift/thrift-02-autoreconf.patch
 create mode 100644 package/thrift/thrift-03-zlib-cross.patch
 create mode 100644 package/thrift/thrift.mk
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH v2 1/5 libevent: add host variant

---
 package/libevent/libevent.mk | 1 +
 1 file changed, 1 insertion(+)
package/libevent/libevent.mk +1 -0
index a6def1a..14ebf72 100644
@@ -20,3 +20,4 @@ LIBEVENT_POST_INSTALL_TARGET_HOOKS += LIBEVENT_REMOVE_PYSCRIPT
 endif
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH v2 2/5 boost: add host variant

In reply to Gustavo Zacarias
---
 package/boost/boost.mk | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
package/boost/boost.mk +33 -0
index b0b3352..b97d12b 100644
@@ -11,11 +11,19 @@ BOOST_SITE = http://downloads.sourceforge.net/project/boost/boost/$(BOOST_VERSIO
 BOOST_INSTALL_STAGING = YES
 
 TARGET_CC_VERSION = $(shell $(TARGET_CC) -dumpversion)
+HOST_CC_VERSION = $(shell $(HOSTCC) -dumpversion)
 
 BOOST_DEPENDENCIES =
 
 BOOST_FLAGS =
 
+# keep host variant as minimal as possible
+HOST_BOOST_FLAGS = --without-icu \
+	--without-libraries=$(subst $(space),$(comma),atomic chrono context \
+	coroutine date_time exception filesystem graph graph_parallel \
+	iostreams locale log math mpi program_options python random regex \
+	serialization signals system test thread timer wave)
+
 # atomic library compile only with upstream version, wait for next release
 # coroutine breaks on some weak toolchains and it's new for 1.54+
 # log breaks with some toolchain combinations and it's new for 1.54+
@@ -54,6 +62,9 @@ ifeq ($(BR2_PACKAGE_BOOST_IOSTREAMS),y)
 BOOST_DEPENDENCIES += bzip2 zlib
 endif
 
+HOST_BOOST_OPT += toolset=gcc threading=multi variant=release link=shared \
+	runtime-link=shared
+
 BOOST_OPT += toolset=gcc \
 	     threading=multi \
 	     variant=$(if $(BR2_ENABLE_DEBUG),debug,release) \
@@ -78,6 +89,12 @@ define BOOST_CONFIGURE_CMDS
 	echo "" >> $(@D)/user-config.jam
 endef
 
+define HOST_BOOST_CONFIGURE_CMDS
+	(cd $(@D) && ./bootstrap.sh $(HOST_BOOST_FLAGS))
+	echo "using gcc : $(HOST_CC_VERSION) : $(HOSTCXX) : <cxxflags>\"$(HOST_CXXFLAGS)\" <linkflags>\"$(HOST_LDFLAGS)\" ;" > $(@D)/user-config.jam
+	echo "" >> $(@D)/user-config.jam
+endef
+
 define BOOST_INSTALL_TARGET_CMDS
 	(cd $(@D) && ./b2 -j$(PARALLEL_JOBS) -q -d+1 \
 	--user-config=$(@D)/user-config.jam \
@@ -86,6 +103,21 @@ define BOOST_INSTALL_TARGET_CMDS
 	--layout=system install )
 endef
 
+define HOST_BOOST_BUILD_CMDS
+	(cd $(@D) && ./b2 -j$(PARALLEL_JOBS) -q -d+1 \
+	--user-config=$(@D)/user-config.jam \
+	$(HOST_BOOST_OPT) \
+	--prefix=$(HOST_DIR)/usr )
+endef
+
+define HOST_BOOST_INSTALL_CMDS
+	(cd $(@D) && ./b2 -j$(PARALLEL_JOBS) -q -d+1 \
+	--user-config=$(@D)/user-config.jam \
+	$(HOST_BOOST_OPT) \
+	--prefix=$(HOST_DIR)/usr \
+	--layout=system install )
+endef
+
 define BOOST_INSTALL_STAGING_CMDS
 	(cd $(@D) && ./bjam -j$(PARALLEL_JOBS) -d+1 \
 	--user-config=$(@D)/user-config.jam \
@@ -95,3 +127,4 @@ define BOOST_INSTALL_STAGING_CMDS
 endef
 
 $(eval $(generic-package))
+$(eval $(host-generic-package))
Signature · 1 line
1.8.1.5
#3 lore raw

PATCH v2 3/5 python-thrift: fix cross building

In reply to Gustavo Zacarias

The C code (fastbinary.so) wasn't built using the cross compiler, hence it was unusable. Fix it.

---
 package/python-thrift/python-thrift.mk | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
package/python-thrift/python-thrift.mk +8 -3
index 4cd35e5..65733d4 100644
@@ -9,13 +9,18 @@ PYTHON_THRIFT_SOURCE = thrift-$(PYTHON_THRIFT_VERSION).tar.gz
 PYTHON_THRIFT_SITE = http://pypi.python.org/packages/source/t/thrift
 PYTHON_THRIFT_LICENSE = Apache-2.0
 PYTHON_THRIFT_LICENSE_FILES = README
-
 PYTHON_THRIFT_DEPENDENCIES = python
 
 define PYTHON_THRIFT_BUILD_CMDS
 	(cd $(@D); \
-		PYTHONXCPREFIX="$(STAGING_DIR)/usr/" \
-		LDFLAGS="-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib" \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS)" \
+		LDSHARED="$(TARGET_CROSS)gcc -shared" \
+		CROSS_COMPILING=yes \
+		_python_sysroot=$(STAGING_DIR) \
+		_python_srcdir=$(BUILD_DIR)/python$(PYTHON_VERSION) \
+		_python_prefix=/usr \
+		_python_exec_prefix=/usr \
 		$(HOST_DIR)/usr/bin/python setup.py build)
 endef
 
Signature · 1 line
1.8.1.5
#4 lore raw

PATCH v2 4/5 python-thrift: bump to version 0.9.1 and switch to apache

In reply to Gustavo Zacarias

Switch away from the PyPI subset version since it has a great filename clash with the full upstream apache version.

---
 package/python-thrift/python-thrift.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
package/python-thrift/python-thrift.mk +5 -5
index 65733d4..91e14e5 100644
@@ -4,15 +4,15 @@
 #
 ################################################################################
 
-PYTHON_THRIFT_VERSION = 0.9.0
+PYTHON_THRIFT_VERSION = 0.9.1
 PYTHON_THRIFT_SOURCE = thrift-$(PYTHON_THRIFT_VERSION).tar.gz
-PYTHON_THRIFT_SITE = http://pypi.python.org/packages/source/t/thrift
+PYTHON_THRIFT_SITE = http://www.us.apache.org/dist/thrift/$(PYTHON_THRIFT_VERSION)
 PYTHON_THRIFT_LICENSE = Apache-2.0
-PYTHON_THRIFT_LICENSE_FILES = README
+PYTHON_THRIFT_LICENSE_FILES = LICENSE
 PYTHON_THRIFT_DEPENDENCIES = python
 
 define PYTHON_THRIFT_BUILD_CMDS
-	(cd $(@D); \
+	(cd $(@D)/lib/py; \
 		CC="$(TARGET_CC)" \
 		CFLAGS="$(TARGET_CFLAGS)" \
 		LDSHARED="$(TARGET_CROSS)gcc -shared" \
@@ -28,7 +28,7 @@ endef
 # the installation directory is in python's load path. For host-python,
 # it is not, so add it explicitly while installing to target.
 define PYTHON_THRIFT_INSTALL_TARGET_CMDS
-	(cd $(@D); PYTHONPATH=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages \
+	(cd $(@D)/lib/py; PYTHONPATH=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages \
 		$(HOST_DIR)/usr/bin/python setup.py install --prefix=$(TARGET_DIR)/usr)
 endef
 
Signature · 1 line
1.8.1.5
#5 lore raw

PATCH v2 5/5 thrift: new package

In reply to Gustavo Zacarias
---
 package/Config.in                             |  1 +
 package/thrift/Config.in                      | 23 ++++++++++
 package/thrift/thrift-01-libevent-cross.patch | 16 +++++++
 package/thrift/thrift-02-autoreconf.patch     | 22 ++++++++++
 package/thrift/thrift-03-zlib-cross.patch     | 16 +++++++
 package/thrift/thrift.mk                      | 60 +++++++++++++++++++++++++++
 6 files changed, 138 insertions(+)
 create mode 100644 package/thrift/Config.in
 create mode 100644 package/thrift/thrift-01-libevent-cross.patch
 create mode 100644 package/thrift/thrift-02-autoreconf.patch
 create mode 100644 package/thrift/thrift-03-zlib-cross.patch
 create mode 100644 package/thrift/thrift.mk
package/Config.in +1 -0
index f3dc65e..eb667a6 100644
@@ -660,6 +660,7 @@ source "package/openpgm/Config.in"
 source "package/ortp/Config.in"
 source "package/slirp/Config.in"
 source "package/snmppp/Config.in"
+source "package/thrift/Config.in"
 source "package/usbredir/Config.in"
 source "package/wvstreams/Config.in"
 source "package/zeromq/Config.in"
package/thrift/Config.in new file +23 -0
new file mode 100644
index 0000000..a7f3479
@@ -0,0 +1,23 @@
+config BR2_PACKAGE_THRIFT
+	bool "thrift"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_USE_WCHAR
+	depends on BR2_LARGEFILE
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_BOOST
+	select BR2_PACKAGE_LIBEVENT
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_ZLIB
+	help
+	  The Apache Thrift software framework, for scalable cross-language
+	  services development, combines a software stack with a
+	  code generation engine to build services that work
+	  efficiently and seamlessly between C++, Java, Python, PHP, Ruby,
+	  Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk,
+	  OCaml and Delphi and other languages.
+
+	  http://thrift.apache.org/
+
+comment "thrift needs a toolchain w/ C++, largefile, wchar, threads"
+	depends on !BR2_LARGEFILE || !BR2_USE_WCHAR || \
+		!BR2_TOOLCHAIN_HAS_THREADS || !BR2_INSTALL_LIBSTDCPP
package/thrift/thrift-01-libevent-cross.patch new file +16 -0
new file mode 100644
index 0000000..f07caa7
@@ -0,0 +1,16 @@
+Make it cross-compile happy the hard way, there's no clean way.
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+diff -Nura thrift-0.9.1.orig/aclocal/ax_lib_event.m4 thrift-0.9.1/aclocal/ax_lib_event.m4
+--- thrift-0.9.1.orig/aclocal/ax_lib_event.m4	2013-08-15 11:04:29.000000000 -0300
++++ thrift-0.9.1/aclocal/ax_lib_event.m4	2013-10-07 20:40:44.076435613 -0300
+@@ -75,7 +75,7 @@
+           AC_LANG_PUSH([C])
+           dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling,
+           dnl but then the version cannot be checked.
+-          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
++          AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+           #include <sys/types.h>
+           #include <event.h>
+           ]], [[
package/thrift/thrift-02-autoreconf.patch new file +22 -0
new file mode 100644
index 0000000..d56212a
@@ -0,0 +1,22 @@
+Fillers to make autoreconf (automake) happy.
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+diff -Nura thrift-0.9.1.orig/AUTHORS thrift-0.9.1/AUTHORS
+--- thrift-0.9.1.orig/AUTHORS	1969-12-31 21:00:00.000000000 -0300
++++ thrift-0.9.1/AUTHORS	2013-10-07 20:45:15.745315148 -0300
+@@ -0,0 +1,2 @@
++
++
+diff -Nura thrift-0.9.1.orig/ChangeLog thrift-0.9.1/ChangeLog
+--- thrift-0.9.1.orig/ChangeLog	1969-12-31 21:00:00.000000000 -0300
++++ thrift-0.9.1/ChangeLog	2013-10-07 20:45:23.078554836 -0300
+@@ -0,0 +1,2 @@
++
++
+diff -Nura thrift-0.9.1.orig/NEWS thrift-0.9.1/NEWS
+--- thrift-0.9.1.orig/NEWS	1969-12-31 21:00:00.000000000 -0300
++++ thrift-0.9.1/NEWS	2013-10-07 20:45:20.351465699 -0300
+@@ -0,0 +1,2 @@
++
++
package/thrift/thrift-03-zlib-cross.patch new file +16 -0
new file mode 100644
index 0000000..3af39c4
@@ -0,0 +1,16 @@
+Make zlib version detection cross-compile happy.
+
+Signed-off-by: Gustavo Zacarias <[email protected]>
+
+diff -Nura thrift-0.9.1.orig/aclocal/ax_lib_zlib.m4 thrift-0.9.1/aclocal/ax_lib_zlib.m4
+--- thrift-0.9.1.orig/aclocal/ax_lib_zlib.m4	2013-08-15 11:04:29.000000000 -0300
++++ thrift-0.9.1/aclocal/ax_lib_zlib.m4	2013-10-07 20:47:44.523177973 -0300
+@@ -73,7 +73,7 @@
+           #   (defined in the library).
+           AC_LANG_PUSH([C])
+           dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling.
+-          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
++          AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+           #include <zlib.h>
+           #if ZLIB_VERNUM >= 0x$WANT_ZLIB_VERSION
+           #else
package/thrift/thrift.mk new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#6 lore raw

v2 cover Add apache thrift

In reply to Gustavo Zacarias

Gustavo,

Gustavo Zacarias <[email protected]> wrote on 10/29/2013 07:28:31 PM:

Quoted 6 lines

Add the apache thrift runtime and host tool.

Changes for v2:
* Fix indentation in python-thrift cross building
* Explicitly select/depend on zlib in thrift
* Patch Makefile.am instead of Makefile in thrift

So how do you envision a new person to add a package that utilizes thrift as their complier? I guess what I'm trying to get at here is I just want to try to understand how the thrift package will be used. I'm pretty sure how you are going to do it but without an example in this patchset I can't be sure.

Here is how I'm envisioning it with the packages you have submitted.

Config.in
----------
has "select BR2_PACKAGE_THRIFT"

foo.mk
--------
FOO_DEPENDENCIES = host-thrift

define FOO_BUILD_CMDS
# This assumes that the package's Makefile uses THRIFT for the
compiler

        $(TARGET_MAKE_ENV) $(MAKE) THRIFT=$(HOST_DIR)/usr/bin/thrift -C 

$(@D)
endif

Granted there is more each of the packages but this covers the thrift specific parts. Please correct me if I have made incorrect assumptions with how you envisioned utilizing THRIFT.

Thanks,
-Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20131029/867114c9/attachment.html>

#7 lore raw

v2 cover Add apache thrift

Quoted 8 lines · rjbarnet at rockwellcollins.com

So how do you envision a new person to add a package that utilizes thrift as their complier? I guess what I'm trying to get at here is I just want to try to understand how the thrift package will be used. I'm pretty sure how you are going to do it but without an example in this patchset I can't be sure.

Here is how I'm envisioning it with the packages you have submitted.

Quoted 8 lines

Config.in
----------
has "select BR2_PACKAGE_THRIFT"

foo.mk
--------
FOO_DEPENDENCIES = host-thrift

FOO_DEPENDENCIES = thrift
You'll need the runtime libs which implement all the networking stack besides the host tool to compile.
A thrift definition file assembles into target source code with the tool with the chosen language. This could ostensibly be done outside buildroot, but very few distributions ship the thrift tool. Coarsely speaking it would fit in a build process like bison or flex.

Quoted 6 lines

define FOO_BUILD_CMDS
# This assumes that the package's Makefile uses THRIFT for the
compiler

        $(TARGET_MAKE_ENV) $(MAKE) THRIFT=$(HOST_DIR)/usr/bin/thrift -C

$(@D)
endif

Not really, for a package/project with a proper Makefile you'd just point THRIFT=$(HOST_DIR)/usr/bin/thrift to it and be handled internally as part of the overall build process.

Quoted 3 lines

Granted there is more each of the packages but this covers the thrift specific parts. Please correct me if I have made incorrect assumptions with how you envisioned utilizing THRIFT.

We can always define $(THRIFT) to make it handy for developers like it's done for QT_QMAKE for example - but being generally used with specific parameters (target language mostly) it would just point to the binary since it's pretty much self-contained.
Regards.

#8 lore raw

v2 cover Add apache thrift

Gustavo,

Gustavo Zacarias <[email protected]> wrote on 10/30/2013 09:39:24 AM:

Quoted 9 lines · rjbarnet at rockwellcollins.com

FOO_DEPENDENCIES = thrift
You'll need the runtime libs which implement all the networking stack besides the host tool to compile.
A thrift definition file assembles into target source code with the tool with the chosen language. This could ostensibly be done outside buildroot, but very few distributions ship the thrift tool. Coarsely speaking it would fit in a build process like bison or flex.

Ok, thanks for the insight and yes of course I forgot about the target version.

Quoted 4 lines
Quoted 4 lines

define FOO_BUILD_CMDS
# This assumes that the package's Makefile uses THRIFT for the
compiler

        $(TARGET_MAKE_ENV) $(MAKE) THRIFT=$(HOST_DIR)/usr/bin/thrift 

-C

Quoted 7 lines
Quoted 2 lines

$(@D)
endif

Not really, for a package/project with a proper Makefile you'd just point THRIFT=$(HOST_DIR)/usr/bin/thrift to it and be handled internally as part of the overall build process.

Quoted 8 lines
Quoted 3 lines

Granted there is more each of the packages but this covers the thrift specific parts. Please correct me if I have made incorrect assumptions with how you envisioned utilizing THRIFT.

We can always define $(THRIFT) to make it handy for developers like it's done for QT_QMAKE for example - but being generally used with specific parameters (target language mostly) it would just point to the binary since it's pretty much self-contained.

Thank for you clarifying this for me. I will try to get around to testing out your patches here by the end of the week.

Thanks,
-Ryan