Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mingw cross-compiler #103

Merged
merged 15 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ jobs:
- "arch.dockerfile"
- "fedora.dockerfile"
- "ubuntu.dockerfile"
- "arch-mingw.dockerfile"
- "fedora-mingw.dockerfile"
- "ubuntu-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
37 changes: 37 additions & 0 deletions dev/docker/__tests__/arch-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## base image
FROM archlinux:base as setup-cpp-arch-mingw

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

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
4 changes: 0 additions & 4 deletions dev/docker/__tests__/arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ commandTests:
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]

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
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
10 changes: 10 additions & 0 deletions dev/docker/__tests__/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ commandTests:
command: /root/llvm/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]
- name: node
command: node
args: ["-v"]
expectedOutput: [".*v12.*"]

fileExistenceTests:
- name: "vcpkg"
Expand All @@ -45,3 +49,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'
28 changes: 28 additions & 0 deletions dev/docker/setup-cpp-arch-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## base image
FROM archlinux:base as setup-cpp-arch-mingw

RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
# install nodejs
pacman -S --noconfirm --needed nodejs npm && \
# install setup-cpp
npm install -g [email protected] && \
# install the compiler and tools
setup-cpp \
--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"]
26 changes: 26 additions & 0 deletions dev/docker/setup-cpp-fedora-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## base image
FROM fedora:38 as setup-cpp-fedora-mingw

# install nodejs
RUN dnf -y install nodejs npm && \
# install setup-cpp
npm install -g [email protected] && \
# install the compiler and tools
setup-cpp \
--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"]
32 changes: 32 additions & 0 deletions dev/docker/setup-cpp-ubuntu-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu-mingw

RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \
# install setup-cpp
npm install -g [email protected] && \
# install the compiler and tools
setup-cpp \
--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"]
7 changes: 7 additions & 0 deletions dev/docker/ubuntu-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### 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'
8 changes: 4 additions & 4 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
"test.lint.prettier": "prettier . --check",
"test.unit": "jest --runInBand",
"build.docker_tests": "pnpm build && node ./dev/scripts/generate-docker-tests.mjs",
"build.docker_tests": "pnpm build && node ./dev/docker/__tests__/generate-docker-tests.mjs",
"build.docker.arch": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/arch.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/fedora.dockerfile -t setup-cpp:fedora .",
"build.docker.ubuntu": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/ubuntu.dockerfile -t setup-cpp:ubuntu .",
"build.docker.arch.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/arch-mingw.dockerfile -t setup-cpp:arch-mingw .",
"build.docker.fedora.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/fedora-mingw.dockerfile -t setup-cpp:fedora-mingw .",
"build.docker.ubuntu.mingw": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/ubuntu-mingw.dockerfile -t setup-cpp:ubuntu-mingw .",
"test.docker.arch": "pnpm build.docker.arch && container-structure-test test --image setup-cpp:arch --config ./dev/docker/__tests__/arch.yml",
"test.docker.fedora": "pnpm build.docker.fedora && container-structure-test test --image setup-cpp:fedora --config ./dev/docker/__tests__/fedora.yml",
"test.docker.ubuntu": "pnpm build.docker.ubuntu && container-structure-test test --image setup-cpp:ubuntu --config ./dev/docker/__tests__/ubuntu.yml"
"test.docker.ubuntu": "pnpm build.docker.ubuntu && container-structure-test test --image setup-cpp:ubuntu --config ./dev/docker/__tests__/ubuntu.yml",
"test.docker.arch.mingw": "pnpm build.docker.arch.mingw && container-structure-test test --image setup-cpp:arch-mingw --config ./dev/docker/__tests__/arch-mingw.yml",
"test.docker.fedora.mingw": "pnpm build.docker.fedora.mingw && container-structure-test test --image setup-cpp:fedora-mingw --config ./dev/docker/__tests__/fedora-mingw.yml",
"test.docker.ubuntu.mingw": "pnpm build.docker.ubuntu.mingw && container-structure-test test --image setup-cpp:ubuntu-mingw --config ./dev/docker/__tests__/ubuntu-mingw.yml"
},
"prettier": "prettier-config-atomic",
"devDependencies": {
Expand Down
Loading