Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/opus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Modified from https://github.com/DSharpPlus/DSharpPlus.Natives/blob/f4391784d99fb2cd0c5e37122b4aa65ec04420ba/.github/workflows/opus.yml

name: Build opus
on:
workflow_dispatch:

env:
COMMON_CMAKE_FLAGS: "-DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release"

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

outputs:
version: ${{ steps.print-version.outputs.version }}

strategy:
fail-fast: false # Run the other two OSs even if one fails
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]

steps:
- name: Clone opus repo
uses: actions/checkout@v5
with:
repository: DSharpPlus/opus # TODO update to repo owned by discord-jda

# https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs#defining-and-using-job-outputs
- name: Checkout latest Tag
id: print-version
shell: bash
run: |
git fetch --tags
LATEST_TAG=$(git tag | grep -E ^v[0-9]+.[0-9]+.[0-9]+$ | tail -1)
git checkout "$LATEST_TAG"
echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT

- name: Build opus
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
for arch in x64 ARM64; do # We dont want Win32
mkdir -p output/$arch
mkdir build-$arch
cd build-$arch
cmake $COMMON_CMAKE_FLAGS -A $arch ..
cmake --build . -j 4 --config Release
cp Release/opus.dll ../output/$arch/libopus.dll
cd ..
done
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
for arch in x64 ARM ARM64; do
mkdir -p output/$arch
mkdir build-$arch
cd build-$arch
if [[ "$arch" == "ARM64" ]]; then
sudo apt update
sudo apt install gcc-aarch64-linux-gnu
cmake $COMMON_CMAKE_FLAGS -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc ..
elif [[ "$arch" == "ARM" ]]; then
sudo apt update
sudo apt install gcc-arm-linux-gnueabihf
cmake $COMMON_CMAKE_FLAGS -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc ..
else
cmake $COMMON_CMAKE_FLAGS ..
fi
cmake --build . -j 4
cp libopus.so ../output/$arch/libopus.so
cd ..
done
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
mkdir build output
cd build
cmake $COMMON_CMAKE_FLAGS "-DCMAKE_OSX_ARCHITECTURES=arm64;arm64e;x86_64;x86_64h" ..
cmake --build . -j 4 --config Release
cp libopus.dylib ../output/libopus.dylib
cd ..
fi

- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: opus-${{ matrix.os }}
path: output

publish:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout opus-java
uses: actions/checkout@v5

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-disabled: true

- name: Download Artifacts
uses: actions/download-artifact@v5
with:
path: temp
pattern: opus-*
merge-multiple: true

- name: Move Artifacts
run: |
mkdir -p natives/src/main/resources/natives/win32-x86-64
mkdir -p natives/src/main/resources/natives/win32-aarch64
mkdir -p natives/src/main/resources/natives/linux-x86-64
mkdir -p natives/src/main/resources/natives/linux-arm
mkdir -p natives/src/main/resources/natives/linux-aarch64
mkdir -p natives/src/main/resources/natives/darwin
cp temp/x64/libopus.dll natives/src/main/resources/natives/win32-x86-64/libopus.dll
cp temp/ARM64/libopus.dll natives/src/main/resources/natives/win32-aarch64/libopus.dll
cp temp/x64/libopus.so natives/src/main/resources/natives/linux-x86-64/libopus.so
cp temp/ARM64/libopus.so natives/src/main/resources/natives/linux-aarch64/libopus.so
cp temp/ARM/libopus.so natives/src/main/resources/natives/linux-arm/libopus.so
cp temp/libopus.dylib natives/src/main/resources/natives/darwin/libopus.dylib

- name: Publish artifact
run: ./gradlew build
54 changes: 0 additions & 54 deletions api/build.gradle

This file was deleted.

21 changes: 21 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
`opus-java-conventions`
`opus-java-publish-conventions`
}

java {
withJavadocJar()
withSourcesJar()
}

dependencies {
api("net.java.dev.jna:jna:5.18.1")
}

tasks.withType<Jar> {
archiveBaseName = "opus-java-api"
}

configurePublishing(artifactId = "opus-java-api") {
from(components["java"])
}
3 changes: 1 addition & 2 deletions api/src/main/java/club/minnced/opus/util/OpusLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public final class OpusLibrary {
platforms.put("darwin", "dylib");
platforms.put("linux-arm", "so");
platforms.put("linux-aarch64", "so");
platforms.put("linux-x86", "so");
platforms.put("linux-x86-64", "so");
platforms.put("win32-x86", "dll");
platforms.put("win32-aarch64", "dll");
platforms.put("win32-x86-64", "dll");
SUPPORTED_SYSTEMS = "Supported Systems: " + platforms.keySet() + "\nCurrent Operating system: " + Platform.RESOURCE_PREFIX;
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/tomp2p/opuswrapper/Opus.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* <a href="https://github.com/tbocek">Thomas Bocek (tbocek)</a>
* <p>
* Completely removed all of the javadoc in this class because it was terrible and throwing errors when gradle
* attempted to create javadoc for it. If you want to see the javadoc, please refer to the the original developer's
* attempted to create javadoc for it. If you want to see the javadoc, please refer to the original developer's
* Github repo.
*/
public interface Opus extends Library {
public static final Opus INSTANCE = (Opus)Native.loadLibrary(System.getProperty("opus.lib"), Opus.class);
public static final Opus INSTANCE = Native.load(System.getProperty("opus.lib"), Opus.class);

// ****** Constants

Expand Down
132 changes: 0 additions & 132 deletions build.gradle

This file was deleted.

19 changes: 19 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
`opus-java-conventions`
`opus-java-publish-conventions`
}

dependencies {
api(project(":api"))
api(project(":natives"))
}

configurePublishing(artifactId = "opus-java") {
// We don't have any sources as this is a POM artifact,
// but if we don't include it, dependencies won't be added
from(components["java"])

pom {
packaging = "pom"
}
}
12 changes: 12 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation("org.jreleaser:org.jreleaser.gradle.plugin:1.20.0")
}
Loading