Skip to contentSkip to conversation

leveldb: new package

PATCH New Steve James 3 participants 4 messages Jan 13, 2015 – Apr 5, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 leveldb: new package

---
Changes v5 -> v6:
- Separated & simplified upstream patches
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 +++++++++
 package/leveldb/002-add-install-recipe.patch       | 38 +++++++++++++++++++
 .../leveldb/003-allow-flags-from-environment.patch | 34 +++++++++++++++++
 package/leveldb/Config.in                          | 13 +++++++
 package/leveldb/leveldb.mk                         | 44 ++++++++++++++++++++++
 6 files changed, 147 insertions(+)
 create mode 100644 package/leveldb/001-ssize_t-undefined.patch
 create mode 100644 package/leveldb/002-add-install-recipe.patch
 create mode 100644 package/leveldb/003-allow-flags-from-environment.patch
 create mode 100644 package/leveldb/Config.in
 create mode 100644 package/leveldb/leveldb.mk
package/Config.in +1 -0
index 90d334c..e9f2255 100644
@@ -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
new file mode 100644
index 0000000..9a958d8
@@ -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-add-install-recipe.patch new file +38 -0
new file mode 100644
index 0000000..203f5bd
@@ -0,0 +1,38 @@
+From 023bb673aad6b44f889ca9d96bc2eb32e4c6d6f8 Mon Sep 17 00:00:00 2001
+From: Steve James <[email protected]>
+Date: Mon, 12 Jan 2015 13:32:24 +0000
+Subject: [PATCH 1/1] add install recipe
+
+Signed-off-by: Steve James <[email protected]>
+Upstream-Status: Submitted [https://github.com/google/leveldb/pull/276]
+---
+ Makefile | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 24f214a..8f68ca8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -229,3 +229,19 @@ else
+ .c.o:
+ 	$(CC) $(CFLAGS) -c $< -o $@
+ endif
++
++INSTALL_ROOT = /
++INSTALL_PREFIX= usr/local
++
++install: $(SHARED) $(LIBRARY)
++	install -d -m 0755 $(INSTALL_ROOT)$(INSTALL_PREFIX)/include/leveldb
++	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
+-- 
+1.9.1
+
package/leveldb/003-allow-flags-from-environment.patch new file +34 -0
new file mode 100644
index 0000000..d1914f0
@@ -0,0 +1,34 @@
+From bca474961da4f102ef1d8b817b856808c9453a9e Mon Sep 17 00:00:00 2001
+From: Steve James <[email protected]>
+Date: Mon, 12 Jan 2015 14:04:44 +0000
+Subject: [PATCH 1/1] allow flags from environment
+
+Signed-off-by: Steve James <[email protected]>
+Upstream-Status: Submitted [https://github.com/google/leveldb/pull/277]
+---
+ Makefile | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 24f214a..43ece67 100644
+--- a/Makefile
++++ b/Makefile
+@@ -20,11 +20,11 @@ $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
+ # this file is generated by the previous line to set build flags and sources
+ include build_config.mk
+ 
+-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)
+ 
+ LIBOBJECTS = $(SOURCES:.cc=.o)
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
+-- 
+1.9.1
+
package/leveldb/Config.in new file +13 -0
new file mode 100644
index 0000000..af097e5
@@ -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 +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH v6 1/1 leveldb: new package

Steve, All,

On 2015-01-13 10:53 +0000, Steve James spake thusly:

Quoted 1 line

[--SNIP--]

Quoted 31 lines
package/leveldb/002-add-install-recipe.patch new file +25 -0
new file mode 100644
index 0000000..203f5bd
@@ -0,0 +1,38 @@
+From 023bb673aad6b44f889ca9d96bc2eb32e4c6d6f8 Mon Sep 17 00:00:00 2001
+From: Steve James <[email protected]>
+Date: Mon, 12 Jan 2015 13:32:24 +0000
+Subject: [PATCH 1/1] add install recipe
+
+Signed-off-by: Steve James <[email protected]>
+Upstream-Status: Submitted [https://github.com/google/leveldb/pull/276]
+---
+ Makefile | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 24f214a..8f68ca8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -229,3 +229,19 @@ else
+ .c.o:
+ 	$(CC) $(CFLAGS) -c $< -o $@
+ endif
++
++INSTALL_ROOT = /
++INSTALL_PREFIX= usr/local
++
++install: $(SHARED) $(LIBRARY)
++	install -d -m 0755 $(INSTALL_ROOT)$(INSTALL_PREFIX)/include/leveldb

package/leveldb/002-add-install-recipe.patch line 35

Quoted 10 lines
package/leveldb/002-add-install-recipe.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

Rather than adding this in the package's Makefile, can't we just do the installation manually in the .mk file, that is, something like:

    ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
    define LEVELDB_INSTALL_STATIC
        $(INSTALL) -D -m 0644 $(@D)/lib/libleveldb.a $(1)/usr/lib/libleveldb.a
    endef
    endif
    ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
    define LEVELDB_INSTALL_SHARED
        $(INSTALL) -D -m 0644 $(@D)/lib/libleveldb.so $(1)/usr/lib/libleveldb.so
        ln -sf libleveldb.so $(1)/usr/lib/libleveldb.so.VERSION
    endef
    endif

    define LEVELDB_INSTALL_STAGING_CMDS
        $(call LEVELDB_INSTALL_STATIC,$(STAGING_DIR))
        $(call LEVELDB_INSTALL_SHARED,$(STAGING_DIR))
        install -D -m 0644 $(@D)/leveldb.h $(STAGING_DIR)/usr/include/leveldb.h
    endef

    define LEVELDB_INSTALL_TARGET_CMDS
        $(call LEVELDB_INSTALL_SHARED,$(STAGING_DIR))
    endef

(to be adapted to the real file names, of course))

Quoted 27 lines
package/leveldb/003-allow-flags-from-environment.patch new file +21 -0
new file mode 100644
index 0000000..d1914f0
@@ -0,0 +1,34 @@
+From bca474961da4f102ef1d8b817b856808c9453a9e Mon Sep 17 00:00:00 2001
+From: Steve James <[email protected]>
+Date: Mon, 12 Jan 2015 14:04:44 +0000
+Subject: [PATCH 1/1] allow flags from environment
+
+Signed-off-by: Steve James <[email protected]>
+Upstream-Status: Submitted [https://github.com/google/leveldb/pull/277]
+---
+ Makefile | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 24f214a..43ece67 100644
+--- a/Makefile
++++ b/Makefile
+@@ -20,11 +20,11 @@ $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
+ # this file is generated by the previous line to set build flags and sources
+ include build_config.mk
+ 
+-CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
+-CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)

package/leveldb/003-allow-flags-from-environment.patch line 31

Quoted 10 lines
package/leveldb/003-allow-flags-from-environment.patch new file +10 -0
++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)
+ 
+ LIBOBJECTS = $(SOURCES:.cc=.o)
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)

