Skip to content

Commit 753b352

Browse files
committed
Initial commit.
0 parents  commit 753b352

File tree

13 files changed

+1174
-0
lines changed

13 files changed

+1174
-0
lines changed

.clang-format

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Language: Cpp
2+
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignConsecutiveAssignments: None
6+
AlignConsecutiveDeclarations: None
7+
AlignEscapedNewlines: Right
8+
AlignOperands: false
9+
AlignTrailingComments: false
10+
AllowAllArgumentsOnNextLine: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortFunctionsOnASingleLine: None
13+
AllowShortLambdasOnASingleLine: None
14+
AlwaysBreakAfterReturnType: None
15+
AlwaysBreakTemplateDeclarations: Yes
16+
BinPackParameters: false
17+
BreakBeforeBraces: Custom
18+
BraceWrapping:
19+
AfterClass: true
20+
AfterControlStatement: true
21+
AfterEnum: true
22+
AfterFunction: true
23+
AfterNamespace: true
24+
BeforeLambdaBody: true
25+
AfterStruct: true
26+
BeforeElse: true
27+
SplitEmptyFunction: false
28+
BreakBeforeTernaryOperators: true
29+
BreakConstructorInitializers: BeforeComma
30+
BreakInheritanceList: BeforeComma
31+
ColumnLimit: 140
32+
ConstructorInitializerIndentWidth: 4
33+
ContinuationIndentWidth: 4
34+
Cpp11BracedListStyle: false
35+
FixNamespaceComments: true
36+
IncludeBlocks: Preserve
37+
IndentCaseBlocks: true
38+
IndentCaseLabels: false
39+
IndentPPDirectives: None
40+
IndentWidth: 4
41+
KeepEmptyLinesAtTheStartOfBlocks: false
42+
MaxEmptyLinesToKeep: 1
43+
NamespaceIndentation: All
44+
PenaltyReturnTypeOnItsOwnLine: 1000
45+
PointerAlignment: Left
46+
SortIncludes: CaseInsensitive
47+
SpaceAfterLogicalNot: false
48+
SpaceAfterTemplateKeyword: false
49+
SpaceBeforeAssignmentOperators: true
50+
SpaceBeforeCpp11BracedList: false
51+
SpaceBeforeCtorInitializerColon: true
52+
SpaceBeforeInheritanceColon: true
53+
SpaceBeforeParens: ControlStatements
54+
SpaceBeforeRangeBasedForLoopColon: true
55+
SpaceInEmptyParentheses: false
56+
SpacesInAngles: false
57+
SpacesInCStyleCastParentheses: false
58+
SpacesInParentheses: false
59+
Standard: c++17
60+
UseTab: Never

.github/workflows/build.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types:
8+
- created
9+
10+
concurrency:
11+
group: "build"
12+
cancel-in-progress: true
13+
14+
jobs:
15+
cleanup:
16+
name: Cleanup
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: write
20+
contents: read
21+
steps:
22+
- name: Check out code
23+
uses: actions/checkout@v4
24+
25+
- name: Cleanup
26+
run: |
27+
gh extension install actions/gh-actions-cache
28+
29+
REPO=${{ github.repository }}
30+
BRANCH=${{ github.ref }}
31+
32+
echo "Fetching list of cache key"
33+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
34+
35+
## Setting this to not fail the workflow while deleting cache keys.
36+
set +e
37+
echo "Deleting caches..."
38+
for cacheKey in $cacheKeysForPR
39+
do
40+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
41+
done
42+
echo "Done"
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
build:
47+
needs: [ cleanup ]
48+
uses: AmplitudeAudio/sdk/.github/workflows/cmake.yml@develop
49+
with:
50+
project-path: .
51+
project-slug: plugin_flac
52+
name: Flac Codec
53+
54+
release:
55+
needs: [ build ]
56+
runs-on: ${{ matrix.config.os }}
57+
name: "[${{ matrix.build_type }}] ${{ matrix.config.name }}"
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
build_type: [ "release", "debug" ]
62+
config:
63+
- name: "Windows Latest MSVC"
64+
os: windows-latest
65+
artifact: "plugin_flac_windows_msvc_x64.7z"
66+
archiver: "7z a"
67+
68+
- name: "Windows Latest MinGW"
69+
os: windows-latest
70+
artifact: "plugin_flac_windows_mingw_x64.7z"
71+
archiver: "7z a"
72+
73+
- name: "Ubuntu Latest GCC"
74+
os: ubuntu-latest
75+
artifact: "plugin_flac_linux_gcc_x64.7z"
76+
archiver: "7z a"
77+
78+
- name: "macOS x64 Latest Clang"
79+
os: macos-13
80+
artifact: "plugin_flac_macos_clang_x64.7z"
81+
archiver: "7za a"
82+
83+
- name: "macOS arm64 Latest Clang"
84+
os: macos-14
85+
artifact: "plugin_flac_macos_clang_arm64.7z"
86+
archiver: "7za a"
87+
88+
steps:
89+
- name: Check out code
90+
uses: actions/checkout@v4
91+
92+
- name: Restore SDK Cache
93+
uses: actions/cache/restore@v4
94+
with:
95+
enableCrossOsArchive: true
96+
path: sdk
97+
key: ${{ matrix.build_type }}-${{ matrix.config.artifact }}-${{ hashFiles('**/sdk') }}
98+
restore-keys: |
99+
${{ matrix.build_type }}-${{ matrix.config.artifact }}-
100+
101+
- name: Pack
102+
shell: bash
103+
run: ${{ matrix.config.archiver }} ./${{ matrix.build_type }}_${{ matrix.config.artifact }} LICENSE NOTICE README.md sdk
104+
105+
- name: Upload
106+
uses: actions/upload-artifact@v4
107+
with:
108+
path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
109+
name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}
110+
111+
- name: Upload release asset
112+
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'created')
113+
uses: actions/upload-release-asset@v1
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
with:
117+
upload_url: ${{ github.event.release.upload_url }}
118+
asset_path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
119+
asset_name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}.zip
120+
asset_content_type: application/zip

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Binary
2+
lib/
3+
libs/
4+
bin/
5+
obj/
6+
7+
# CMake files
8+
CMakeCache.txt
9+
CMakeFiles/
10+
CMakeScripts/
11+
cmake_install.cmake
12+
tests/Debug/
13+
tests/Release/
14+
tests/audio_engine_test.dir/
15+
16+
# Gnumake
17+
Makefile
18+
19+
# Visual Studio files
20+
.vs/
21+
.vscode/
22+
[bB]uild/
23+
*.sln
24+
*.user
25+
*.suo
26+
*.vcxproj
27+
*.vcxproj.filters
28+
[dD]ebug/
29+
Win32/
30+
31+
# Jetbrains files
32+
.idea/
33+
cmake-build-*/
34+
35+
# Misc generated files
36+
gen/
37+
.DS_Store
38+
39+
# CLangd cache
40+
.cache/
41+
42+
# VCPKG
43+
vcpkg_installed/

