Skip to content

Commit

Permalink
Merge pull request #7 from ak5k/ak5k-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ak5k authored Jan 3, 2024
2 parents 99bc2f6 + 89a6ac4 commit 83ee853
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 6 deletions.
180 changes: 180 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
name: C++ CI

on:
push:
branches:
- main
tags:
- '*'
env:
APPVEYOR: true
APPVEYOR_BUILD_NUMBER: ${{ github.run_number }}
APPVEYOR_REPO_COMMIT: ${{ github.sha }}
VS_PATH: "%ProgramFiles%\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build"
MACOSX_DEPLOYMENT_TARGET: 11.0

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- os: macos-latest
arch: arm64;x86_64
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-latest
arch: aarch64
- os: ubuntu-latest
arch: i686
- os: ubuntu-latest
arch: armv7l
- os: windows-latest
arch: x64
win_build_type: RelWithDebInfo
- os: windows-latest
arch: x86
win_build_type: Release

steps:
- uses: actions/checkout@v2

- name: Create Build Environment
# Some setup steps may vary depending on the operating system
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
ARCH=${{ matrix.arch }}
sudo sed -i '/arch=/! s/^deb/deb [arch=amd64,i386]/' /etc/apt/sources.list
install-deps() {
# sudo add-apt-repository --remove "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main"
local arch="$1"; shift
local native=("$@" php-cli qemu-user-binfmt )
local target=()
sudo dpkg --add-architecture $arch
sudo apt-get update -qq
sudo apt-get install -qq aptitude > /dev/null
sudo aptitude install -yR ${native[@]} ${target[@]/%/:$arch} > /dev/null
}
# sudo update-alternatives --set gcc /usr/bin/gcc-7
case $ARCH in
x86_64)
install-deps amd64
;;
i686)
install-deps i386 g++-multilib
export TOOLCHAIN=$(pwd)/cmake/linux-cross.cmake \
TOOLCHAIN_PREFIX=i386-linux-gnu
;;
armv7l)
install-deps armhf g++-arm-linux-gnueabihf
export TOOLCHAIN=$(pwd)/cmake/linux-cross.cmake \
TOOLCHAIN_PREFIX=arm-linux-gnueabihf
;;
aarch64)
install-deps arm64 g++-aarch64-linux-gnu
export TOOLCHAIN=$(pwd)/cmake/linux-cross.cmake \
TOOLCHAIN_PREFIX=aarch64-linux-gnu
;;
esac
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
choco install ninja
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
:
fi
- name: Windows build
if: runner.os == 'Windows'
working-directory: ${{ github.workspace }}
shell: cmd
run: |
if "${{matrix.arch}}" == "x64" call "%VS_PATH%\vcvars64.bat"
if "${{matrix.arch}}" == "x86" call "%VS_PATH%\vcvars32.bat"
cmake -B ${{ github.workspace }} ^
-G "Ninja" ^
-DCMAKE_BUILD_TYPE=${{ matrix.win_build_type }} ^
-S ${{ github.workspace }} ^
-DVCPKG_TARGET_TRIPLET=${{matrix.arch}}-windows-static ^
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%\scripts\buildsystems\vcpkg.cmake
cmake --build ${{ github.workspace }} --config ${{ matrix.win_build_type }}
- name: Unix-like build
if: runner.os != 'Windows'
run: |
cmake -B ${{ github.workspace }} \
-DCMAKE_BUILD_TYPE=Release \
-S ${{ github.workspace }} \
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
-DVCPKG_TARGET_TRIPLET=arch-env -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$TOOLCHAIN \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build ${{ github.workspace }} --config Release
- name: CTest
if: runner.os != 'Windows'
working-directory: ${{ github.workspace }}
run: ctest --build-config Release

- name: CPack
working-directory: ${{ github.workspace }}
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" &&
"${{ matrix.arch }}" == "x64" ]]; then
cpack
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
sudo cpack
fi
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: my-artifact
path: |
./reaper_*.dll
./reaper_*.pdb
./reaper_*.dylib
./reaper_*.so
./*.exe
./*.pkg
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: my-artifact
path: ./artifacts

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: true
prerelease: false

- name: Upload Release Assets
run: |
for file in ./artifacts/*; do
if [ -f "$file" ]; then
echo "Uploading $file"
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}=$(basename $file)"
fi
done
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ cmake_minimum_required(VERSION 3.15)

project(reallm VERSION 0.0.0 LANGUAGES C CXX)

# Find Git
find_package(Git)

# If Git was found
if(GIT_FOUND)
# Get the latest git tag
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_LATEST_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT "${GIT_LATEST_TAG}" STREQUAL "")
string(REGEX REPLACE "[^0-9.]" "" GIT_LATEST_TAG ${GIT_LATEST_TAG})
# Set the project version to the latest git tag
project(${PROJECT_NAME} VERSION ${GIT_LATEST_TAG} LANGUAGES C CXX)
project(${PROJECT_NAME} VERSION ${GIT_LATEST_TAG} LANGUAGES C CXX)
endif()
endif()
message("Project version: ${PROJECT_VERSION}")

Expand Down

0 comments on commit 83ee853

Please sign in to comment.