Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
LabyStudio committed Jun 30, 2022
2 parents 614256e + ae96714 commit c1eb16c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on: [push]
on: [push, workflow_dispatch]

jobs:
build-binaries-unix:
Expand Down Expand Up @@ -101,4 +101,4 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: Final artifacts
path: opus-jni-java/build/libs/
path: opus-jni-java/build/libs/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea/
.vscode/
build/
cmake-build*/
.gradle/
*.log
.DS_Store
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if(project.hasProperty("32bit")) {

project(":opus-jni-java").afterEvaluate { javaProject ->
project("opus-jni-native").afterEvaluate { nativeProject ->
nativeProject.tasks["build"].dependsOn(javaProject.tasks["generateJniHeaders"])
nativeProject.tasks["build"].dependsOn(javaProject.tasks["compileJava"])

if(!isExternalBuild) {
javaProject.tasks["processResources"].dependsOn(nativeProject.tasks["build"])
Expand Down
39 changes: 5 additions & 34 deletions opus-jni-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ plugins {
group 'net.labymod'
version '1.0'

jar {
from {
// TODO: use shadow plugin
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

static def osDependentBinary(name) {
return Os.isFamily(Os.FAMILY_WINDOWS) ? "${name}.exe" : name
}
Expand All @@ -30,8 +23,8 @@ static def findJavaH() {

def path = System.getenv("PATH")
if (path != null) {
String paths = path.split(File.pathSeparator);
for (def currentPath in paths) {
def paths = path.split(File.pathSeparator)
for (def currentPath : paths) {
javaHBinary = new File(currentPath, osDependentBinary("javah"))
if (javaHBinary.exists()) {
return javaHBinary.absolutePath
Expand All @@ -46,37 +39,15 @@ static def findJavaH() {

def javaHCommand = findJavaH()

task generateJniHeaders(dependsOn: compileJava) {
doFirst {
fileTree(generatedHeadersDir).each {
it.delete()
}
}

doLast {
if (exec {
commandLine javaHCommand,
"-jni",
"-cp", tasks.compileJava.destinationDir.getAbsolutePath() + File.pathSeparator +
sourceSets.main.compileClasspath.asPath,
"-d", generatedHeadersDir,
"net.labymod.opus.OpusCodec"

standardOutput = prefixedOutputStream("[JNI | GEN | INFO] ", System.out)
errorOutput = prefixedOutputStream("[JNI | GEN | ERR] ", System.err)
}.exitValue != 0) {
throw new GradleException("Failed to generate JNI headers")
}
}
}

processResources {
from(nativeBinaries) {
into "native-binaries"
}
}

compileJava.finalizedBy generateJniHeaders
compileJava {
options.compilerArgs += ["-h", generatedHeadersDir.getAbsolutePath()]
}

OutputStream prefixedOutputStream(String prefix, OutputStream parentStream) {
OutputStream ret = new OutputStream() {
Expand Down
5 changes: 5 additions & 0 deletions opus-jni-native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0048 NEW)

#####################
# Pre project setup #
#####################
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version" FORCE)

#################
# Project setup #
#################
Expand Down

0 comments on commit c1eb16c

Please sign in to comment.