Skip to content

Commit

Permalink
add gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechnobear committed Feb 12, 2024
1 parent cf0aecc commit 8885d39
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
UseTab: Never

---
Language: Cpp

AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly

BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false

Cpp11BracedListStyle: false

MaxEmptyLinesToKeep: 2

---

152 changes: 152 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Build EigenLite
permissions:
contents: write

on:
push:
tags:
- '*'

jobs:
# Ubuntu - would need libusb

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

# strategy:
# # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
# fail-fast: false

# # Set up a matrix to run the following 3 configurations:
# # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
# #
# # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
# matrix:
# # os: [ubuntu-latest]
# # os: [ubuntu-latest, windows-latest]
# build_type: [Release]
# c_compiler: [clang]
# cpp_compiler: [clang++]

# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# submodules: 'true'

# - name: Set reusable strings
# # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
# id: strings
# shell: bash
# run: |
# echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

# - name: Configure CMake
# # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# run: >
# cmake -B ${{ steps.strings.outputs.build-output-dir }}
# -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
# -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
# -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
# -S ${{ github.workspace }}

# - name: Build
# # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# path: dist/*
# name: ${{runner.os}}

build-mac:
name: mac
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build_type: [Release]
c_compiler: [clang]
cpp_compiler: [clang++]
platform: [x86_64, arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.platform }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*
name: mac-${{ matrix.platform }}

publish-header:
name: publish-header
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/eigenapi/eigenapi.h
name: header


publish:
name: Publish release
# only create a release if a tag was created that is called e.g. v1.2.3
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# needs: [build, build-mac,publish-header]
needs: [build-mac,publish-header]
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ env.CI_REF_NAME }}
body: |
${{ env.CI_REPOSITORY_NAME }} EigenLite ${{ env.CI_REF_NAME }}
draft: false
prerelease: false
- uses: actions/download-artifact@v3
with:
path: _artifacts
- name: Upload release assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _artifacts/**/*
tag: ${{ github.ref }}
file_glob: true
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*.lock
profile
**/build/*
build*

**/*.sublime-workspace
cmake-build*/
Expand All @@ -30,11 +29,8 @@ Podfile.lock
!default.perspectivev3
*.xccheckout

**/*.pd_linux
**/*.pd_darwin
**/*.dll
**/*.o
build/**/*.so
build/**/*.dylib
dist/*


23 changes: 22 additions & 1 deletion eigenapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ project (eigenapi)
# USE_DUMMY_PICO - if you do not want to use prebuilt binaries (advanced use only), implies dynamic!
# USE_DYNAMIC - use shared libraries for pico decoder


# REL_DIR not supported currently
set(REL_DIR "${CMAKE_SOURCE_DIR}/release/eigenapi")

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(REL_DIR "${REL_DIR}/macOs/${CMAKE_OSX_ARCHITECTURES}")
set(REL_FILE "eigenapi-macOs-${CMAKE_OSX_ARCHITECTURES}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(REL_DIR "${REL_DIR}/linux/${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(REL_FILE "eigenapi-linux-${CMAKE_HOST_SYSTEM_PROCESSOR}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(REL_DIR "${REL_DIR}/windows/${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(REL_FILE "eigenapi-win-${CMAKE_HOST_SYSTEM_PROCESSOR}")
else()
set(REL_DIR "${REL_DIR}/unknown/${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(REL_FILE "eigenapi-unknown-${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
#temporary, so I can see 'real' errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
Expand Down Expand Up @@ -87,7 +105,10 @@ target_include_directories(eigenapi PUBLIC
.
)


add_custom_command(TARGET eigenapi POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/dist
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eigenapi> ${CMAKE_SOURCE_DIR}/dist/${REL_FILE}.a
)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(eigenapi atomic)
Expand Down
Binary file not shown.

0 comments on commit 8885d39

Please sign in to comment.