Skip to content

Commit

Permalink
add s390x support
Browse files Browse the repository at this point in the history
  • Loading branch information
sudip-ibm committed Apr 15, 2023
1 parent 509fe72 commit 7a343fd
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -149,7 +149,7 @@ native: jni-header snappy-header $(NATIVE_DLL)
native-nocmake: jni-header $(NATIVE_DLL)
snappy: native $(TARGET)/$(snappy-jar-version).jar

native-all: native native-arm mac64 win32 win64 linux32 linux64 linux-ppc64le linux-riscv64
native-all: native native-arm mac64 win32 win64 linux32 linux64 linux-ppc64le linux-riscv64 linux-s390x

$(NATIVE_DLL): $(SNAPPY_OUT)/$(LIBNAME)
@mkdir -p $(@D)
Expand Down Expand Up @@ -216,6 +216,9 @@ linux-arm64: jni-header
linux-riscv64: jni-header
./docker/dockcross-riscv64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=riscv64'

linux-s390x: jni-header
./docker/dockcross-s390x -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu- OS_NAME=Linux OS_ARCH=s390x'

javadoc:
$(SBT) doc

Expand Down
4 changes: 2 additions & 2 deletions Makefile.common
Expand Up @@ -169,8 +169,8 @@ Linux-s390_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-s390_LIBNAME := libsnappyjava.so
Linux-s390_SNAPPY_FLAGS :=

Linux-s390x_CXX := g++
Linux-s390x_STRIP := strip
Linux-s390x_CXX := $(CROSS_PREFIX)g++
Linux-s390x_STRIP := $(CROSS_PREFIX)strip
ifeq ($(IBM_JDK_7),)
Linux-s390x_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64 -std=c++11
else
Expand Down
199 changes: 199 additions & 0 deletions docker/dockcross-s390x
@@ -0,0 +1,199 @@
#!/bin/bash
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-s390x

#------------------------------------------------------------------------------
# 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
Usage: dockcross [options] [--] command [args]
By default, run the given *command* in an dockcross Docker container.
The *options* can be one of:
--args|-a Extra args to the *docker run* command
--image|-i Docker cross-compiler image to use
--config|-c Bash script to source before running this script
Additionally, there are special update commands:
update-image
update-script
update
For update command help use: $0 help <command>
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.
#
################################################################################

0 comments on commit 7a343fd

Please sign in to comment.