Skip to content

Commit

Permalink
Merge pull request #103 from abeimler/feature/cross-mingw
Browse files Browse the repository at this point in the history
add mingw cross-compiler
  • Loading branch information
aminya authored Jul 24, 2023
2 parents 3d4b6fc + cee1b63 commit 14b5580
Show file tree
Hide file tree
Showing 30 changed files with 421 additions and 70 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ jobs:
pnpm:
- 8
container:
- "arch.dockerfile"
- "fedora.dockerfile"
- "ubuntu.dockerfile"
- "fedora.dockerfile"
- "arch.dockerfile"
- "ubuntu-mingw.dockerfile"
# - "fedora-mingw.dockerfile"
# - "arch-mingw.dockerfile"
steps:
- uses: actions/checkout@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ words:
- whatwg
- xcrun
- Yahyaabadi
- VCPKG
- DVCPKG
- SYSROOT
ignoreWords: []
import: []
dictionaryDefinitions: []
Expand Down
53 changes: 53 additions & 0 deletions dev/docker/__tests__/arch-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## base image
FROM archlinux:base-devel as setup-cpp-arch-mingw

COPY "./dist/legacy" "/usr/lib/setup-cpp/"

# install git
RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
pacman -S --noconfirm --needed git
# install yay
RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay
WORKDIR /opt/yay
RUN chown -R yay:root . && chmod -R 775 .
USER yay
WORKDIR /opt/yay
RUN makepkg -si --noprogressbar --noconfirm
## clean up
USER root
WORKDIR /
RUN rm -rf /opt/yay

RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
# install nodejs
pacman -S --noconfirm --needed nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# arch cleanup
pacman -Scc --noconfirm && \
rm -rf /var/cache/pacman/pkg/* && \
rm -rf /tmp/*

ENTRYPOINT ["/bin/bash"]

#### Cross Building (example)
FROM setup-cpp-arch-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
23 changes: 23 additions & 0 deletions dev/docker/__tests__/arch-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schemaVersion: 2.0.0

commandTests:
- name: mingw c compiler
command: x86_64-w64-mingw32-gcc
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
- name: mingw c++ compiler
command: x86_64-w64-mingw32-g++
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-g\\+\\+*"]
- name: powershell
command: pwsh
args: ["-Version"]
expectedOutput: [".*PowerShell.*"]

fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
- name: "cross root"
path: "/usr/x86_64-w64-mingw32"
shouldExist: true
18 changes: 3 additions & 15 deletions dev/docker/__tests__/arch.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
schemaVersion: 2.0.0

commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*GCC.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*GCC.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
Expand All @@ -29,10 +17,10 @@ commandTests:
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
- name: clang
command: /usr/lib/llvm-15/bin/clang
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
expectedOutput: [".*clang.*"]

fileExistenceTests:
- name: "vcpkg"
Expand Down
35 changes: 35 additions & 0 deletions dev/docker/__tests__/fedora-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## base image
FROM fedora:38 as setup-cpp-fedora-mingw

COPY "./dist/legacy" "/usr/lib/setup-cpp/"

# install nodejs
RUN dnf -y install nodejs npm && \

# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true \
--powershell true && \
# cleanup
dnf clean all && \
rm -rf /tmp/*

ENTRYPOINT ["/bin/bash"]

#### Cross Building (example)
FROM setup-cpp-fedora-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
23 changes: 23 additions & 0 deletions dev/docker/__tests__/fedora-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schemaVersion: 2.0.0

commandTests:
- name: mingw c compiler
command: x86_64-w64-mingw32-gcc
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
- name: mingw c++ compiler
command: x86_64-w64-mingw32-cpp
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-cpp.*"]
- name: powershell
command: pwsh
args: ["-Version"]
expectedOutput: [".*PowerShell.*"]

fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
- name: "cross root"
path: "/usr/x86_64-w64-mingw32"
shouldExist: true
16 changes: 4 additions & 12 deletions dev/docker/__tests__/fedora.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
schemaVersion: 2.0.0

commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*GCC.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*GCC.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
Expand All @@ -29,6 +17,10 @@ commandTests:
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: clang
command: /usr/lib/llvm-15/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]

fileExistenceTests:
- name: "vcpkg"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile, writeFile } from "fs/promises"

async function main() {
const dockerFiles = ["ubuntu", "arch", "fedora"]
const dockerFiles = ["ubuntu", "arch", "fedora", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
await Promise.all(
dockerFiles.map(async (dockerFile) => {
const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8")
Expand Down
41 changes: 41 additions & 0 deletions dev/docker/__tests__/ubuntu-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu-mingw

COPY "./dist/legacy" "/usr/lib/setup-cpp/"

RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \

# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--nala true \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true \
--powershell true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

ENTRYPOINT ["/bin/bash"]

#### Cross Building (example)
FROM setup-cpp-ubuntu-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
23 changes: 23 additions & 0 deletions dev/docker/__tests__/ubuntu-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schemaVersion: 2.0.0

commandTests:
- name: mingw c compiler
command: x86_64-w64-mingw32-gcc
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-gcc.*"]
- name: mingw c++ compiler
command: x86_64-w64-mingw32-g++
args: ["--version"]
expectedOutput: [".*x86_64-w64-mingw32-g\\+\\+*"]
- name: powershell
command: pwsh
args: ["-Version"]
expectedOutput: [".*PowerShell.*"]

fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
- name: "cross root"
path: "/usr/x86_64-w64-mingw32"
shouldExist: true
28 changes: 11 additions & 17 deletions dev/docker/__tests__/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
schemaVersion: 2.0.0

commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
command: /usr/local/bin/gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
command: /usr/bin/ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
command: /usr/bin/doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
command: /usr/bin/cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
- name: clang
command: /root/llvm/bin/clang
command: /usr/lib/llvm-15/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]

Expand All @@ -45,3 +33,9 @@ fileExistenceTests:
- name: "llvm"
path: "/root/llvm"
shouldExist: true
- name: "ninja"
path: "/root/ninja"
shouldExist: true
- name: "cmake"
path: "/root/cmake"
shouldExist: true
7 changes: 7 additions & 0 deletions dev/docker/arch-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### Cross Building (example)
FROM setup-cpp-arch-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
7 changes: 7 additions & 0 deletions dev/docker/fedora-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### Cross Building (example)
FROM setup-cpp-fedora-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
Loading

0 comments on commit 14b5580

Please sign in to comment.