diff --git a/Makefile b/Makefile index 41cab9e..dc932dd 100644 --- a/Makefile +++ b/Makefile @@ -1,118 +1,119 @@ + +# +# Parameters +# + +# Name of the docker executable DOCKER = docker + +# Docker organization to pull the images from ORG = dockcross + +# Directory where to generate the dockcross script for each images (e.g bin/dockcross-manylinux-x64) BIN = bin -images: base android-arm linux-x86 linux-x64 manylinux-x64 manylinux-x86 linux-arm64 linux-armv5 linux-armv6 linux-armv7 windows-x86 windows-x64 +# These images are built using the "build implicit rule" +STANDARD_IMAGES = android-arm linux-x86 linux-x64 linux-arm64 linux-armv5 linux-armv6 linux-armv7 linux-ppc64le windows-x86 windows-x64 -test: base.test android-arm.test linux-x86.test linux-x64.test manylinux-x64.test manylinux-x86.test linux-arm64.test linux-armv5.test linux-armv6.test linux-armv7.test windows-x86.test windows-x64.test +# These images are expected to have explicit rules for *both* build and testing +NON_STANDARD_IMAGES = browser-asmjs manylinux-x64 manylinux-x86 -android-arm: base android-arm/Dockerfile - $(DOCKER) build -t $(ORG)/android-arm android-arm +# This list all available images +IMAGES = $(STANDARD_IMAGES) $(NON_STANDARD_IMAGES) -android-arm.test: android-arm test/run.py - $(DOCKER) run --rm dockcross/android-arm > $(BIN)/dockcross-android-arm && chmod +x $(BIN)/dockcross-android-arm - $(BIN)/dockcross-android-arm python test/run.py +# Optional arguments for test runner (test/run.py) associated with "testing implicit rule" +linux-ppc64le.test_ARGS = --languages C +windows-x86.test_ARGS = --exe-suffix ".exe" +windows-x64.test_ARGS = --exe-suffix ".exe" -browser-asmjs: base browser-asmjs/Dockerfile +# +# images: This target builds all IMAGES (because it is the first one, it is built by default) +# +images: base $(IMAGES) + +# +# test: This target ensures all IMAGES are built and run the associated tests +# +test: base.test $(addsuffix .test,$(IMAGES)) + +# +# browser-asmjs +# +browser-asmjs: base cp -r test browser-asmjs/ $(DOCKER) build -t $(ORG)/browser-asmjs browser-asmjs rm -rf browser-asmjs/test -browser-asmjs.test: browser-asmjs test/run.py +browser-asmjs.test: browser-asmjs $(DOCKER) run --rm dockcross/browser-asmjs > $(BIN)/dockcross-browser-asmjs && chmod +x $(BIN)/dockcross-browser-asmjs $(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 - -linux-x86.test: linux-x86 test/run.py - $(DOCKER) run --rm dockcross/linux-x86 > $(BIN)/dockcross-linux-x86 && chmod +x $(BIN)/dockcross-linux-x86 - $(BIN)/dockcross-linux-x86 python test/run.py - -linux-x64: base linux-x64/Dockerfile - $(DOCKER) build -t $(ORG)/linux-x64 linux-x64 - -linux-x64.test: linux-x64 test/run.py - $(DOCKER) run --rm dockcross/linux-x64 > $(BIN)/dockcross-linux-x64 && chmod +x $(BIN)/dockcross-linux-x64 - $(BIN)/dockcross-linux-x64 python test/run.py - -linux-arm64: base linux-arm64/Dockerfile linux-arm64/Toolchain.cmake - $(DOCKER) build -t $(ORG)/linux-arm64 linux-arm64 - -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 - -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 - -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 - -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 - -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 --languages C - +# +# manylinux-x64 +# manylinux-x64/Dockerfile: manylinux-x64/Dockerfile.in common.docker sed '/common.docker/ r common.docker' manylinux-x64/Dockerfile.in > manylinux-x64/Dockerfile manylinux-x64: manylinux-x64/Dockerfile $(DOCKER) build -t $(ORG)/manylinux-x64 -f manylinux-x64/Dockerfile . -manylinux-x64.test: manylinux-x64 test/run.py +manylinux-x64.test: manylinux-x64 $(DOCKER) run --rm dockcross/manylinux-x64 > $(BIN)/dockcross-manylinux-x64 && chmod +x $(BIN)/dockcross-manylinux-x64 $(BIN)/dockcross-manylinux-x64 /opt/python/cp35-cp35m/bin/python test/run.py +# +# manylinux-x86 +# manylinux-x86/Dockerfile: manylinux-x86/Dockerfile.in common.docker sed '/common.docker/ r common.docker' manylinux-x86/Dockerfile.in > manylinux-x86/Dockerfile manylinux-x86: manylinux-x86/Dockerfile $(DOCKER) build -t $(ORG)/manylinux-x86 -f manylinux-x86/Dockerfile . -manylinux-x86.test: manylinux-x86 test/run.py +manylinux-x86.test: manylinux-x86 $(DOCKER) run --rm dockcross/manylinux-x86 > $(BIN)/dockcross-manylinux-x86 && chmod +x $(BIN)/dockcross-manylinux-x86 $(BIN)/dockcross-manylinux-x86 /opt/python/cp35-cp35m/bin/python test/run.py -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 --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 --exe-suffix ".exe" - +# +# base +# Dockerfile: Dockerfile.in common.docker sed '/common.docker/ r common.docker' Dockerfile.in > Dockerfile base: Dockerfile $(DOCKER) build -t $(ORG)/base . -base.test: base test/run.py - mkdir -p $(BIN) +base.test: base $(DOCKER) run --rm dockcross/base > $(BIN)/dockcross-base && chmod +x $(BIN)/dockcross-base -.PHONY: images base android-arm linux-x86 linux-x64 manylinux-x64 manylinux-x86 linux-arm64 linux-armv5 linux-armv6 linux-armv7 windows-x86 windows-x64 tests %.test +# +# display +# +display_images: + for image in $(IMAGES); do echo $$image; done + +$(VERBOSE).SILENT: display_images + +# +# build implicit rule +# +$(STANDARD_IMAGES): base + $(DOCKER) build -t $(ORG)/$@ $@ + +# +# testing implicit rule +# +.SECONDEXPANSION: +$(addsuffix .test,$(STANDARD_IMAGES)): $$(basename $$@) + $(DOCKER) run --rm dockcross/$(basename $@) > $(BIN)/dockcross-$(basename $@) && chmod +x $(BIN)/dockcross-$(basename $@) + $(BIN)/dockcross-$(basename $@) python test/run.py $($@_ARGS) + +# +# testing prerequisites implicit rule +# +test.prerequisites: + mkdir -p $(BIN) + +$(addsuffix .test,$(IMAGES)): test.prerequisites + +.PHONY: base images $(IMAGES) test %.test diff --git a/README.rst b/README.rst index 656f4d8..b8b3957 100644 --- a/README.rst +++ b/README.rst @@ -180,6 +180,35 @@ source cross-compiler Docker image or the dockcross script itself. - ``dockcross update``: Update both the docker image, and the dockcross script. +Download all images +------------------- + +To easily download all images, the convenience target ``display_images`` could be used:: + + curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile + for image in $(make -f dockcross-Makefile display_images); do + echo "Pulling dockcross/$image" + docker pull dockcross/$image + done + +Install all dockcross scripts +----------------------------- + +To automatically install in ``~/bin`` the dockcross scripts for each images already downloaded, the +convenience target ``display_images`` could be used:: + + curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile + for image in $(make -f dockcross-Makefile display_images); do + if [[ $(docker images -q dockcross/$image) == "" ]]; then + echo "~/bin/dockcross-$image skipping: image not found locally" + continue + fi + echo "~/bin/dockcross-$image ok" + docker run dockcross/$image > ~/bin/dockcross-$image && \ + chmod u+x ~/bin/dockcross-$image + done + + Configuration ------------- diff --git a/circle.yml b/circle.yml index c4b9830..8294c57 100644 --- a/circle.yml +++ b/circle.yml @@ -14,32 +14,13 @@ dependencies: - docker info - if [[ -e ~/docker/base.tar ]]; then docker load -i ~/docker/base.tar; fi - docker pull dockcross/base - - if [[ -e ~/docker/android-arm.tar ]]; then docker load -i ~/docker/android-arm.tar; fi - - docker pull dockcross/android-arm - - if [[ -e ~/docker/browser-asmjs.tar ]]; then docker load -i ~/docker/browser-asmjs.tar; fi - - docker pull dockcross/browser-asmjs - - if [[ -e ~/docker/linux-arm64.tar ]]; then docker load -i ~/docker/linux-arm64.tar; fi - - docker pull dockcross/linux-arm64 - - if [[ -e ~/docker/linux-armv5.tar ]]; then docker load -i ~/docker/linux-armv5.tar; fi - - docker pull dockcross/linux-armv5 - - if [[ -e ~/docker/linux-armv6.tar ]]; then docker load -i ~/docker/linux-armv6.tar; fi - - docker pull dockcross/linux-armv6 - - if [[ -e ~/docker/linux-armv7.tar ]]; then docker load -i ~/docker/linux-armv7.tar; fi - - docker pull dockcross/linux-armv7 - - if [[ -e ~/docker/linux-ppc64le.tar ]]; then docker load -i ~/docker/linux-ppc64le.tar; fi - - docker pull dockcross/linux-ppc64le - - if [[ -e ~/docker/linux-x64.tar ]]; then docker load -i ~/docker/linux-x64.tar; fi - - docker pull dockcross/linux-x64 - - if [[ -e ~/docker/linux-x86.tar ]]; then docker load -i ~/docker/linux-x86.tar; fi - - docker pull dockcross/linux-x86 - - if [[ -e ~/docker/manylinux-x64.tar ]]; then docker load -i ~/docker/manylinux-x64.tar; fi - - docker pull dockcross/manylinux-x64 - - if [[ -e ~/docker/manylinux-x86.tar ]]; then docker load -i ~/docker/manylinux-x86.tar; fi - - docker pull dockcross/manylinux-x86 - - if [[ -e ~/docker/windows-x64.tar ]]; then docker load -i ~/docker/windows-x64.tar; fi - - docker pull dockcross/windows-x64 - - if [[ -e ~/docker/windows-x86.tar ]]; then docker load -i ~/docker/windows-x86.tar; fi - - docker pull dockcross/windows-x86 + - | + for image in $(make display_images); do + if [[ -e ~/docker/$image.tar ]]; then + echo "Loading $image.tar" + docker load -i ~/docker/$image.tar; + fi + docker pull dockcross/$image test: override: @@ -80,16 +61,4 @@ deployment: commands: - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - docker push dockcross/base - - docker push dockcross/android-arm - - docker push dockcross/browser-asmjs - - docker push dockcross/linux-arm64 - - docker push dockcross/linux-armv5 - - docker push dockcross/linux-armv6 - - docker push dockcross/linux-armv7 - - docker push dockcross/linux-ppc64le - - docker push dockcross/linux-x64 - - docker push dockcross/linux-x86 - - docker push dockcross/manylinux-x64 - - docker push dockcross/manylinux-x86 - - docker push dockcross/windows-x64 - - docker push dockcross/windows-x86 + - for image in $(make display_images); do docker push dockcross/$image; done