Skip to content

Commit

Permalink
Provide static builds for macOS and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed Dec 23, 2023
1 parent 81e8a52 commit db691cf
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 32 deletions.
87 changes: 76 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defaults:
shell: bash

env:
VCPKG_COMMITTISH: 962e5e39f8a25f42522f51fffc574e05a3efd26b
VCPKG_COMMITTISH: c8696863d371ab7f46e213d8f5ca923c4aef2a00

jobs:
build_windows:
Expand Down Expand Up @@ -97,6 +97,7 @@ jobs:
run: cmake -S . -B build
-G "${{env.CMAKE_GENERATOR}}"
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
-DVCPKG_MANIFEST_FEATURES="ffmpeg;libebur128;inih;"
-DVCPKG_OVERLAY_PORTS=build/overlays/ports
-DVCPKG_OVERLAY_TRIPLETS=config/vcpkg_triplets
-DVCPKG_TARGET_TRIPLET=${{env.VCPKG_TRIPLET}}
Expand Down Expand Up @@ -134,11 +135,19 @@ jobs:
docker_image: debian:bookworm
package_type: DEB
package_ext: .deb
vcpkg_features: fmt;

- name: Fedora
docker_image: fedora:38
package_type: RPM
package_ext: .rpm
vcpkg_features: fmt;

- name: Static
docker_image: debian:bullseye
package_type: TXZ
package_ext: .tar.xz
vcpkg_features: fmt;ffmpeg;libebur128;inih;

container:
image: ${{matrix.config.docker_image}}
Expand All @@ -157,11 +166,14 @@ jobs:
- name: "Install dependencies"
run: |
if [[ "${{matrix.config.name}}" == "Debian" ]]; then
apt update && apt install -y curl zip unzip tar build-essential git cmake pkg-config libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libebur128-dev libinih-dev
apt update && apt install -y curl zip unzip tar build-essential git cmake pkg-config libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libebur128-dev libinih-dev binutils
fi
if [[ "${{matrix.config.name}}" == "Fedora" ]]; then
dnf install -y curl zip unzip tar git make pkg-config gcc-c++ fedora-packager rpmdevtools cmake libavcodec-free-devel libavformat-free-devel libswresample-free-devel libavutil-free-devel libebur128-devel inih-devel
fi
if [[ "${{matrix.config.name}}" == "Static" ]]; then
apt update && apt install -y curl zip unzip tar build-essential git cmake pkg-config python3 nasm binutils
fi
- name: Setup vcpkg
uses: friendlyanon/setup-vcpkg@v1
Expand All @@ -170,14 +182,23 @@ jobs:
cache-key: vcpkg-${{matrix.config.name}}-${{env.VCPKG_COMMITISH}}
cache-restore-keys: vcpkg-${{matrix.config.name}}-${{env.VCPKG_COMMITISH}}

- name: Setup Overlays
uses: actions/checkout@v3
with:
repository: complexlogic/vcpkg
ref: refs/heads/rsgain
path: build/overlays

- name: Configure
run: cmake -S . -B build
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
-DVCPKG_TARGET_TRIPLET=${{env.VCPKG_TRIPLET}}
-DVCPKG_MANIFEST_FEATURES="external-fmt;"
-DVCPKG_MANIFEST_FEATURES="${{matrix.config.vcpkg_features}}"
-DVCPKG_OVERLAY_PORTS=build/overlays/ports
-DCMAKE_BUILD_TYPE=${{env.CMAKE_BUILD_TYPE}}
-DCMAKE_INSTALL_PREFIX=/usr
-DPACKAGE=${{matrix.config.package_type}}
-DSTRIP_BINARY=ON

- name: Build
run: |
Expand Down Expand Up @@ -206,6 +227,15 @@ jobs:
packages: write
strategy:
fail-fast: false
matrix:
config:
- name: Intel
OSX_ARCH: x86_64
VCPKG_TRIPLET: x64-osx

- name: Apple Silicon
OSX_ARCH: arm64
VCPKG_TRIPLET: arm64-osx

env:
CMAKE_BUILD_TYPE: Release
Expand All @@ -216,19 +246,54 @@ jobs:
with:
fetch-depth: 0

- name: "Install dependencies"
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install libebur128 taglib ffmpeg fmt inih cmake pkg-config || true
- name: Install Dependencies
run: brew install nasm automake autoconf-archive ninja

- name: Setup vcpkg
uses: friendlyanon/setup-vcpkg@v1
with:
committish: ${{env.VCPKG_COMMITTISH}}
cache-key: vcpkg-${{matrix.config.name}}-${{env.VCPKG_COMMITISH}}
cache-restore-keys: vcpkg-${{matrix.config.name}}-${{env.VCPKG_COMMITISH}}

- name: Setup Overlays
uses: actions/checkout@v3
with:
repository: complexlogic/vcpkg
ref: refs/heads/rsgain
path: build/overlays

- name: Configure
run: cmake -S . -B build
-DCMAKE_BUILD_TYPE=${{env.CMAKE_BUILD_TYPE}}
-DCMAKE_INSTALL_PREFIX=/usr
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_OSX_ARCHITECTURES=${{matrix.config.OSX_ARCH}}
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
-DVCPKG_OVERLAY_PORTS=build/overlays/ports
-DVCPKG_TARGET_TRIPLET=${{matrix.config.VCPKG_TRIPLET}}
-DVCPKG_MANIFEST_FEATURES="fmt;ffmpeg;libebur128;inih;"
-DSTRIP_BINARY=ON
-DPACKAGE=ZIP
-DCPACK_SYSTEM_NAME="macOS-${{matrix.config.OSX_ARCH}}"

