Windows MinGW #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# File: %windows-mingw-build.yml | |
# | |
#=============================================================================# | |
# | |
# This uses a Linux container and the "Minimalist GNU for Windows" to cross | |
# compile executables for Windows. | |
# | |
# The main reason this exists in addition to the MSVC-based non-cross-compiling | |
# process is because the original CI process on Travis did not have containers | |
# running windows. So this was the only way to build Windows executables. | |
# | |
# Keeping it working has several advantages: | |
# | |
# * It tests compilation in a somewhat "alien" environment, which increases the | |
# likelihood that the code is being kept in shape such that it could be | |
# compiled for other unusual platforms. | |
# | |
# * If the cross-compilation with MinGW works, then odds are pretty good that | |
# the non-cross-compiling MinGW that runs on native Windows will work too. | |
# | |
# * Some open source libraries do not have configuration environments tailored | |
# to the MSVC toolchain. It may come up that someone wants to use such a | |
# library on Windows, and it can be easier to do that with MinGW than to | |
# try and figure out how to get it working with the MSVC toolset. | |
# | |
# There are limits to how much work is worth it to keep this working, but it | |
# has been historically not much cost so it's allowed to stay. | |
# | |
#====# PLEASE READ THE README #===============================================# | |
# | |
# Whenever this file says "See README", that is referring to the notes in the | |
# %.github/workflows/README.md file. If something appears in multiple GitHub | |
# Workflow files, it's best to document it there instead of repeating it: | |
# | |
# https://github.com/metaeducation/ren-c/blob/master/.github/workflows/README.md | |
# | |
name: Windows MinGW | |
# See README: When To Trigger Builds | |
# | |
on: | |
push: | |
branches: [ | |
# master, | |
mingw, # pushing to mingw won't build other workflows, use to debug | |
windows # pushing to windows builds this and msvc, use to debug | |
] | |
pull_request: | |
branches: [ | |
master | |
] | |
workflow_dispatch: # Allows running this workflow manually from Actions tab | |
# Standardize to use bash on all platforms. | |
# | |
# See README: Using The Strict Erroring Bash Shell | |
# | |
defaults: | |
run: | |
shell: bash | |
# Each "Job" runs in its own VM, and a workflow run is made up of one or more | |
# jobs that can run sequentially or in parallel. | |
# | |
# See README: Jobs | |
# | |
jobs: | |
windows-mingw-build: # Name of this workflow's only job | |
# https://github.com/actions/virtual-environments#available-environments | |
# | |
runs-on: ubuntu-latest | |
# See README: Build Matrix | |
# | |
# NOTE: The older MinGW used here is missing imports required by libuv. | |
# | |
# https://github.com/libuv/libuv/issues/3178 | |
# | |
# These are fixed in a modern MinGW, however running on an older MinGW | |
# is more interesting to keep on top of these glitches and how many of | |
# them there are. (If the core can't build even without libuv on an older | |
# MinGW it's more worth knowing about than that the extensions can build | |
# on a newer MinGW.) | |
# | |
strategy: | |
matrix: | |
include: | |
- os-id: 0.3.40 # 64-bit Target (built on this 64-bit platform) | |
config-file: mingw-x64.r | |
standard: c++17 | |
debug: none | |
extensions: "Network - Filesystem - Process - Locale - DNS -" | |
variation: "" # ^-- Note | |
- os-id: 0.3.1 # 32-bit Target (built on this 64-bit platform) | |
config-file: mingw-x86.r | |
standard: c99 | |
debug: normal | |
extensions: "Network - Filesystem - Process - Locale - DNS -" | |
variation: "" # ^-- Note | |
# See README: Environment Variables | |
# | |
env: | |
AWS_S3_BUCKET_NAME: metaeducation | |
# See README: Minimize GitHub-Specific Syntax | |
# | |
OS_ID: ${{ matrix.os-id }} | |
CONFIG_FILE: ${{ matrix.config-file }} | |
STANDARD: ${{ matrix.standard }} | |
DEBUG: ${{ matrix.debug }} | |
EXTENSIONS: ${{ matrix.extensions }} | |
VARIATION: ${{ matrix.variation }} | |
# Steps are a sequence of tasks that will be executed within a single VM | |
# as part of the job. | |
# | |
# See README: Steps | |
# | |
steps: # (no indentatation needed below; so indent the minimum!) | |
#====# CHECKOUT STEPS #=====================================================# | |
# https://github.com/actions/checkout | |
# | |
# See README: Checkout Action | |
# | |
- uses: actions/checkout@v3 # See README: Trusted Actions | |
# The full commit is passed to make to build into the binary, and the | |
# abbreviated commit is used to name the executable. | |
# | |
# See README: Portably Capturing Git Hashes | |
# | |
- name: Grab Git Hash and Short Hash Into Environment Variables | |
run: | | |
git_commit="$(git show --format="%H" --no-patch)" | |
git_commit_short="$(git show --format="%h" --no-patch)" | |
echo "GIT_COMMIT=$git_commit" >> $GITHUB_ENV | |
echo "GIT_COMMIT_SHORT=$git_commit_short" >> $GITHUB_ENV | |
#====# TOOLCHAIN INSTALLATION STEPS #=======================================# | |
# !!! Ideally this would use the same step that clients can use to build | |
# the system with `make.sh`. Unfortunately, something about the GitHub | |
# Ubuntus do not like the old bootstrap executable. Make sure the | |
# ordinary path works, but for the moment patch over it just to get | |
# to a point where the action works. | |
# | |
- name: Fetch R3 To Use For "Prep" Build Steps as $R3MAKE | |
run: | | |
repo_dir=$(pwd)/ | |
source tools/bash/fetch-prebuilt.sh | |
r3make=$(fetch_prebuilt) | |
echo "R3MAKE is set to $r3make" | |
echo "But that executable won't run on GitHub for some reason" | |
# "$r3make" --do "print {TESTING 1 2 3}" # NOT WORKING, dunno why | |
cd prebuilt | |
wget http://hostilefork.com/media/shared/github/r3-linux-8994d23-patched | |
chmod +x r3-linux-8994d23-patched | |
r3make=$(pwd)/r3-linux-8994d23-patched | |
echo "So now R3MAKE is $r3make" | |
echo "R3MAKE=$r3make" >> $GITHUB_ENV # pass to next step | |
- name: Stop the build early if the R3MAKE is no good | |
run: | | |
"$R3MAKE" --do "print {R3MAKE is Working} quit" | |
# MinGW appens to include the libraries for ODBC, since those are present | |
# by default for Windows. | |
# | |
- name: Get MinGW | |
run: | | |
sudo apt install binutils-mingw-w64-i686 | |
sudo apt install gcc-mingw-w64-i686 | |
sudo apt install mingw-w64 | |
# Show a little bit of sanity check information. | |
# | |
- name: Output System Information | |
run: | | |
echo "GCC version check:" | |
gcc -v # not the same as MinGW | |
#====# BUILD STEPS #========================================================# | |
# See README: {Braces} For %make.r String Parameters | |
# | |
- name: Use Rebmake to Generate a makefile | |
run: | | |
mkdir build | |
cd build | |
"$R3MAKE" ../make.r \ | |
config="../configs/$CONFIG_FILE" \ | |
target=makefile \ | |
standard=$STANDARD \ | |
os_id=$OS_ID \ | |
debug=$DEBUG \ | |
git_commit="{$GIT_COMMIT}" \ | |
rigorous=no \ | |
static=no \ | |
extensions="$EXTENSIONS" | |
- name: Create Folders For Build Products (Compiler Won't Create Them) | |
run: | | |
cd build | |
make folders | |
- name: Prep the Build By Making Various Auto-Generated .h and .c Files | |
run: | | |
cd build | |
make prep | |
# https://github.com/actions/upload-artifact | |
# | |
- name: Optional Download of Prep Files Before They Can Cause Build Failure | |
if: false # Change this to true to download a file | |
uses: actions/upload-artifact@v2 # See README: Trusted Actions | |
with: | |
name: tmp-internals.h | |
path: build/prep/include/tmp-internals.h | |
- name: Compile and Link the C Files to into R3BUILT | |
run: | | |
cd build | |
make -j 2 # Linux GitHub Runners have 2 cores, use 2 jobs | |
#====# NO TEST OR DEPLOYMENT #==============================================# | |
# We currently don't deploy or test the executables, trusting the MSVC | |
# build which is already on a Windows container to do it. Also, this | |
# lacks filesystem and network functions due to missing libuv dependencies. | |
# | |
# It would be possible to create another job specific to the testing, that | |
# would run in a Windows container...but really, this is already a bit of | |
# a stretch as being important given how many higher priority builds are | |
# being made. If someone has a good reason to be dependent upon MinGW | |
# then they can worry about taking this further. |