diff --git a/Makefile b/Makefile index bcbc324..4ff661b 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ $(SNAPPY_SOURCE_CONFIGURED): $(SNAPPY_GIT_UNPACKED) cd $(SNAPPY_SRC_DIR) && ./autogen.sh && ./configure touch $@ -jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h $(SRC)/org/xerial/snappy/BitShuffleNative.h +jni-header: $(SNAPPY_SOURCE_CONFIGURED) $(SRC)/org/xerial/snappy/SnappyNative.h $(SRC)/org/xerial/snappy/BitShuffleNative.h $(TARGET)/jni-classes/org/xerial/snappy/SnappyNative.class: $(SRC)/org/xerial/snappy/SnappyNative.java @mkdir -p $(TARGET)/jni-classes @@ -153,32 +153,37 @@ win32: jni-header win64: jni-header ./docker/dockcross-windows-x64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64' -mac32: +# deprecated +mac32: jni-header $(MAKE) native OS_NAME=Mac OS_ARCH=x86 +mac64: jni-header + docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64 + linux32: $(MAKE) native OS_NAME=Linux OS_ARCH=x86 freebsd64: $(MAKE) native OS_NAME=FreeBSD OS_ARCH=x86_64 -# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package -linux-arm: - $(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm +# For ARM +linux-arm: jni-header + ./docker/dockcross-armv5 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm' -# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabihf package -linux-armhf: - $(MAKE) native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armhf +linux-armv6: jni-header + ./docker/dockcross-armv6 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv6' -# for cross-compilation on Ubuntu, install the g++-aarch64-linux-gnu -linux-aarch64: - $(MAKE) native CROSS_PREFIX=aarch64-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64 +linux-armv7: jni-header + ./docker/dockcross-armv7 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv7' -clean-native-linux32: - $(MAKE) clean-native OS_NAME=Linux OS_ARCH=x86 +linux-android-arm: jni-header + ./docker/dockcross-android-arm -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/arm-linux-androideabi/bin/arm-linux-androideabi- OS_NAME=Linux OS_ARCH=android-arm' -clean-native-win32: - $(MAKE) clean-native OS_NAME=Windows OS_ARCH=x86 +linux-ppc64: jni-header + ./docker/dockcross-ppc64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64le' + +linux-aarch64: jni-header + ./docker/dockcross-armv7 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64' javadoc: $(SBT) doc diff --git a/Makefile.common b/Makefile.common index f1b6ad4..5e1c22c 100755 --- a/Makefile.common +++ b/Makefile.common @@ -214,8 +214,8 @@ Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc Mac-x86_LIBNAME := libsnappyjava.jnilib Mac-x86_SNAPPY_FLAGS := -Mac-x86_64_CXX := g++ -arch $(OS_ARCH) -Mac-x86_64_STRIP := strip -x +Mac-x86_64_CXX := $(CROSS_PREFIX)g++ -arch $(OS_ARCH) +Mac-x86_64_STRIP := $(CROSS_PREFIX)strip -x Mac-x86_64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5 -fvisibility=hidden Mac-x86_64_LINKFLAGS := -dynamiclib Mac-x86_64_LIBNAME := libsnappyjava.jnilib diff --git a/build.sbt b/build.sbt index f00176f..5fadcca 100644 --- a/build.sbt +++ b/build.sbt @@ -45,7 +45,7 @@ pomExtra := { } -scalaVersion := "2.11.6" +scalaVersion in ThisBuild := "2.11.8" javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6") diff --git a/docker/dockcross-aarch64 b/docker/dockcross-aarch64 new file mode 100755 index 0000000..778afb0 --- /dev/null +++ b/docker/dockcross-aarch64 @@ -0,0 +1,200 @@ +#!/bin/bash + +DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-arm64 + +#------------------------------------------------------------------------------ +# Helpers +# +err() { + echo -e >&2 ERROR: $@\\n +} + +die() { + err $@ + exit 1 +} + +has() { + # eg. has command update + local kind=$1 + local name=$2 + + type -t $kind:$name | grep -q function +} + +#------------------------------------------------------------------------------ +# Command handlers +# +command:update-image() { + docker pull $FINAL_IMAGE +} + +help:update-image() { + echo Pull the latest $FINAL_IMAGE . +} + +command:update-script() { + if cmp -s <( docker run $FINAL_IMAGE ) $0; then + echo $0 is up to date + else + echo -n Updating $0 '... ' + docker run $FINAL_IMAGE > $0 && echo ok + fi +} + +help:update-image() { + echo Update $0 from $FINAL_IMAGE . +} + +command:update() { + command:update-image + command:update-script +} + +help:update() { + echo Pull the latest $FINAL_IMAGE, and then update $0 from that. +} + +command:help() { + if [[ $# != 0 ]]; then + if ! has command $1; then + err \"$1\" is not an dockcross command + command:help + elif ! has help $1; then + err No help found for \"$1\" + else + help:$1 + fi + else + cat >&2 < +ENDHELP + exit 1 + fi +} + +#------------------------------------------------------------------------------ +# Option processing +# +special_update_command='' +while [[ $# != 0 ]]; do + case $1 in + + --) + break + ;; + + --args|-a) + ARG_ARGS="$2" + shift 2 + ;; + + --config|-c) + ARG_CONFIG="$2" + shift 2 + ;; + + --image|-i) + ARG_IMAGE="$2" + shift 2 + ;; + update|update-image|update-script) + special_update_command=$1 + break + ;; + -*) + err Unknown option \"$1\" + command:help + exit + ;; + + *) + break + ;; + + esac +done + +# The precedence for options is: +# 1. command-line arguments +# 2. environment variables +# 3. defaults + +# Source the config file if it exists +DEFAULT_DOCKCROSS_CONFIG=~/.dockcross +FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}} + +[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG" + +# Set the docker image +FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}} + +# Handle special update command +if [ "$special_update_command" != "" ]; then + case $special_update_command in + + update) + command:update + exit $? + ;; + + update-image) + command:update-image + exit $? + ;; + + update-script) + command:update-script + exit $? + ;; + + esac +fi + +# Set the docker run extra args (if any) +FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}} + +# If we are not running via boot2docker +if [ -z $DOCKER_HOST ]; then + USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )" +fi + +#------------------------------------------------------------------------------ +# Now, finally, run the command in a container +# +docker run --rm \ + -v $PWD:/work \ + $USER_IDS \ + $FINAL_ARGS \ + $FINAL_IMAGE "$@" + +################################################################################ +# +# This image is not intended to be run manually. +# +# To create a dockcross helper script for the +# dockcross/linux-armv7 image, run: +# +# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7 +# chmod +x dockcross-linux-armv7 +# +# You may then wish to move the dockcross script to your PATH. +# +################################################################################ diff --git a/project/build.properties b/project/build.properties index 02cb92b..24be09b 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ -sbt.version=0.13.9 +sbt.version=0.13.13 diff --git a/project/plugins.sbt b/project/plugins.sbt index 01d0a14..0f071ce 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.0") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")