I think this would not be needed if you do:

    define LEVELDB_BUILD_CMDS
        $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
            $(LEVELDB_MAKE_ARGS) -C $(@D)
    endef

i.e. pass the TARGET_CONFIGURE_OPTS in the environment, and not as make arguments.

To be tested and confirmed, of course.

Quoted 21 lines
package/leveldb/leveldb.mk new file +15 -0
new file mode 100644
index 0000000..3c03515
@@ -0,0 +1,44 @@
+################################################################################
+#
+# leveldb
+#
+################################################################################
+
+LEVELDB_VERSION = 803d69203a62faf50f1b77897310a3a1fcae712b
+LEVELDB_SITE = $(call github,google,leveldb,$(LEVELDB_VERSION))
+LEVELDB_LICENSE = BSD-3c
+LEVELDB_LICENSE_FILES = LICENSE
+LEVELDB_INSTALL_STAGING = YES
+LEVELDB_DEPENDENCIES = snappy
+
+# We will pass optimisation level via CFLAGS so remove leveldb default
+LEVELDB_MAKE_ARGS += OPTIM=

package/leveldb/leveldb.mk line 25

Quoted 10 lines
package/leveldb/leveldb.mk new file +10 -0
+
+# 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

I would prefer we actually we use direct logic, like:

    ifeq ($(BR2_STATIC_LIBS),)
    LEVELDB_MAKE_ARGS += SHARED=
    endif

    ifeq ($(BR2_SHARED_LIBS),)
    LEVELDB_MAKE_ARGS += LIBRARY=
    endif

package/leveldb/leveldb.mk line 30

Quoted 4 lines
package/leveldb/leveldb.mk new file +4 -0
+define LEVELDB_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		$(LEVELDB_MAKE_ARGS) -C $(@D)
+endef

Here switch the order of TARGET_CONFIGURE_OPTS, like explained above.

package/leveldb/leveldb.mk line 42

