Skip to content

Commit

Permalink
Static builds of rapidyenc
Browse files Browse the repository at this point in the history
  • Loading branch information
mnightingale committed Oct 31, 2023
1 parent dcb4c29 commit 95eecef
Show file tree
Hide file tree
Showing 74 changed files with 14,870 additions and 14 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Build

on:
push:
paths:
- 'rapidyenc/**'
- '.github/workflows/build.yml'

jobs:
build_macos:
name: Build macOS
runs-on: macos-13

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build
run: |
export ZERO_AR_DATE=1
cmake -S rapidyenc -B rapidyenc/build \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \
-DCMAKE_C_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
-DCMAKE_CXX_COMPILER=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ \
-DCMAKE_AR=/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu)
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_darwin.a
- name: Upload static library
uses: actions/upload-artifact@v3
with:
name: static
path: librapidyenc_darwin.a

build_windows:
name: Build Windows x64
runs-on: windows-latest

defaults:
run:
shell: msys2 {0}

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
pacboy: >-
gcc:p
cmake:p
ninja:p
- name: Build
run: |
cmake -S rapidyenc -B rapidyenc/build -G Ninja
cmake --build rapidyenc/build --config Release --target rapidyenc_static
cp rapidyenc/build/rapidyenc_static/librapidyenc.a librapidyenc_windows_amd64.a
- name: Upload shared library
uses: actions/upload-artifact@v3
with:
name: static
path: librapidyenc_windows_amd64.a

build_linux:
name: Build ${{ matrix.platform }}
runs-on: ubuntu-latest

strategy:
matrix:
include:
- platform: linux/amd64
library: librapidyenc_linux_amd64.a
- platform: linux/arm64
library: librapidyenc_linux_arm64.a

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
if: matrix.platform == 'linux/arm64'
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build cross-compilation environment
uses: docker/build-push-action@v4
with:
context: .
tags: builder/${{ matrix.platform }}:latest
platforms: ${{ matrix.platform }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: false

- name: Build with Docker
uses: addnab/docker-run-action@v3
with:
image: builder/${{ matrix.platform }}:latest
options: |
--platform ${{ matrix.platform }}
--volume ${{ github.workspace }}:/workspace
--workdir /workspace
run: |
cmake -S rapidyenc -B rapidyenc/build \
-D CMAKE_BUILD_TYPE=Release
cmake --build rapidyenc/build --target rapidyenc_static -j$(sysctl -n hw.ncpu)
cp rapidyenc/build/rapidyenc_static/librapidyenc.a ${{ matrix.library }}
- name: Upload static library
uses: actions/upload-artifact@v3
with:
name: static
path: ${{ matrix.library }}

test:
name: Test ${{ matrix.os }} go/${{ matrix.go }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.21]
runs-on: ${{ matrix.os }}
needs: [build_linux, build_macos, build_windows]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go ${{ matrix.go }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- uses: actions/download-artifact@v3
with:
name: static
path: lib
- name: Run tests
run: go test -v

publish:
name: Publish rapidyenc build
runs-on: ubuntu-latest

needs: [test]

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: actions/download-artifact@v3
with:
name: static
- uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: '*.a'
commit_message: Built rapidyenc
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rapidyenc/build
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM gcc:13 AS cross

ARG TARGETPLATFORM

RUN apt-get update && apt-get install -y cmake
4 changes: 4 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package rapidyenc

/*
#cgo CFLAGS: -I${SRCDIR}/rapidyenc
#cgo darwin LDFLAGS: ${SRCDIR}/librapidyenc_darwin.a -lstdc++
#cgo windows,amd64 LDFLAGS: ${SRCDIR}/librapidyenc_windows_amd64.a -lstdc++
#cgo linux,amd64 LDFLAGS: ${SRCDIR}/librapidyenc_linux_amd64.a -lstdc++
#cgo linux,arm64 LDFLAGS: ${SRCDIR}/librapidyenc_linux_arm64.a -lstdc++
#include "rapidyenc.h"
*/
import "C"
Expand Down
4 changes: 4 additions & 0 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package rapidyenc

/*
#cgo CFLAGS: -I${SRCDIR}/rapidyenc
#cgo darwin LDFLAGS: ${SRCDIR}/librapidyenc_darwin.a -lstdc++
#cgo windows,amd64 LDFLAGS: ${SRCDIR}/librapidyenc_windows_amd64.a -lstdc++
#cgo linux,amd64 LDFLAGS: ${SRCDIR}/librapidyenc_linux_amd64.a -lstdc++
#cgo linux,arm64 LDFLAGS: ${SRCDIR}/librapidyenc_linux_arm64.a -lstdc++
#include "rapidyenc.h"
*/
import "C"
Expand Down
Empty file removed lib/.gitignore
Empty file.
Binary file added librapidyenc_darwin.a
Binary file not shown.
Binary file added librapidyenc_linux_amd64.a
Binary file not shown.
Binary file added librapidyenc_linux_arm64.a
Binary file not shown.
Binary file added librapidyenc_windows_amd64.a
Binary file not shown.
1 change: 0 additions & 1 deletion rapidyenc
Submodule rapidyenc deleted from 9c6f0b
Loading

0 comments on commit 95eecef

Please sign in to comment.