Skip to content

Commit 70762be

Browse files
committed
Merge tag 'v154' into be
2 parents 03b80f7 + 46c0956 commit 70762be

File tree

46 files changed

+662
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+662
-449
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Container image that runs your code
2+
FROM ubuntu:18.04
3+
4+
# Copies your code file from your action repository to the filesystem path `/` of the container
5+
COPY entrypoint.sh /entrypoint.sh
6+
7+
# Code file to execute when the docker container starts up (`entrypoint.sh`)
8+
ENTRYPOINT ["/entrypoint.sh"]
9+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: 'Build Linux Natives in Docker Container'
2+
description: 'Build Linux Natives in Ubuntu 18.04 docker container'
3+
runs:
4+
using: 'docker'
5+
image: 'Dockerfile'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh -l
2+
3+
# ubuntu dockerfile is very minimal (only 122 packages are installed)
4+
# need to install updated git (from official git ppa)
5+
apt-get -q update
6+
apt-get -yq install software-properties-common
7+
add-apt-repository ppa:git-core/ppa -y
8+
# install dependencies expected by other steps
9+
apt-get -q update
10+
apt-get -yq install git \
11+
curl \
12+
ca-certificates \
13+
wget \
14+
bzip2 \
15+
zip \
16+
unzip \
17+
xz-utils \
18+
sudo gnupg locales
19+
20+
# set Locale to en_US.UTF-8 (avoids hang during compilation)
21+
locale-gen en_US.UTF-8
22+
export LANG=en_US.UTF-8
23+
export LANGUAGE=en_US.UTF-8
24+
export LC_ALL=en_US.UTF-8
25+
26+
# add zulu apt repository - https://docs.azul.com/core/install/debian
27+
curl -s https://repos.azul.com/azul-repo.key | gpg --dearmor -o /usr/share/keyrings/azul.gpg
28+
echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | tee /etc/apt/sources.list.d/zulu.list
29+
apt-get -q update
30+
# install zulu JDK and Java build tools
31+
apt-get -yq install zulu17-jdk-headless maven ant
32+
33+
# Install cross-compilation toolchains
34+
apt-get -yq --force-yes install gcc g++
35+
apt-get -yq --force-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
36+
apt-get -yq --force-yes install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
37+
apt-get -yq --force-yes install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross
38+
39+
# Build Linux natives
40+
./gradlew arc-core:jnigenBuildLinux64 --no-daemon
41+
42+
# Pack artifacts
43+
find . -name "*.so" | grep "arc-core/libs" > native-files-list
44+
zip natives-linux -@ < native-files-list

.github/workflows/natives.yml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,63 @@ name: Build Natives
33
on: [workflow_dispatch]
44