- name: Build
run: |
cmake \
--build build \
--config ${{env.CMAKE_BUILD_TYPE}}
build/rsgain -v
--target package
- name: Test
if: ${{matrix.config.OSX_ARCH == 'x86_64'}}
run: build/rsgain -v

- name: Upload Package
uses: actions/upload-artifact@v3
with:
name: macOS ${{matrix.config.name}} build
path: build/*.zip

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/*.zip
token: ${{secrets.ACTIONS_SECRET}}
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ elseif (UNIX)
pkg_check_modules(TAGLIB REQUIRED IMPORTED_TARGET taglib>=1.11.1)
pkg_check_modules(LIBEBUR128 REQUIRED IMPORTED_TARGET libebur128>=1.2.4)
pkg_check_modules(INIH REQUIRED IMPORTED_TARGET inih)
if (STRIP_BINARY)
find_program(STRIP strip REQUIRED)
endif ()
if (NOT USE_STD_FORMAT)
pkg_check_modules(FMT REQUIRED IMPORTED_TARGET fmt)
endif ()
Expand Down Expand Up @@ -180,6 +183,15 @@ elseif (UNIX)
install(FILES "${PROJECT_SOURCE_DIR}/docs/${EXECUTABLE_TITLE}.1" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1")
endif ()
install(DIRECTORY "${PROJECT_SOURCE_DIR}/config/presets" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${EXECUTABLE_TITLE}")
if (PACKAGE STREQUAL "TXZ" OR PACKAGE STREQUAL "ZIP")
set(BINARY_PREFIX ".")
set(PRESETS_PREFIX ".")
else ()
set(BINARY_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
set(PRESETS_PREFIX "${CMAKE_INSTALL_PREFIX}/share/${EXECUTABLE_TITLE}")
endif ()
install(TARGETS ${EXECUTABLE_TITLE} DESTINATION "${BINARY_PREFIX}")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/config/presets" DESTINATION "${PRESETS_PREFIX}")
set(PRESETS_DIR ${CMAKE_INSTALL_PREFIX}/share/${EXECUTABLE_TITLE}/presets)

# Build Debian packages
Expand All @@ -205,6 +217,8 @@ elseif (UNIX)
set(CPACK_RPM_PACKAGE_GROUP "Applications/Multimedia")
set(CPACK_RPM_PACKAGE_AUTOREQPROV 0)
set(CPACK_RPM_PACKAGE_REQUIRES "libavcodec-free >= 6, libavformat-free >= 6, libswresample-free >= 6, libavutil-free >= 6, libebur128, zlib, inih")
elseif (PACKAGE STREQUAL "TXZ")
set(CPACK_ARCHIVE_FILE_EXTENSION ".tar.xz")
endif ()
if (PACKAGE)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
Expand Down
3 changes: 3 additions & 0 deletions config/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ FetchContent_MakeAvailable(vcpkg vcpkg_overlay)
set(VCPKG_OVERLAY_PORTS "${CMAKE_BINARY_DIR}/_deps/vcpkg_overlay-src/ports")

if (WIN32)
if (NOT VCPKG_MANIFEST_FEATURES)
set(VCPKG_MANIFEST_FEATURES ffmpeg libebur128 inih)
endif ()
if (NOT VCPKG_OVERLAY_TRIPLETS)
list(APPEND VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/config/vcpkg_triplets")
endif ()
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ elseif (UNIX)
if (NOT USE_STD_FORMAT)
target_link_libraries(${EXECUTABLE_TITLE} PkgConfig::FMT)
endif ()
if (STRIP)
add_custom_command(TARGET ${EXECUTABLE_TITLE}
POST_BUILD
COMMAND "${STRIP}" "${PROJECT_BINARY_DIR}/${EXECUTABLE_TITLE}"
)
endif ()
endif()
set (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}")
string(TIMESTAMP BUILD_DATE "%Y-%m-%d")
Expand Down
44 changes: 23 additions & 21 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
{
"dependencies": [
{
"name": "libebur128",
"platform": "windows"
},
"taglib",
{
"name": "ffmpeg",
"platform": "windows",
"default-features": false,
"features": ["avcodec", "avformat", "swresample", "fdk-aac"]
},
{
"name": "fdk-aac",
"platform": "windows",
"features": ["he-aac"]
},
{
"name": "inih",
"platform": "windows"
},
{
"name": "getopt",
"platform": "windows"
}
],
"features": {
"external-fmt": {
"fmt": {
"description": "Use the fmtlib library for formatting",
"dependencies": ["fmt"]
},
"ffmpeg": {
"description": "Build FFmpeg",
"dependencies": [
{
"name": "ffmpeg",
"default-features": false,
"features": ["avcodec", "avformat", "swresample", "fdk-aac"]
},
{
"name": "fdk-aac",
"features": ["he-aac"]
}
]
},
"libebur128": {
"description": "Build libebur128",
"dependencies": ["libebur128"]
},
"inih": {
"description": "Build inih",
"dependencies": ["inih"]
}

}
}

0 comments on commit db691cf

Please sign in to comment.