-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.ci-windows
161 lines (133 loc) · 5.61 KB
/
Dockerfile.ci-windows
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
## base image
FROM ubuntu:22.04 AS base
ARG extra_libraries
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y -qq && apt-get install --no-install-recommends -y gnupg wget curl apt-transport-https software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# keys used by apt
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
# Install packages available from standard repos
RUN apt-get update -y && \
apt-get install --no-install-recommends -yq \
gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 wget curl pkg-config zip unzip tar git build-essential && \
apt-get install --no-install-recommends -y \
mingw-w64 mingw-w64-tools binutils bison \
${extra_libraries} \
python3 python3-pip doxygen graphviz \
cmake make ninja-build ccache cppcheck cmake-extras \
clang clang-tidy clang-format \
valgrind gcovr linux-tools-common linux-tools-generic google-perftools \
neovim emacs nano && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# install powershell
ENV PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache
ADD https://github.com/PowerShell/PowerShell/releases/download/v7.2.5/powershell-lts_7.2.5-1.deb_amd64.deb /tmp/powershell.deb
RUN apt-get update -y && apt-get install --no-install-recommends -y /tmp/powershell.deb && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
rm /tmp/powershell.deb
ENV POWERSHELL_TELEMETRY_OPTOUT 1
# install mxe (old)
#RUN apt-get update -y && \
# apt-get install -y \
# software-properties-common lsb-release && \
# apt-get clean && rm -rf /var/lib/apt/lists/*
#RUN apt-key adv \
# --keyserver keyserver.ubuntu.com \
# --recv-keys 86B72ED9 && \
# add-apt-repository \
# "deb [arch=amd64] https://pkg.mxe.cc/repos/apt `lsb_release -sc` main" && \
# apt-get update -y
#RUN apt-get update -y && apt-get install -y mxe-x86-64-w64-mingw32.shared-cc mxe-x86-64-w64-mingw32.static-cc mxe-x86-64-w64-mingw32.shared-cmake mxe-x86-64-w64-mingw32.static-cmake
#ENV PATH="/usr/lib/mxe/usr/bin:${PATH}"
# Install conan
RUN python3 -m pip install --no-cache-dir conan==1.56.0 && \
conan --version
# Install more pip tools
RUN python3 -m pip install --no-cache-dir \
cogapp==3.3.0 \
coverage==7.0.3 \
cmake-format==0.6.13 \
cmakelint==1.4.2
# install task
ADD https://taskfile.dev/install.sh /tmp/taskfile_install.sh
RUN chmod +x /tmp/taskfile_install.sh
RUN /tmp/taskfile_install.sh -d -b /usr/local/bin && rm /tmp/taskfile_install.sh
# thx to https://github.com/lefticus/cpp_starter_project/pull/121
# By default, anything you run in Docker is done as superuser.
# Conan runs some install commands as superuser, and will prepend `sudo` to
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
ENV CONAN_SYSREQUIRES_SUDO 0
# Some packages request that Conan use the system package manager to install
# a few dependencies. This flag allows Conan to proceed with these installations;
# leaving this flag undefined can cause some installation failures.
ENV CONAN_SYSREQUIRES_MODE enabled
ENV CMAKE "cmake"
ENV MAKE "make"
ENV CC "x86_64-w64-mingw32-gcc"
ENV CXX "x86_64-w64-mingw32-g++"
# setup project env
WORKDIR /home/project
## ci image for windows build
FROM base AS ci-base-windows
ARG extra_libraries
ARG vcpkg_host_triplet="x64-linux"
ARG processor="x86_64"
# e.g. x64-mingw-dynamic
ARG vcpkg_target_triplet="x64-mingw-dynamic"
ARG cc="x86_64-w64-mingw32-gcc"
ARG cxx="x86_64-w64-mingw32-g++"
ARG cmake="cmake"
ARG make="ninja"
ARG cmake_generator="Ninja Multi-Config"
ARG cmake_toolchain_file="/home/cmake/x86_64-w64-mingw32.toolchain.cmake"
ARG cross_root "/usr/x86_64-w64-mingw32"
# compiler env settings
# e.g. mingw-env, emsdk_env.sh
RUN mkdir -p /home/cross && touch /home/cross/.bashrc
ARG setup_env_script="/home/cross/.bashrc"
ARG setup_env_script_args=""
ENV SETUP_ENV_SCRIPT $setup_env_script
ENV SETUP_ENV_SCRIPT_ARGS $setup_env_script_args
RUN echo 'source "$SETUP_ENV_SCRIPT $SETUP_ENV_SCRIPT_ARGS"' >> /root/.bash_profile && \
. $setup_env_script $setup_env_script_args
# cross compiler settings
ENV CC $cc
ENV CXX $cxx
ENV CMAKE $cmake
ENV MAKE $make
ENV PROCESSOR $processor
ENV TARGET_TRIPLET $vcpkg_target_triplet
ENV CROSS_CMAKE $cmake
ENV CROSS_MAKE $make
ENV CROSS "${cross_triple}-"
ENV CROSS_ROOT $cross_root
ENV CROSS_TOOLCHAIN $cmake_toolchain_file
# install vcpkg
## https://github.com/microsoft/vcpkg/blob/master/docs/users/mingw.md
ENV VCPKG_DEFAULT_HOST_TRIPLET $vcpkg_host_triplet
ENV VCPKG_DEFAULT_TRIPLET $vcpkg_target_triplet
ENV VCPKG_DISABLE_METRICS 1
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git /home/vcpkg && \
/home/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT "/home/vcpkg"
ENV VCPKG_TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
ENV TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
# build script settings
ENV TARGET "all"
ENV BUILD_TYPE "Release"
ENV CMAKE_GENERATOR $cmake_generator
ENV CHAINLOAD_TOOLCHAIN_FILE $cmake_toolchain_file
ENV CMAKE_ARGS ""
# setup project env
WORKDIR /home/project
COPY ./cmake /home/cmake
COPY ./scripts/docker-build.ci-mingw.sh ./docker-build.sh
COPY ./taskfiles/*.yml /home/taskfiles/
COPY ./taskfiles/TaskfileCross.yml /home/taskfiles/Taskfile.yml
ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build