.gitmodules

Whitespace-only changes.

CMakeLists.txt

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright (c) 2021-present Sparky Studios. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.20)
16+
17+
cmake_policy(SET CMP0048 NEW)
18+
19+
list(APPEND CMAKE_MODULE_PATH "${ENV_AM_SDK_PATH}/cmake" "${AM_SDK_PATH}/cmake")
20+
list(APPEND CMAKE_PREFIX_PATH "${ENV_AM_SDK_PATH}/cmake" "${AM_SDK_PATH}/cmake")
21+
22+
set(AM_SDK_PLATFORM ${VCPKG_TARGET_TRIPLET})
23+
24+
project(AmplitudeFlacCodecPlugin)
25+
26+
set(CMAKE_CXX_STANDARD 20)
27+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
28+
29+
set(CMAKE_DEBUG_POSTFIX "_d")
30+
31+
set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
32+
set(OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}/obj)
33+
34+
if(APPLE)
35+
set(CMAKE_MACOSX_RPATH 1)
36+
list(APPEND CMAKE_INSTALL_RPATH "@executable_path" "@loader_path/../shared/")
37+
elseif(UNIX AND NOT ANDROID)
38+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
39+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ORIGIN/../shared/")
40+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
41+
else()
42+
list(APPEND CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/../shared/)
43+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
44+
endif()
45+
endif()
46+
47+
# Setup Plugin dependencies
48+
# ------------------------------------------------------------------------------
49+
find_package(FLAC CONFIG REQUIRED)
50+
51+
# Setup Amplitude
52+
# ------------------------------------------------------------------------------
53+
find_package(AmplitudeAudioSDK REQUIRED)
54+
55+
# Setup Plugin
56+
# ------------------------------------------------------------------------------
57+
58+
# Source files
59+
set(PLUGIN_SOURCE
60+
Plugin.h
61+
Plugin.cpp
62+
Codec.h
63+
Codec.cpp
64+
)
65+
66+
# Includes
67+
include_directories(
68+
${CMAKE_CURRENT_SOURCE_DIR}
69+
${AM_SDK_PATH}/include
70+
)
71+
72+
add_library(${PROJECT_NAME} SHARED ${PLUGIN_SOURCE})
73+
target_compile_definitions(${PROJECT_NAME} PRIVATE AM_BUILDSYSTEM_BUILDING_PLUGIN)
74+
75+
target_link_libraries(${PROJECT_NAME}
76+
PRIVATE SparkyStudios::Audio::Amplitude::SDK::Shared FLAC::FLAC++
77+
)
78+
79+
# Install
80+
# ------------------------------------------------------------------------------
81+
set(AM_LIB_DESTINATION "lib/${AM_SDK_PLATFORM}")
82+
set(AM_INC_DESTINATION "include")
83+
84+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${AM_LIB_DESTINATION}")
85+
86+
set(CMAKE_INSTALL_PREFIX ${AM_SDK_PATH})
87+
88+
install(
89+
TARGETS ${PROJECT_NAME}
90+
ARCHIVE DESTINATION ${AM_LIB_DESTINATION}/plugins
91+
LIBRARY DESTINATION ${AM_LIB_DESTINATION}/plugins
92+
RUNTIME DESTINATION ${AM_LIB_DESTINATION}/plugins
93+
)
94+
95+
install(
96+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
97+
DESTINATION ${AM_INC_DESTINATION}
98+
FILES_MATCHING PATTERN "*.h*"
99+
)
100+
101+
export(PACKAGE ${PROJECT_NAME})

0 commit comments

Comments
 (0)