Skip to content

Commit 43fd660

Browse files
author
abeimler
committed
feat: add mingw cross compiler
* add docker mingw tests * add node16 test
1 parent ecd2b40 commit 43fd660

22 files changed

+422
-12
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ jobs:
121121
- ubuntu-20.04
122122
container:
123123
- "ubuntu_node.dockerfile"
124+
- "ubuntu_node_16.dockerfile"
125+
- "ubuntu_node.mingw.dockerfile"
126+
- "ubuntu_22.04_node.dockerfile"
124127
- "ubuntu_20.04_node.dockerfile"
125128
- "arch_node.dockerfile"
129+
- "arch_node.mingw.dockerfile"
126130
- "fedora_node.dockerfile"
131+
- "fedora_node.mingw.dockerfile"
127132
node:
128133
- 14
129134
pnpm:

cspell.config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ words:
8383
- vsversion
8484
- xcrun
8585
- Yahyaabadi
86+
- VCPKG
87+
- DVCPKG
88+
- SYSROOT
8689
ignoreWords: []
8790
import: []
8891
dictionaryDefinitions: []

dev/container-tests/arch.mingw.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: mingw c compiler
5+
command: $CC
6+
args: ["--version"]
7+
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
8+
- name: mingw c++ compiler
9+
command: $CXX
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: "cmake toolchain"
22+
path: "/home/cmake/toolchains/x86_64-w64-mingw32.toolchain.cmake"
23+
shouldExist: true
24+
- name: "cross root"
25+
path: "/usr/x86_64-w64-mingw32"
26+
shouldExist: true

dev/container-tests/arch.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ commandTests:
2929
command: doxygen
3030
args: ["--version"]
3131
expectedOutput: [".*1.*"]
32-
- name: cppcheck
33-
command: cppcheck
34-
args: ["--version"]
35-
expectedOutput: [".*Cppcheck.*"]
3632

3733
fileExistenceTests:
3834
- name: "vcpkg"

dev/container-tests/fedora.mingw.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: mingw c compiler
5+
command: $CC
6+
args: ["--version"]
7+
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
8+
- name: mingw c++ compiler
9+
command: $CXX
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: "cmake toolchain"
22+
path: "/home/cmake/toolchains/x86_64-w64-mingw32.toolchain.cmake"
23+
shouldExist: true
24+
- name: "cross root"
25+
path: "/usr/x86_64-w64-mingw32"
26+
shouldExist: true

dev/container-tests/ubuntu.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/container-tests/ubuntu.node16.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
schemaVersion: 2.0.0
2+
3+
commandTests:
4+
- name: gcc compiler
5+
command: gcc
6+
args: ["--version"]
7+
expectedOutput: [".*gcc.*"]
8+
- name: g++ compiler
9+
command: g++
10+
args: ["--version"]
11+
expectedOutput: [".*g\\+\\+.*"]
12+
- name: make
13+
command: make
14+
args: ["--version"]
15+
expectedOutput: [".*GNU Make.*"]
16+
- name: ninja
17+
command: /root/ninja/ninja
18+
args: ["--version"]
19+
expectedOutput: [".*1.*"]
20+
- name: gcovr
21+
command: gcovr
22+
args: ["--version"]
23+
expectedOutput: [".*gcovr.*"]
24+
- name: ccache
25+
command: ccache
26+
args: ["--version"]
27+
expectedOutput: [".*ccache.*"]
28+
- name: doxygen
29+
command: doxygen
30+
args: ["--version"]
31+
expectedOutput: [".*1.*"]
32+
- name: cppcheck
33+
command: cppcheck
34+
args: ["--version"]
35+
expectedOutput: [".*Cppcheck.*"]
36+
- name: clang
37+
command: /root/llvm/bin/clang
38+
args: ["--version"]
39+
expectedOutput: [".*clang.*"]
40+
- name: node
41+
command: node
42+
args: ["-v"]
43+
expectedOutput: [".*v16.*"]
44+
45+
fileExistenceTests:
46+
- name: "vcpkg"
47+
path: "/root/vcpkg"
48+
shouldExist: true
49+
- name: "llvm"
50+
path: "/root/llvm"
51+
shouldExist: true

dev/container-tests/ubuntu.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ commandTests:
3737
command: /root/llvm/bin/clang
3838
args: ["--version"]
3939
expectedOutput: [".*clang.*"]
40+
- name: node
41+
command: node
42+
args: ["-v"]
43+
expectedOutput: [".*v12.*"]
4044

4145
fileExistenceTests:
4246
- name: "vcpkg"
@@ -45,3 +49,9 @@ fileExistenceTests:
4549
- name: "llvm"
4650
path: "/root/llvm"
4751
shouldExist: true
52+
- name: "ninja"
53+
path: "/root/ninja"
54+
shouldExist: true
55+
- name: "cmake"
56+
path: "/root/cmake"
57+
shouldExist: true

dev/docker/arch_node.mingw.dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## base image
2+
FROM archlinux as base
3+
4+
RUN pacman -Syuu --noconfirm
5+
RUN pacman-db-upgrade
6+
7+
# yay for AUR installs
8+
RUN pacman -S --noconfirm --needed git base-devel
9+
## can't run makepkg as root, "ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system."
10+
## add new user
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+
chown -R yay:root /opt/yay && chmod -R 775 /opt/yay
14+
USER yay
15+
RUN cd /opt/yay && makepkg -si --noprogressbar --noconfirm
16+
USER root
17+
RUN rm -rf /tmp/yay
18+
19+
# nodejs
20+
RUN pacman -S --noconfirm --needed nodejs
21+
22+
# curl for downloading setup-cpp
23+
RUN pacman -S --noconfirm --needed curl
24+
25+
# add setup_cpp.js
26+
COPY "./dist/node12" "/"
27+
WORKDIR "/"
28+
29+
# run installation
30+
RUN node ./setup_cpp.js --cmake true --ninja true --ccache true --vcpkg true --doxygen true --gcovr true --task true
31+
## ERROR: Running makepkg as root is not allowed as it can cause permanent,
32+
## Error: Command failed with exit code 1: sudo 'yay' '-S' '--noconfirm' 'powershell-bin'
33+
## need to run this as yay-user so I can install powershell and mingw
34+
USER yay
35+
RUN node ./setup_cpp.js --compiler mingw --powershell true
36+
USER root
37+
38+
# clean up
39+
RUN pacman -Scc --noconfirm
40+
RUN rm -rf /tmp/*
41+
42+
CMD source ~/.cpprc
43+
ENTRYPOINT [ "/bin/bash" ]
44+
45+
## setup vcpkg env. (triplets)
46+
## https://github.com/microsoft/vcpkg/blob/master/docs/users/mingw.md
47+
ENV VCPKG_DEFAULT_HOST_TRIPLET "x64-linux"
48+
ENV VCPKG_DEFAULT_TRIPLET "x64-mingw-dynamic"
49+
ENV CC "x86_64-w64-mingw32-gcc"
50+
ENV CXX "x86_64-w64-mingw32-g++"
51+
52+
# TODO: better setup for cmake toolchains ?
53+
COPY ./dev/cmake/x86_64-w64-mingw32.toolchain.cmake /home/cmake/toolchains/x86_64-w64-mingw32.toolchain.cmake
54+
55+
#### Building
56+
FROM base AS builder
57+
COPY ./dev/cpp_vcpkg_project /home/app
58+
WORKDIR /home/app
59+
RUN bash -c 'source ~/.cpprc \
60+
&& task cross_build_mingw'
61+

0 commit comments

Comments
 (0)