mirror of
https://github.com/bensuperpc/dockcross.git
synced 2024-11-10 05:07:26 +01:00
Merge pull request #20 from thewtex/CMAKE_TOOLCHAIN_FILE-auto
Always pass CMAKE_TOOLCHAIN_FILE to cmake and ccmake #17
This commit is contained in:
commit
11e27190e8
@ -58,6 +58,7 @@ RUN git clone git://cmake.org/cmake.git CMake && \
|
||||
make install && \
|
||||
cd .. && \
|
||||
rm -rf CMake*
|
||||
# Wrappers that point to CMAKE_TOOLCHAIN_FILE
|
||||
|
||||
# Build and install Ninja from source
|
||||
RUN git clone https://github.com/martine/ninja.git && \
|
||||
@ -67,6 +68,8 @@ RUN git clone https://github.com/martine/ninja.git && \
|
||||
./ninja && \
|
||||
cp ./ninja /usr/bin/ && \
|
||||
cd .. && rm -rf ninja
|
||||
COPY imagefiles/cmake.sh /usr/local/bin/cmake
|
||||
COPY imagefiles/ccmake.sh /usr/local/bin/ccmake
|
||||
|
||||
RUN echo "root:root" | chpasswd
|
||||
WORKDIR /work
|
||||
|
19
Makefile
19
Makefile
@ -4,7 +4,7 @@ BIN = bin
|
||||
|
||||
images: base android-arm linux-x86 linux-x64 linux-arm64 linux-armv5 linux-armv6 linux-armv7 windows-x86 windows-x64
|
||||
|
||||
tests: base.test android-arm.test linux-x86.test linux-x64.test linux-arm64.test linux-armv5.test linux-armv6.test linux-armv7.test windows-x86.test windows-x64.test
|
||||
test: base.test android-arm.test linux-x86.test linux-x64.test linux-arm64.test linux-armv5.test linux-armv6.test linux-armv7.test windows-x86.test windows-x64.test
|
||||
|
||||
android-arm: base android-arm/Dockerfile
|
||||
$(DOCKER) build -t $(ORG)/android-arm android-arm
|
||||
@ -20,7 +20,7 @@ browser-asmjs: base browser-asmjs/Dockerfile
|
||||
|
||||
browser-asmjs.test: browser-asmjs test/run.py
|
||||
$(DOCKER) run --rm dockcross/browser-asmjs > $(BIN)/dockcross-browser-asmjs && chmod +x $(BIN)/dockcross-browser-asmjs
|
||||
$(BIN)/dockcross-browser-asmjs python test/run.py --emulator /usr/bin/node --exe-suffix ".js"
|
||||
$(BIN)/dockcross-browser-asmjs python test/run.py --exe-suffix ".js"
|
||||
|
||||
linux-x86: base linux-x86/Dockerfile linux-x86/Toolchain.cmake
|
||||
$(DOCKER) build -t $(ORG)/linux-x86 linux-x86
|
||||
@ -41,49 +41,49 @@ linux-arm64: base linux-arm64/Dockerfile linux-arm64/Toolchain.cmake
|
||||
|
||||
linux-arm64.test: linux-arm64 test/run.py
|
||||
$(DOCKER) run --rm dockcross/linux-arm64 > $(BIN)/dockcross-linux-arm64 && chmod +x $(BIN)/dockcross-linux-arm64
|
||||
$(BIN)/dockcross-linux-arm64 python test/run.py --emulator /usr/bin/qemu-aarch64
|
||||
$(BIN)/dockcross-linux-arm64 python test/run.py
|
||||
|
||||
linux-armv5: base linux-armv5/Dockerfile linux-armv5/Toolchain.cmake
|
||||
$(DOCKER) build -t $(ORG)/linux-armv5 linux-armv5
|
||||
|
||||
linux-armv5.test: linux-armv5 test/run.py
|
||||
$(DOCKER) run --rm dockcross/linux-armv5 > $(BIN)/dockcross-linux-armv5 && chmod +x $(BIN)/dockcross-linux-armv5
|
||||
$(BIN)/dockcross-linux-armv5 python test/run.py --emulator /usr/bin/qemu-arm
|
||||
$(BIN)/dockcross-linux-armv5 python test/run.py
|
||||
|
||||
linux-armv6: base linux-armv6/Dockerfile linux-armv6/Toolchain.cmake
|
||||
$(DOCKER) build -t $(ORG)/linux-armv6 linux-armv6
|
||||
|
||||
linux-armv6.test: linux-armv6 test/run.py
|
||||
$(DOCKER) run --rm dockcross/linux-armv6 > $(BIN)/dockcross-linux-armv6 && chmod +x $(BIN)/dockcross-linux-armv6
|
||||
$(BIN)/dockcross-linux-armv6 python test/run.py --emulator /usr/bin/qemu-arm
|
||||
$(BIN)/dockcross-linux-armv6 python test/run.py
|
||||
|
||||
linux-armv7: base linux-armv7/Dockerfile linux-armv7/Toolchain.cmake
|
||||
$(DOCKER) build -t $(ORG)/linux-armv7 linux-armv7
|
||||
|
||||
linux-armv7.test: linux-armv7 test/run.py
|
||||
$(DOCKER) run --rm dockcross/linux-armv7 > $(BIN)/dockcross-linux-armv7 && chmod +x $(BIN)/dockcross-linux-armv7
|
||||
$(BIN)/dockcross-linux-armv7 python test/run.py --emulator /usr/bin/qemu-arm
|
||||
$(BIN)/dockcross-linux-armv7 python test/run.py
|
||||
|
||||
linux-ppc64le: base linux-ppc64le/Dockerfile linux-ppc64le/Toolchain.cmake
|
||||
$(DOCKER) build -t $(ORG)/linux-ppc64le linux-ppc64le
|
||||
|
||||
linux-ppc64le.test: linux-ppc64le test/run.py
|
||||
$(DOCKER) run --rm dockcross/linux-ppc64le > $(BIN)/dockcross-linux-ppc64le && chmod +x $(BIN)/dockcross-linux-ppc64le
|
||||
$(BIN)/dockcross-linux-ppc64le python test/run.py --emulator /usr/bin/qemu-ppc64le --languages C
|
||||
$(BIN)/dockcross-linux-ppc64le python test/run.py --languages C
|
||||
|
||||
windows-x86: base windows-x86/Dockerfile windows-x86/settings.mk
|
||||
$(DOCKER) build -t $(ORG)/windows-x86 windows-x86
|
||||
|
||||
windows-x86.test: windows-x86 test/run.py
|
||||
$(DOCKER) run --rm dockcross/windows-x86 > $(BIN)/dockcross-windows-x86 && chmod +x $(BIN)/dockcross-windows-x86
|
||||
$(BIN)/dockcross-windows-x86 python test/run.py --emulator /usr/bin/wine --exe-suffix ".exe"
|
||||
$(BIN)/dockcross-windows-x86 python test/run.py --exe-suffix ".exe"
|
||||
|
||||
windows-x64: base windows-x64/Dockerfile windows-x64/settings.mk
|
||||
$(DOCKER) build -t $(ORG)/windows-x64 windows-x64
|
||||
|
||||
windows-x64.test: windows-x64 test/run.py
|
||||
$(DOCKER) run --rm dockcross/windows-x64 > $(BIN)/dockcross-windows-x64 && chmod +x $(BIN)/dockcross-windows-x64
|
||||
$(BIN)/dockcross-windows-x64 python test/run.py --emulator /usr/bin/wine --exe-suffix ".exe"
|
||||
$(BIN)/dockcross-windows-x64 python test/run.py --exe-suffix ".exe"
|
||||
|
||||
base: Dockerfile
|
||||
$(DOCKER) build -t $(ORG)/base .
|
||||
@ -91,6 +91,5 @@ base: Dockerfile
|
||||
base.test: base test/run.py
|
||||
mkdir -p $(BIN)
|
||||
$(DOCKER) run --rm dockcross/base > $(BIN)/dockcross-base && chmod +x $(BIN)/dockcross-base
|
||||
$(BIN)/dockcross-base python test/run.py --emulator 'sh -c'
|
||||
|
||||
.PHONY: images base android-arm linux-x86 linux-x64 linux-arm64 linux-armv5 linux-armv6 linux-armv7 windows-x86 windows-x64 tests %.test
|
||||
|
6
imagefiles/ccmake.sh
Executable file
6
imagefiles/ccmake.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Always pass the CMAKE_TOOLCHAIN_FILE variable to CMake when inside a
|
||||
# dockcross environment -- the CMAKE_TOOLCHAIN_FILE environmental variable is
|
||||
# always set in this context
|
||||
exec /usr/bin/ccmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} "$@"
|
6
imagefiles/cmake.sh
Executable file
6
imagefiles/cmake.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Always pass the CMAKE_TOOLCHAIN_FILE variable to CMake when inside a
|
||||
# dockcross environment -- the CMAKE_TOOLCHAIN_FILE environmental variable is
|
||||
# always set in this context
|
||||
exec /usr/bin/cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} "$@"
|
@ -2,7 +2,7 @@ FROM dockcross/base
|
||||
MAINTAINER Matt McCormick "matt.mccormick@kitware.com"
|
||||
|
||||
ENV CROSS_TRIPLE x86_64-linux-gnu
|
||||
ENV CROSS_ROOT /usr/bin/${CROSS_TRIPLE}
|
||||
ENV CROSS_ROOT /usr/bin
|
||||
ENV AS=/usr/bin/${CROSS_TRIPLE}-as \
|
||||
AR=/usr/bin/${CROSS_TRIPLE}-ar \
|
||||
CC=/usr/bin/${CROSS_TRIPLE}-gcc \
|
||||
@ -10,4 +10,8 @@ ENV AS=/usr/bin/${CROSS_TRIPLE}-as \
|
||||
CXX=/usr/bin/${CROSS_TRIPLE}-g++ \
|
||||
LD=/usr/bin/${CROSS_TRIPLE}-ld
|
||||
|
||||
COPY ${CROSS_TRIPLE}-noop.sh /usr/bin/${CROSS_TRIPLE}-noop
|
||||
|
||||
COPY Toolchain.cmake /usr/lib/${CROSS_TRIPLE}/
|
||||
ENV CMAKE_TOOLCHAIN_FILE /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake
|
||||
ENV DEFAULT_DOCKCROSS_IMAGE dockcross/linux-x64
|
||||
|
11
linux-x64/Toolchain.cmake
Normal file
11
linux-x64/Toolchain.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(cross_triple "x86_64-linux-gnu")
|
||||
|
||||
set(CMAKE_C_COMPILER /usr/bin/${cross_triple}-gcc)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/${cross_triple}-g++)
|
||||
set(CMAKE_ASM_COMPILER /usr/bin/${cross_triple}-as)
|
||||
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/${cross_triple}-noop)
|
174
linux-x64/dockcross-linux-x64
Executable file
174
linux-x64/dockcross-linux-x64
Executable file
@ -0,0 +1,174 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-x64
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# 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
|
||||
#
|
||||
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
|
||||
;;
|
||||
|
||||
-*)
|
||||
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}}
|
||||
|
||||
# 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 -i -t --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.
|
||||
#
|
||||
################################################################################
|
2
linux-x64/x86_64-linux-gnu-noop.sh
Executable file
2
linux-x64/x86_64-linux-gnu-noop.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec "$@"
|
@ -58,10 +58,6 @@ def test_cmake_build_system(build_dir, language, source, emulator, linker_flags,
|
||||
if linker_flags:
|
||||
cmake_configuration_cmd.insert(1,
|
||||
'-DCMAKE_EXE_LINKER_FLAGS="{0}"'.format(' '.join(linker_flags)))
|
||||
toolchain_file = os.getenv('CMAKE_TOOLCHAIN_FILE')
|
||||
if toolchain_file:
|
||||
cmake_configuration_cmd.insert(1,
|
||||
'-DCMAKE_TOOLCHAIN_FILE={0}'.format(toolchain_file))
|
||||
print(' '.join(cmake_configuration_cmd))
|
||||
sys.stdout.flush()
|
||||
if subprocess.call(cmake_configuration_cmd):
|
||||
|
@ -48,10 +48,10 @@ ENV WINEARCH win64
|
||||
RUN wine hostname
|
||||
|
||||
WORKDIR /usr/src
|
||||
# mxe master 2016-04-09
|
||||
# mxe master 2016-07-21
|
||||
RUN git clone https://github.com/mxe/mxe.git && \
|
||||
cd mxe && \
|
||||
git checkout 4accc990de7741f4d5aa37e368a732f3d47d803a
|
||||
git checkout 041ab69b457edd7b9944e6ae7b85f915e2596c2c
|
||||
WORKDIR /usr/src/mxe
|
||||
COPY settings.mk /usr/src/mxe/
|
||||
RUN make -j$(nproc)
|
||||
|
@ -48,10 +48,10 @@ ENV WINEARCH win32
|
||||
RUN wine hostname
|
||||
|
||||
WORKDIR /usr/src
|
||||
# mxe master 2016-04-09
|
||||
# mxe master 2016-07-21
|
||||
RUN git clone https://github.com/mxe/mxe.git && \
|
||||
cd mxe && \
|
||||
git checkout 4accc990de7741f4d5aa37e368a732f3d47d803a
|
||||
git checkout 041ab69b457edd7b9944e6ae7b85f915e2596c2c
|
||||
WORKDIR /usr/src/mxe
|
||||
COPY settings.mk /usr/src/mxe/
|
||||
RUN make -j$(nproc)
|
||||
|
Loading…
Reference in New Issue
Block a user