Skip to content

Commit ceeacd5

Browse files
committed
Android support
1 parent c81dde9 commit ceeacd5

Some content is hidden

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

43 files changed

+1117
-412
lines changed

CMakeLists.txt

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cmake_minimum_required (VERSION 3.28)
2222
include (cmake/yup.cmake)
2323
_yup_setup_platform()
2424

25-
if ("${yup_platform}" MATCHES "^(osx)$")
25+
if ("${yup_platform}" MATCHES "^(osx)$" AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
2626
set (CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
2727
endif()
2828

@@ -31,31 +31,14 @@ project (yup VERSION 1.0)
3131
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
3232

3333
# Options
34-
option (YUP_ENABLE_PROFILING "Build the profiling" OFF)
34+
option (YUP_TARGET_ANDROID "Target Android project" OFF)
35+
option (YUP_TARGET_ANDROID_BUILD_GRADLE "When building for Android, build the gradle infrastructure" OFF)
36+
option (YUP_ENABLE_PROFILING "Enable the profiling code using Perfetto SDK" OFF)
3537
option (YUP_BUILD_EXAMPLES "Build the examples" ON)
3638
option (YUP_BUILD_TESTS "Build the tests" ON)
3739

3840
# Dependencies modules
39-
yup_add_module (thirdparty/zlib)
40-
yup_add_module (thirdparty/glad)
41-
yup_add_module (thirdparty/harfbuzz)
42-
yup_add_module (thirdparty/sheenbidi)
43-
yup_add_module (thirdparty/yoga_library)
44-
yup_add_module (thirdparty/rive)
45-
yup_add_module (thirdparty/rive_renderer)
46-
yup_add_module (thirdparty/oboe)
47-
48-
# Original juce modules
49-
yup_add_module (modules/juce_core)
50-
yup_add_module (modules/juce_events)
51-
yup_add_module (modules/juce_audio_basics)
52-
yup_add_module (modules/juce_audio_devices)
53-
54-
# New yup modules
55-
yup_add_module (modules/yup_audio_processors)
56-
yup_add_module (modules/yup_audio_plugin_client)
57-
yup_add_module (modules/yup_graphics)
58-
yup_add_module (modules/yup_gui)
41+
_yup_add_default_modules (${CMAKE_CURRENT_LIST_DIR})
5942

6043
# Enable profiling
6144
if (YUP_ENABLE_PROFILING)
@@ -70,12 +53,12 @@ if (YUP_BUILD_EXAMPLES)
7053
add_subdirectory (examples/console)
7154
add_subdirectory (examples/graphics)
7255
add_subdirectory (examples/render)
73-
if (NOT "${yup_platform}" STREQUAL "emscripten")
56+
if (NOT "${yup_platform}" MATCHES "^(emscripten|android)$" AND NOT YUP_TARGET_ANDROID)
7457
add_subdirectory (examples/plugin)
7558
endif()
7659
endif()
7760

78-
if (YUP_BUILD_TESTS)
61+
if (YUP_BUILD_TESTS AND NOT YUP_TARGET_ANDROID)
7962
message (STATUS "YUP -- Building tests")
8063
add_subdirectory (tests)
8164
endif()
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
plugins {
2+
alias(libs.plugins.androidApplication)
3+
}
4+
5+
android {
6+
namespace = "@YUP_ANDROID_APPLICATION_NAMESPACE@"
7+
compileSdk = @YUP_ANDROID_COMPILE_SDK_VERSION@
8+
9+
defaultConfig {
10+
applicationId = "@YUP_ANDROID_APPLICATION_ID@"
11+
versionCode = @YUP_ANDROID_APPLICATION_VERSION_CODE@
12+
versionName = "@YUP_ANDROID_APPLICATION_VERSION@"
13+
minSdk = @YUP_ANDROID_MIN_SDK_VERSION@
14+
targetSdk = @YUP_ANDROID_TARGET_SDK_VERSION@
15+
16+
ndk {
17+
@YUP_ANDROID_ABI@
18+
}
19+
20+
externalNativeBuild {
21+
cmake {
22+
cppFlags += "-std=c++@YUP_ANDROID_CPP_VERSION@"
23+
arguments += "-DCMAKE_VERBOSE_MAKEFILE=ON"
24+
arguments += "-DANDROID_TOOLCHAIN=@YUP_ANDROID_TOOLCHAIN@"
25+
arguments += "-DANDROID_PLATFORM=@YUP_ANDROID_PLATFORM@"
26+
arguments += "-DANDROID_STL=@YUP_ANDROID_STL@"
27+
arguments += "-DANDROID_CPP_FEATURES=rtti exceptions"
28+
arguments += "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=FALSE"
29+
arguments += "-DANDROID_PIE=ON"
30+
}
31+
}
32+
}
33+
34+
/*signingConfigs {
35+
create("release") {
36+
storeFile = file("certs/app.keystore")
37+
storePassword = "app"
38+
keyAlias = "app"
39+
keyPassword = "app"
40+
}
41+
}*/
42+
43+
buildTypes {
44+
getByName("debug") {
45+
isDebuggable = true
46+
isMinifyEnabled = false
47+
}
48+
49+
getByName("release") {
50+
/*signingConfig = signingConfigs.getByName("release")*/
51+
isDebuggable = true
52+
isMinifyEnabled = false
53+
proguardFiles(
54+
getDefaultProguardFile("proguard-android-optimize.txt"),
55+
"proguard-rules.pro"
56+
)
57+
}
58+
}
59+
60+
externalNativeBuild {
61+
cmake {
62+
path = file("@YUP_ANDROID_APPLICATION_PATH@/CMakeLists.txt")
63+
version = "@YUP_ANDROID_CMAKE_VERSION@"
64+
}
65+
}
66+
67+
compileOptions {
68+
sourceCompatibility = JavaVersion.VERSION_1_8
69+
targetCompatibility = JavaVersion.VERSION_1_8
70+
}
71+
72+
lint {
73+
checkReleaseBuilds = true
74+
abortOnError = false
75+
}
76+
77+
packaging {
78+
jniLibs {
79+
keepDebugSymbols += "*/*/*.so"
80+
}
81+
}
82+
83+
buildFeatures {
84+
viewBinding = true
85+
}
86+
}
87+
88+
dependencies {
89+
/*implementation(libs.appcompat)
90+
implementation(libs.material)
91+
implementation(libs.constraintlayout)
92+
testImplementation(libs.junit)
93+
androidTestImplementation(libs.ext.junit)
94+
androidTestImplementation(libs.espresso.core)*/
95+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# Uncomment this to preserve the line number information for
9+
# debugging stack traces.
10+
# -keepattributes SourceFile,LineNumberTable
11+
12+
# If you keep the line number information, uncomment this to
13+
# hide the original source file name.
14+
# -renamesourcefileattribute SourceFile
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<!--
6+
android:dataExtractionRules="@xml/data_extraction_rules"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:theme="@style/Theme.Application"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:screenOrientation="portrait"
12+
-->
13+
14+
<application
15+
android:hasCode="true"
16+
android:label="@YUP_ANDROID_TARGET_NAME@"
17+
android:extractNativeLibs="true"
18+
android:isGame="true">
19+
<activity
20+
android:name="android.app.NativeActivity"
21+
android:exported="true">
22+
<meta-data
23+
android:name="android.app.lib_name"
24+
android:value="@YUP_ANDROID_TARGET_NAME@" />
25+
<intent-filter>
26+
<action android:name="android.intent.action.MAIN"/>
27+
<category android:name="android.intent.category.LAUNCHER"/>
28+
</intent-filter>
29+
</activity>
30+
</application>
31+
32+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
33+
<uses-permission android:name="android.permission.INTERNET" />
34+
35+
</manifest>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
alias(libs.plugins.androidApplication) apply false
4+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Project-wide Gradle settings.
2+
# IDE (e.g. Android Studio) users:
3+
# Gradle settings configured through the IDE *will override*
4+
# any settings specified in this file.
5+
# For more details on how to configure your build environment visit
6+
# http://www.gradle.org/docs/current/userguide/build_environment.html
7+
# Specifies the JVM arguments used for the daemon process.
8+
# The setting is particularly useful for tweaking memory settings.
9+
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10+
11+
# When configured, Gradle will run in incubating parallel mode.
12+
# This option should only be used with decoupled projects. For more details, visit
13+
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
14+
org.gradle.parallel=true
15+
16+
# Custom flags for Gradle.
17+
org.gradle.daemon=false
18+
org.gradle.configureondemand=false
19+
org.gradle.caching=true
20+
21+
# AndroidX package structure to make it clearer which packages are bundled with the
22+
# Android operating system, and which are packaged with your app's APK
23+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
24+
android.useAndroidX=true
25+
26+
# Enables namespacing of each library's R class so that its R class includes only the
27+
# resources declared in the library itself and none from the library's dependencies,
28+
# thereby reducing the size of the R class for that library
29+
android.nonTransitiveRClass=true
30+
31+
# Enable verbose cmake output by default
32+
android.native.buildOutput=verbose
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[versions]
2+
agp = "8.3.2"
3+
junit = "4.13.2"
4+
junitVersion = "1.1.5"
5+
espressoCore = "3.5.1"
6+
appcompat = "1.6.1"
7+
material = "1.10.0"
8+
constraintlayout = "2.1.4"
9+
10+
[libraries]
11+
junit = { group = "junit", name = "junit", version.ref = "junit" }
12+
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
13+
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
14+
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
15+
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
16+
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
17+
18+
[plugins]
19+
androidApplication = { id = "com.android.application", version.ref = "agp" }
20+
57.8 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 10 12:46:56 CEST 2024
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
17+
@if "%DEBUG%" == "" @echo off
18+
@rem ##########################################################################
19+
@rem
20+
@rem Gradle startup script for Windows
21+
@rem
22+
@rem ##########################################################################
23+
24+
@rem Set local scope for the variables with windows NT shell
25+
if "%OS%"=="Windows_NT" setlocal
26+
27+
set DIRNAME=%~dp0
28+
if "%DIRNAME%" == "" set DIRNAME=.
29+
set APP_BASE_NAME=%~n0
30+
set APP_HOME=%DIRNAME%
31+
32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
35+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37+
38+
@rem Find java.exe
39+
if defined JAVA_HOME goto findJavaFromJavaHome
40+
41+
set JAVA_EXE=java.exe
42+
%JAVA_EXE% -version >NUL 2>&1
43+
if "%ERRORLEVEL%" == "0" goto execute
44+
45+
echo.
46+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47+
echo.
48+
echo Please set the JAVA_HOME variable in your environment to match the
49+
echo location of your Java installation.
50+
51+
goto fail
52+
53+
:findJavaFromJavaHome
54+
set JAVA_HOME=%JAVA_HOME:"=%
55+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56+
57+
if exist "%JAVA_EXE%" goto execute
58+
59+
echo.
60+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61+
echo.
62+
echo Please set the JAVA_HOME variable in your environment to match the
63+
echo location of your Java installation.
64+
65+
goto fail
66+
67+
:execute
68+
@rem Setup the command line
69+
70+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71+
72+
73+
@rem Execute Gradle
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75+
76+
:end
77+
@rem End local scope for the variables with windows NT shell
78+
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
80+
:fail
81+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82+
rem the _cmd.exe /c_ return code!
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84+
exit /b 1
85+
86+
:mainEnd
87+
if "%OS%"=="Windows_NT" endlocal
88+
89+
:omega

0 commit comments

Comments
 (0)