Skip to content

Commit

Permalink
update build system
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed May 11, 2024
1 parent 782f199 commit 88d9e55
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 42 deletions.
112 changes: 91 additions & 21 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,102 @@
name: linux
name: Linux

on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/linux.yml'
pull_request:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/linux.yml'
release:
types: [published]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: ubuntu-20.04
strategy:
fail-fast: false
max-parallel: 1
matrix:
bits: [32, 64]
include:
- bits: 32
ARCH: "i386"
ARCH_NAME: "i386"
COMPILER_PATH: "/user/bin"
- bits: 64
ARCH: "x86_64"
ARCH_NAME: "amd64"
COMPILER_PATH: "/user/bin"

env:
RELEASE_NAME: RGFW-dev_linux_${{ matrix.ARCH_NAME }}

- name: wget_vulkan
run: wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc && sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
steps:
- name: Checkout code
uses: actions/checkout@master

- name: apt-update
run: sudo apt-get update
- name: Setup Release Version
run: |
echo "RELEASE_NAME=RGFW-${{ github.event.release.tag_name }}_linux_${{ matrix.ARCH_NAME }}" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'

- name: apt-vulkan
run: sudo apt install vulkan-sdk

- name: install_xrandr
run: sudo apt install libxrandr-dev
- name: Setup Environment
run: |
sudo apt-get update -qq
sudo apt-get install gcc-multilib
sudo apt-get install -y --no-install-recommends libx11-dev mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
mkdir build
cd build
mkdir ${{ env.RELEASE_NAME }}
cd ${{ env.RELEASE_NAME }}
mkdir include
mkdir lib
cd ../../../RGFW
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
# TODO: Support 32bit (i386) static/shared library building
- name: Build Library
run: |
make libRGFW.a CUSTOM_CFLAGS="-m32"
if: matrix.bits == 32

- name: apt
run: sudo apt-get install mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers
- name: make
run: make
- name: Build Library
run: |
make libRGFW.a
make libRGFW.so
cp -v ./libRGFW.so ./build/${{ env.RELEASE_NAME }}/lib
if: matrix.bits == 64

- name: Generate Artifacts
run: |
cp -v ./RGFW.h ./build/${{ env.RELEASE_NAME }}/include
cp -v ./libRGFW.a ./build/${{ env.RELEASE_NAME }}/lib
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
cd build
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz

- name: Upload Artifact to Release
uses: softprops/action-gh-release@v1
with:
files: ./build/${{ env.RELEASE_NAME }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release' && github.event.action == 'published'
109 changes: 99 additions & 10 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,109 @@
name: macos
name: macOS

on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/macos.yml'
pull_request:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/macos.yml'
release:
types: [published]

permissions:
contents: read

jobs:
build:

permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: macos-latest


env:
RELEASE_NAME: RGFW-dev_macos

steps:
- uses: actions/checkout@v3
- name: gcc-basic
run: gcc -I./ ./examples/basic/main.c -Wall -framework AppKit -framework OpenGL -framework CoreVideo -std=c99
- name: Checkout
uses: actions/checkout@master

- name: gcc-gl33
run: gcc -I./ ./examples/gl33/main.c -framework AppKit -framework OpenGL -framework CoreVideo -std=c99
- name: Setup Release Version
run: |
echo "RELEASE_NAME=RGFW-${{ github.event.release.tag_name }}_macos" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'

- name: Setup Environment
run: |
mkdir build
cd build
mkdir ${{ env.RELEASE_NAME }}
cd ${{ env.RELEASE_NAME }}
mkdir include
mkdir lib
cd ../..
# Generating static + shared library, note that i386 architecture is deprecated
# Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS
- name: Build Library
run: |
clang --version
# Extract version numbers from Makefile
brew install grep
# Build RGFW x86_64 static
make libRGFW.a CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
mv libRGFW.a /tmp/libRGFW_x86_64.a
rm -f RGFW.o
# Build RGFW arm64 static
make libRGFW.a CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION"
mv libRGFW.a /tmp/libRGFW_arm64.a
rm -f RGFW.o
# Join x86_64 and arm64 static
lipo -create -output build/${{ env.RELEASE_NAME }}/lib/libRGFW.a /tmp/libRGFW_x86_64.a /tmp/libRGFW_arm64.a
# Build RGFW x86_64 dynamic
make libRGFW.dylib CUSTOM_CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
mv libRGFW.dylib /tmp/libRGFW_x86_64.dylib
rm -f RGFW.o
# Build RGFW arm64 dynamic
make libRGFW.dylib CUSTOM_CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION"
mv libRGFW.dylib /tmp/libRGFW_arm64.dylib
# Join x86_64 and arm64 dynamic
rm -f ./build/lib/*
lipo -create -output libRGFW.dylib /tmp/libRGFW_x86_64.dylib /tmp/libRGFW_arm64.dylib
ln -sv libRGFW.dylib build/${{ env.RELEASE_NAME }}/lib/libRGFW.dylib
- name: Generate Artifacts
run: |
mkdir -p build
mkdir -p build/include
mkdir -p build/lib
cp -v ./RGFW.h ./build/${{ env.RELEASE_NAME }}/include
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
cd build
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz

- name: Upload Artifact to Release
uses: softprops/action-gh-release@v1
with:
files: ./build/${{ env.RELEASE_NAME }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release' && github.event.action == 'published'
139 changes: 130 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,141 @@
name: windows
name: Windows

on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/windows.yml'
pull_request:
branches: [ "main" ]
paths:
- '**'
- 'examples/**'
- '.github/workflows/windows.yml'
release:
types: [published]

permissions:
contents: read

jobs:
build:

permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
compiler: [mingw-w64, msvc16]
bits: [32, 64]
include:
- compiler: mingw-w64
bits: 32
ARCH: "i686"
WINDRES_ARCH: pe-i386
- compiler: mingw-w64
bits: 64
ARCH: "x86_64"
WINDRES_ARCH: pe-x86-64
- compiler: msvc16
bits: 32
ARCH: "x86"
VSARCHPATH: "Win32"
- compiler: msvc16
bits: 64
ARCH: "x64"
VSARCHPATH: "x64"

env:
RELEASE_NAME: RGFW-dev_win${{ matrix.bits }}_${{ matrix.compiler }}
GNUTARGET: default

steps:
- uses: actions/checkout@v3
- name: gcc
run: gcc -I./ ./examples/basic/main.c -lXInput -lopengl32 -lShcore -lshell32 -lgdi32
- name: Checkout
uses: actions/checkout@master

- name: Setup Release Version
run: |
echo "RELEASE_NAME=RGFW-${{ github.event.release.tag_name }}_win${{ matrix.bits }}_${{ matrix.compiler }}" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'

- name: Setup Environment
run: |
dir
mkdir build
cd build
mkdir ${{ env.RELEASE_NAME }}
cd ${{ env.RELEASE_NAME }}
mkdir include
mkdir lib
cd ../../../RGFW
# Setup MSBuild.exe path if required
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
if: matrix.compiler == 'msvc16'

- name: Build Library (MinGW-w64 32bit)
run: |
x86_64-w64-mingw32-gcc.exe --version
windres.exe --version
dir C:\msys64\mingw64\bin
make libRGFW.a CUSTOM_CFLAGS=-m32
shell: cmd
if: |
matrix.compiler == 'mingw-w64' &&
matrix.bits == 32
- name: Build Library (MinGW-w64 64bit)
run: |
${{ matrix.ARCH }}-w64-mingw32-gcc.exe --version
windres.exe --version
dir C:\msys64\mingw64\bin
rm -f RGFW.o
make libRGFW.a
make libRGFW.dll
copy /Y .\libRGFW.dll .\build\${{ env.RELEASE_NAME }}\lib
shell: cmd
if: |
matrix.compiler == 'mingw-w64' &&
matrix.bits == 64
# - name: Build Library (MSVC16)
# run: |
# cd projects/VS2022
# msbuild.exe RGFW.sln /target:RGFW /property:Configuration=Release /property:Platform=${{ matrix.ARCH }}
# copy /Y .\build\RGFW\bin\${{ matrix.VSARCHPATH }}\Release\RGFW.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\RGFW.lib
# msbuild.exe RGFW.sln /target:RGFW /property:Configuration=Release.DLL /property:Platform=${{ matrix.ARCH }}
# copy /Y .\build\RGFW\bin\${{ matrix.VSARCHPATH }}\Release.DLL\RGFW.dll .\..\..\build\${{ env.RELEASE_NAME }}\lib\RGFW.dll
# copy /Y .\build\RGFW\bin\${{ matrix.VSARCHPATH }}\Release.DLL\RGFW.lib .\..\..\build\${{ env.RELEASE_NAME }}\lib\RGFWdll.lib
#cd ../..
#shell: cmd
#if: matrix.compiler == 'msvc16'

- name: Generate Artifacts
run: |
copy /Y .\RGFW.h .\build\${{ env.RELEASE_NAME }}\include
xcopy .\deps .\build\${{ env.RELEASE_NAME }}\include /E /I /Y
copy /Y .\libRGFW.a .\build\${{ env.RELEASE_NAME }}\lib
copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md
copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE
cd build
7z a ./${{ env.RELEASE_NAME }}.zip ./${{ env.RELEASE_NAME }}
dir
shell: cmd

- name: gcc-gl33
run: gcc -I./ ./examples/gl33/main.c -lXInput -Wall -Wall -lShcore -lopengl32 -lshell32 -lgdi32 -std=c99
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}.zip
path: ./build/${{ env.RELEASE_NAME }}.zip

- name: Upload Artifact to Release
uses: softprops/action-gh-release@v1
with:
files: ./build/${{ env.RELEASE_NAME }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release' && github.event.action == 'published'
Loading

0 comments on commit 88d9e55

Please sign in to comment.