Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add triple aliases #8

Merged
merged 4 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add triple aliases
  • Loading branch information
moul committed Dec 15, 2015
commit bd232f9f94b21187b1214d8dfe8c9dde2c5f7486
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
IMAGE = multiarch/crossbuild:dev
LINUX_TRIPLES = arm-linux-gnueabihf arm-linux-gnueabi powerpc64le-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf mipsel-linux-gnu
DARWIN_TRIPLES = x86_64-apple-darwin i386-apple-darwin x86_64h-apple-darwin
ALIAS_TRIPLES = arm armhf arm64 amd64 x86_64 mips mipsel powerpc powerpc64 powerpc64le
DOCKER_TEST_ARGS ?= -it --rm -v $(shell pwd)/test:/test -w /test


Expand Down
35 changes: 31 additions & 4 deletions assets/crossbuild
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
#!/bin/sh

# set -x

# alternative names mapping
case "${CROSS_TRIPLE}" in
arm)
CROSS_TRIPLE="arm-linux-gnueabi"
;;
armhf)
CROSS_TRIPLE="arm-linux-gnueabihf"
;;
mipsel|mips)
CROSS_TRIPLE="mipsel-linux-gnu"
;;
arm64|aarch64)
CROSS_TRIPLE="aarch64-linux-gnu"
;;
powerpc64le|powerpc64|powerpc)
CROSS_TRIPLE="powerpc64le-linux-gnu"
;;
darwin)
CROSS_TRIPLE="x86_64-apple-darwin${DARWIN_VERSION}"
;;
*-apple-darwin)
CROSS_TRIPLE="${CROSS_TRIPLE}${DARWIN_VERSION}"
;;
x86_64|amd64)
unset CROSS_TRIPLE
;;
i386|i386-linux-gnu)
echo "i386-linux-gnu not yet implemented."
exit 1
;;
esac

# configure environment
if [ -n "${CROSS_TRIPLE}" ]; then
export CROSS_ROOT="/usr/${CROSS_TRIPLE}"
export PATH="${CROSS_ROOT}/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/x86_64-linux-gnu/${CROSS_TRIPLE}/lib:${LD_LIBRARY_PATH}"
fi

# try to exec direct binary instead on relying on the $PATH
binary=$1
shift

if [ -f "${CROSS_ROOT}/bin/$binary" ]; then
if [ -n "${CROSS_TRIPLE}" -a -f "${CROSS_ROOT}/bin/$binary" ]; then
binary="${CROSS_ROOT}/bin/$binary"
fi

# finally exec
exec "${binary}" $@
exit $?