Skip to content

Commit 14b5580

Browse files
authored
Merge pull request #103 from abeimler/feature/cross-mingw
add mingw cross-compiler
2 parents 3d4b6fc + cee1b63 commit 14b5580

30 files changed

+421
-70
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ jobs:
140140
pnpm:
141141
- 8
142142
container:
143-
- "arch.dockerfile"
144-
- "fedora.dockerfile"
145143
- "ubuntu.dockerfile"
144+
- "fedora.dockerfile"
145+
- "arch.dockerfile"
146+
- "ubuntu-mingw.dockerfile"
147+
# - "fedora-mingw.dockerfile"
148+
# - "arch-mingw.dockerfile"
146149
steps:
147150
- uses: actions/checkout@v3
148151
with:

cspell.config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ words:
9090
- whatwg
9191
- xcrun
9292
- Yahyaabadi
93+
- VCPKG
94+
- DVCPKG
95+
- SYSROOT
9396
ignoreWords: []
9497
import: []
9598
dictionaryDefinitions: []
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## base image
2+
FROM archlinux:base-devel as setup-cpp-arch-mingw
3+
4+
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
5+
6+
# install git
7+
RUN pacman -Syuu --noconfirm && \
8+
pacman-db-upgrade && \
9+
pacman -S --noconfirm --needed git
10+
# install yay
11+
RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
12+
RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay
13+
WORKDIR /opt/yay
14+
RUN chown -R yay:root . && chmod -R 775 .
15+
USER yay
16+
WORKDIR /opt/yay
17+
RUN makepkg -si --noprogressbar --noconfirm
18+
## clean up
19+
USER root
20+
WORKDIR /
21+
RUN rm -rf /opt/yay
22+
23+
RUN pacman -Syuu --noconfirm && \
24+
pacman-db-upgrade && \
25+
# install nodejs
26+
pacman -S --noconfirm --needed nodejs npm && \
27+
# install the compiler and tools
28+
node /usr/lib/setup-cpp/setup-cpp.js \
29+
--compiler mingw \
30+
--cmake true \
31+
--ninja true \
32+
--task true \
33+
--vcpkg true \
34+
--python true \
35+
--make true \
36+
--cppcheck true \
37+
--gcovr true \
38+
--doxygen true \
39+
--ccache true && \
40+
# arch cleanup
41+
pacman -Scc --noconfirm && \
42+
rm -rf /var/cache/pacman/pkg/* && \
43+
rm -rf /tmp/*
44+
45+
ENTRYPOINT ["/bin/bash"]
46+
47+
#### Cross Building (example)
48+
FROM setup-cpp-arch-mingw AS builder-mingw
49+
50+
COPY ./dev/cpp_vcpkg_project /home/app
51+
WORKDIR /home/app
52+
RUN bash -c 'source ~/.cpprc \
53+
&& task build_cross_mingw'

dev/docker/__tests__/arch-mingw.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: mingw c compiler
5+
command: x86_64-w64-mingw32-gcc
6+
args: ["--version"]
7+
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
8+
- name: mingw c++ compiler
9+
command: x86_64-w64-mingw32-g++
10+
args: ["--version"]
11+
expectedOutput: [".*x86_64-w64-mingw32-g\\+\\+*"]
12+
- name: powershell
13+
command: pwsh
14+
args: ["-Version"]
15+
expectedOutput: [".*PowerShell.*"]
16+
17+
fileExistenceTests:
18+
- name: "vcpkg"
19+
path: "/root/vcpkg"
20+
shouldExist: true
21+
- name: "cross root"
22+
path: "/usr/x86_64-w64-mingw32"
23+
shouldExist: true

dev/docker/__tests__/arch.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
schemaVersion: 2.0.0
22

33
commandTests:
4-
- name: gcc compiler
5-
command: gcc
6-
args: ["--version"]
7-
expectedOutput: [".*gcc.*GCC.*"]
8-
- name: g++ compiler
9-
command: g++
10-
args: ["--version"]
11-
expectedOutput: [".*g\\+\\+.*GCC.*"]
12-
- name: make
13-
command: make
14-
args: ["--version"]
15-
expectedOutput: [".*GNU Make.*"]
164
- name: ninja
175
command: /root/ninja/ninja
186
args: ["--version"]
@@ -29,10 +17,10 @@ commandTests:
2917
command: doxygen
3018
args: ["--version"]
3119
expectedOutput: [".*1.*"]
32-
- name: cppcheck
33-
command: cppcheck
20+
- name: clang
21+
command: /usr/lib/llvm-15/bin/clang
3422
args: ["--version"]
35-
expectedOutput: [".*Cppcheck.*"]
23+
expectedOutput: [".*clang.*"]
3624

3725
fileExistenceTests:
3826
- name: "vcpkg"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## base image
2+
FROM fedora:38 as setup-cpp-fedora-mingw
3+
4+
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
5+
6+
# install nodejs
7+
RUN dnf -y install nodejs npm && \
8+
9+
# install the compiler and tools
10+
node /usr/lib/setup-cpp/setup-cpp.js \
11+
--compiler mingw \
12+
--cmake true \
13+
--ninja true \
14+
--task true \
15+
--vcpkg true \
16+
--python true \
17+
--make true \
18+
--cppcheck true \
19+
--gcovr true \
20+
--doxygen true \
21+
--ccache true \
22+
--powershell true && \
23+
# cleanup
24+
dnf clean all && \
25+
rm -rf /tmp/*
26+
27+
ENTRYPOINT ["/bin/bash"]
28+
29+
#### Cross Building (example)
30+
FROM setup-cpp-fedora-mingw AS builder-mingw
31+
32+
COPY ./dev/cpp_vcpkg_project /home/app
33+
WORKDIR /home/app
34+
RUN bash -c 'source ~/.cpprc \
35+
&& task build_cross_mingw'

dev/docker/__tests__/fedora-mingw.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: mingw c compiler
5+
command: x86_64-w64-mingw32-gcc
6+
args: ["--version"]
7+
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
8+
- name: mingw c++ compiler
9+
command: x86_64-w64-mingw32-cpp
10+
args: ["--version"]
11+
expectedOutput: [".*x86_64-w64-mingw32-cpp.*"]
12+
- name: powershell
13+
command: pwsh
14+
args: ["-Version"]
15+
expectedOutput: [".*PowerShell.*"]
16+
17+
fileExistenceTests:
18+
- name: "vcpkg"
19+
path: "/root/vcpkg"
20+
shouldExist: true
21+
- name: "cross root"
22+
path: "/usr/x86_64-w64-mingw32"
23+
shouldExist: true

dev/docker/__tests__/fedora.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
schemaVersion: 2.0.0
22

33
commandTests:
4-
- name: gcc compiler
5-
command: gcc
6-
args: ["--version"]
7-
expectedOutput: [".*gcc.*GCC.*"]
8-
- name: g++ compiler
9-
command: g++
10-
args: ["--version"]
11-
expectedOutput: [".*g\\+\\+.*GCC.*"]
12-
- name: make
13-
command: make
14-
args: ["--version"]
15-
expectedOutput: [".*GNU Make.*"]
164
- name: ninja
175
command: /root/ninja/ninja
186
args: ["--version"]
@@ -29,6 +17,10 @@ commandTests:
2917
command: doxygen
3018
args: ["--version"]
3119
expectedOutput: [".*1.*"]
20+
- name: clang
21+
command: /usr/lib/llvm-15/bin/clang
22+
args: ["--version"]
23+
expectedOutput: [".*clang.*"]
3224

3325
fileExistenceTests:
3426
- name: "vcpkg"

dev/scripts/generate-docker-tests.mjs renamed to dev/docker/__tests__/generate-docker-tests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFile, writeFile } from "fs/promises"
22

33
async function main() {
4-
const dockerFiles = ["ubuntu", "arch", "fedora"]
4+
const dockerFiles = ["ubuntu", "arch", "fedora", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
55
await Promise.all(
66
dockerFiles.map(async (dockerFile) => {
77
const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8")
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#### Base Image
2+
FROM ubuntu:22.04 as setup-cpp-ubuntu-mingw
3+
4+
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
5+
6+
RUN apt-get update -qq && \
7+
# install nodejs
8+
apt-get install -y --no-install-recommends nodejs npm && \
9+
10+
# install the compiler and tools
11+
node /usr/lib/setup-cpp/setup-cpp.js \
12+
--nala true \
13+
--compiler mingw \
14+
--cmake true \
15+
--ninja true \
16+
--task true \
17+
--vcpkg true \
18+
--python true \
19+
--make true \
20+
--cppcheck true \
21+
--gcovr true \
22+
--doxygen true \
23+
--ccache true \
24+
--powershell true && \
25+
# cleanup
26+
nala autoremove -y && \
27+
nala autopurge -y && \
28+
apt-get clean && \
29+
nala clean --lists && \
30+
rm -rf /var/lib/apt/lists/* && \
31+
rm -rf /tmp/*
32+
33+
ENTRYPOINT ["/bin/bash"]
34+
35+
#### Cross Building (example)
36+
FROM setup-cpp-ubuntu-mingw AS builder-mingw
37+
38+
COPY ./dev/cpp_vcpkg_project /home/app
39+
WORKDIR /home/app
40+
RUN bash -c 'source ~/.cpprc \
41+
&& task build_cross_mingw'

0 commit comments

Comments
 (0)