leveldb: new package
PATCH v5 1/1 leveldb: new package
---
Changes v4 -> v5:
- Simplify our make by patching Buildroot support into upstream
Changes v3 -> v4:
- Don't damage global scope make macros
- Add dependency on threads toolchain
Changes v2 -> v3:
- Re-submit without line wrapping
Changes v1 -> v2:
- Upstream release labels don't include package name, giving us an
anonymous download archive, so use $(call github) method instead
- Use $(TARGET_CONFIGURE_OPTS)
- Support new shared vs static vs shared+static possibilities
package/Config.in | 1 + package/leveldb/001-ssize_t-undefined.patch | 17 +++++ ...002-facilitate-integration-into-buildroot.patch | 78 ++++++++++++++++++++++ package/leveldb/Config.in | 13 ++++ package/leveldb/leveldb.mk | 46 +++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 package/leveldb/001-ssize_t-undefined.patch create mode 100644 package/leveldb/002-facilitate-integration-into-buildroot.patch create mode 100644 package/leveldb/Config.in create mode 100644 package/leveldb/leveldb.mk
package/Config.in +1 -0
@@ -631,6 +631,7 @@ menu "Database" source "package/berkeleydb/Config.in" source "package/cppdb/Config.in" source "package/gdbm/Config.in" + source "package/leveldb/Config.in" source "package/mysql/Config.in" source "package/postgresql/Config.in" source "package/redis/Config.in"
package/leveldb/001-ssize_t-undefined.patch new file +17 -0
@@ -0,0 +1,17 @@ +Fix leveldb issue 233 leveldb does not compile with g++ 4.8.2 + +Where db_iter.cc fails to get a typedef for ssize_t when compiled by GCC. + +Upstream-Status: Submitted [https://github.com/google/leveldb/issues/233] +Signed-off-by: Steve James <[email protected]> + +--- a/db/db_iter.cc.orig 2014-12-08 16:54:31.384615752 +0000 ++++ b/db/db_iter.cc 2014-12-08 16:54:35.464656890 +0000 +@@ -13,6 +13,7 @@ + #include "util/logging.h" + #include "util/mutexlock.h" + #include "util/random.h" ++#include <sys/types.h> // for ssize_t + + namespace leveldb { +
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +78 -0
78 lines not on this page · raw message
package/leveldb/Config.in new file +13 -0
@@ -0,0 +1,13 @@ +config BR2_PACKAGE_LEVELDB + bool "leveldb" + depends on BR2_INSTALL_LIBSTDCPP + depends on BR2_TOOLCHAIN_HAS_THREADS + select BR2_PACKAGE_SNAPPY + help + LevelDB is a fast key-value storage library written at Google that + provides an ordered mapping from string keys to string values. + + https://github.com/google/leveldb + +comment "leveldb needs a toolchain w/ C++, threads" + depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS
package/leveldb/leveldb.mk new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v5 1/1 leveldb: new package
Dear Steve James,
Thanks for this new version!
package/leveldb/002-facilitate-integration-into-buildroot.patch line 7
Quoted 13 lines · Steve James
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +7
-0@@ -0,0 +1,78 @@ +From 83d4b0db22f661718e9568e8bcde549ad3fd4222 Mon Sep 17 00:00:00 2001 +From: Steve James <[email protected]> +Date: Fri, 9 Jan 2015 10:38:21 +0000 +Subject: [PATCH 1/1] facilitate integration into Buildroot: + - Add Buildroot TARGET_OS + - Allow flags from the environment + - Add install recipe
There are three different things being done, so it should be three separate patches, especially for upstream submission.
However, I believe adding a Buildroot TARGET_OS is a mistake, and has no chance of being merged upstream. Buildroot is not an OS. It builds Linux based systems, so the existing TARGET_OS=Linux should work just fine for Buildroot.
package/leveldb/002-facilitate-integration-into-buildroot.patch line 32
Quoted 9 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +9
-0+-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) +-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) ++override CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) ++override CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) + +-LDFLAGS += $(PLATFORM_LDFLAGS) +-LIBS += $(PLATFORM_LIBS) ++override LDFLAGS += $(PLATFORM_LDFLAGS) ++override LIBS += $(PLATFORM_LIBS)
So this should be one patch.
Quoted 13 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +13
-0+ + LIBOBJECTS = $(SOURCES:.cc=.o) + MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) +@@ -229,3 +229,20 @@ else + .c.o: + $(CC) $(CFLAGS) -c $< -o $@ + endif ++ ++INSTALL_ROOT = ++INSTALL_PREFIX= usr ++ ++install: $(SHARED) $(LIBRARY) ++ install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb
package/leveldb/002-facilitate-integration-into-buildroot.patch line 55
Quoted 10 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +10
-0++ install -D -m 0644 include/leveldb/*.h $(INSTALL_ROOT)/$(INSTALL_PREFIX)/include/leveldb ++ install -d -m 0755 $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib ++ ifneq (,$(LIBRARY)) ++ install -m 0644 $(LIBRARY) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib ++ endif ++ ifneq (,$(SHARED)) ++ install -m 0755 $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib ++ ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED1) ++ ln -sf $(SHARED3) $(INSTALL_ROOT)/$(INSTALL_PREFIX)/lib/$(SHARED2) ++ endif
This should be another patch.
package/leveldb/002-facilitate-integration-into-buildroot.patch line 72
Quoted 8 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +8
-0++ Buildroot) ++ PLATFORM=OS_LINUX ++ COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" ++ PLATFORM_LDFLAGS="-pthread" ++ PLATFORM_CXXFLAGS="-std=c++0x" ++ PORT_FILE=port/port_posix.cc ++ CROSS_COMPILE=true ++ ;;
This should not be needed.
package/leveldb/002-facilitate-integration-into-buildroot.patch line 56
Quoted 9 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +9
-0+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),) +# Dynamic library not required +LEVELDB_MAKE_ARGS += SHARED= +endif + +ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),) +# Static library not required +LEVELDB_MAKE_ARGS += LIBRARY= +endif
I found this a bit odd to read, maybe:
# Disable the static library for shared only build ifeq ($(BR2_SHARED_LIBS),y) LEVELDB_MAKE_ARGS += LIBRARY=
endif
# Disable the shared library for static only build ifeq ($(BR2_STATIC_LIBS),y) LEVELDB_MAKE_ARGS += SHARED=
endif
is more readable.
package/leveldb/002-facilitate-integration-into-buildroot.patch line 57
Quoted 1 line
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +1
-0+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
Not needed, just call install unconditionally. It will install the static library to $(TARGET_DIR), but that's not a problem, as it gets removed afterwards by Buildroot anyway.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v5 1/1 leveldb: new package
Quoted 4 lines · On Saturday 10 Jan 2015 10:19:50 Thomas Petazzoni wrote:
Dear Steve James,
Thanks for this new version!
--snip--
Quoted 7 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch line 7
Quoted 4 lines
package/leveldb/002-facilitate-integration-into-buildroot.patch new file +4
-0+Subject: [PATCH 1/1] facilitate integration into Buildroot: + - Add Buildroot TARGET_OS + - Allow flags from the environment + - Add install recipeThere are three different things being done, so it should be three separate patches, especially for upstream submission.
OK.
Quoted 4 lines
However, I believe adding a Buildroot
TARGET_OSis a mistake, and has no chance of being merged upstream. Buildroot is not an OS. It builds Linux based systems, so the existing TARGET_OS=Linux should work just fine for Buildroot.
Hmm. Yes TARGET_OS=Linux should be enough, but I failed to make this work with Leveldb's home-brew autoconf script. Unfortunately that was a while ago so I can't added any data here. It may just be that I was simply failing to pass the target compiler path to the configure script...
Quoted 2 lines
Quoted 2 lines
+-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
--snip--
Quoted 3 lines
Quoted 1 line
++override LIBS += $(PLATFORM_LIBS)
So this should be one patch.
OK, now submitted upstream.
Quoted 2 lines
Quoted 2 lines
+ LIBOBJECTS = $(SOURCES:.cc=.o)
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
--snip--
Quoted 2 lines
This should be another patch.
OK, now submitted upstream.
Quoted 11 lines
Quoted 9 lines
++ Buildroot)
++ PLATFORM=OS_LINUX
++ COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX
-DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT"++ PLATFORM_LDFLAGS="-pthread" ++ PLATFORM_CXXFLAGS="-std=c++0x" ++ PORT_FILE=port/port_posix.cc ++ CROSS_COMPILE=true ++ ;;This should not be needed.
The configure-style script uses the usual method of compiling test programs to detect target features and libraries. The one exception to this method is when TARGET_OS=Android. In this case the compile options are set in-line in the case statement. What I have done is re-use the Android method for Buildroot.
Note that TARGET_OS does not appear in the code: PLATFORM is set to OS_LINUX when TARGET_OS=Linux|CYGWIN_*|Buildroot and it is PLATFORM that affects the code.
So something is needed somewhere to capture the correct combination of flags for use with Buildroot. My first attempt of putting them in leveldb.mk was ugly. At least my later proposed changes for Buildroot are simple, confined to a new case statement and follow the precedent set by Android.
That said, I will try once more to make the the configure script work as intended.
Quoted 17 lines
package/leveldb/leveldb.mk line 27
Quoted 9 lines
package/leveldb/leveldb.mk new file +9
-0+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),) +# Dynamic library not required +LEVELDB_MAKE_ARGS += SHARED= +endif + +ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),) +# Static library not required +LEVELDB_MAKE_ARGS += LIBRARY= +endifI found this a bit odd to read, maybe:
# Disable the static library for shared only build ifeq ($(BR2_SHARED_LIBS),y)
LEVELDB_MAKE_ARGS+= LIBRARY=
endif
Quoted 6 lines
# Disable the shared library for static only build ifeq ($(BR2_STATIC_LIBS),y)
LEVELDB_MAKE_ARGS+= SHARED=
endifis more readable.
Agreed, that's better.
Quoted 5 lines
Quoted 1 line
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
Not needed, just call install unconditionally. It will install the static library to $(TARGET_DIR), but that's not a problem, as it gets removed afterwards by Buildroot anyway.
OK.
Thanks,
Steve.