From 77d8beacc8e6745787ad2b1fbc2fc6320bdc6b19 Mon Sep 17 00:00:00 2001 From: Isaac Garzon Date: Thu, 25 Aug 2022 18:41:02 +0300 Subject: [PATCH] build: clean up the build configuration to allow rebranding (#64) This updates the CMake and Makefile configuration and related scripts to use variables where possible and avoid explicit references to RocksDB in order to allow rebranding of the output artefacts. --- CMakeLists.txt | 16 +-- Makefile | 179 +++++++++++++++--------------- build_tools/build_detect_platform | 35 ++---- examples/Makefile | 45 ++++---- fuzz/Makefile | 4 +- java/CMakeLists.txt | 20 ++-- java/Makefile | 34 +++--- java/pom.xml.template | 11 +- 8 files changed, 165 insertions(+), 179 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0f2d576a..079731546d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -494,7 +494,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp") endif() -option(ROCKSDB_LITE "Build RocksDBLite version" OFF) +option(ROCKSDB_LITE "Build LITE version" OFF) if(ROCKSDB_LITE) add_definitions(-DROCKSDB_LITE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -Os") @@ -1110,8 +1110,10 @@ if(USE_FOLLY_LITE) list(APPEND THIRDPARTY_LIBS glog) endif() -set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX}) -set(ROCKSDB_SHARED_LIB rocksdb-shared${ARTIFACT_SUFFIX}) +set(ROCKSDB_STATIC_LIB ${PROJECT_NAME}${ARTIFACT_SUFFIX}) +set(ROCKSDB_SHARED_LIB ${PROJECT_NAME}-shared${ARTIFACT_SUFFIX}) + +option(ROCKSDB_BUILD_SHARED "Build shared versions of the libraries" ON) if(WIN32) @@ -1165,9 +1167,9 @@ if(ROCKSDB_BUILD_SHARED) else() set_target_properties(${ROCKSDB_SHARED_LIB} PROPERTIES LINKER_LANGUAGE CXX - VERSION ${rocksdb_VERSION} + VERSION ${PROJECT_VERSION} SOVERSION ${rocksdb_VERSION_MAJOR} - OUTPUT_NAME "rocksdb${ARTIFACT_SUFFIX}") + OUTPUT_NAME "${PROJECT_NAME}${ARTIFACT_SUFFIX}") endif() endif() @@ -1210,7 +1212,7 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) include(GNUInstallDirs) include(CMakePackageConfigHelpers) - set(package_config_destination ${CMAKE_INSTALL_LIBDIR}/cmake/rocksdb) + set(package_config_destination ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) configure_package_config_file( ${CMAKE_CURRENT_LIST_DIR}/cmake/RocksDBConfig.cmake.in RocksDBConfig.cmake @@ -1219,7 +1221,7 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) write_basic_package_version_file( RocksDBConfigVersion.cmake - VERSION ${rocksdb_VERSION} + VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) diff --git a/Makefile b/Makefile index 9d875b7d65..6f9bdfc5c8 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ SHELL := $(shell command -v bash || echo $(SHELL)) include common.mk +PROJECT_NAME := rocksdb + CLEAN_FILES = # deliberately empty, so we can append below. CFLAGS += ${EXTRA_CFLAGS} CXXFLAGS += ${EXTRA_CXXFLAGS} @@ -233,6 +235,15 @@ am__v_AR_1 = AM_LINK = $(AM_V_CCLD)$(CXX) -L. $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) AM_SHARE = $(AM_V_CCLD) $(CXX) $(PLATFORM_SHARED_LDFLAGS)$@ -L. $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^) $(EXEC_LDFLAGS) $(LDFLAGS) -o $@ +# if user didn't config LIBNAME, set the default +ifeq ($(LIBNAME),) + export LIBNAME=lib$(PROJECT_NAME) +# we should only run Rocksdb in production with DEBUG_LEVEL 0 +ifneq ($(DEBUG_LEVEL),0) + LIBDEBUG=_debug +endif + +endif # Only regenerate make_config.mk if it doesn't exists or if we're invoked in a mode # that executes target recipes (i.e. not -n or -q) ifeq ($(and $(or $(findstring n,$(MAKEFLAGS)),$(findstring q,$(MAKEFLAGS))),$(wildcard make_config.mk)),) @@ -252,8 +263,7 @@ ifneq ($(strip $(and $(wildcard make_config.mk),$(filter-out $(NO_CONFIG_REGENER # Export some common variables that might have been passed as Make variables # instead of environment variables. $(info * GEN make_config.mk) -dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \ - export CXXFLAGS="$(EXTRA_CXXFLAGS)"; \ +dummy := $(shell (export CXXFLAGS="$(EXTRA_CXXFLAGS)"; \ export LDFLAGS="$(EXTRA_LDFLAGS)"; \ export COMPILE_WITH_ASAN="$(COMPILE_WITH_ASAN)"; \ export COMPILE_WITH_TSAN="$(COMPILE_WITH_TSAN)"; \ @@ -261,6 +271,7 @@ dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \ export PORTABLE="$(PORTABLE)"; \ export ROCKSDB_NO_FBCODE="$(ROCKSDB_NO_FBCODE)"; \ export USE_CLANG="$(USE_CLANG)"; \ + export LIBNAME="$(LIBNAME)"; \ export LIB_MODE="$(LIB_MODE)"; \ export ROCKSDB_CXX_STANDARD="$(ROCKSDB_CXX_STANDARD)"; \ export USE_FOLLY="$(USE_FOLLY)"; \ @@ -324,7 +335,7 @@ endif endif export JAVAC_ARGS -CLEAN_FILES += make_config.mk test_config.mk rocksdb.pc +CLEAN_FILES += make_config.mk test_config.mk $(PROJECT_NAME).pc ifeq ($(V), 1) $(info $(shell uname -a)) @@ -782,21 +793,13 @@ endif TOOLS = $(patsubst %.cc, %, $(notdir $(patsubst %_tool.cc, %.cc, $(TOOLS_MAIN_SOURCES)))) TEST_LIBS = \ - librocksdb_env_basic_test.a + lib$(PROJECT_NAME)_env_basic_test.a # TODO: add back forward_iterator_bench, after making it build in all environemnts. BENCHMARKS = $(patsubst %.cc, %, $(notdir $(BENCH_MAIN_SOURCES))) MICROBENCHS = $(patsubst %.cc, %, $(notdir $(MICROBENCH_SOURCES))) -# if user didn't config LIBNAME, set the default -ifeq ($(LIBNAME),) - LIBNAME=librocksdb -# we should only run rocksdb in production with DEBUG_LEVEL 0 -ifneq ($(DEBUG_LEVEL),0) - LIBDEBUG=_debug -endif -endif STATIC_LIBRARY = ${LIBNAME}$(LIBDEBUG).a STATIC_TEST_LIBRARY = ${LIBNAME}_test$(LIBDEBUG).a STATIC_TOOLS_LIBRARY = ${LIBNAME}_tools$(LIBDEBUG).a @@ -868,9 +871,9 @@ SHARED3 = $(SHARED1) SHARED4 = $(SHARED1) SHARED = $(SHARED1) else -SHARED_MAJOR = $(ROCKSDB_MAJOR) -SHARED_MINOR = $(ROCKSDB_MINOR) -SHARED_PATCH = $(ROCKSDB_PATCH) +SHARED_MAJOR = $(VERSION_MAJOR) +SHARED_MINOR = $(VERSION_MINOR) +SHARED_PATCH = $(VERSION_PATCH) SHARED1 = ${LIBNAME}.$(PLATFORM_SHARED_EXT) ifeq ($(PLATFORM), OS_MACOSX) SHARED_OSX = $(LIBNAME)$(LIBDEBUG).$(SHARED_MAJOR) @@ -1239,8 +1242,8 @@ unity_test: $(OBJ_DIR)/db/db_basic_test.o $(OBJ_DIR)/db/db_test_util.o $(TEST_OB $(AM_LINK) ./unity_test -rocksdb.h rocksdb.cc: build_tools/amalgamate.py Makefile $(LIB_SOURCES) unity.cc - build_tools/amalgamate.py -I. -i./include unity.cc -x include/rocksdb/c.h -H rocksdb.h -o rocksdb.cc +$(PROJECT_NAME).h $(PROJECT_NAME).cc: build_tools/amalgamate.py Makefile $(LIB_SOURCES) unity.cc + build_tools/amalgamate.py -I. -i./include unity.cc -x include/rocksdb/c.h -H $(PROJECT_NAME).h -o $(PROJECT_NAME).cc clean: clean-ext-libraries-all clean-rocks clean-rocksjava @@ -1292,7 +1295,7 @@ check-sources: build_tools/check-sources.sh package: - bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR) + bash build_tools/make_package.sh $(VERSION_MAJOR).$(VERSION_MINOR) # --------------------------------------------------------------------------- # Unit tests and tools @@ -1325,7 +1328,7 @@ $(SHARED_STRESS_LIBRARY): $(ANALYZE_OBJECTS) $(STRESS_OBJECTS) $(TESTUTIL) $(SHA $(AM_V_AR)rm -f $@ $(STATIC_STRESS_LIBRARY) $(AM_SHARE) -librocksdb_env_basic_test.a: $(OBJ_DIR)/env/env_basic_test.o $(LIB_OBJECTS) $(TESTHARNESS) +lib$(PROJECT_NAME)_env_basic_test.a: $(OBJ_DIR)/env/env_basic_test.o $(LIB_OBJECTS) $(TESTHARNESS) $(AM_V_AR)rm -f $@ $(AM_V_at)$(AR) $(ARFLAGS) $@ $^ @@ -2016,7 +2019,7 @@ uninstall: $(INSTALL_LIBDIR)/$(SHARED3) \ $(INSTALL_LIBDIR)/$(SHARED2) \ $(INSTALL_LIBDIR)/$(SHARED1) \ - $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc + $(INSTALL_LIBDIR)/pkgconfig/$(PROJECT_NAME).pc install-headers: gen-pc install -d $(INSTALL_LIBDIR) @@ -2031,7 +2034,7 @@ install-headers: gen-pc install -d $(DESTDIR)/$(PREFIX)/include/rocksdb/`dirname $$header`; \ install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/include/rocksdb/$$header; \ done - install -C -m 644 rocksdb.pc $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc + install -C -m 644 $(PROJECT_NAME).pc $(INSTALL_LIBDIR)/pkgconfig/$(PROJECT_NAME).pc install-static: install-headers $(LIBRARY) install -d $(INSTALL_LIBDIR) @@ -2056,13 +2059,13 @@ gen-pc: 'includedir=$${prefix}/include' \ 'libdir=$(LIBDIR)' \ '' \ - 'Name: rocksdb' \ + 'Name: $(PROJECT_NAME)' \ 'Description: An embeddable persistent key-value store for fast storage' \ 'Version: $(shell ./build_tools/version.sh full)' \ 'Libs: -L$${libdir} $(EXEC_LDFLAGS) -lrocksdb' \ 'Libs.private: $(PLATFORM_LDFLAGS)' \ 'Cflags: -I$${includedir} $(PLATFORM_CXXFLAGS)' \ - 'Requires: $(subst ",,$(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES))' > rocksdb.pc + 'Requires: $(subst ",,$(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES))' > $(PROJECT_NAME).pc #------------------------------------------------- @@ -2094,18 +2097,18 @@ ifneq ($(origin JNI_LIBC), undefined) JNI_LIBC_POSTFIX = -$(JNI_LIBC) endif -ifeq (,$(ROCKSDBJNILIB)) +ifeq (,$(JNILIBNAME)) ifneq (,$(filter ppc% s390x arm64 aarch64 sparc64, $(MACHINE))) - ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE)$(JNI_LIBC_POSTFIX).so + JNILIBNAME = lib$(PROJECT_NAME)jni-linux-$(MACHINE)$(JNI_LIBC_POSTFIX).so else - ROCKSDBJNILIB = librocksdbjni-linux$(ARCH)$(JNI_LIBC_POSTFIX).so + JNILIBNAME = lib$(PROJECT_NAME)jni-linux$(ARCH)$(JNI_LIBC_POSTFIX).so endif endif -ROCKSDB_JAVA_VERSION ?= $(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH) -ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux$(ARCH)$(JNI_LIBC_POSTFIX).jar -ROCKSDB_JAR_ALL = rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar -ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-javadoc.jar -ROCKSDB_SOURCES_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-sources.jar +LIB_JAVA_VERSION ?= $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) +LIB_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-linux$(ARCH)$(JNI_LIBC_POSTFIX).jar +LIB_JAR_ALL = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar +LIB_JAVADOCS_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-javadoc.jar +LIB_SOURCES_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-sources.jar SHA256_CMD = sha256sum ZLIB_VER ?= 1.2.12 @@ -2126,16 +2129,16 @@ ZSTD_DOWNLOAD_BASE ?= https://github.com/facebook/zstd/archive CURL_SSL_OPTS ?= --tlsv1 ifeq ($(PLATFORM), OS_MACOSX) -ifeq (,$(findstring librocksdbjni-osx,$(ROCKSDBJNILIB))) +ifeq (,$(findstring lib$(PROJECT_NAME)jni-osx,$(JNILIBNAME))) ifeq ($(MACHINE),arm64) - ROCKSDBJNILIB = librocksdbjni-osx-arm64.jnilib + JNILIBNAME = lib$(PROJECT_NAME)jni-osx-arm64.jnilib else ifeq ($(MACHINE),x86_64) - ROCKSDBJNILIB = librocksdbjni-osx-x86_64.jnilib + JNILIBNAME = lib$(PROJECT_NAME)jni-osx-x86_64.jnilib else - ROCKSDBJNILIB = librocksdbjni-osx.jnilib + JNILIBNAME = lib$(PROJECT_NAME)jni-osx.jnilib endif endif - ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-osx.jar + LIB_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-osx.jar SHA256_CMD = openssl sha256 -r ifneq ("$(wildcard $(JAVA_HOME)/include/darwin)","") JAVA_INCLUDE = -I$(JAVA_HOME)/include -I $(JAVA_HOME)/include/darwin @@ -2146,25 +2149,25 @@ endif ifeq ($(PLATFORM), OS_FREEBSD) JAVA_INCLUDE = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/freebsd - ROCKSDBJNILIB = librocksdbjni-freebsd$(ARCH).so - ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-freebsd$(ARCH).jar + JNILIBNAME = lib$(PROJECT_NAME)jni-freebsd$(ARCH).so + LIB_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-freebsd$(ARCH).jar endif ifeq ($(PLATFORM), OS_SOLARIS) - ROCKSDBJNILIB = librocksdbjni-solaris$(ARCH).so - ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-solaris$(ARCH).jar + JNILIBNAME = lib$(PROJECT_NAME)jni-solaris$(ARCH).so + LIB_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-solaris$(ARCH).jar JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/solaris SHA256_CMD = digest -a sha256 endif ifeq ($(PLATFORM), OS_AIX) JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/aix - ROCKSDBJNILIB = librocksdbjni-aix.so + JNILIBNAME = lib$(PROJECT_NAME)jni-aix.so EXTRACT_SOURCES = gunzip < TAR_GZ | tar xvf - SNAPPY_MAKE_TARGET = libsnappy.la endif ifeq ($(PLATFORM), OS_OPENBSD) JAVA_INCLUDE = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/openbsd - ROCKSDBJNILIB = librocksdbjni-openbsd$(ARCH).so - ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-openbsd$(ARCH).jar + JNILIBNAME = lib$(PROJECT_NAME)jni-openbsd$(ARCH).so + LIB_JAR = $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-openbsd$(ARCH).jar endif export SHA256_CMD @@ -2265,17 +2268,17 @@ endif $(MAKE) rocksdbjava_jar rocksdbjavastaticosx: rocksdbjavastaticosx_archs - cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR) HISTORY*.md - cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR) librocksdbjni-osx-x86_64.jnilib librocksdbjni-osx-arm64.jnilib - cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class - openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1 + cd java; $(JAR_CMD) -cf target/$(LIB_JAR) HISTORY*.md + cd java/target; $(JAR_CMD) -uf $(LIB_JAR) lib$(PROJECT_NAME)jni-osx-x86_64.jnilib lib$(PROJECT_NAME)jni-osx-arm64.jnilib + cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class + openssl sha1 java/target/$(LIB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR).sha1 rocksdbjavastaticosx_ub: rocksdbjavastaticosx_archs - cd java/target; lipo -create -output librocksdbjni-osx.jnilib librocksdbjni-osx-x86_64.jnilib librocksdbjni-osx-arm64.jnilib - cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR) HISTORY*.md - cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR) librocksdbjni-osx.jnilib - cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class - openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1 + cd java/target; lipo -create -output lib$(PROJECT_NAME)jni-osx.jnilib lib$(PROJECT_NAME)jni-osx-x86_64.jnilib lib$(PROJECT_NAME)jni-osx-arm64.jnilib + cd java; $(JAR_CMD) -cf target/$(LIB_JAR) HISTORY*.md + cd java/target; $(JAR_CMD) -uf $(LIB_JAR) lib$(PROJECT_NAME)jni-osx.jnilib + cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class + openssl sha1 java/target/$(LIB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR).sha1 rocksdbjavastaticosx_archs: $(MAKE) rocksdbjavastaticosx_arch_x86_64 @@ -2289,7 +2292,7 @@ endif $(MAKE) clean-rocks ARCHFLAG="-arch $*" $(MAKE) rocksdbjavastatic_deps ARCHFLAG="-arch $*" $(MAKE) rocksdbjavastatic_libobjects - ARCHFLAG="-arch $*" ROCKSDBJNILIB="librocksdbjni-osx-$*.jnilib" $(MAKE) rocksdbjavastatic_javalib + ARCHFLAG="-arch $*" JNILIBNAME="lib$(PROJECT_NAME)jni-osx-$*.jnilib" $(MAKE) rocksdbjavastatic_javalib ifeq ($(JAR_CMD),) ifneq ($(JAVA_HOME),) @@ -2300,28 +2303,28 @@ endif endif rocksdbjavastatic_javalib: cd java; $(MAKE) javalib - rm -f java/target/$(ROCKSDBJNILIB) + rm -f java/target/$(JNILIBNAME) $(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \ - -o ./java/target/$(ROCKSDBJNILIB) $(ALL_JNI_NATIVE_SOURCES) \ + -o ./java/target/$(JNILIBNAME) $(ALL_JNI_NATIVE_SOURCES) \ $(LIB_OBJECTS) $(COVERAGEFLAGS) \ $(JAVA_COMPRESSIONS) $(JAVA_STATIC_LDFLAGS) cd java/target;if [ "$(DEBUG_LEVEL)" == "0" ]; then \ - strip $(STRIPFLAGS) $(ROCKSDBJNILIB); \ + strip $(STRIPFLAGS) $(JNILIBNAME); \ fi rocksdbjava_jar: - cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR) HISTORY*.md - cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB) - cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class - openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1 + cd java; $(JAR_CMD) -cf target/$(LIB_JAR) HISTORY*.md + cd java/target; $(JAR_CMD) -uf $(LIB_JAR) $(JNILIBNAME) + cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class + openssl sha1 java/target/$(LIB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR).sha1 rocksdbjava_javadocs_jar: - cd java/target/apidocs; $(JAR_CMD) -cf ../$(ROCKSDB_JAVADOCS_JAR) * - openssl sha1 java/target/$(ROCKSDB_JAVADOCS_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAVADOCS_JAR).sha1 + cd java/target/apidocs; $(JAR_CMD) -cf ../$(LIB_JAVADOCS_JAR) * + openssl sha1 java/target/$(LIB_JAVADOCS_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAVADOCS_JAR).sha1 rocksdbjava_sources_jar: - cd java/src/main/java; $(JAR_CMD) -cf ../../../target/$(ROCKSDB_SOURCES_JAR) org - openssl sha1 java/target/$(ROCKSDB_SOURCES_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_SOURCES_JAR).sha1 + cd java/src/main/java; $(JAR_CMD) -cf ../../../target/$(LIB_SOURCES_JAR) org + openssl sha1 java/target/$(LIB_SOURCES_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_SOURCES_JAR).sha1 rocksdbjavastatic_deps: $(JAVA_COMPRESSIONS) @@ -2329,16 +2332,16 @@ rocksdbjavastatic_libobjects: $(LIB_OBJECTS) rocksdbjavastaticrelease: rocksdbjavastaticosx rocksdbjava_javadocs_jar rocksdbjava_sources_jar cd java/crossbuild && (vagrant destroy -f || true) && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64 && vagrant up linux64-musl && vagrant halt linux64-musl - cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md - cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib - cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class - openssl sha1 java/target/$(ROCKSDB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR_ALL).sha1 + cd java; $(JAR_CMD) -cf target/$(LIB_JAR_ALL) HISTORY*.md + cd java/target; $(JAR_CMD) -uf $(LIB_JAR_ALL) lib$(PROJECT_NAME)jni-*.so lib$(PROJECT_NAME)jni-*.jnilib + cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class + openssl sha1 java/target/$(LIB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR_ALL).sha1 rocksdbjavastaticreleasedocker: rocksdbjavastaticosx rocksdbjavastaticdockerx86 rocksdbjavastaticdockerx86_64 rocksdbjavastaticdockerx86musl rocksdbjavastaticdockerx86_64musl rocksdbjava_javadocs_jar rocksdbjava_sources_jar - cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md - cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib - cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class - openssl sha1 java/target/$(ROCKSDB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR_ALL).sha1 + cd java; $(JAR_CMD) -cf target/$(LIB_JAR_ALL) HISTORY*.md + cd java/target; $(JAR_CMD) -uf $(LIB_JAR_ALL) lib$(PROJECT_NAME)jni-*.so lib$(PROJECT_NAME)jni-*.jnilib + cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class + openssl sha1 java/target/$(LIB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR_ALL).sha1 rocksdbjavastaticdockerx86: mkdir -p java/target @@ -2384,24 +2387,24 @@ rocksdbjavastaticpublish: rocksdbjavastaticrelease rocksdbjavastaticpublishcentr rocksdbjavastaticpublishdocker: rocksdbjavastaticreleasedocker rocksdbjavastaticpublishcentral -ROCKSDB_JAVA_RELEASE_CLASSIFIERS = javadoc sources linux64 linux32 linux64-musl linux32-musl osx win64 +LIB_JAVA_RELEASE_CLASSIFIERS = javadoc sources linux64 linux32 linux64-musl linux32-musl osx win64 rocksdbjavastaticpublishcentral: rocksdbjavageneratepom - mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar - $(foreach classifier, $(ROCKSDB_JAVA_RELEASE_CLASSIFIERS), mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar -Dclassifier=$(classifier);) + mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(LIB_JAVA_VERSION).jar + $(foreach classifier, $(LIB_JAVA_RELEASE_CLASSIFIERS), mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar -Dclassifier=$(classifier);) rocksdbjavageneratepom: - cd java;cat pom.xml.template | sed 's/\$${ROCKSDB_JAVA_VERSION}/$(ROCKSDB_JAVA_VERSION)/' > pom.xml + cd java;cat pom.xml.template | sed 's/\$${LIB_JAVA_VERSION}/$(LIB_JAVA_VERSION)/' > pom.xml rocksdbjavastaticnexusbundlejar: rocksdbjavageneratepom openssl sha1 -r java/pom.xml | awk '{ print $$1 }' > java/target/pom.xml.sha1 - openssl sha1 -r java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar | awk '{ print $$1 }' > java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar.sha1 - $(foreach classifier, $(ROCKSDB_JAVA_RELEASE_CLASSIFIERS), openssl sha1 -r java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar | awk '{ print $$1 }' > java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar.sha1;) + openssl sha1 -r java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar | awk '{ print $$1 }' > java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar.sha1 + $(foreach classifier, $(LIB_JAVA_RELEASE_CLASSIFIERS), openssl sha1 -r java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar | awk '{ print $$1 }' > java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar.sha1;) gpg --yes --output java/target/pom.xml.asc -ab java/pom.xml - gpg --yes -ab java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar - $(foreach classifier, $(ROCKSDB_JAVA_RELEASE_CLASSIFIERS), gpg --yes -ab java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar;) - $(JAR_CMD) cvf java/target/nexus-bundle-rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar -C java pom.xml -C java/target pom.xml.sha1 -C java/target pom.xml.asc -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar.sha1 -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar.asc - $(foreach classifier, $(ROCKSDB_JAVA_RELEASE_CLASSIFIERS), $(JAR_CMD) uf java/target/nexus-bundle-rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar.sha1 -C java/target rocksdbjni-$(ROCKSDB_JAVA_VERSION)-$(classifier).jar.asc;) + gpg --yes -ab java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar + $(foreach classifier, $(LIB_JAVA_RELEASE_CLASSIFIERS), gpg --yes -ab java/target/$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar;) + $(JAR_CMD) cvf java/target/nexus-bundle-$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar -C java pom.xml -C java/target pom.xml.sha1 -C java/target pom.xml.asc -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar.sha1 -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar.asc + $(foreach classifier, $(LIB_JAVA_RELEASE_CLASSIFIERS), $(JAR_CMD) uf java/target/nexus-bundle-$(PROJECT_NAME)jni-$(LIB_JAVA_VERSION).jar -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar.sha1 -C java/target $(PROJECT_NAME)jni-$(LIB_JAVA_VERSION)-$(classifier).jar.asc;) # A version of each $(LIBOBJECTS) compiled with -fPIC @@ -2414,12 +2417,12 @@ ifeq ($(JAVA_HOME),) $(error JAVA_HOME is not set) endif $(AM_V_GEN)cd java; $(MAKE) javalib; - $(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB) - $(AM_V_at)$(CXX) $(CXXFLAGS) -I./java/. -I./java/rocksjni $(JAVA_INCLUDE) $(ROCKSDB_PLUGIN_JNI_CXX_INCLUDEFLAGS) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(ALL_JNI_NATIVE_SOURCES) $(LIB_OBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS) - $(AM_V_at)cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR) HISTORY*.md - $(AM_V_at)cd java/target; $(JAR_CMD) -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB) - $(AM_V_at)cd java/target/classes; $(JAR_CMD) -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class - $(AM_V_at)openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1 + $(AM_V_at)rm -f ./java/target/$(JNILIBNAME) + $(AM_V_at)$(CXX) $(CXXFLAGS) -I./java/. -I./java/rocksjni $(JAVA_INCLUDE) $(ROCKSDB_PLUGIN_JNI_CXX_INCLUDEFLAGS) -shared -fPIC -o ./java/target/$(JNILIBNAME) $(ALL_JNI_NATIVE_SOURCES) $(LIB_OBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS) + $(AM_V_at)cd java; $(JAR_CMD) -cf target/$(LIB_JAR) HISTORY*.md + $(AM_V_at)cd java/target; $(JAR_CMD) -uf $(LIB_JAR) $(JNILIBNAME) + $(AM_V_at)cd java/target/classes; $(JAR_CMD) -uf ../$(LIB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class + $(AM_V_at)openssl sha1 java/target/$(LIB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(LIB_JAR).sha1 jclean: cd java;$(MAKE) clean; diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index d47068c43f..9a5abab085 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -136,9 +136,6 @@ PLATFORM_SHARED_LDFLAGS="-Wl,--no-as-needed -shared -Wl,-soname -Wl," PLATFORM_SHARED_CFLAGS="-fPIC" PLATFORM_SHARED_VERSIONED=true -# generic port files (working on all platform by #ifdef) go directly in /port -GENERIC_PORT_FILES=`cd "$ROCKSDB_ROOT"; find port -name '*.cc' | tr "\n" " "` - # On GCC, we pick libc's memcmp over GCC's memcmp via -fno-builtin-memcmp case "$TARGET_OS" in Darwin) @@ -146,7 +143,6 @@ case "$TARGET_OS" in COMMON_FLAGS="$COMMON_FLAGS -DOS_MACOSX" PLATFORM_SHARED_EXT=dylib PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name " - # PORT_FILES=port/darwin/darwin_specific.cc ;; IOS) PLATFORM=IOS @@ -183,27 +179,23 @@ EOF COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_IOURING_PRESENT" fi fi - # PORT_FILES=port/linux/linux_specific.cc ;; SunOS) PLATFORM=OS_SOLARIS COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_SOLARIS -m64" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt -static-libstdc++ -static-libgcc -m64" - # PORT_FILES=port/sunos/sunos_specific.cc ;; AIX) PLATFORM=OS_AIX CC=gcc COMMON_FLAGS="$COMMON_FLAGS -maix64 -pthread -fno-builtin-memcmp -D_REENTRANT -DOS_AIX -D__STDC_FORMAT_MACROS" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -pthread -lpthread -lrt -maix64 -static-libstdc++ -static-libgcc" - # PORT_FILES=port/aix/aix_specific.cc ;; FreeBSD) PLATFORM=OS_FREEBSD CXX=clang++ COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_FREEBSD" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread" - # PORT_FILES=port/freebsd/freebsd_specific.cc ;; GNU/kFreeBSD) PLATFORM=OS_GNU_KFREEBSD @@ -214,28 +206,24 @@ EOF PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic" fi PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt" - # PORT_FILES=port/gnu_kfreebsd/gnu_kfreebsd_specific.cc ;; NetBSD) PLATFORM=OS_NETBSD COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lgcc_s" - # PORT_FILES=port/netbsd/netbsd_specific.cc ;; OpenBSD) PLATFORM=OS_OPENBSD CXX=clang++ COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_OPENBSD" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -pthread" - # PORT_FILES=port/openbsd/openbsd_specific.cc - FIND=gfind - WATCH=gnuwatch + FIND=gfind + WATCH=gnuwatch ;; DragonFly) PLATFORM=OS_DRAGONFLYBSD COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_DRAGONFLYBSD" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread" - # PORT_FILES=port/dragonfly/dragonfly_specific.cc ;; Cygwin) PLATFORM=CYGWIN @@ -248,13 +236,11 @@ EOF PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic" fi PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt" - # PORT_FILES=port/linux/linux_specific.cc ;; OS_ANDROID_CROSSCOMPILE) PLATFORM=OS_ANDROID - COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_ANDROID -DROCKSDB_PLATFORM_POSIX" - PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS " # All pthread features are in the Android C library - # PORT_FILES=port/android/android.cc + COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_ANDROID -DROCKSDB_PLATFORM_POSIX" + PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS " # All pthread features are in the Android C library CROSS_COMPILE=true ;; *) @@ -845,9 +831,9 @@ fi PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS" PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS $COMMON_FLAGS" -ROCKSDB_MAJOR="$(build_tools/version.sh major)" -ROCKSDB_MINOR="$(build_tools/version.sh minor)" -ROCKSDB_PATCH="$(build_tools/version.sh patch)" +VERSION_MAJOR="$(build_tools/version.sh major)" +VERSION_MINOR="$(build_tools/version.sh minor)" +VERSION_PATCH="$(build_tools/version.sh patch)" TMP_OUTPUT="${OUTPUT}.tmp" @@ -874,9 +860,10 @@ TMP_OUTPUT="${OUTPUT}.tmp" echo "EXEC_LDFLAGS=$EXEC_LDFLAGS" echo "JEMALLOC_INCLUDE=$JEMALLOC_INCLUDE" echo "JEMALLOC_LIB=$JEMALLOC_LIB" - echo "ROCKSDB_MAJOR=$ROCKSDB_MAJOR" - echo "ROCKSDB_MINOR=$ROCKSDB_MINOR" - echo "ROCKSDB_PATCH=$ROCKSDB_PATCH" + echo "LIBNAME=$LIBNAME" + echo "VERSION_MAJOR=$VERSION_MAJOR" + echo "VERSION_MINOR=$VERSION_MINOR" + echo "VERSION_PATCH=$VERSION_PATCH" echo "CLANG_SCAN_BUILD=$CLANG_SCAN_BUILD" echo "CLANG_ANALYZER=$CLANG_ANALYZER" echo "PROFILING_FLAGS=$PROFILING_FLAGS" diff --git a/examples/Makefile b/examples/Makefile index b056508a6c..6d7a8fa621 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,8 @@ include ../make_config.mk +PROJECT_NAME?=rocksdb +LIBNAME?=lib$(PROJECT_NAME) + ifndef DISABLE_JEMALLOC ifdef JEMALLOC PLATFORM_CXXFLAGS += -DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE @@ -14,39 +17,39 @@ endif CFLAGS += -Wstrict-prototypes -.PHONY: clean librocksdb +.PHONY: clean static_lib all: simple_example column_families_example compact_files_example c_simple_example optimistic_transaction_example transaction_example compaction_filter_example options_file_example rocksdb_backup_restore_example -simple_example: librocksdb simple_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +simple_example: static_lib simple_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -column_families_example: librocksdb column_families_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +column_families_example: static_lib column_families_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -compaction_filter_example: librocksdb compaction_filter_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +compaction_filter_example: static_lib compaction_filter_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -compact_files_example: librocksdb compact_files_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +compact_files_example: static_lib compact_files_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) .c.o: $(CC) $(CFLAGS) -c $< -o $@ -I../include -c_simple_example: librocksdb c_simple_example.o - $(CXX) $@.o -o$@ ../librocksdb.a $(PLATFORM_LDFLAGS) $(EXEC_LDFLAGS) +c_simple_example: static_lib c_simple_example.o + $(CXX) $@.o -o$@ ../$(LIBNAME).a $(PLATFORM_LDFLAGS) $(EXEC_LDFLAGS) -optimistic_transaction_example: librocksdb optimistic_transaction_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +optimistic_transaction_example: static_lib optimistic_transaction_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -transaction_example: librocksdb transaction_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +transaction_example: static_lib transaction_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -options_file_example: librocksdb options_file_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +options_file_example: static_lib options_file_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) -multi_processes_example: librocksdb multi_processes_example.cc - $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) +multi_processes_example: static_lib multi_processes_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ ../$(LIBNAME).a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) rocksdb_backup_restore_example: librocksdb rocksdb_backup_restore_example.cc $(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) @@ -54,5 +57,5 @@ rocksdb_backup_restore_example: librocksdb rocksdb_backup_restore_example.cc clean: rm -rf ./simple_example ./column_families_example ./compact_files_example ./compaction_filter_example ./c_simple_example c_simple_example.o ./optimistic_transaction_example ./transaction_example ./options_file_example ./multi_processes_example ./rocksdb_backup_restore_example -librocksdb: - cd .. && $(MAKE) static_lib +static_lib: + LIBNAME="$(LIBNAME)" $(MAKE) -C .. static_lib diff --git a/fuzz/Makefile b/fuzz/Makefile index 588b676f09..57c609e571 100644 --- a/fuzz/Makefile +++ b/fuzz/Makefile @@ -23,7 +23,7 @@ ifneq ($(FUZZ_ENV), ossfuzz) CC = $(CXX) CCFLAGS += -Wall -fsanitize=address,fuzzer CFLAGS += $(PLATFORM_CXXFLAGS) $(PROTOBUF_CFLAGS) $(PROTOBUF_MUTATOR_CFLAGS) -I$(PROTO_OUT) -I$(ROCKSDB_INCLUDE_DIR) -I$(ROCKSDB_LIB_DIR) -LDFLAGS += $(PLATFORM_LDFLAGS) $(PROTOBUF_MUTATOR_LDFLAGS) $(PROTOBUF_LDFLAGS) -L$(ROCKSDB_LIB_DIR) -lrocksdb +LDFLAGS += $(PLATFORM_LDFLAGS) $(PROTOBUF_MUTATOR_LDFLAGS) $(PROTOBUF_LDFLAGS) -L$(ROCKSDB_LIB_DIR) -l$(LIBNAME:lib%=%) else # OSS-Fuzz sets various environment flags that are used for compilation. # These environment flags depend on which type of sanitizer build is being @@ -39,7 +39,7 @@ else CC = $(CXX) CCFLAGS = $(CXXFLAGS) CFLAGS += $(PROTOBUF_CFLAGS) $(PROTOBUF_MUTATOR_CFLAGS) -I$(PROTO_OUT) -I$(ROCKSDB_INCLUDE_DIR) -I$(ROCKSDB_LIB_DIR) -LDFLAGS += $(PLATFORM_LDFLAGS) $(LIB_FUZZING_ENGINE) $(PROTOBUF_MUTATOR_LDFLAGS) $(PROTOBUF_LDFLAGS) -L$(ROCKSDB_LIB_DIR) -lrocksdb +LDFLAGS += $(PLATFORM_LDFLAGS) $(LIB_FUZZING_ENGINE) $(PROTOBUF_MUTATOR_LDFLAGS) $(PROTOBUF_LDFLAGS) -L$(ROCKSDB_LIB_DIR) -l$(LIBNAME:lib%=%) endif .PHONY: gen_proto clean diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 5d62630fde..b3250c65c2 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -322,7 +322,7 @@ elseif(${CMAKE_VERSION} VERSION_LESS "3.11.4") # Old CMake message("Using an old CMAKE (${CMAKE_VERSION}) - JNI headers generated in separate step") add_jar( - rocksdbjni_classes + ${PROJECT_NAME}jni_classes SOURCES ${JAVA_MAIN_CLASSES} ${JAVA_TEST_CLASSES} @@ -333,12 +333,12 @@ else () # Java 1.8 or newer prepare the JAR... message("Preparing Jar for JDK ${Java_VERSION_STRING}") add_jar( - rocksdbjni_classes + ${PROJECT_NAME}jni_classes SOURCES ${JAVA_MAIN_CLASSES} ${JAVA_TEST_CLASSES} INCLUDE_JARS ${JAVA_TESTCLASSPATH} - GENERATE_NATIVE_HEADERS rocksdbjni_headers DESTINATION ${JNI_OUTPUT_DIR} + GENERATE_NATIVE_HEADERS ${PROJECT_NAME}jni_headers DESTINATION ${JNI_OUTPUT_DIR} ) endif() @@ -518,9 +518,9 @@ if(${CMAKE_VERSION} VERSION_LESS "3.11.4") ) create_javah( - TARGET rocksdbjni_headers + TARGET ${PROJECT_NAME}jni_headers CLASSES ${NATIVE_JAVA_CLASSES} - CLASSPATH rocksdbjni_classes ${JAVA_TESTCLASSPATH} + CLASSPATH ${PROJECT_NAME}jni_classes ${JAVA_TESTCLASSPATH} OUTPUT_DIR ${JNI_OUTPUT_DIR} ) endif() @@ -529,15 +529,15 @@ if(NOT MSVC) set_property(TARGET ${ROCKSDB_STATIC_LIB} PROPERTY POSITION_INDEPENDENT_CODE ON) endif() -set(ROCKSDBJNI_STATIC_LIB rocksdbjni${ARTIFACT_SUFFIX}) +set(ROCKSDBJNI_STATIC_LIB ${PROJECT_NAME}jni${ARTIFACT_SUFFIX}) add_library(${ROCKSDBJNI_STATIC_LIB} ${JNI_NATIVE_SOURCES}) -add_dependencies(${ROCKSDBJNI_STATIC_LIB} rocksdbjni_headers) -target_link_libraries(${ROCKSDBJNI_STATIC_LIB} ${ROCKSDB_STATIC_LIB} ${ROCKSDB_LIB}) +add_dependencies(${ROCKSDBJNI_STATIC_LIB} ${PROJECT_NAME}jni_headers) +target_link_libraries(${ROCKSDBJNI_STATIC_LIB} ${ROCKS_STATIC_LIB} ${ROCKS_LIB}) if(NOT MINGW) - set(ROCKSDBJNI_SHARED_LIB rocksdbjni-shared${ARTIFACT_SUFFIX}) + set(ROCKSDBJNI_SHARED_LIB ${PROJECT_NAME}jni-shared${ARTIFACT_SUFFIX}) add_library(${ROCKSDBJNI_SHARED_LIB} SHARED ${JNI_NATIVE_SOURCES}) - add_dependencies(${ROCKSDBJNI_SHARED_LIB} rocksdbjni_headers) + add_dependencies(${ROCKSDBJNI_SHARED_LIB} ${PROJECT_NAME}jni_headers) target_link_libraries(${ROCKSDBJNI_SHARED_LIB} ${ROCKSDB_STATIC_LIB} ${ROCKSDB_LIB}) set_target_properties( diff --git a/java/Makefile b/java/Makefile index 8ed47905b1..34a6574754 100644 --- a/java/Makefile +++ b/java/Makefile @@ -1,3 +1,5 @@ +PROJECT_NAME?=rocksdb + NATIVE_JAVA_CLASSES = \ org.rocksdb.AbstractCompactionFilter\ org.rocksdb.AbstractCompactionFilterFactory\ @@ -96,10 +98,6 @@ NATIVE_JAVA_TEST_CLASSES = \ org.rocksdb.WriteBatchTest\ org.rocksdb.WriteBatchTestInternalHelper -ROCKSDB_MAJOR = $(shell grep -E "ROCKSDB_MAJOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) -ROCKSDB_MINOR = $(shell grep -E "ROCKSDB_MINOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) -ROCKSDB_PATCH = $(shell grep -E "ROCKSDB_PATCH.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) - NATIVE_INCLUDE = ./include ARCH := $(shell getconf LONG_BIT) SHA256_CMD ?= sha256sum @@ -340,32 +338,32 @@ java: java-version sample: java $(AM_V_GEN)mkdir -p $(SAMPLES_MAIN_CLASSES) $(AM_V_at)$(JAVAC_CMD) $(JAVAC_ARGS) -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/RocksDBSample.java - $(AM_V_at)@rm -rf /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni_not_found - $(JAVA_CMD) $(JAVA_ARGS) -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBSample /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni_not_found + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni_not_found + $(JAVA_CMD) $(JAVA_ARGS) -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBSample /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni_not_found column_family_sample: java $(AM_V_GEN)mkdir -p $(SAMPLES_MAIN_CLASSES) $(AM_V_at)$(JAVAC_CMD) $(JAVAC_ARGS) -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/RocksDBColumnFamilySample.java - $(AM_V_at)@rm -rf /tmp/rocksdbjni - $(JAVA_CMD) $(JAVA_ARGS) -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBColumnFamilySample /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni + $(JAVA_CMD) $(JAVA_ARGS) -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBColumnFamilySample /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni transaction_sample: java $(AM_V_GEN)mkdir -p $(SAMPLES_MAIN_CLASSES) $(AM_V_at)$(JAVAC_CMD) -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/TransactionSample.java - $(AM_V_at)@rm -rf /tmp/rocksdbjni - $(JAVA_CMD) -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) TransactionSample /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni + $(JAVA_CMD) -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) TransactionSample /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni optimistic_transaction_sample: java $(AM_V_GEN)mkdir -p $(SAMPLES_MAIN_CLASSES) $(AM_V_at)$(JAVAC_CMD) -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/OptimisticTransactionSample.java - $(AM_V_at)@rm -rf /tmp/rocksdbjni - $(JAVA_CMD) -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) OptimisticTransactionSample /tmp/rocksdbjni - $(AM_V_at)@rm -rf /tmp/rocksdbjni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni + $(JAVA_CMD) -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) OptimisticTransactionSample /tmp/$(PROJECT_NAME)jni + $(AM_V_at)@rm -rf /tmp/$(PROJECT_NAME)jni $(JAVA_TEST_LIBDIR): mkdir -p "$(JAVA_TEST_LIBDIR)" diff --git a/java/pom.xml.template b/java/pom.xml.template index 4abff4768e..8a6acfb7c7 100644 --- a/java/pom.xml.template +++ b/java/pom.xml.template @@ -4,7 +4,7 @@ org.rocksdb rocksdbjni - ${ROCKSDB_JAVA_VERSION} + ${LIB_JAVA_VERSION} RocksDB JNI RocksDB fat jar that contains .so files for linux32 and linux64 (glibc and musl-libc), jnilib files @@ -123,14 +123,7 @@ Xenu - String fileContents = new File(project.basedir.absolutePath + '/../include/rocksdb/version.h').getText('UTF-8') - matcher = (fileContents =~ /(?s).*ROCKSDB_MAJOR ([0-9]+).*?/) - String major_version = matcher.getAt(0).getAt(1) - matcher = (fileContents =~ /(?s).*ROCKSDB_MINOR ([0-9]+).*?/) - String minor_version = matcher.getAt(0).getAt(1) - matcher = (fileContents =~ /(?s).*ROCKSDB_PATCH ([0-9]+).*?/) - String patch_version = matcher.getAt(0).getAt(1) - String version = String.format('%s.%s.%s', major_version, minor_version, patch_version) + String version = "${LIB_JAVA_VERSION}" // Set version to be used in pom.properties project.version = version // Set version to be set as jar name