55
jobs:
6-
buildLinux:
6+
natives-linux:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- name: Set up JDK 1.8
9+
- uses: actions/checkout@v6
10+
with:
11+
fetch-depth: 0
12+
submodules: 'recursive'
13+
14+
- name: Build Linux Natives in Docker Container
15+
uses: ./.github/workflows/build-linux-natives
16+
id: docker
17+
18+
- name: Upload artifacts
19+
uses: actions/upload-artifact@v5
20+
with:
21+
name: natives-linux.zip
22+
path: natives-linux.zip
23+
24+
natives-windows:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v6
28+
- name: Set up JDK 17
1129
uses: actions/setup-java@v1
1230
with:
13-
java-version: 1.8
31+
java-version: 17
1432
- name: Install dependencies
15-
run: sudo apt install g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libasound2-dev libdrm-dev libsdl2-dev libgbm-dev
33+
run: sudo apt install g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64
1634
- name: Set env
1735
run: echo "NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
1836
- name: Build natives
1937
run: |
2038
./gradlew arc-core:jnigenBuild
2139
./gradlew extensions:freetype:jnigenBuild
22-
./gradlew backends:backend-sdl:jnigenBuild
2340
- name: Upload natives
24-
uses: actions/upload-artifact@v4
41+
uses: actions/upload-artifact@v5
2542
with:
2643
name: Arc-core desktop natives
2744
path: |
28-
natives/natives-desktop/libs/libarc64.so
2945
natives/natives-desktop/libs/arc.dll
3046
natives/natives-desktop/libs/arc64.dll
31-
backends/backend-sdl/libs/linux64/libsdl-arc64.so
32-
backends/backend-sdl/libs/windows32/sdl-arc.dll
33-
backends/backend-sdl/libs/windows64/sdl-arc64.dll
34-
natives/natives-freetype-desktop/libs/libarc-freetype64.so
3547
natives/natives-freetype-desktop/libs/arc-freetype.dll
3648
natives/natives-freetype-desktop/libs/arc-freetype64.dll
3749
- name: Upload Android natives
38-
uses: actions/upload-artifact@v4
50+
uses: actions/upload-artifact@v5
3951
with:
4052
name: Arc-core android natives
4153
path: |
4254
natives/natives-android/libs
43-
natives/natives-freetype-android/libs
44-
buildMac:
45-
runs-on: macos-13
55+
natives-mac:
56+
runs-on: macos-latest
4657
steps:
47-
- uses: actions/checkout@v2
48-
- name: Set up JDK 1.8
58+
- uses: actions/checkout@v6
59+
- name: Set up JDK 17
4960
uses: actions/setup-java@v1
5061
with:
51-
java-version: 1.8
62+
java-version: 17
5263
- name: Install dependencies
5364
run: |
5465
brew install sdl2
@@ -58,21 +69,21 @@ jobs:
5869
MACOSX_DEPLOYMENT_TARGET: '10.9'
5970
run: |
6071
./gradlew arc-core:jnigenBuild
61-
./gradlew extensions:freetype:jnigenBuild
62-
./gradlew backends:backend-sdl:jnigenBuild
72+
# ./gradlew extensions:freetype:jnigenBuild
73+
# ./gradlew backends:backend-sdl:jnigenBuild
6374
- name: Upload natives
64-
uses: actions/upload-artifact@v4
75+
uses: actions/upload-artifact@v5
6576
with:
6677
name: Arc-core MacOS natives
6778
path: |
6879
natives/natives-desktop/libs/libarc64.dylib
6980
natives/natives-desktop/libs/libarcarm64.dylib
70-
natives/natives-freetype-desktop/libs/libarc-freetype64.dylib
71-
natives/natives-freetype-desktop/libs/libarc-freetypearm64.dylib
72-
backends/backend-sdl/libs/macosx64/libsdl-arc64.dylib
73-
backends/backend-sdl/libs/macosx64/libsdl-arcarm64.dylib
81+
# natives/natives-freetype-desktop/libs/libarc-freetype64.dylib
82+
# natives/natives-freetype-desktop/libs/libarc-freetypearm64.dylib
83+
# backends/backend-sdl/libs/macosx64/libsdl-arc64.dylib
84+
# backends/backend-sdl/libs/macosx64/libsdl-arcarm64.dylib
7485
- name: Upload iOS natives
75-
uses: actions/upload-artifact@v4
86+
uses: actions/upload-artifact@v5
7687
with:
7788
name: Arc-core iOS natives
7889
path: |

arc-core/build.gradle

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,51 @@ sourceSets.main.java.srcDirs = ["src"]
22
sourceSets.test.java.srcDirs = ["test"]
33
sourceSets.test.resources.srcDirs = ["test/resources"]
44

