From 42ac4e442925f2d52e4bd48d6702f4c916ec6490 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Fri, 8 Jan 2021 17:47:09 +0100 Subject: [PATCH] ci(cmake): Add ARM cross compile jobs * update .dockerignore --- .dockerignore | 2 ++ cmake/Makefile | 50 +++++++++++++++++++++++++++- cmake/docker/arm/glop.Dockerfile | 30 +++++++++++++++++ cmake/docker/arm/or-tools.Dockerfile | 30 +++++++++++++++++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 cmake/docker/arm/glop.Dockerfile create mode 100644 cmake/docker/arm/or-tools.Dockerfile diff --git a/.dockerignore b/.dockerignore index 270b29472d..56137ee54c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -53,6 +53,8 @@ lib bin packages build/ +build_cmake/ +build_cross/ examples/data/vector_packing examples/data/rcpsp examples/data/binpacking diff --git a/cmake/Makefile b/cmake/Makefile index e614a884bd..23e5c8349e 100644 --- a/cmake/Makefile +++ b/cmake/Makefile @@ -75,7 +75,19 @@ help: @echo -e "\tWith ${BOLD}${RESET}:" @echo -e "\t\t${BOLD}freebsd${RESET} (FreeBSD)" @echo - @echo -e "\tWith ${BOLD}${RESET}:" + @echo + @echo -e "\t${BOLD}glop_${RESET}: build for glop using an ubuntu docker." + @echo -e "\t${BOLD}arm__${RESET}: cross build docker image for for aarch64." + @echo + @echo -e "\tWith ${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}glop${RESET} Build libglop" + @echo -e "\t\t${BOLD}or-tools${RESET} Build libortools" + @echo + @echo -e "\tWith ${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}env${RESET}" + @echo -e "\t\t${BOLD}devel${RESET}" + @echo -e "\t\t${BOLD}build${RESET}" + @echo -e "\t\t${BOLD}test${RESET}" @echo @echo -e "\t${BOLD}clean${RESET}: Remove cache and docker image." @echo -e "\t${BOLD}clean_${RESET}: Remove cache and docker image for the specified distro." @@ -355,6 +367,42 @@ $(clean_glop_targets): clean_glop_% docker image rm -f ${IMAGE}:glop_$* 2>/dev/null rm -f cache/glop/docker_$*.tar +############ +## ARM 64 ## +############ +TARGETS = glop or-tools +STEPS = env devel build test +define make-arm-target = +#$$(info TARGET: $1) +#$$(info Create targets: $(addprefix arm_$1_, $(STEPS))) +arm_targets = $(addprefix arm_$1_, $(STEPS)) +.PHONY: $$(arm_targets) +$$(arm_targets): arm_$1_%: docker/arm/$1.Dockerfile + #@docker image rm -f ${IMAGE}:$$@ 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$$* --tag ${IMAGE}:$$@ -f $$< .. + +save_arm_targets = $(addprefix save_arm_$1_, $(STEPS)) +.PHONY: $(save_arm_targets) +$(save_arm_targets): save_arm_$1_%: cache/arm/docker_$1_%.tar +cache/arm/docker_$1_%.tar: arm_$1_% + @rm -f $$@ + mkdir -p cache/arm + docker save ${IMAGE}:$$< -o $$@ + +sh_arm_targets = $(addprefix sh_arm_$1_, $(STEPS)) +.PHONY: $$(sh_arm_targets) +$$(sh_arm_targets): sh_arm_$1_%: arm_$1_% + ${DOCKER_RUN_CMD} -it --name ${PROJECT}_${BUILD_SYSTEM}_$$< ${IMAGE}:$$< + +clean_arm_targets = $(addprefix clean_arm_$1_, $(STEPS)) +.PHONY: $$(clean_arm_targets) +$$(clean_arm_targets): clean_arm_$1_% + docker image rm -f ${IMAGE}:arm_$1_$$* 2>/dev/null + rm -f cache/arm/docker_$1_$$*.tar +endef + +$(foreach target,$(TARGETS),$(eval $(call make-arm-target,$(target)))) + # CLEAN targets = $(addprefix clean_, $(DISTROS)) vms = $(addprefix clean_, $(VMS)) diff --git a/cmake/docker/arm/glop.Dockerfile b/cmake/docker/arm/glop.Dockerfile new file mode 100644 index 0000000000..3737317f56 --- /dev/null +++ b/cmake/docker/arm/glop.Dockerfile @@ -0,0 +1,30 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/ubuntu +FROM ubuntu:rolling AS env +LABEL maintainer="corentinl@google.com" +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN apt-get update -qq \ +&& apt-get install -yq git wget libssl-dev build-essential \ + ninja-build python3 pkgconf libglib2.0-dev \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install CMake 3.19.2 +RUN wget "https://cmake.org/files/v3.19/cmake-3.19.2-Linux-x86_64.sh" \ +&& chmod a+x cmake-3.19.2-Linux-x86_64.sh \ +&& ./cmake-3.19.2-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \ +&& rm cmake-3.19.2-Linux-x86_64.sh + +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +ENV PROJECT=glop +ENV TARGET=aarch64-linux-gnu +RUN ./tools/cross_compile.sh build + +FROM build AS test +RUN ./tools/cross_compile.sh qemu +RUN ./tools/cross_compile.sh test diff --git a/cmake/docker/arm/or-tools.Dockerfile b/cmake/docker/arm/or-tools.Dockerfile new file mode 100644 index 0000000000..56caf9b9fc --- /dev/null +++ b/cmake/docker/arm/or-tools.Dockerfile @@ -0,0 +1,30 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/ubuntu +FROM ubuntu:rolling AS env +LABEL maintainer="corentinl@google.com" +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN apt-get update -qq \ +&& apt-get install -yq git wget libssl-dev build-essential \ + ninja-build python3 pkgconf libglib2.0-dev \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install CMake 3.19.2 +RUN wget "https://cmake.org/files/v3.19/cmake-3.19.2-Linux-x86_64.sh" \ +&& chmod a+x cmake-3.19.2-Linux-x86_64.sh \ +&& ./cmake-3.19.2-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \ +&& rm cmake-3.19.2-Linux-x86_64.sh + +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +ENV PROJECT=or-tools +ENV TARGET=aarch64-linux-gnu +RUN ./tools/cross_compile.sh build + +FROM build AS test +RUN ./tools/cross_compile.sh qemu +RUN ./tools/cross_compile.sh test