diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..7efea0e553 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,193 @@ +name: Docker + +on: [push, pull_request] + +jobs: + Alpine: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake alpine_env + - name: Build devel project + run: make --directory=cmake alpine_devel + - name: Build project + run: make --directory=cmake alpine_build + - name: Test C++ + run: make --directory=cmake alpine_cpp_test + - name: Test Python + run: make --directory=cmake alpine_python_test + - name: Test Java + run: make --directory=cmake alpine_java_test + - name: Test .Net + run: make --directory=cmake alpine_dotnet_test + - name: Test C++ Install + run: make --directory=cmake alpine_cpp_install_test + - name: Test Python Install + run: make --directory=cmake alpine_python_install_test + - name: Test Java Install + run: make --directory=cmake alpine_java_install_test + - name: Test .Net Install + run: make --directory=cmake alpine_dotnet_install_test + + Archlinux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake archlinux_env + - name: Build devel project + run: make --directory=cmake archlinux_devel + - name: Build project + run: make --directory=cmake archlinux_build + - name: Test C++ + run: make --directory=cmake archlinux_cpp_test + - name: Test Python + run: make --directory=cmake archlinux_python_test + - name: Test Java + run: make --directory=cmake archlinux_java_test + - name: Test .Net + run: make --directory=cmake archlinux_dotnet_test + - name: Test C++ Install + run: make --directory=cmake archlinux_cpp_install_test + - name: Test Python Install + run: make --directory=cmake archlinux_python_install_test + - name: Test Java Install + run: make --directory=cmake archlinux_java_install_test + - name: Test .Net Install + run: make --directory=cmake archlinux_dotnet_install_test + + Centos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake centos_env + - name: Build devel project + run: make --directory=cmake centos_devel + - name: Build project + run: make --directory=cmake centos_build + - name: Test C++ + run: make --directory=cmake centos_cpp_test + - name: Test Python + run: make --directory=cmake centos_python_test + - name: Test Java + run: make --directory=cmake centos_java_test + - name: Test .Net + run: make --directory=cmake centos_dotnet_test + - name: Test C++ Install + run: make --directory=cmake centos_cpp_install_test + - name: Test Python Install + run: make --directory=cmake centos_python_install_test + - name: Test Java Install + run: make --directory=cmake centos_java_install_test + - name: Test .Net Install + run: make --directory=cmake centos_dotnet_install_test + + Debian: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake debian_env + - name: Build devel project + run: make --directory=cmake debian_devel + - name: Build project + run: make --directory=cmake debian_build + - name: Test C++ + run: make --directory=cmake debian_cpp_test + - name: Test Python + run: make --directory=cmake debian_python_test + - name: Test Java + run: make --directory=cmake debian_java_test + - name: Test .Net + run: make --directory=cmake debian_dotnet_test + - name: Test C++ Install + run: make --directory=cmake debian_cpp_install_test + - name: Test Python Install + run: make --directory=cmake debian_python_install_test + - name: Test Java Install + run: make --directory=cmake debian_java_install_test + - name: Test .Net Install + run: make --directory=cmake debian_dotnet_install_test + + Fedora: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake fedora_env + - name: Build devel project + run: make --directory=cmake fedora_devel + - name: Build project + run: make --directory=cmake fedora_build + - name: Test C++ + run: make --directory=cmake fedora_cpp_test + - name: Test Python + run: make --directory=cmake fedora_python_test + - name: Test Java + run: make --directory=cmake fedora_java_test + - name: Test .Net + run: make --directory=cmake fedora_dotnet_test + - name: Test C++ Install + run: make --directory=cmake fedora_cpp_install_test + - name: Test Python Install + run: make --directory=cmake fedora_python_install_test + - name: Test Java Install + run: make --directory=cmake fedora_java_install_test + - name: Test .Net Install + run: make --directory=cmake fedora_dotnet_install_test + + OpenSuse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake opensuse_env + - name: Build devel project + run: make --directory=cmake opensuse_devel + - name: Build project + run: make --directory=cmake opensuse_build + - name: Test C++ + run: make --directory=cmake opensuse_cpp_test + - name: Test Python + run: make --directory=cmake opensuse_python_test + - name: Test Java + run: make --directory=cmake opensuse_java_test + - name: Test .Net + run: make --directory=cmake opensuse_dotnet_test + - name: Test C++ Install + run: make --directory=cmake opensuse_cpp_install_test + - name: Test Python Install + run: make --directory=cmake opensuse_python_install_test + - name: Test Java Install + run: make --directory=cmake opensuse_java_install_test + - name: Test .Net Install + run: make --directory=cmake opensuse_dotnet_install_test + + Ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build env image + run: make --directory=cmake ubuntu_env + - name: Build devel project + run: make --directory=cmake ubuntu_devel + - name: Build project + run: make --directory=cmake ubuntu_build + - name: Test C++ + run: make --directory=cmake ubuntu_cpp_test + - name: Test Python + run: make --directory=cmake ubuntu_python_test + - name: Test Java + run: make --directory=cmake ubuntu_java_test + - name: Test .Net + run: make --directory=cmake ubuntu_dotnet_test + - name: Test C++ Install + run: make --directory=cmake ubuntu_cpp_install_test + - name: Test Python Install + run: make --directory=cmake ubuntu_python_install_test + - name: Test Java Install + run: make --directory=cmake ubuntu_java_install_test + - name: Test .Net Install + run: make --directory=cmake ubuntu_dotnet_install_test diff --git a/cmake/Makefile b/cmake/Makefile index 295aabb4f6..60f599d028 100644 --- a/cmake/Makefile +++ b/cmake/Makefile @@ -17,26 +17,36 @@ help: @echo -e "${BOLD}MAKE TARGETS${RESET}" @echo -e "\t${BOLD}help${RESET}: display this help and exit." @echo - @echo -e "\t${BOLD}env${RESET}: build a virtual env image." - @echo -e "\t${BOLD}sh_env_${RESET}: run a container using the virtual env image (debug purpose)." + @echo -e "\t${BOLD}${RESET}: build docker images for ALL DISTROS." + @echo -e "\t${BOLD}_${RESET}: build the docker image for a specific distro." + @echo -e "\t${BOLD}save_${RESET}: Save docker images for ALL DISTROS." + @echo -e "\t${BOLD}save__${RESET}: Save the docker image for a specific distro." + @echo -e "\t${BOLD}sh__${RESET}: run a container using the docker image specified (debug purpose)." @echo - @echo -e "\t${BOLD}devel${RESET}: build the library for all LANGUAGES and all DISTROS." - @echo -e "\t${BOLD}devel_${RESET}: build the library for all LANGUAGES using a specific distro." - @echo -e "\t${BOLD}devel_${RESET}: build the library for all DISTROS using a specific language." - @echo -e "\t${BOLD}devel__${RESET}: build the library using a specific distro and language." + @echo -e "\t${BOLD}${RESET}: build docker images for ALL DISTROS and ALL LANGUAGES." + @echo -e "\t${BOLD}_${RESET}: build docker images for a specific distro for ALL LANGUAGES." + @echo -e "\t${BOLD}_${RESET}: build docker images for ALL DISTROS for a specific language." + @echo -e "\t${BOLD}__${RESET}: build the docker image for a specific distro for a specific language." + @echo -e "\t${BOLD}save_${RESET}: Save docker images for ALL DISTROS for ALL LANGUAGES." + @echo -e "\t${BOLD}save__${RESET}: Save docker images for a specific distro for ALL LANGUAGES." + @echo -e "\t${BOLD}save__${RESET}: Save docker images for ALL DISTRO for a specific language." + @echo -e "\t${BOLD}save___${RESET}: Save the docker image for a specific distro for a specific language." + @echo -e "\t${BOLD}sh___${RESET}: run a container using the docker image specified (debug purpose)." @echo - @echo -e "\t${BOLD}test_${RESET}: auto test using the devel image." - @echo -e "\t${BOLD}test__${RESET}: auto test using the devel image." - @echo -e "\t${BOLD}sh__${RESET}: run a container using the devel image (debug purpose)." + @echo -e "\t${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}alpine${RESET} (edge)" + @echo -e "\t\t${BOLD}archlinux${RESET} (latest)" + @echo -e "\t\t${BOLD}centos${RESET} (latest)" + @echo -e "\t\t${BOLD}debian${RESET} (latest)" + @echo -e "\t\t${BOLD}fedora${RESET} (latest)" + @echo -e "\t\t${BOLD}opensuse${RESET} (tumbleweed)" + @echo -e "\t\t${BOLD}ubuntu${RESET} (rolling)" + @echo -e "\te.g. 'make test_ubuntu'" @echo - @echo -e "\t${BOLD}install${RESET}: execute the cmake target ${BOLD}install${RESET} using all devel image container, then create an install image with it." - @echo -e "\t${BOLD}install_${RESET}: execute the cmake target ${BOLD}install${RESET} using the devel image container specified, then create an install image with it." - @echo -e "\t${BOLD}test_install${RESET}: configure, build, install then test a sample project against it using all ${BOLD}install${RESET} image containers." - @echo -e "\t${BOLD}test_install_${RESET}: configure, build, install then test a sample project against it using the ${BOLD}install${RESET} image container specified." - @echo -e "\t${BOLD}sh_install__${RESET}: run a container using the install image (debug purpose)." - @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." + @echo -e "\t${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}base${RESET} (need by cpp)" + @echo -e "\t\t${BOLD}swig${RESET} (need by .Net, Java and Python)" + @echo -e "\te.g. 'make base'" @echo @echo -e "\t${BOLD}${RESET}:" @echo -e "\t\t${BOLD}cpp${RESET} (C++)" @@ -45,18 +55,20 @@ help: @echo -e "\t\t${BOLD}dotnet${RESET} (.Net Core >= 2.1)" @echo -e "\te.g. 'make devel_cpp'" @echo - @echo -e "\t${BOLD}${RESET}:" - @echo -e "\t\t${BOLD}alpine${RESET} (latest)" - @echo -e "\t\t${BOLD}archlinux${RESET} (latest)" - @echo -e "\t\t${BOLD}centos${RESET} (latest)" - @echo -e "\t\t${BOLD}debian${RESET} (latest)" - @echo -e "\t\t${BOLD}fedora${RESET} (latest)" - @echo -e "\t\t${BOLD}opensuse${RESET} (tumbleweed)" - @echo -e "\t\t${BOLD}ubuntu${RESET} (latest)" - @echo -e "\te.g. 'make devel_alpine'" + @echo -e "\t${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 -e "\t\t${BOLD}install_env${RESET}" + @echo -e "\t\t${BOLD}install_devel${RESET}" + @echo -e "\t\t${BOLD}install_build${RESET}" + @echo -e "\t\t${BOLD}install_test${RESET}" + @echo -e "\te.g. 'make build'" @echo - @echo -e "\tYou can also mix both using: ${BOLD}_${RESET}" - @echo -e "\te.g. 'make devel_alpine_cpp'" + @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." @echo @echo -e "\t${BOLD}NOCACHE=1${RESET}: use 'docker build --no-cache' when building container (default use cache)." @echo @@ -96,244 +108,196 @@ LANGUAGES = cpp python java dotnet # $< first prerequist # $@ target name -# ENV -targets = $(addprefix env_, $(DISTROS)) -.PHONY: env $(targets) -env: $(targets) -$(targets): env_%: cache/%/docker_env.tar -cache/%/docker_env.tar: docker/%/Dockerfile - @docker image rm -f ${IMAGE}:$*_env 2>/dev/null - ${DOCKER_BUILD_CMD} --target=env --tag ${IMAGE}:$*_env -f $< docker/$* - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_env -o $@ +############### +## PRESTAGES ## +############### +PRESTAGES = base swig +define make-prestage-target +#$$(info STAGE: $1) +#$$(info Create targets: $1 $(addsuffix _$1, $(DISTROS)).) +targets_$1 = $(addsuffix _$1, $(DISTROS)) +.PHONY: $1 $$(targets_$1) +$1: $$(targets_$1) +$$(targets_$1): %_$1: docker/%/Dockerfile + #@docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_$1 -f $$< .. -# Run a container using the env image. -targets = $(addprefix sh_env_, $(DISTROS)) -.PHONY: $(targets) -$(targets): sh_env_%: cache/%/docker_env.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$* ${IMAGE}:$*_env /bin/sh +#$$(info Create targets: save_$1 $(addprefix save_, $(addsuffix _$1, $(DISTROS))) (debug).) +save_targets_$1 = $(addprefix save_, $(addsuffix _$1, $(DISTROS))) +.PHONY: save_$1 $$(save_targets_$1) +save_$1: $$(save_targets_$1) +$$(save_targets_$1): save_%_$1: cache/%/docker_$1.tar +cache/%/docker_$1.tar: %_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_$1 -o $$@ -# DEVEL -.PHONY: devel -devel: $(addprefix devel_, $(DISTROS)) +#$$(info Create targets: $(addprefix sh_, $(addsuffix _$1, $(DISTROS))) (debug).) +sh_targets_$1 = $(addprefix sh_, $(addsuffix _$1, $(DISTROS))) +.PHONY: $$(sh_targets_$1) +$$(sh_targets_$1): sh_%_$1: %_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_$1 ${IMAGE}:$$*_$1 /bin/sh -distro_targets = $(addprefix devel_, $(DISTROS)) -.PHONY: $(distro_targets) -$(distro_targets): devel_%: $(addprefix devel_%_, $(LANGUAGES)) +#$$(info Create targets: $(addprefix clean_, $(addsuffix _$1, $(DISTROS))).) +clean_targets_$1 = $(addprefix clean_, $(addsuffix _$1, $(DISTROS))) +.PHONY: clean_$1 $$(clean_targets_$1) +clean_$1: $$(clean_targets_$1) +$$(clean_targets_$1): clean_%_$1: + docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null + rm -f cache/$$*/docker_$1.tar +endef -lang_targets = $(addprefix devel_, $(LANGUAGES)) -.PHONY: $(lang_targets) -$(lang_targets): devel_%: $(addsuffix _%, $(addprefix devel_, $(DISTROS))) +$(foreach stage,$(PRESTAGES),$(eval $(call make-prestage-target,$(stage)))) -distro_cpp_targets = $(addprefix devel_, $(addsuffix _cpp, $(DISTROS))) -distro_python_targets = $(addprefix devel_, $(addsuffix _python, $(DISTROS))) -distro_java_targets = $(addprefix devel_, $(addsuffix _java, $(DISTROS))) -distro_dotnet_targets = $(addprefix devel_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets) -$(distro_cpp_targets): devel_%_cpp: cache/%/docker_cpp.tar -$(distro_python_targets): devel_%_python: cache/%/docker_python.tar -$(distro_java_targets): devel_%_java: cache/%/docker_java.tar -$(distro_dotnet_targets): devel_%_dotnet: cache/%/docker_dotnet.tar +############ +## STAGES ## +############ +STAGES = env devel build test install_env install_devel install_build install_test +define make-stage-target +#$$(info STAGE: $1) +#$$(info Create targets: $1 $(addsuffix _$1, $(DISTROS)).) +targets_$1 = $(addsuffix _$1, $(DISTROS)) +.PHONY: $1 $$(targets_$1) +$1: $$(targets_$1) +$$(targets_$1): %_$1: $(addprefix %_, $(addsuffix _$1, $(LANGUAGES))) -cache/%/docker_cpp.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake - @echo building $@... - @docker image rm -f ${IMAGE}:$*_cpp 2>/dev/null - ${DOCKER_BUILD_CMD} --target=cpp --tag ${IMAGE}:$*_cpp -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_cpp -o $@ +#$$(info Create targets: $(addsuffix _$1, $(LANGUAGES)).) +targets_$1 = $(addsuffix _$1, $(LANGUAGES)) +.PHONY: $$(targets_$1) +$$(targets_$1): %_$1: $(addsuffix _$1, $(addsuffix _%, $(DISTROS))) -cache/%/docker_python.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake - @echo building $@... - @docker image rm -f ${IMAGE}:$*_python 2>/dev/null - ${DOCKER_BUILD_CMD} --target=python --tag ${IMAGE}:$*_python -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_python -o $@ +#$$(info Create targets: $(addsuffix _cpp_$1, $(DISTROS))) +cpp_targets_$1 = $(addsuffix _cpp_$1, $(DISTROS)) +#$$(info Create targets: $(addsuffix _dotnet_$1, $(DISTROS))) +dotnet_targets_$1 = $(addsuffix _dotnet_$1, $(DISTROS)) +#$$(info Create targets: $(addsuffix _java_$1, $(DISTROS))) +java_targets_$1 = $(addsuffix _java_$1, $(DISTROS)) +#$$(info Create targets: $(addsuffix _python_$1, $(DISTROS))) +python_targets_$1 = $(addsuffix _python_$1, $(DISTROS)) +.PHONY: $$(cpp_targets_$1) $$(dotnet_targets_$1) $$(java_targets_$1) $$(python_targets_$1) -cache/%/docker_java.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake - @echo building $@... - @docker image rm -f ${IMAGE}:$*_java 2>/dev/null - ${DOCKER_BUILD_CMD} --target=java --tag ${IMAGE}:$*_java -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_java -o $@ +$$(cpp_targets_$1): %_cpp_$1: docker/%/cpp.Dockerfile %_base + #@docker image rm -f ${IMAGE}:$$*_cpp_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_cpp_$1 -f $$< .. +$$(dotnet_targets_$1): %_dotnet_$1: docker/%/dotnet.Dockerfile %_swig + #@docker image rm -f ${IMAGE}:$$*_dotnet_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_dotnet_$1 -f $$< .. +$$(java_targets_$1): %_java_$1: docker/%/java.Dockerfile %_swig + #@docker image rm -f ${IMAGE}:$$*_java_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_java_$1 -f $$< .. +$$(python_targets_$1): %_python_$1: docker/%/python.Dockerfile %_swig + #@docker image rm -f ${IMAGE}:$$*_python_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_python_$1 -f $$< .. -cache/%/docker_dotnet.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake - @echo building $@... - @docker image rm -f ${IMAGE}:$*_dotnet 2>/dev/null - ${DOCKER_BUILD_CMD} --target=dotnet --tag ${IMAGE}:$*_dotnet -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_dotnet -o $@ +# Save $1 docker images (debug). +#$$(info Create targets: save_$1 $(addprefix save_, $(addsuffix _$1, $(DISTROS))).) +targets_$1 = $(addprefix save_, $(addsuffix _$1, $(DISTROS))) +.PHONY: save_$1 $$(targets_$1) +save_$1: $$(targets_$1) +$$(targets_$1): save_%_$1: $(addprefix save_%_, $(addsuffix _$1, $(LANGUAGES))) -# DOCKER BASH INSTALL (debug) -distro_cpp_targets = $(addprefix sh_, $(addsuffix _cpp, $(DISTROS))) -distro_python_targets = $(addprefix sh_, $(addsuffix _python, $(DISTROS))) -distro_java_targets = $(addprefix sh_, $(addsuffix _java, $(DISTROS))) -distro_dotnet_targets = $(addprefix sh_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets) +#$$(info Create targets: $(addprefix save_, $(addsuffix _$1, $(LANGUAGES))).) +targets_$1 = $(addprefix save_, $(addsuffix _$1, $(LANGUAGES))) +.PHONY: $$(targets_$1) +$$(targets_$1): save_%_$1: $(addprefix save_, $(addsuffix _%_$1, $(DISTROS))) -$(distro_cpp_targets): sh_%_cpp: cache/%/docker_cpp.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_cpp ${IMAGE}:$*_cpp /bin/sh -$(distro_python_targets): sh_%_python: cache/%/docker_python.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_python ${IMAGE}:$*_python /bin/sh -$(distro_java_targets): sh_%_java: cache/%/docker_java.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_java ${IMAGE}:$*_java /bin/sh -$(distro_dotnet_targets): sh_%_dotnet: cache/%/docker_dotnet.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_dotnet ${IMAGE}:$*_dotnet /bin/sh +#$$(info Create targets: $(addprefix save_, $(addsuffix _cpp_$1, $(DISTROS)))) +cpp_targets_$1 = $(addprefix save_, $(addsuffix _cpp_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix save_, $(addsuffix _dotnet_$1, $(DISTROS)))) +dotnet_targets_$1 = $(addprefix save_, $(addsuffix _dotnet_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix save_, $(addsuffix _java_$1, $(DISTROS)))) +java_targets_$1 = $(addprefix save_, $(addsuffix _java_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix save_, $(addsuffix _python_$1, $(DISTROS)))) +python_targets_$1 = $(addprefix save_, $(addsuffix _python_$1, $(DISTROS))) +.PHONY: $$(cpp_targets_$1) $$(dotnet_targets_$1) $$(java_targets_$1) $$(python_targets_$1) -# TEST DEVEL -.PHONY: test -test: $(addprefix test_, $(DISTROS)) +$$(cpp_targets_$1): save_%_cpp_$1: cache/%/docker_cpp_$1.tar +cache/%/docker_cpp_$1.tar: %_cpp_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_cpp_$1 -o $$@ +$$(dotnet_targets_$1): save_%_dotnet_$1: cache/%/docker_dotnet_$1.tar +cache/%/docker_dotnet_$1.tar: %_dotnet_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_dotnet_$1 -o $$@ +$$(java_targets_$1): save_%_java_$1: cache/%/docker_java_$1.tar +cache/%/docker_java_$1.tar: %_java_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_java_$1 -o $$@ +$$(python_targets_$1): save_%_python_$1: cache/%/docker_python_$1.tar +cache/%/docker_python_$1.tar: %_python_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_python_$1 -o $$@ -distro_targets = $(addprefix test_, $(DISTROS)) -.PHONY: $(distro_targets) -$(distro_targets): test_%: $(addprefix test_%_, $(LANGUAGES)) +# Run a container using the __$1 image (debug). +#$$(info Create targets: $(addprefix sh_, $(addsuffix _cpp_$1, $(DISTROS)))) +cpp_targets_$1 = $(addprefix sh_, $(addsuffix _cpp_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix sh_, $(addsuffix _dotnet_$1, $(DISTROS)))) +dotnet_targets_$1 = $(addprefix sh_, $(addsuffix _dotnet_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix sh_, $(addsuffix _java_$1, $(DISTROS)))) +java_targets_$1 = $(addprefix sh_, $(addsuffix _java_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix sh_, $(addsuffix _python_$1, $(DISTROS)))) +python_targets_$1 = $(addprefix sh_, $(addsuffix _python_$1, $(DISTROS))) +.PHONY: $$(cpp_targets_$1) $$(dotnet_targets_$1) $$(java_targets_$1) $$(python_targets_$1) -lang_targets = $(addprefix test_, $(LANGUAGES)) -.PHONY: $(lang_targets) -$(lang_targets): test_%: $(addsuffix _%, $(addprefix test_, $(DISTROS))) +$$(cpp_targets): sh_%_cpp_$1: %_cpp_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_cpp_$1 ${IMAGE}:$$*_cpp_$1 /bin/sh +$$(dotnet_targets): sh_%_dotnet_$1: %_dotnet_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_dotnet_$1 ${IMAGE}:$$*_dotnet_$1 /bin/sh +$$(java_targets): sh_%_java_$1: %_java_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_java_$1 ${IMAGE}:$$*_java_$1 /bin/sh +$$(python_targets): sh_%_python_$1: %_python_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_python_$1 ${IMAGE}:$$*_python_$1 /bin/sh -distro_cpp_targets = $(addprefix test_, $(addsuffix _cpp, $(DISTROS))) -distro_python_targets = $(addprefix test_, $(addsuffix _python, $(DISTROS))) -distro_java_targets = $(addprefix test_, $(addsuffix _java, $(DISTROS))) -distro_dotnet_targets = $(addprefix test_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets) +# Clean $1 docker images. +#$$(info Create targets: clean_$1 $(addprefix clean_, $(addsuffix _$1, $(DISTROS))).) +targets_$1 = $(addprefix clean_, $(addsuffix _$1, $(DISTROS))) +.PHONY: clean_$1 $(targets_$1) +clean_$1: $$(targets_$1) +$$(targets_$1): clean_%_$1: $(addprefix clean_%_, $(addsuffix _$1, $(LANGUAGES))) -$(distro_cpp_targets): test_%_cpp: cache/%/docker_cpp.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_cpp ${IMAGE}:$*_cpp cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1 -$(distro_python_targets): test_%_python: cache/%/docker_python.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_python ${IMAGE}:$*_python cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1 -$(distro_java_targets): test_%_java: cache/%/docker_java.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_java ${IMAGE}:$*_java cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1 -$(distro_dotnet_targets): test_%_dotnet: cache/%/docker_dotnet.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_dotnet ${IMAGE}:$*_dotnet cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1 +#$$(info Create targets: $(addprefix clean_, $(addsuffix _$1, $(LANGUAGES))).) +targets_$1 = $(addprefix clean_, $(addsuffix _$1, $(LANGUAGES))) +.PHONY: $$(targets_$1) +$$(targets_$1): clean_%_$1: $(addprefix clean_, $(addsuffix _%_$1, $(DISTROS))) -# INSTALL -.PHONY: install -install: $(addprefix install_, $(DISTROS)) +#$$(info Create targets: $(addprefix clean_, $(addsuffix _cpp_$1, $(DISTROS)))) +cpp_targets_$1 = $(addprefix clean_, $(addsuffix _cpp_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix clean_, $(addsuffix _dotnet_$1, $(DISTROS)))) +dotnet_targets_$1 = $(addprefix clean_, $(addsuffix _dotnet_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix clean_, $(addsuffix _java_$1, $(DISTROS)))) +java_targets_$1 = $(addprefix clean_, $(addsuffix _java_$1, $(DISTROS))) +#$$(info Create targets: $(addprefix clean_, $(addsuffix _python_$1, $(DISTROS)))) +python_targets_$1 = $(addprefix clean_, $(addsuffix _python_$1, $(DISTROS))) +.PHONY: $$(cpp_targets_$1) $$(dotnet_targets_$1) $$(java_targets_$1) $$(python_targets_$1) -distro_targets = $(addprefix install_, $(DISTROS)) -.PHONY: $(distro_targets) -$(distro_targets): install_%: $(addprefix install_%_, $(LANGUAGES)) +$$(cpp_targets_$1): clean_%_cpp_$1: + docker image rm -f ${IMAGE}:$$*_cpp_$1 2>/dev/null + rm -f cache/$$*/docker_cpp_$1.tar +$$(dotnet_targets_$1): clean_%_dotnet_$1: + docker image rm -f ${IMAGE}:$$*_dotnet_$1 2>/dev/null + rm -f cache/$$*/docker_dotnet_$1.tar +$$(java_targets_$1): clean_%_java_$1: + docker image rm -f ${IMAGE}:$$*_java_$1 2>/dev/null + rm -f cache/$$*/docker_java_$1.tar +$$(python_targets_$1): clean_%_python_$1: + docker image rm -f ${IMAGE}:$$*_python_$1 2>/dev/null + rm -f cache/$$*/docker_python_$1.tar +endef -lang_targets = $(addprefix install_, $(LANGUAGES)) -.PHONY: $(lang_targets) -$(lang_targets): install_%: $(addsuffix _%, $(addprefix install_, $(DISTROS))) - -distro_cpp_targets = $(addprefix install_, $(addsuffix _cpp, $(DISTROS))) -distro_python_targets = $(addprefix install_, $(addsuffix _python, $(DISTROS))) -distro_java_targets = $(addprefix install_, $(addsuffix _java, $(DISTROS))) -distro_dotnet_targets = $(addprefix install_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets) -$(distro_cpp_targets): install_%_cpp: cache/%/docker_install_cpp.tar -$(distro_python_targets): install_%_python: cache/%/docker_install_python.tar -$(distro_java_targets): install_%_java: cache/%/docker_install_java.tar -$(distro_dotnet_targets): install_%_dotnet: cache/%/docker_install_dotnet.tar - -cache/%/docker_install_cpp.tar: docker/%/Dockerfile sample_cpp - @docker image rm -f ${IMAGE}:$*_install_cpp 2>/dev/null - ${DOCKER_BUILD_CMD} --target=install_cpp --tag ${IMAGE}:$*_install_cpp -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_install_cpp -o $@ - -cache/%/docker_install_python.tar: docker/%/Dockerfile sample_python - @docker image rm -f ${IMAGE}:$*_install_python 2>/dev/null - ${DOCKER_BUILD_CMD} --target=install_python --tag ${IMAGE}:$*_install_python -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_install_python -o $@ - -cache/%/docker_install_java.tar: docker/%/Dockerfile sample_java - @docker image rm -f ${IMAGE}:$*_install_java 2>/dev/null - ${DOCKER_BUILD_CMD} --target=install_java --tag ${IMAGE}:$*_install_java -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_install_java -o $@ - -cache/%/docker_install_dotnet.tar: docker/%/Dockerfile sample_dotnet - @docker image rm -f ${IMAGE}:$*_install_dotnet 2>/dev/null - ${DOCKER_BUILD_CMD} --target=install_dotnet --tag ${IMAGE}:$*_install_dotnet -f $< .. - @rm -f $@ - mkdir -p cache/$* - docker save ${IMAGE}:$*_install_dotnet -o $@ - -# DOCKER BASH INSTALL (debug) -distro_cpp_targets = $(addprefix sh_install_, $(addsuffix _cpp, $(DISTROS))) -.PHONY: $(distro_cpp_targets) -distro_python_targets = $(addprefix sh_install_, $(addsuffix _python, $(DISTROS))) -.PHONY: $(distro_python_targets) -distro_java_targets = $(addprefix sh_install_, $(addsuffix _java, $(DISTROS))) -.PHONY: $(distro_java_targets) -distro_dotnet_targets = $(addprefix sh_install_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_dotnet_targets) - -$(distro_cpp_targets): sh_install_%_cpp: cache/%/docker_install_cpp.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_cpp ${IMAGE}:$*_install_cpp /bin/sh -$(distro_python_targets): sh_install_%_python: cache/%/docker_install_python.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_python ${IMAGE}:$*_install_python /bin/sh -$(distro_java_targets): sh_install_%_java: cache/%/docker_install_java.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_java ${IMAGE}:$*_install_java /bin/sh -$(distro_dotnet_targets): sh_install_%_dotnet: cache/%/docker_install_dotnet.tar - ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_dotnet ${IMAGE}:$*_install_dotnet /bin/sh - -# TEST INSTALL# -.PHONY: test_install -test_install: $(addprefix test_install, $(DISTROS)) - -distro_targets = $(addprefix test_install_, $(DISTROS)) -.PHONY: $(distro_targets) -$(distro_targets): test_install_%: $(addprefix test_install_%_, cpp) - -distro_cpp_targets = $(addprefix test_install_, $(addsuffix _cpp, $(DISTROS))) -distro_python_targets = $(addprefix test_install_, $(addsuffix _python, $(DISTROS))) -distro_java_targets = $(addprefix test_install_, $(addsuffix _java, $(DISTROS))) -distro_dotnet_targets = $(addprefix test_install_, $(addsuffix _dotnet, $(DISTROS))) -.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets) - -$(distro_cpp_targets): test_install_%_cpp: cache/%/docker_install_cpp.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_cpp ${IMAGE}:$*_install_cpp /bin/sh -c \ - "cmake -H. -Bbuild; \ - cmake --build build --target all; \ - cmake --build build --target test; \ - cmake --build build --target install" - -$(distro_python_targets): test_install_%_python: cache/%/docker_install_python.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_python ${IMAGE}:$*_install_python /bin/sh -c \ - "./sample.py" - -$(distro_java_targets): test_install_%_java: cache/%/docker_install_java.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_java ${IMAGE}:$*_install_java /bin/sh -c \ - "java sample.java" - -$(distro_dotnet_targets): test_install_%_dotnet: cache/%/docker_install_dotnet.tar - ${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_dotnet ${IMAGE}:$*_install_dotnet /bin/sh -c \ - "dotnet build; \ - dotnet run --project sample.csproj" +$(foreach stage,$(STAGES),$(eval $(call make-stage-target,$(stage)))) # CLEAN targets = $(addprefix clean_, $(DISTROS)) .PHONY: clean $(targets) clean: $(targets) - -rmdir cache -$(targets): clean_%: docker container prune -f docker image prune -f - -docker image rm -f ${IMAGE}:$*_install_cpp 2>/dev/null - -docker image rm -f ${IMAGE}:$*_dotnet 2>/dev/null - -docker image rm -f ${IMAGE}:$*_java 2>/dev/null - -docker image rm -f ${IMAGE}:$*_python 2>/dev/null - -docker image rm -f ${IMAGE}:$*_cpp 2>/dev/null - -docker image rm -f ${IMAGE}:$*_env 2>/dev/null - -rm -f cache/$*/docker_install_cpp.tar - -rm -f cache/$*/docker_dotnet.tar - -rm -f cache/$*/docker_java.tar - -rm -f cache/$*/docker_python.tar - -rm -f cache/$*/docker_cpp.tar - -rm -f cache/$*/docker_env.tar + -rmdir cache +$(targets): clean_%: $(addprefix clean_%_, $(PRESTAGES)) $(addprefix clean_%_, $(STAGES)) -rmdir cache/$* .PHONY: distclean diff --git a/cmake/README.md b/cmake/README.md index 13b55da061..a1787d06c3 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -43,6 +43,7 @@ .Net Core | Java | Integration | +CI | OR-Tools comes with a CMake based build ([CMakeLists.txt](../CMakeLists.txt)) diff --git a/cmake/doc/ci.md b/cmake/doc/ci.md new file mode 100644 index 0000000000..e726afc192 --- /dev/null +++ b/cmake/doc/ci.md @@ -0,0 +1,37 @@ +# CI: Makefile/Docker testing +To test the build on various distro, I'm using docker containers and a Makefile for orchestration. + +pros: +* You are independent of third party CI runner config (e.g. github actions runners or Travis-CI VM images). +* You can run it locally on your linux system. +* Most CI provide runner with docker and Makefile installed (e.g. tarvis-ci [minimal images](https://docs.travis-ci.com/user/languages/minimal-and-generic/). + +cons: +* Only GNU/Linux distro supported. +* Could take few GiB (~30 GiB for all distro and all languages) + * ~500MiB OS + C++/CMake tools, + * ~150 MiB Python, + * ~400 MiB dotnet-sdk, + * ~400 MiB java-jdk. + +# Usage +To get the help simply type: +```sh +make +``` + +note: you can also use from top directory +```sh +make --directory=ci +``` + +## Example +For example to test `Python` inside an `Alpine` container: +```sh +make test_alpine_python +``` + +# Docker layers +Dockerfile is splitted in several stages. + +![docker](docker.svg) diff --git a/cmake/doc/cmake.svg b/cmake/doc/cmake.svg new file mode 100644 index 0000000000..ce3a454a11 --- /dev/null +++ b/cmake/doc/cmake.svg @@ -0,0 +1,684 @@ + + + + + + +CMake + + +clusterPrerequisite + +Prerequisite + + +clusterOR + +OR-Tools (CMake) + + +clusterDeps + +Dependencies +(-DBUILD_DEPS=ON) + + +clusterZLIB + +madler/zlib.git + cmake patch + + +clusterAbsl + +abseil/abseil-cpp.git + + +clusterGFlags + +gflags/gflags.git + + +clusterGLog + +google/glog.git + + +clusterProtobuf + +protocolbuffers/protobuf.git + + +clusterCoinOR + +Coin-OR Solver +(-DUSE_COINOR=ON) + + +clusterCoinUtils + +mizux/CoinUtils.git + + +clusterOsi + +mizux/Osi.git + + +clusterClp + +mizux/Clp.git + + +clusterCgl + +mizux/Cgl.git + + +clusterCbc + +mizux/Cbc.git + + +clusterCXX + +C++ +(-DBUILD_CXX=ON) + + +clusterCXXTest + +Examples +(-DENABLE_TESTING=ON) + + +clusterPython + +Python +(-DBUILD_PYTHON=ON) + + +clusterPythonTest + +Examples +(-DENABLE_TESTING=ON) + + +clusterJava + +Java +(-DBUILD_JAVA=ON) + + +clusterJavaTest + +Examples +(-DENABLE_TESTING=ON) + + +clusterNet + +.Net +(-DBUILD_DOTNET=ON) + + +clusterNetTest + +Examples +(-DENABLE_TESTING=ON) + + + +CM + +CMake + + + +SWIG + +Swig +(Unix) + + + +CM->SWIG + + + +PY + +Python +(3.5+) + + + +SWIG->PY + + + +Java + +Java +(openJDK 8+) + + + +SWIG->Java + + + +Dotnet + +.Net Core SDK +(3.0.101) + + + +SWIG->Dotnet + + + +ZLIB + +ZLIB::ZLIB + + + +OR_SRC + + + +OR-Tools src + + + +ZLIB->OR_SRC + + + + + +Absl + +absl::absl_* + + + +Absl->OR_SRC + + + + + +GFlags + +gflags::gflags + + + +GFlags->OR_SRC + + + + + +GLog + +glog::glog + + + +GLog->OR_SRC + + + + + +Protobuf + +protobuf::libprotobuf + + + +Protobuf->OR_SRC + + + + + +CoinUtils + +Coin::CoinUtils + + + +Osi + +Coin::Osi + + + +CoinUtils->Osi + + + + + +Clp + +Coin::Clp + + + +CoinUtils->Clp + + + + + +OsiClp + +Coin::OsiClp + + + +CoinUtils->OsiClp + + + + + +Cgl + +Coin::Cgl + + + +CoinUtils->Cgl + + + + + +Cbc + +Coin::Cbc + + + +CoinUtils->Cbc + + + + + +OsiCbc + +Coin::OsiCbc + + + +CoinUtils->OsiCbc + + + + + +Osi->Clp + + + + + +Osi->OsiClp + + + + + +Osi->Cgl + + + + + +Osi->Cbc + + + + + +Osi->OsiCbc + + + + + +Clp->OsiClp + + + + + +ClpSolver + +Coin::ClpSolver + + + +Clp->ClpSolver + + + + + +Clp->Cbc + + + + + +OsiClp->Cgl + + + + + +ClpSolver->OR_SRC + + + + + +Cgl->Cbc + + + + + +Cbc->OsiCbc + + + + + +CbcSolver + +Coin::CbcSolver + + + +Cbc->CbcSolver + + + + + +CbcSolver->OR_SRC + + + + + +SWIG_WIN + +swigwin +(Windows) + + + +OR_CPP + +ortools::ortools + + + +OR_SRC->OR_CPP + + + + + +OR_WPY + + + +C++ Python wrappers + + + +OR_SRC->OR_WPY + + +swig + + + +OR_PY + + + +Python files + + + +OR_SRC->OR_PY + + +swig + + + +OR_WJAVA + + + +C++ Java wrappers + + + +OR_SRC->OR_WJAVA + + +swig + + + +OR_JAVA + + + +Java files + + + +OR_SRC->OR_JAVA + + +swig + + + +OR_WNET + + + +C++ .Net wrappers + + + +OR_SRC->OR_WNET + + +swig + + + +OR_NET + + + +.Net files + + + +OR_SRC->OR_NET + + +swig + + + +PKG_CPP + + + + +CMake Package + + + +OR_CPP->PKG_CPP + + +WIP + + + +EX_CPP + +C++ samples + + + +PKG_CPP->EX_CPP + + + + + +OR_WPY->OR_PY + + + + + +PKG_PY + + + + +Wheel package + + + +OR_PY->PKG_PY + + + + + +EX_PY + +Python samples + + + +PKG_PY->EX_PY + + + + + +OR_WJAVA->OR_JAVA + + + + + +PKG_JAVA + + + + +Maven package + + + +OR_JAVA->PKG_JAVA + + + + + +EX_JAVA + +Java samples + + + +PKG_JAVA->EX_JAVA + + + + + +OR_WNET->OR_NET + + + + + +PKG_NET_RT + + + + +Nuget runtime package +Google.OrTools.runtime.rid.nupkg + + + +OR_WNET->PKG_NET_RT + + + + + +PKG_NET + + + + +Nuget package +Google.OrTools.nupkg + + + +OR_NET->PKG_NET + + + + + +PKG_NET_RT->PKG_NET + + + + + +EX_NET + +.Net samples + + + +PKG_NET->EX_NET + + + + + diff --git a/cmake/doc/deps.svg b/cmake/doc/deps.svg new file mode 100644 index 0000000000..290f427d27 --- /dev/null +++ b/cmake/doc/deps.svg @@ -0,0 +1,292 @@ + + + + + + +CMakeDeps + + +clusterZLIB + +madler/zlib.git + cmake patch + + +clusterAbsl + +abseil/abseil-cpp.git + + +clusterGFlags + +gflags/gflags.git + + +clusterGLog + +google/glog.git + + +clusterProtobuf + +protocolbuffers/protobuf.git + + +clusterCoinOR + +-DUSE_COINOR=ON AND -DBUILD_DEPS=ON + + +clusterCoinUtils + +CoinUtils.git + + +clusterOsi + +Osi.git + + +clusterClp + +Clp.git + + +clusterCgl + +Cgl.git + + +clusterCbc + +Cbc.git + + + +ZLIB + +ZLIB::ZLIB + + + +Protobuf + +protobuf::libprotobuf + + + +ZLIB->Protobuf + + + + + +Cbc + +Coin::Cbc + + + +ZLIB->Cbc + + + + + +Absl + +absl::absl_* + + + +Absl->Protobuf + + + + + +GFlags + +gflags::gflags + + + +GLog + +glog::glog + + + +GFlags->GLog + + + + + +Protoc + + + +protobuf::protoc + + + +CoinUtils + +Coin::CoinUtils + + + +Osi + +Coin::Osi + + + +CoinUtils->Osi + + + + + +Clp + +Coin::Clp + + + +CoinUtils->Clp + + + + + +OsiClp + +Coin::OsiClp + + + +CoinUtils->OsiClp + + + + + +Cgl + +Coin::Cgl + + + +CoinUtils->Cgl + + + + + +CoinUtils->Cbc + + + + + +OsiCbc + +Coin::OsiCbc + + + +CoinUtils->OsiCbc + + + + + +Osi->Clp + + + + + +Osi->OsiClp + + + + + +Osi->Cgl + + + + + +Osi->Cbc + + + + + +Osi->OsiCbc + + + + + +Clp->OsiClp + + + + + +ClpSolver + +Coin::ClpSolver + + + +Clp->ClpSolver + + + + + +Clp->Cbc + + + + + +OsiClp->Cgl + + + + + +Cgl->Cbc + + + + + +Cbc->OsiCbc + + + + + +CbcSolver + +Coin::CbcSolver + + + +Cbc->CbcSolver + + + + + diff --git a/cmake/doc/docker.dot b/cmake/doc/docker.dot new file mode 100644 index 0000000000..a05ba48196 --- /dev/null +++ b/cmake/doc/docker.dot @@ -0,0 +1,85 @@ +@startdot +digraph DockerDeps { + //rankdir=BT; + rankdir=TD; + node [shape=cylinder, style="rounded,filled", color=black, fillcolor=royalblue]; + DISTRO_IMG [label=":latest"]; + PKG [label="Build packages\ne.g. cmake, g++", shape=box3d]; + PYPKG [label="Python packages\ne.g. python-dev", shape=box3d, fillcolor=gold]; + JAVAPKG [label="Java packages\ne.g. openjdk", shape=box3d, fillcolor=crimson]; + DOTNETPKG [label=".Net packages\ne.g. dotnet-cli", shape=box3d, fillcolor=forestgreen]; + SRC [label="git repo", shape=folder]; + SAMPLE [label="sample", shape=folder]; + + subgraph clusterDockerfile { + BASE_IMG [label="ortools:_base\nbase"]; + SWIG_IMG [label="ortools:_swig\nswig"]; + + BASE_IMG -> SWIG_IMG; + + color=royalblue; + label = "docker//Dockerfile"; + } + DISTRO_IMG -> BASE_IMG; + PKG -> BASE_IMG [label="install", style="dashed"]; + +// LANG + subgraph clusterLang { + LANGENV_IMG [label="ortools:__env\nenv"]; + LANGDEVEL_IMG [label="ortools:__devel\ndevel"]; + LANGBUILD_IMG [label="ortools:__build\nbuild"]; + LANGTEST_IMG [label="ortools:__test\ntest"]; + LANGINSTALLENV_IMG [label="ortools:__install_env\ninstall_env"]; + LANGINSTALLDEVEL_IMG [label="ortools:__install_devel\ninstall_devel"]; + LANGINSTALLBUILD_IMG [label="ortools:__install_build\ninstall_build"]; + LANGINSTALLTEST_IMG [label="ortools:__install_test\ninstall_test"]; + + LANGENV_IMG -> LANGDEVEL_IMG; + LANGDEVEL_IMG -> LANGBUILD_IMG; + LANGBUILD_IMG -> LANGTEST_IMG; + LANGBUILD_IMG -> LANGINSTALLENV_IMG [label="copy install", style="dashed"]; + LANGENV_IMG -> LANGINSTALLENV_IMG; + LANGINSTALLENV_IMG -> LANGINSTALLDEVEL_IMG; + LANGINSTALLDEVEL_IMG -> LANGINSTALLBUILD_IMG; + LANGINSTALLBUILD_IMG -> LANGINSTALLTEST_IMG; + + color=royalblue; + label = "docker//.Dockerfile"; + } + SWIG_IMG -> LANGENV_IMG; + PYPKG -> LANGENV_IMG [label="install", style="dashed"]; + JAVAPKG -> LANGENV_IMG [label="install", style="dashed"]; + DOTNETPKG -> LANGENV_IMG [label="install", style="dashed"]; + SRC -> LANGDEVEL_IMG [label="copy", style="dashed"]; + SAMPLE -> LANGINSTALLDEVEL_IMG [label="copy", style="dashed"]; + + subgraph clusterCache { + node [shape=note, style="rounded,filled", color=black, fillcolor=royalblue]; + BASE_TAR [label="docker_base.tar"]; + SWIG_TAR [label="docker_swig.tar"]; + LANGENV_TAR [label="docker__env.tar"]; + LANGDEVEL_TAR [label="docker__devel.tar"]; + LANGBUILD_TAR [label="docker__build.tar"]; + LANGTEST_TAR [label="docker__test.tar"]; + LANGINSTALLENV_TAR [label="docker__install_env.tar"]; + LANGINSTALLDEVEL_TAR [label="docker__install_devel.tar"]; + LANGINSTALLBUILD_TAR [label="docker__install_build.tar"]; + LANGINSTALLTEST_TAR [label="docker__install_test.tar"]; + + edge [color=red]; + BASE_IMG -> BASE_TAR [label="make save__base"]; + SWIG_IMG -> SWIG_TAR [label="make save__swig"]; + LANGENV_IMG -> LANGENV_TAR [label="make save___env"]; + LANGDEVEL_IMG -> LANGDEVEL_TAR [label="make save___devel"]; + LANGBUILD_IMG -> LANGBUILD_TAR [label="make save___build"]; + LANGTEST_IMG -> LANGTEST_TAR [label="make save___test"]; + LANGINSTALLENV_IMG -> LANGINSTALLENV_TAR [label="make save___install_env"]; + LANGINSTALLDEVEL_IMG -> LANGINSTALLDEVEL_TAR [label="make save___install_devel"]; + LANGINSTALLBUILD_IMG -> LANGINSTALLBUILD_TAR [label="make save___install_build"]; + LANGINSTALLTEST_IMG -> LANGINSTALLTEST_TAR [label="make save___install_test"]; + + color=royalblue; + label = "cache//"; + } +} +@enddot diff --git a/cmake/doc/docker.svg b/cmake/doc/docker.svg new file mode 100644 index 0000000000..e54ea12587 --- /dev/null +++ b/cmake/doc/docker.svg @@ -0,0 +1,426 @@ + + + + + + +DockerDeps + + +clusterDockerfile + +docker/<distro>/Dockerfile + + +clusterLang + +docker/<distro>/<lang>.Dockerfile + + +clusterCache + +cache/<distro>/ + + + +DISTRO_IMG + + +<distro>:latest + + + +BASE_IMG + + +ortools:<distro>_base +base + + + +DISTRO_IMG->BASE_IMG + + + + + +PKG + + + + +Build packages +e.g. cmake, g++ + + + +PKG->BASE_IMG + + +install + + + +PYPKG + + + + +Python packages +e.g. python-dev + + + +LANGENV_IMG + + +ortools:<distro>_<lang>_env +env + + + +PYPKG->LANGENV_IMG + + +install + + + +JAVAPKG + + + + +Java packages +e.g. openjdk + + + +JAVAPKG->LANGENV_IMG + + +install + + + +DOTNETPKG + + + + +.Net packages +e.g. dotnet-cli + + + +DOTNETPKG->LANGENV_IMG + + +install + + + +SRC + +git repo + + + +LANGDEVEL_IMG + + +ortools:<distro>_<lang>_devel +devel + + + +SRC->LANGDEVEL_IMG + + +copy + + + +SAMPLE + +sample + + + +LANGINSTALLDEVEL_IMG + + +ortools:<distro>_<lang>_install_devel +install_devel + + + +SAMPLE->LANGINSTALLDEVEL_IMG + + +copy + + + +SWIG_IMG + + +ortools:<distro>_swig +swig + + + +BASE_IMG->SWIG_IMG + + + + + +BASE_TAR + + + +docker_base.tar + + + +BASE_IMG->BASE_TAR + + +make save_<distro>_base + + + +SWIG_IMG->LANGENV_IMG + + + + + +SWIG_TAR + + + +docker_swig.tar + + + +SWIG_IMG->SWIG_TAR + + +make save_<distro>_swig + + + +LANGENV_IMG->LANGDEVEL_IMG + + + + + +LANGINSTALLENV_IMG + + +ortools:<distro>_<lang>_install_env +install_env + + + +LANGENV_IMG->LANGINSTALLENV_IMG + + + + + +LANGENV_TAR + + + +docker_<lang>_env.tar + + + +LANGENV_IMG->LANGENV_TAR + + +make save_<distro>_<lang>_env + + + +LANGBUILD_IMG + + +ortools:<distro>_<lang>_build +build + + + +LANGDEVEL_IMG->LANGBUILD_IMG + + + + + +LANGDEVEL_TAR + + + +docker_<lang>_devel.tar + + + +LANGDEVEL_IMG->LANGDEVEL_TAR + + +make save_<distro>_<lang>_devel + + + +LANGTEST_IMG + + +ortools:<distro>_<lang>_test +test + + + +LANGBUILD_IMG->LANGTEST_IMG + + + + + +LANGBUILD_IMG->LANGINSTALLENV_IMG + + +copy install + + + +LANGBUILD_TAR + + + +docker_<lang>_build.tar + + + +LANGBUILD_IMG->LANGBUILD_TAR + + +make save_<distro>_<lang>_build + + + +LANGTEST_TAR + + + +docker_<lang>_test.tar + + + +LANGTEST_IMG->LANGTEST_TAR + + +make save_<distro>_<lang>_test + + + +LANGINSTALLENV_IMG->LANGINSTALLDEVEL_IMG + + + + + +LANGINSTALLENV_TAR + + + +docker_<lang>_install_env.tar + + + +LANGINSTALLENV_IMG->LANGINSTALLENV_TAR + + +make save_<distro>_<lang>_install_env + + + +LANGINSTALLBUILD_IMG + + +ortools:<distro>_<lang>_install_build +install_build + + + +LANGINSTALLDEVEL_IMG->LANGINSTALLBUILD_IMG + + + + + +LANGINSTALLDEVEL_TAR + + + +docker_<lang>_install_devel.tar + + + +LANGINSTALLDEVEL_IMG->LANGINSTALLDEVEL_TAR + + +make save_<distro>_<lang>_install_devel + + + +LANGINSTALLTEST_IMG + + +ortools:<distro>_<lang>_install_test +install_test + + + +LANGINSTALLBUILD_IMG->LANGINSTALLTEST_IMG + + + + + +LANGINSTALLBUILD_TAR + + + +docker_<lang>_install_build.tar + + + +LANGINSTALLBUILD_IMG->LANGINSTALLBUILD_TAR + + +make save_<distro>_<lang>_install_build + + + +LANGINSTALLTEST_TAR + + + +docker_<lang>_install_test.tar + + + +LANGINSTALLTEST_IMG->LANGINSTALLTEST_TAR + + +make save_<distro>_<lang>_install_test + + + diff --git a/cmake/doc/dotnet.md b/cmake/doc/dotnet.md index 8c0fcd5eab..b7322386ac 100644 --- a/cmake/doc/dotnet.md +++ b/cmake/doc/dotnet.md @@ -15,7 +15,7 @@ Try to build a .NetStandard2.0 native (for win-x64, linux-x64 and osx-x64) nuget # Build the Binary Packages To build the .Net nuget packages, simply run: ```sh -cmake -S. -Bbuild -DBUILD_DOTNET=ON +cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON cmake --build build --target dotnet_package -v ``` note: Since `dotnet_package` is in target `all`, you can also ommit the @@ -82,14 +82,14 @@ src: `tree build/dotnet --prune -I "obj|bin"` * [Requirement](#requirement) * [Directory Layout](#directory-layout) * [Build Process](#build-process) - * [Local Mizux.CMakeSwig Package](#local-mizuxfoo-package) - * [Building a runtime Mizux.CMakeSwig Package](#building-local-runtime-mizuxfoo-package) - * [Building a Local Mizux.CMakeSwig Package](#building-local-mizuxfoo-package) - * [Testing the Local Mizux.CMakeSwig Package](#testing-local-mizuxfoo-package) - * [Complete Mizux.CMakeSwig Package](#complete-mizuxfoo-package) - * [Building all runtime Mizux.CMakeSwig Package](#building-all-runtime-mizuxfoo-package) - * [Building a Complete Mizux.CMakeSwig Package](#building-complete-mizuxfoo-package) - * [Testing the Complete Mizux.CMakeSwig Package](#testing-complete-mizuxfoo-package) + * [Local Google.OrTools Package](#local-googleortools-package) + * [Building a runtime Google.OrTools Package](#building-local-runtime-googleortools-package) + * [Building a Local Google.OrTools Package](#building-local-googleortools-package) + * [Testing the Local Google.OrTools Package](#testing-local-googleortools-package) + * [Complete Google.OrTools Package](#complete-googleortools-package) + * [Building all runtime Google.OrTools Package](#building-all-runtime-googleortools-package) + * [Building a Complete Google.OrTools Package](#building-complete-googleortools-package) + * [Testing the Complete Google.OrTools Package](#testing-complete-googleortools-package) * [Appendices](#appendices) * [Ressources](#ressources) * [Issues](#issues) @@ -100,64 +100,64 @@ You'll need the ".Net Core SDK 3.1" to get the dotnet cli. i.e. We won't/can't rely on VS 2019 since we want a portable cross-platform [`dotnet/cli`](https://github.com/dotnet/cli) pipeline. # Directory Layout -* [`src/dotnet/Mizux.CMakeSwig.runtime.linux-x64`](src/dotnet/Mizux.CMakeSwig.runtime.linux-x64) +* [`src/dotnet/Google.OrTools.runtime.linux-x64`](src/dotnet/Google.OrTools.runtime.linux-x64) Contains the hypothetical C++ linux-x64 shared library. -* [`src/dotnet/Mizux.CMakeSwig.runtime.osx-x64`](src/dotnet/Mizux.CMakeSwig.runtime.osx-x64) +* [`src/dotnet/Google.OrTools.runtime.osx-x64`](src/dotnet/Google.OrTools.runtime.osx-x64) Contains the hypothetical C++ osx-x64 shared library. -* [`src/dotnet/Mizux.CMakeSwig.runtime.win-x64`](src/dotnet/Mizux.CMakeSwig.runtime.win-x64) +* [`src/dotnet/Google.OrTools.runtime.win-x64`](src/dotnet/Google.OrTools.runtime.win-x64) Contains the hypothetical C++ win-x64 shared library. -* [`src/dotnet/Mizux.CMakeSwig`](src/dotnet/Mizux.CMakeSwig) +* [`src/dotnet/Google.OrTools`](src/dotnet/Google.OrTools) Is the .NetStandard2.0 library which should depends on all previous available packages. -* [`src/dotnet/Mizux.CMakeSwigApp`](src/dotnet/Mizux.CMakeSwigApp) -Is a .NetCoreApp2.1 application with a **`PackageReference`** to `Mizux.CMakeSwig` project to test. +* [`src/dotnet/Google.OrToolsApp`](src/dotnet/Google.OrToolsApp) +Is a .NetCoreApp2.1 application with a **`PackageReference`** to `Google.OrTools` project to test. note: While Microsoft use `runtime-.Company.Project` for native libraries naming, it is very difficult to get ownership on it, so you should prefer to use`Company.Project.runtime-` instead since you can have ownership on `Company.*` prefix more easily. # Build Process To Create a native dependent package we will split it in two parts: -* A bunch of `Mizux.CMakeSwig.runtime.{rid}.nupkg` packages for each +* A bunch of `Google.OrTools.runtime.{rid}.nupkg` packages for each [Runtime Identifier (RId)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) targeted. -* A meta-package `Mizux.CMakeSwig.nupkg` depending on each runtime packages. +* A meta-package `Google.OrTools.nupkg` depending on each runtime packages. note: [`Microsoft.NetCore.App` packages](https://www.nuget.org/packages?q=Microsoft.NETCore.App) follow this layout. We have two use case scenario: -1. Locally, be able to build a Mizux.CMakeSwig package which **only** target the local `OS Platform`, +1. Locally, be able to build a Google.OrTools package which **only** target the local `OS Platform`, i.e. building for only one [Runtime Identifier (RID)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). note: This is useful when the C++ build is a complex process for Windows, Linux and MacOS. i.e. You don't support cross-compilation for the native library. -2. Be able to create a complete cross-platform (ed. platform as multiple rid) Mizux.CMakeSwig package. -i.e. First you generate each native Nuget package (`runtime.{rid}.Mizux.CMakeSwig.nupkg`) +2. Be able to create a complete cross-platform (ed. platform as multiple rid) Google.OrTools package. +i.e. First you generate each native Nuget package (`runtime.{rid}.Google.OrTools.nupkg`) on each native architecture, then copy paste these artifacts on one native machine -to generate the meta-package `Mizux.CMakeSwig`. +to generate the meta-package `Google.OrTools`. -## Local Mizux.CMakeSwig Package -Let's start with scenario 1: Create a *Local* `Mizux.CMakeSwig.nupkg` package targeting **one** [Runtime Identifier (RID)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). -We would like to build a `Mizux.CMakeSwig.nupkg` package which only depends on one `Mizux.CMakeSwig.runtime.{rid}.nupkg` in order to dev/test locally. +## Local Google.OrTools Package +Let's start with scenario 1: Create a *Local* `Google.OrTools.nupkg` package targeting **one** [Runtime Identifier (RID)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). +We would like to build a `Google.OrTools.nupkg` package which only depends on one `Google.OrTools.runtime.{rid}.nupkg` in order to dev/test locally. The pipeline for `linux-x64` should be as follow: note: The pipeline will be similar for `osx-x64` and `win-x64` architecture, don't hesitate to look at the CI log. ![Local Pipeline](doc/local_pipeline.svg) ![Legend](doc/legend.svg) -### Building local Mizux.CMakeSwig.runtime Package +### Building local Google.OrTools.runtime Package disclaimer: for simplicity, in this git repository, we suppose the `g++` and `swig` process has been already performed. Thus we have the C++ shared library `Native.so` and the swig generated C# wrapper `Native.cs` already available. note: For a C++ CMake cross-platform project sample, take a look at [Mizux/cmake-cpp](https://github.com/Mizux/cmake-cpp). note: For a C++/Swig CMake cross-platform project sample, take a look at [Mizux/cmake-swig](https://github.com/Mizux/cmake-swig). -So first let's create the local `Mizux.CMakeSwig.runtime.{rid}.nupkg` nuget package. +So first let's create the local `Google.OrTools.runtime.{rid}.nupkg` nuget package. -Here some dev-note concerning this `Mizux.CMakeSwig.runtime.{rid}.csproj`. -* `AssemblyName` must be `Mizux.CMakeSwig.dll` i.e. all {rid} projects **must** generate an assembly with the **same** name (i.e. no {rid} in the name) +Here some dev-note concerning this `Google.OrTools.runtime.{rid}.csproj`. +* `AssemblyName` must be `Google.OrTools.dll` i.e. all {rid} projects **must** generate an assembly with the **same** name (i.e. no {rid} in the name) ```xml {rid} - Mizux.CMakeSwig - Mizux.CMakeSwig.runtime.{rid} + Google.OrTools + Google.OrTools.runtime.{rid} ``` * Once you specify a `RuntimeIdentifier` then `dotnet build` or `dotnet build -r {rid}` will behave identically (save you from typing it). @@ -181,7 +181,7 @@ to add the tag `native` to the PreserveNewest ``` -* Generate the runtime package to a defined directory (i.e. so later in meta CMakeSwig package we will be able to locate it) +* Generate the runtime package to a defined directory (i.e. so later in meta OrTools package we will be able to locate it) ```xml {...}/packages ``` @@ -192,19 +192,19 @@ to add the tag `native` to the Then you can generate the package using: ```bash -dotnet pack src/runtime.{rid}.CMakeSwig +dotnet pack src/runtime.{rid}.OrTools ``` note: this will automatically trigger the `dotnet build`. If everything good the package (located where your `PackageOutputPath` was defined) should have this layout: ``` -{...}/packages/Mizux.CMakeSwig.runtime.{rid}.nupkg: -\- Mizux.CMakeSwig.runtime.{rid}.nuspec +{...}/packages/Google.OrTools.runtime.{rid}.nupkg: +\- Google.OrTools.runtime.{rid}.nuspec \- runtimes \- {rid} \- lib \- {framework} - \- Mizux.CMakeSwig.dll + \- Google.OrTools.dll \- native \- *.so / *.dylib / *.dll ... @@ -213,10 +213,10 @@ note: `{rid}` could be `linux-x64` and `{framework}` could be `netstandard2.0` tips: since nuget package are zip archive you can use `unzip -l .nupkg` to study their layout. -### Building local Mizux.CMakeSwig Package -So now, let's create the local `Mizux.CMakeSwig.nupkg` nuget package which will depend on our previous runtime package. +### Building local Google.OrTools Package +So now, let's create the local `Google.OrTools.nupkg` nuget package which will depend on our previous runtime package. -Here some dev-note concerning this `CMakeSwig.csproj`. +Here some dev-note concerning this `OrTools.csproj`. * This package is a meta-package so we don't want to ship an empty assembly file: ```xml false @@ -227,16 +227,16 @@ Here some dev-note concerning this `CMakeSwig.csproj`. ``` * Add dependency (i.e. `PackageReference`) on each runtime package(s) availabe: ```xml - - + + ``` Thanks to the `RestoreSource` we can work locally we our just builded package without the need to upload it on [nuget.org](https://www.nuget.org/). -* To expose the .Net Surface API the `CMakeSwig.csproj` must contains a least one +* To expose the .Net Surface API the `OrTools.csproj` must contains a least one [Reference Assembly](https://docs.microsoft.com/en-us/nuget/reference/nuspec#explicit-assembly-references) of the previously rumtime package. ```xml - + ref/$(TargetFramework)/%(Filename)%(Extension) true PreserveNewest @@ -245,104 +245,104 @@ Here some dev-note concerning this `CMakeSwig.csproj`. Then you can generate the package using: ```bash -dotnet pack src/.CMakeSwig +dotnet pack src/.OrTools ``` If everything good the package (located where your `PackageOutputPath` was defined) should have this layout: ``` -{...}/packages/Mizux.CMakeSwig.nupkg: -\- Mizux.CMakeSwig.nuspec +{...}/packages/Google.OrTools.nupkg: +\- Google.OrTools.nuspec \- ref \- {framework} - \- Mizux.CMakeSwig.dll + \- Google.OrTools.dll ... ``` note: `{framework}` could be `netstandard2.0` -### Testing local Mizux.CMakeSwig Package -We can test everything is working by using the `CMakeSwigApp` project. +### Testing local Google.OrTools Package +We can test everything is working by using the `OrToolsApp` project. First you can build it using: ``` -dotnet build src/CMakeSwigApp +dotnet build src/OrToolsApp ``` -note: Since CMakeSwigApp `PackageReference` CMakeSwig and add `{...}/packages` to the `RestoreSource`. -During the build of CMakeSwigApp you can see that `Mizux.CMakeSwig` and -`Mizux.CMakeSwig.runtime.{rid}` are automatically installed in the nuget cache. +note: Since OrToolsApp `PackageReference` OrTools and add `{...}/packages` to the `RestoreSource`. +During the build of OrToolsApp you can see that `Google.OrTools` and +`Google.OrTools.runtime.{rid}` are automatically installed in the nuget cache. Then you can run it using: ``` -dotnet build src/CMakeSwigApp +dotnet build src/OrToolsApp ``` You should see something like this ```bash -[1] Enter CMakeSwigApp -[2] Enter CMakeSwig -[3] Enter CMakeSwig.{rid} -[3] Exit CMakeSwig.{rid} -[2] Exit CMakeSwig -[1] Exit CMakeSwigApp +[1] Enter OrToolsApp +[2] Enter OrTools +[3] Enter OrTools.{rid} +[3] Exit OrTools.{rid} +[2] Exit OrTools +[1] Exit OrToolsApp ``` -## Complete Mizux.CMakeSwig Package -Let's start with scenario 2: Create a *Complete* `Mizux.CMakeSwig.nupkg` package targeting multiple [Runtime Identifier (RID)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). -We would like to build a `Mizux.CMakeSwig.nupkg` package which depends on several `Mizux.CMakeSwig.runtime.{rid}.nupkg`. +## Complete Google.OrTools Package +Let's start with scenario 2: Create a *Complete* `Google.OrTools.nupkg` package targeting multiple [Runtime Identifier (RID)](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). +We would like to build a `Google.OrTools.nupkg` package which depends on several `Google.OrTools.runtime.{rid}.nupkg`. The pipeline should be as follow: note: This pipeline should be run on any architecture, -provided you have generated the three architecture dependent `Mizux.CMakeSwig.runtime.{rid}.nupkg` nuget packages. +provided you have generated the three architecture dependent `Google.OrTools.runtime.{rid}.nupkg` nuget packages. ![Full Pipeline](doc/full_pipeline.svg) ![Legend](doc/legend.svg) -### Building All runtime Mizux.CMakeSwig Package +### Building All runtime Google.OrTools Package Like in the previous scenario, on each targeted OS Platform you can build the corresponding -`runtime.{rid}.Mizux.CMakeSwig.nupkg` package. +`runtime.{rid}.Google.OrTools.nupkg` package. Simply run on each platform ```bash -dotnet build src/runtime.{rid}.CMakeSwig -dotnet pack src/runtime.{rid}.CMakeSwig +dotnet build src/runtime.{rid}.OrTools +dotnet pack src/runtime.{rid}.OrTools ``` note: replace `{rid}` by the Runtime Identifier associated to the current OS platform. Then on one machine used, you copy all other packages in the `{...}/packages` so -when building `CMakeSwig.csproj` we can have access to all package... +when building `OrTools.csproj` we can have access to all package... -### Building Complete Mizux.CMakeSwig Package +### Building Complete Google.OrTools Package This is the same step than in the previous scenario, since we "see" all runtime packages in `{...}/packages`, the project will depends on each of them. Once copied all runtime package locally, simply run: ```bash -dotnet build src/CMakeSwig -dotnet pack src/CMakeSwig +dotnet build src/OrTools +dotnet pack src/OrTools ``` -### Testing Complete Mizux.CMakeSwig Package -We can test everything is working by using the `CMakeSwigApp` project. +### Testing Complete Google.OrTools Package +We can test everything is working by using the `OrToolsApp` project. First you can build it using: ``` -dotnet build src/CMakeSwigApp +dotnet build src/OrToolsApp ``` -note: Since CMakeSwigApp `PackageReference` CMakeSwig and add `{...}/packages` to the `RestoreSource`. -During the build of CMakeSwigApp you can see that `Mizux.CMakeSwig` and -`runtime.{rid}.Mizux.CMakeSwig` are automatically installed in the nuget cache. +note: Since OrToolsApp `PackageReference` OrTools and add `{...}/packages` to the `RestoreSource`. +During the build of OrToolsApp you can see that `Google.OrTools` and +`runtime.{rid}.Google.OrTools` are automatically installed in the nuget cache. Then you can run it using: ``` -dotnet run --project src/CMakeSwigApp +dotnet run --project src/OrToolsApp ``` You should see something like this ```bash -[1] Enter CMakeSwigApp -[2] Enter CMakeSwig -[3] Enter CMakeSwig.{rid} -[3] Exit CMakeSwig.{rid} -[2] Exit CMakeSwig -[1] Exit CMakeSwigApp +[1] Enter OrToolsApp +[2] Enter OrTools +[3] Enter OrTools.{rid} +[3] Exit OrTools.{rid} +[2] Exit OrTools +[1] Exit OrToolsApp ``` # Ressources diff --git a/cmake/doc/generate_image.sh b/cmake/doc/generate_image.sh index da0d2103d4..cd1743a7f1 100755 --- a/cmake/doc/generate_image.sh +++ b/cmake/doc/generate_image.sh @@ -3,6 +3,6 @@ set -ex rm -f *.svg *.png for i in *.dot; do - plantuml -Tpng "$i"; + #plantuml -Tpng "$i"; plantuml -Tsvg "$i"; done diff --git a/cmake/docker/alpine/Dockerfile b/cmake/docker/alpine/Dockerfile index 16e587763c..6c6e7daa65 100644 --- a/cmake/docker/alpine/Dockerfile +++ b/cmake/docker/alpine/Dockerfile @@ -1,102 +1,11 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/alpine -FROM alpine:edge AS env +FROM alpine:edge AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN apk add --no-cache git build-base linux-headers cmake CMD [ "/bin/sh" ] - - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS python -# Swig install +FROM base AS swig RUN apk add --no-cache swig -# Python install -RUN apk add --no-cache python3-dev py3-pip -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS java -# Swig install -RUN apk add --no-cache swig -# Java install -ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk -RUN apk add --no-cache openjdk8 -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS dotnet -# Swig install -RUN apk add --no-cache swig -# Add dependencies for disabling invariant mode (set in base image) -RUN apk add --no-cache wget icu-libs libintl -# .NET install -RUN dotnet_sdk_version=3.1.101 \ -&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \ -&& dotnet_sha512='ce386da8bc07033957fd404909fc230e8ab9e29929675478b90f400a1838223379595a4459056c6c2251ab5c722f80858b9ca536db1a2f6d1670a97094d0fe55' \ -&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ -&& mkdir -p /usr/share/dotnet \ -&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \ -&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ -&& rm dotnet.tar.gz -# Trigger first run experience by running arbitrary cmd -RUN dotnet --info -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install_cpp -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/alpine/cpp.Dockerfile b/cmake/docker/alpine/cpp.Dockerfile new file mode 100644 index 0000000000..4196667bf6 --- /dev/null +++ b/cmake/docker/alpine/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:alpine_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/alpine/dotnet.Dockerfile b/cmake/docker/alpine/dotnet.Dockerfile new file mode 100644 index 0000000000..8208512f21 --- /dev/null +++ b/cmake/docker/alpine/dotnet.Dockerfile @@ -0,0 +1,40 @@ +FROM ortools:alpine_swig AS env +RUN apk add --no-cache wget icu-libs libintl +# .NET install +RUN dotnet_sdk_version=3.1.101 \ +&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \ +&& dotnet_sha512='ce386da8bc07033957fd404909fc230e8ab9e29929675478b90f400a1838223379595a4459056c6c2251ab5c722f80858b9ca536db1a2f6d1670a97094d0fe55' \ +&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ +&& mkdir -p /usr/share/dotnet \ +&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \ +&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ +&& rm dotnet.tar.gz +# Trigger first run experience by running arbitrary cmd +RUN dotnet --info + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/alpine/java.Dockerfile b/cmake/docker/alpine/java.Dockerfile new file mode 100644 index 0000000000..894151d8ea --- /dev/null +++ b/cmake/docker/alpine/java.Dockerfile @@ -0,0 +1,30 @@ +FROM ortools:alpine_swig AS env +ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk +RUN apk add --no-cache openjdk8 maven + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/alpine/python.Dockerfile b/cmake/docker/alpine/python.Dockerfile new file mode 100644 index 0000000000..b8e95326a1 --- /dev/null +++ b/cmake/docker/alpine/python.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:alpine_swig AS env +RUN apk add --no-cache python3-dev py3-pip + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/archlinux/Dockerfile b/cmake/docker/archlinux/Dockerfile index 4c47de166b..8e346c58b0 100644 --- a/cmake/docker/archlinux/Dockerfile +++ b/cmake/docker/archlinux/Dockerfile @@ -1,92 +1,11 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/archlinux/ -FROM archlinux/base AS env +FROM archlinux/base AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN pacman -Syu --noconfirm git base-devel cmake CMD [ "/bin/sh" ] - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS python -# Swig install +FROM base AS swig RUN pacman -Syu --noconfirm swig -# Python install -RUN pacman -Syu --noconfirm python python-pip -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS java -# Swig install -RUN pacman -Syu --noconfirm swig -# Java install -RUN pacman -Syu --noconfirm jdk-openjdk -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS dotnet -# Swig install -RUN pacman -Syu --noconfirm swig -# .Net install -RUN pacman -Syu --noconfirm dotnet-sdk -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install_cpp -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/archlinux/cpp.Dockerfile b/cmake/docker/archlinux/cpp.Dockerfile new file mode 100644 index 0000000000..bb87b1ff07 --- /dev/null +++ b/cmake/docker/archlinux/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:archlinux_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/archlinux/dotnet.Dockerfile b/cmake/docker/archlinux/dotnet.Dockerfile new file mode 100644 index 0000000000..b3e27ef397 --- /dev/null +++ b/cmake/docker/archlinux/dotnet.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:archlinux_swig AS env +RUN pacman -Syu --noconfirm dotnet-sdk + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/archlinux/java.Dockerfile b/cmake/docker/archlinux/java.Dockerfile new file mode 100644 index 0000000000..8d70119152 --- /dev/null +++ b/cmake/docker/archlinux/java.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:archlinux_swig AS env +RUN pacman -Syu --noconfirm jdk-openjdk maven + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/archlinux/python.Dockerfile b/cmake/docker/archlinux/python.Dockerfile new file mode 100644 index 0000000000..ab870c4312 --- /dev/null +++ b/cmake/docker/archlinux/python.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:archlinux_swig AS env +RUN pacman -Syu --noconfirm python python-pip + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/centos/Dockerfile b/cmake/docker/centos/Dockerfile index 9878d8b58f..b8e5590a9d 100644 --- a/cmake/docker/centos/Dockerfile +++ b/cmake/docker/centos/Dockerfile @@ -1,9 +1,9 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/centos -FROM centos:latest AS env +FROM centos:latest AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN yum -y update \ && yum -y install git wget openssl-devel \ && yum -y groupinstall "Development Tools" \ @@ -16,28 +16,7 @@ RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \ && rm cmake-3.16.4-Linux-x86_64.sh CMD [ "/bin/sh" ] - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS python -# Swig install +FROM base AS swig RUN yum -y update \ && yum -y install pcre-devel \ && yum clean all \ @@ -51,98 +30,3 @@ RUN yum -y update \ && make install \ && cd .. \ && rm -rf swig-4.0.1 -# Python install -RUN yum -y update \ -&& yum -y install python36-devel \ -&& yum clean all \ -&& rm -rf /var/cache/yum -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS java -# Swig install -RUN yum -y update \ -&& yum -y install pcre-devel \ -&& yum clean all \ -&& rm -rf /var/cache/yum \ -&& wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \ -&& tar xvf swig-4.0.1.tar.gz \ -&& rm swig-4.0.1.tar.gz \ -&& cd swig-4.0.1 \ -&& ./configure --prefix=/usr \ -&& make -j 4 \ -&& make install \ -&& cd .. \ -&& rm -rf swig-4.0.1 -# Java install -RUN yum -y update \ -&& yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel \ -&& yum clean all \ -&& rm -rf /var/cache/yum -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Add the library src to our build env -FROM env AS dotnet -# Swig install -RUN yum -y update \ -&& yum -y install pcre-devel \ -&& yum clean all \ -&& rm -rf /var/cache/yum \ -&& wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \ -&& tar xvf swig-4.0.1.tar.gz \ -&& rm swig-4.0.1.tar.gz \ -&& cd swig-4.0.1 \ -&& ./configure --prefix=/usr \ -&& make -j 4 \ -&& make install \ -&& cd .. \ -&& rm -rf swig-4.0.1 -# .Net install -# see https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7 -RUN rpm -Uvh "https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm" \ -&& yum -y update \ -&& yum -y install dotnet-sdk-3.1 \ -&& yum clean all \ -&& rm -rf /var/cache/yum -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install_cpp -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/centos/cpp.Dockerfile b/cmake/docker/centos/cpp.Dockerfile new file mode 100644 index 0000000000..9379f5bb13 --- /dev/null +++ b/cmake/docker/centos/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:centos_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/centos/dotnet.Dockerfile b/cmake/docker/centos/dotnet.Dockerfile new file mode 100644 index 0000000000..fcf3e90de6 --- /dev/null +++ b/cmake/docker/centos/dotnet.Dockerfile @@ -0,0 +1,34 @@ +FROM ortools:centos_swig AS env +# see https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7 +RUN rpm -Uvh "https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm" \ +&& yum -y update \ +&& yum -y install dotnet-sdk-3.1 \ +&& yum clean all \ +&& rm -rf /var/cache/yum + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/centos/java.Dockerfile b/cmake/docker/centos/java.Dockerfile new file mode 100644 index 0000000000..6c378822c9 --- /dev/null +++ b/cmake/docker/centos/java.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:centos_swig AS env +RUN yum -y update \ +&& yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel maven \ +&& yum clean all \ +&& rm -rf /var/cache/yum + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/centos/python.Dockerfile b/cmake/docker/centos/python.Dockerfile new file mode 100644 index 0000000000..27bc72c0a9 --- /dev/null +++ b/cmake/docker/centos/python.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:centos_swig AS env +RUN yum -y update \ +&& yum -y install python36-devel \ +&& yum clean all \ +&& rm -rf /var/cache/yum + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/debian/Dockerfile b/cmake/docker/debian/Dockerfile index 2e420b74cb..4d2e318126 100644 --- a/cmake/docker/debian/Dockerfile +++ b/cmake/docker/debian/Dockerfile @@ -1,9 +1,9 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/debian -FROM debian:latest AS env +FROM debian:latest AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN apt-get update -qq \ && apt-get install -yq git wget libssl-dev build-essential \ && apt-get clean \ @@ -15,112 +15,8 @@ RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \ && rm cmake-3.16.4-Linux-x86_64.sh CMD [ "/bin/sh" ] - - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -FROM env AS python -# Swig install +FROM base AS swig RUN apt-get update -qq \ && apt-get install -yq swig \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Python install -RUN apt-get update -qq \ -&& apt-get install -yq python3-dev python3-pip \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -FROM env AS java -# Swig install -RUN apt-get update -qq \ -&& apt-get install -yq swig \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Java install -RUN apt-get update -qq \ -&& apt-get install -yq default-jdk \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - - -FROM env AS dotnet -# Swig install -RUN apt-get update -qq \ -&& apt-get install -yq swig \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# .Net install -# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-debian10 -RUN apt-get update -qq \ -&& apt-get install -yq wget gpg apt-transport-https \ -&& wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \ -&& mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \ -&& wget -q https://packages.microsoft.com/config/debian/10/prod.list \ -&& mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \ -&& apt-get update -qq \ -&& apt-get install -yq dotnet-sdk-3.1 \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Trigger first run experience by running arbitrary cmd -RUN dotnet --info -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/debian/cpp.Dockerfile b/cmake/docker/debian/cpp.Dockerfile new file mode 100644 index 0000000000..ad71e1d5ab --- /dev/null +++ b/cmake/docker/debian/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:debian_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/debian/dotnet.Dockerfile b/cmake/docker/debian/dotnet.Dockerfile new file mode 100644 index 0000000000..03baedf86d --- /dev/null +++ b/cmake/docker/debian/dotnet.Dockerfile @@ -0,0 +1,41 @@ +FROM ortools:debian_swig AS env +# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-debian10 +RUN apt-get update -qq \ +&& apt-get install -yq wget gpg apt-transport-https \ +&& wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \ +&& mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \ +&& wget -q https://packages.microsoft.com/config/debian/10/prod.list \ +&& mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \ +&& apt-get update -qq \ +&& apt-get install -yq dotnet-sdk-3.1 \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Trigger first run experience by running arbitrary cmd +RUN dotnet --info + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/debian/java.Dockerfile b/cmake/docker/debian/java.Dockerfile new file mode 100644 index 0000000000..515b95ae74 --- /dev/null +++ b/cmake/docker/debian/java.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:debian_swig AS env +RUN apt-get update -qq \ +&& apt-get install -yq default-jdk maven \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/debian/python.Dockerfile b/cmake/docker/debian/python.Dockerfile new file mode 100644 index 0000000000..af70c65778 --- /dev/null +++ b/cmake/docker/debian/python.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:debian_swig AS env +RUN apt-get update -qq \ +&& apt-get install -yq python3-dev python3-pip \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/fedora/Dockerfile b/cmake/docker/fedora/Dockerfile index 42598debd9..414fd18152 100644 --- a/cmake/docker/fedora/Dockerfile +++ b/cmake/docker/fedora/Dockerfile @@ -1,9 +1,9 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/fedora -FROM fedora:latest AS env +FROM fedora:latest AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN dnf -y update \ && dnf -y install git wget \ && dnf -y groupinstall "Development Tools" \ @@ -11,101 +11,7 @@ RUN dnf -y update \ && dnf clean all CMD [ "/bin/sh" ] - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/liBundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS python -# Swig install +FROM base AS swig RUN dnf -y update \ && dnf -y install swig \ && dnf clean all -# Python install -RUN dnf -y update \ -&& dnf -y install python3 python3-devel python3-pip \ -&& dnf clean all -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS java -# Swig install -RUN dnf -y update \ -&& dnf -y install swig \ -&& dnf clean all -# Java install -ENV JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk -RUN dnf -y update \ -&& dnf -y install java-1.8.0-openjdk-devel \ -&& dnf clean all -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - - -FROM env AS dotnet -# Swig install -RUN dnf -y update \ -&& dnf -y install swig \ -&& dnf clean all -# .Net install -# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-fedora31 -RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc \ -&& wget -q -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/31/prod.repo \ -&& dnf -y update \ -&& dnf -y install dotnet-sdk-3.1 \ -&& dnf clean all -# Trigger first run experience by running arbitrary cmd -RUN dotnet --info -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/fedora/cpp.Dockerfile b/cmake/docker/fedora/cpp.Dockerfile new file mode 100644 index 0000000000..51a0818188 --- /dev/null +++ b/cmake/docker/fedora/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:fedora_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/fedora/dotnet.Dockerfile b/cmake/docker/fedora/dotnet.Dockerfile new file mode 100644 index 0000000000..6e41dc9955 --- /dev/null +++ b/cmake/docker/fedora/dotnet.Dockerfile @@ -0,0 +1,36 @@ +FROM ortools:fedora_swig AS env +# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-fedora31 +RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc \ +&& wget -q -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/31/prod.repo \ +&& dnf -y update \ +&& dnf -y install dotnet-sdk-3.1 \ +&& dnf clean all +# Trigger first run experience by running arbitrary cmd +RUN dotnet --info + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/fedora/java.Dockerfile b/cmake/docker/fedora/java.Dockerfile new file mode 100644 index 0000000000..86b7f2afe0 --- /dev/null +++ b/cmake/docker/fedora/java.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:fedora_swig AS env +ENV JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk +RUN dnf -y update \ +&& dnf -y install java-1.8.0-openjdk-devel maven \ +&& dnf clean all + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/fedora/python.Dockerfile b/cmake/docker/fedora/python.Dockerfile new file mode 100644 index 0000000000..44e42cbef0 --- /dev/null +++ b/cmake/docker/fedora/python.Dockerfile @@ -0,0 +1,31 @@ +FROM ortools:fedora_swig AS env +RUN dnf -y update \ +&& dnf -y install python3 python3-devel python3-pip \ +&& dnf clean all + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/manylinux/Dockerfile b/cmake/docker/manylinux/Dockerfile index 045aaf30fa..38e56292a7 100644 --- a/cmake/docker/manylinux/Dockerfile +++ b/cmake/docker/manylinux/Dockerfile @@ -1,7 +1,6 @@ -FROM quay.io/pypa/manylinux2010_x86_64:latest +# Create a virtual environment with all tools installed +FROM quay.io/pypa/manylinux2010_x86_64:latest AS env LABEL maintainer="mizux.dev@gmail.com" - -# Base install ENV PATH=$PATH:/usr/local/bin RUN yum -y update \ && yum -y groupinstall 'Development Tools' \ diff --git a/cmake/docker/opensuse/Dockerfile b/cmake/docker/opensuse/Dockerfile index 818decd275..4b12e17490 100644 --- a/cmake/docker/opensuse/Dockerfile +++ b/cmake/docker/opensuse/Dockerfile @@ -1,114 +1,16 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/r/opensuse/tumbleweed -FROM opensuse/tumbleweed AS env +FROM opensuse/tumbleweed AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN zypper update -y \ && zypper install -y git gcc gcc-c++ cmake \ && zypper clean -a ENV CC=gcc CXX=g++ CMD [ "/bin/sh" ] - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS python -# Swig install +FROM base AS swig RUN zypper update -y \ && zypper install -y swig \ && zypper clean -a -# Python install -RUN zypper update -y \ -&& zypper install -y python3 python3-pip python3-devel \ -&& zypper clean -a -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -FROM env AS java -# Swig install -RUN zypper update -y \ -&& zypper install -y swig \ -&& zypper clean -a -# Java install -RUN zypper update -y \ -&& zypper install -y java-1_8_0-openjdk-devel \ -&& zypper clean -a -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - - -FROM env AS dotnet -# Swig install -RUN zypper update -y \ -&& zypper install -y swig \ -&& zypper clean -a -# .Net install -RUN zypper update -y \ -&& zypper install -y wget tar libicu-devel -RUN dotnet_sdk_version=3.1.102 \ -&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz \ -&& dotnet_sha512='9cacdc9700468a915e6fa51a3e5539b3519dd35b13e7f9d6c4dd0077e298baac0e50ad1880181df6781ef1dc64a232e9f78ad8e4494022987d12812c4ca15f29' \ -&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ -&& mkdir -p /usr/share/dotnet \ -&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \ -&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ -&& rm dotnet.tar.gz -# Trigger first run experience by running arbitrary cmd -RUN dotnet --info -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -v -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/opensuse/cpp.Dockerfile b/cmake/docker/opensuse/cpp.Dockerfile new file mode 100644 index 0000000000..3dee2f374d --- /dev/null +++ b/cmake/docker/opensuse/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:opensuse_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/opensuse/dotnet.Dockerfile b/cmake/docker/opensuse/dotnet.Dockerfile new file mode 100644 index 0000000000..59be5f3a39 --- /dev/null +++ b/cmake/docker/opensuse/dotnet.Dockerfile @@ -0,0 +1,40 @@ +FROM ortools:opensuse_swig AS env +RUN zypper update -y \ +&& zypper install -y wget tar libicu-devel +RUN dotnet_sdk_version=3.1.102 \ +&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz \ +&& dotnet_sha512='9cacdc9700468a915e6fa51a3e5539b3519dd35b13e7f9d6c4dd0077e298baac0e50ad1880181df6781ef1dc64a232e9f78ad8e4494022987d12812c4ca15f29' \ +&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ +&& mkdir -p /usr/share/dotnet \ +&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \ +&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ +&& rm dotnet.tar.gz +# Trigger first run experience by running arbitrary cmd +RUN dotnet --info + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/opensuse/java.Dockerfile b/cmake/docker/opensuse/java.Dockerfile new file mode 100644 index 0000000000..e9a5a2de6e --- /dev/null +++ b/cmake/docker/opensuse/java.Dockerfile @@ -0,0 +1,31 @@ +FROM ortools:opensuse_swig AS env +RUN zypper update -y \ +&& zypper install -y java-1_8_0-openjdk-devel maven \ +&& zypper clean -a + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/opensuse/python.Dockerfile b/cmake/docker/opensuse/python.Dockerfile new file mode 100644 index 0000000000..7091eede51 --- /dev/null +++ b/cmake/docker/opensuse/python.Dockerfile @@ -0,0 +1,31 @@ +FROM ortools:opensuse_swig AS env +RUN zypper update -y \ +&& zypper install -y python3 python3-pip python3-devel \ +&& zypper clean -a + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/ubuntu/Dockerfile b/cmake/docker/ubuntu/Dockerfile index a434892acd..9b5e5b5c3d 100644 --- a/cmake/docker/ubuntu/Dockerfile +++ b/cmake/docker/ubuntu/Dockerfile @@ -1,129 +1,22 @@ # Create a virtual environment with all tools installed # ref: https://hub.docker.com/_/ubuntu -FROM ubuntu:rolling AS env +FROM ubuntu:rolling AS base LABEL maintainer="mizux.dev@gmail.com" # Install system build dependencies -ENV PATH=$PATH:/usr/local/bin +ENV PATH=/usr/local/bin:$PATH RUN apt-get update -qq \ && apt-get install -yq git wget libssl-dev build-essential \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Install CMake 3.16.4 -RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4.tar.gz" \ -&& tar xzf cmake-3.16.4.tar.gz \ -&& rm cmake-3.16.4.tar.gz \ -&& cd cmake-3.16.4 \ -&& ./bootstrap --prefix=/usr \ -&& make \ -&& make install \ -&& cd .. \ -&& rm -rf cmake-3.16.4 +RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \ +&& chmod a+x cmake-3.16.4-Linux-x86_64.sh \ +&& ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \ +&& rm cmake-3.16.4-Linux-x86_64.sh CMD [ "/bin/sh" ] - - - -# Add the library src to our build env -FROM env AS cpp -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake version -RUN cmake -version -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -FROM env AS python -# Swig +FROM base AS swig RUN apt-get update -qq \ && apt-get install -yq swig \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Python install -RUN apt-get update -qq \ -&& apt-get install -yq python3-dev python3-pip \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -FROM env AS java -# Swig install -RUN apt-get update -qq \ -&& apt-get install -yq swig \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Java install -RUN apt-get update -qq \ -&& apt-get install -yq default-jdk \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - - -FROM env AS dotnet -# Swig install -RUN apt-get update -qq \ -&& apt-get install -yq swig \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# .Net install -# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1910 -RUN apt-get update -qq \ -&& apt-get install -yq wget apt-transport-https \ -&& wget -q https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ -&& dpkg -i packages-microsoft-prod.deb \ -&& apt-get update -qq \ -&& apt-get install -yq dotnet-sdk-3.1 \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Trigger first run experience by running arbitrary cmd -RUN dotnet --info -# Create lib directory -WORKDIR /home/lib -# Bundle lib source -COPY . . -# CMake configure -RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON -# CMake build -RUN cmake --build build --target all -# CMake build -RUN cmake --build build --target install - - - -# Create an install image -FROM env AS install -# Copy lib from devel to prod -COPY --from=cpp /usr/local /usr/local/ -# Copy sample -WORKDIR /home/sample -COPY ci/sample . diff --git a/cmake/docker/ubuntu/cpp.Dockerfile b/cmake/docker/ubuntu/cpp.Dockerfile new file mode 100644 index 0000000000..49ad5888ae --- /dev/null +++ b/cmake/docker/ubuntu/cpp.Dockerfile @@ -0,0 +1,29 @@ +FROM ortools:ubuntu_base AS env +RUN cmake -version + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/ubuntu/dotnet.Dockerfile b/cmake/docker/ubuntu/dotnet.Dockerfile new file mode 100644 index 0000000000..31f5bf6931 --- /dev/null +++ b/cmake/docker/ubuntu/dotnet.Dockerfile @@ -0,0 +1,39 @@ +FROM ortools:ubuntu_swig AS env +# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1910 +RUN apt-get update -qq \ +&& apt-get install -yq wget apt-transport-https \ +&& wget -q https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ +&& dpkg -i packages-microsoft-prod.deb \ +&& apt-get update -qq \ +&& apt-get install -yq dotnet-sdk-3.1 \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Trigger first run experience by running arbitrary cmd +RUN dotnet --info + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/ubuntu/java.Dockerfile b/cmake/docker/ubuntu/java.Dockerfile new file mode 100644 index 0000000000..7b64298e3d --- /dev/null +++ b/cmake/docker/ubuntu/java.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:ubuntu_swig AS env +RUN apt-get update -qq \ +&& apt-get install -yq default-jdk maven \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild -DBUILD_DOTNET=ON +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test diff --git a/cmake/docker/ubuntu/python.Dockerfile b/cmake/docker/ubuntu/python.Dockerfile new file mode 100644 index 0000000000..5517b4a7fc --- /dev/null +++ b/cmake/docker/ubuntu/python.Dockerfile @@ -0,0 +1,32 @@ +FROM ortools:ubuntu_swig AS env +RUN apt-get update -qq \ +&& apt-get install -yq python3-dev python3-pip \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +FROM env AS devel +WORKDIR /home/lib +COPY . . + +FROM devel AS build +RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON +RUN cmake --build build --target all +RUN cmake --build build --target install + +FROM build AS test +RUN cmake --build build --target test + +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v +RUN cmake --build build --target install + +FROM install_build AS install_test +RUN cmake --build build --target test