5+
configurations{
6+
extraLibs
7+
}
8+
59
dependencies{
610
testImplementation libraries.junit
711
testImplementation aproj(":natives:natives-desktop")
12+
testImplementation files("unsafe/unsafe.jar")
13+
//file generated from UnsafeBuffers.java
14+
compileOnly files("unsafe/unsafe.jar")
15+
extraLibs files("unsafe/unsafe.jar")
16+
}
17+
18+
jar{
19+
from{
20+
configurations.extraLibs.collect{ it.isDirectory() ? it : zipTree(it) }
21+
}
22+
}
23+
24+
//now, you may ask: why don't I make this a new module? why do I include JARs in the repository? why don't I make this a separate build step?
25+
//the reason is: I don't want to deal with compiler arguments, --add-opens, or whatever else Java throws at you these days
26+
//this just works and I don't want to touch it, it's a dependency that has already been compiled and won't explode as much as source compilation might
27+
//"why are you using unsafe, why aren't you using the new memory access APIs?" because they don't work on Android or iOS
28+
//and no, I cannot work with buffer put() because of Java's idiotic design making it so that you need to put()/limit()/position() to write memory, breaking multithreading
29+
//this makes Unsafe the only viable option - any "state independent" methods are Java-16 specific, and iOS/Android don't support those
30+
31+
tasks.register("compileBuffersUnsafe", Exec){
32+
workingDir "unsafe"
33+
commandLine "javac --target 8 --source 8 -d . UnsafeBuffers.java".split(" ")
34+
}
35+
36+
tasks.register("compileBuffersSafe", Exec){
37+
workingDir "unsafe"
38+
commandLine "javac --target 16 --source 16 -d . Java16Buffers.java".split(" ")
39+
}
40+
41+
tasks.register("recompileUnsafe", Exec){
42+
dependsOn "compileBuffersUnsafe", "compileBuffersSafe"
43+
workingDir "unsafe"
44+
commandLine "jar cvf unsafe.jar arc".split(" ")
45+
doLast{
46+
delete{
47+
delete "unsafe/arc"
48+
}
49+
}
850
}
951