Quoted 11 lines
package/leveldb/leveldb.mk new file +11 -0
+define LEVELDB_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		INSTALL_ROOT=$(STAGING_DIR) INSTALL_PREFIX=/usr \
+		$(LEVELDB_MAKE_ARGS) -C $(@D) install
+endef
+
+define LEVELDB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		INSTALL_ROOT=$(TARGET_DIR) INSTALL_PREFIX=/usr \
+		$(LEVELDB_MAKE_ARGS) -C $(@D) install
+endef

And adapt the install commands as explained above.

Regards,
Yann E. MORIN.

Quoted 8 lines
package/leveldb/leveldb.mk new file +1 -0
+$(eval $(generic-package))
Signature · 6 lines
1.9.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v6 1/1 leveldb: new package

Dear Yann E. MORIN,

Quoted 16 lines · Yann E. MORIN

Rather than adding this in the package's Makefile, can't we just do the installation manually in the .mk file, that is, something like:

    ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
    define LEVELDB_INSTALL_STATIC
        $(INSTALL) -D -m 0644 $(@D)/lib/libleveldb.a $(1)/usr/lib/libleveldb.a
    endef
    endif
    ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
    define LEVELDB_INSTALL_SHARED
        $(INSTALL) -D -m 0644 $(@D)/lib/libleveldb.so $(1)/usr/lib/libleveldb.so
        ln -sf libleveldb.so $(1)/usr/lib/libleveldb.so.VERSION
    endef
    endif

    define LEVELDB_INSTALL_STAGING_CMDS
Quoted 8 lines
        $(call LEVELDB_INSTALL_STATIC,$(STAGING_DIR))
        $(call LEVELDB_INSTALL_SHARED,$(STAGING_DIR))
        install -D -m 0644 $(@D)/leveldb.h $(STAGING_DIR)/usr/include/leveldb.h
    endef

    define LEVELDB_INSTALL_TARGET_CMDS
        $(call LEVELDB_INSTALL_SHARED,$(STAGING_DIR))
    endef

Well, I actually asked Steve to write patches that can be submitted upstream (leveldb upstream is active) rather than solving all problems in the Buildroot .mk file.

Quoted 15 lines
Quoted 7 lines
+-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)
Quoted 5 lines

++override LDFLAGS += $(PLATFORM_LDFLAGS)
++override LIBS += $(PLATFORM_LIBS)
+
+ LIBOBJECTS = $(SOURCES:.cc=.o)
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)

I think this would not be needed if you do:

Quoted 7 lines
    define LEVELDB_BUILD_CMDS
        $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
            $(LEVELDB_MAKE_ARGS) -C $(@D)
    endef

i.e. pass the TARGET_CONFIGURE_OPTS in the environment, and not as make arguments.

Aaah, yes, indeed. When passed in the environment, a normal += work, and you don't need the override.

Quoted 12 lines

package/leveldb/leveldb.mk line 25

Quoted 9 lines
package/leveldb/leveldb.mk new file +9 -0
+# 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

I would prefer we actually we use direct logic, like:

Quoted 7 lines
    ifeq ($(BR2_STATIC_LIBS),)
    LEVELDB_MAKE_ARGS += SHARED=
    endif

    ifeq ($(BR2_SHARED_LIBS),)
    LEVELDB_MAKE_ARGS += LIBRARY=
    endif

Well I actually asked for the opposite, in order to use positive logic, i.e test BR2_SHARED_LIBS==y.

Quoted 7 lines

package/leveldb/leveldb.mk line 42

Quoted 5 lines
package/leveldb/leveldb.mk new file +5 -0
+define LEVELDB_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		INSTALL_ROOT=$(TARGET_DIR) INSTALL_PREFIX=/usr \
+		$(LEVELDB_MAKE_ARGS) -C $(@D) install
+endef

And adapt the install commands as explained above.

Or not, depending on whether we want the patch to be upstreamed.

Thomas

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

PATCH v6 1/1 leveldb: new package

In reply to Steve James

Dear Steve James,

Quoted 1 line · Steve James

Applied, thanks, after doing some small changes:

[Thomas:
- remove 003-allow-flags-from-environment.patch, and pass TARGET_CONFIGURE_OPTS in the environment instead.
- convert the patches to Git formatted patches.
- use the v1.18 tag instead of a commit hash.
- do not pass TARGET_CONFIGURE_OPTS at install time, this is not needed.]

Thomas

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