1052
test{
@@ -21,12 +63,13 @@ file("jni").mkdir()
2163
jnigen{
2264
sharedLibName = "arc"
2365
temporaryDir = file("build/target/native").absolutePath
24-
libsDir = file("libs").absolutePath
66+
libsDir = "libs"
2567

2668
all{
2769
headerDirs += ["soloud/include"]
2870
cppIncludes = ["*.cpp", "soloud/src/core/**", "soloud/src/audiosource/wav/**", "soloud/src/filter/**"]
2971
cIncludes = ["*.c", "soloud/src/core/**", "soloud/src/audiosource/wav/**", "soloud/src/filter/**"]
72+
cppFlags = "-DSOLOUD_MAX_VOICE_COUNT=100 " + cppFlags
3073
}
3174
add(Linux, x64){
3275
cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"]
@@ -47,65 +90,60 @@ jnigen{
4790
cppFlags = "-DWITH_OPENSLES " + cppFlags
4891
}
4992
add(MacOsX, x64){
50-
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp"]
93+
cppIncludes += ["soloud/src/backend/coreaudio/*.mm"]
5194
cppFlags = "-std=c++11 -DWITH_COREAUDIO " + cppFlags
5295
libraries += "-Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
5396
}
5497
add(MacOsX, x64, ARM){
55-
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp"]
98+
cppIncludes += ["soloud/src/backend/coreaudio/*.mm"]
5699
cppFlags = "-std=c++11 -DWITH_COREAUDIO " + cppFlags.replace("x86_64", "arm64")
57100
cFlags = cFlags.replace("x86_64", "arm64")
58101
libraries += "-Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
59102
linkerFlags = linkerFlags.replace("x86_64", "arm64")
60103
}
61104
add(IOS){
62105
headerDirs += ["iosgl"]
63-
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp", "iosgl/**"]
106+
cppIncludes += ["soloud/src/backend/coreaudio/*.mm", "iosgl/**"]
64107
cppFlags = "-stdlib=libc++ -std=c++11 -DWITH_COREAUDIO " + cppFlags
65108
libraries += "-Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
66109
linkerFlags += " -undefined dynamic_lookup "
67110
}
68111
}
69112

70-
task fixWrap{
71-
doFirst{
72-
println "--FIXING SCRIPTS--"
113+
tasks.register('copyUnsafeStuff'){
114+
doLast{
73115
copy{
74-
from "../natives/memcpy_wrap.c"
75-
into "jni/"
76-
}
77-
78-
def f = file("$rootDir/arc-core/jni/build-linux64.xml");
79-
if(f.exists()){
80-
f.text = f.text.replace("-Wl,-wrap,memcpy", "-Wl,-wrap,memcpy,-wrap,pow,-wrap,powf,-wrap,log,-wrap,logf,-wrap,exp,-wrap,expf,-wrap,clock_gettime")
116+
from zipTree("unsafe/unsafe.jar")
117+
into "build/classes/java/main"
118+
include '**/*.class'
81119
}
82120
}
83121
}
84122

85123
getTasksByName("jnigen", true).each{
86-
it.finalizedBy fixWrap
124+
it.dependsOn copyUnsafeStuff
87125
}
88126

89-
task cleanNatives{
127+
tasks.register('cleanNatives'){
90128
doLast{
91-
delete{delete "$rootDir/arc-core/jni"}
92-
delete{delete "$rootDir/arc-core/libs"}
93-
delete{delete "$rootDir/arc-core/csrc/soloud"}
94-
delete{delete "$rootDir/arc-core/csrc/stb_image.h"}
129+
delete{ delete "$rootDir/arc-core/jni" }
130+
delete{ delete "$rootDir/arc-core/libs" }
131+
delete{ delete "$rootDir/arc-core/csrc/soloud" }
132+
delete{ delete "$rootDir/arc-core/csrc/stb_image.h" }
95133
}
96134
}
97135

98-
task preJni{
136+
tasks.register('preJni'){
99137
doFirst{
100138
if(!file("csrc/stb_image.h").exists()){
101139
println "Fetching stb_image source..."
102140
//currently locked to a specific commit
103-
"curl -o $rootDir/arc-core/csrc/stb_image.h https://raw.githubusercontent.com/nothings/stb/e140649ccf40818781b7e408f6228a486f6d254b/stb_image.h".execute().waitFor()
141+
"curl -o $rootDir/arc-core/csrc/stb_image.h https://raw.githubusercontent.com/nothings/stb/013ac3beddff3dbffafd5177e7972067cd2b5083/stb_image.h".execute().waitFor()
104142
}
105143

106144
if(!file("csrc/soloud").exists()){
107145
println "Fetching soloud source..."
108-
"git clone --depth 1 --branch v0.11 https://github.com/Anuken/soloud.git $rootDir/arc-core/csrc/soloud".execute().waitFor()
146+
"git clone --depth 1 --branch 2025.12.01 https://github.com/Anuken/soloud.git $rootDir/arc-core/csrc/soloud".execute().waitFor()
109147
}
110148

111149
copy{
@@ -117,26 +155,26 @@ task preJni{
117155
}
118156

119157
//copies files into the right locations
120-
task postJni{
158+
tasks.register('postJni'){
121159
doLast{
122160
copy{
123161
from "libs/linux64", "libs/windows32", "libs/windows64", "libs/macosx64"
124-
into "../natives/natives-desktop/libs"
162+
into "${project.rootDir}/natives/natives-desktop/libs"
125163
include "**"
126164
}
127165

128166
["arm64-v8a", "x86", "x86_64", "armeabi-v7a"].each{ p ->
129167
copy{
130168
from "libs/$p"
131-
into "../natives/natives-android/libs/$p/"
169+
into "${project.rootDir}/natives/natives-android/libs/$p/"
132170
include "**"
133171
}
134172
}
135173

136174
[".tvos", ""].each{ p ->
137175
copy{
138176
from "libs/ios32/libarc.a$p"
139-
into "../natives/natives-ios/libs/"
177+
into "${project.rootDir}/natives/natives-ios/libs/"
140178
include "**"
141179
}
142180
}

arc-core/src/arc/audio/Audio.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class Audio implements Disposable{
1111
public float globalPitch = 1f;
1212
/** Falloff when playing audio.*/
1313
public float falloff = 16000f;
14+
/** Default value for maximum instances of a sound. Must be set before a sound is loaded. */
15+
public int defaultSoundMaxConcurrent = 6;
1416

1517
boolean initialized;
1618
float sfxVolume = 0f;
@@ -97,7 +99,7 @@ public Music newMusic(Fi file){
9799

98100
public boolean isPlaying(int soundId){
99101
if(!initialized) return false;
100-
return idValid(soundId);
102+
return soundId > 0 && idValid(soundId);
101103
}
102104

103105
public void protect(int voice, boolean protect){
@@ -166,6 +168,11 @@ public int countPlaying(AudioSource source){
166168
return sourceCount(source.handle);
167169
}
168170

171+
public int countTotalPlaying(){
172+
if(!initialized) return 0;
173+
return activeVoiceCount();
174+
}
175+
169176
@Override
170177
public void dispose(){
171178
if(!initialized) return;

0 commit comments

Comments
 (0)