Skip to content
Draft
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
6 changes: 6 additions & 0 deletions .idea/AndroidProjectSystem.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,186 changes: 1,186 additions & 0 deletions .idea/caches/deviceStreaming.xml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/deviceManager.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

249 changes: 249 additions & 0 deletions .idea/editor.xml

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 41 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,44 +1,67 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 22
namespace 'com.github.projectm_android'
compileSdk 35

defaultConfig {
applicationId "com.github.projectm_android"
minSdkVersion 22
targetSdkVersion 22
minSdk 21
targetSdk 35

versionCode 1
versionName "1.0"

ndk {
abiFilters 'x86_64', 'arm64-v8a', 'armeabi-v7a'
}

externalNativeBuild {
cmake {
cppFlags "-std=c++11"
arguments "-DANDROID_STL=c++_shared"
cppFlags "-std=c++17 -fexceptions -frtti"
// optional: use local projectM sources
// arguments "-DPROJECTM_SOURCE_DIR=/my/local/projectm"
}
}
ndk {
abiFilters "armeabi-v7a"
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}

externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
path file('src/main/cpp/CMakeLists.txt')
}
}
sourceSets {
main {
jniLibs.srcDirs 'jniLibs', 'jniLibs/armeabi-v7a'
}

buildFeatures {
viewBinding true
}
productFlavors {

packaging {
jniLibs {
useLegacyPackaging = true
}
resources {
excludes += ['/META-INF/{AL2.0,LGPL2.1}']
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:22.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// Ensure consistent Kotlin stdlib versions across all transitive deps.
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.9.24')

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.projectm_android"
android:versionCode="1"
android:versionName="1.0">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature
android:glEsVersion="0x00030001"
Expand All @@ -18,7 +15,7 @@
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
115 changes: 90 additions & 25 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,113 @@
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.22.1)
project(projectm_android LANGUAGES C CXX)

cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Install/staging prefix inside this ABI build directory
set(PROJECTM_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/projectm-install" CACHE PATH "")

# Force install prefix so projectM installs headers into:
# ${PROJECTM_INSTALL_PREFIX}/include/projectM-4/...
set(CMAKE_INSTALL_PREFIX "${PROJECTM_INSTALL_PREFIX}" CACHE PATH "" FORCE)


# ---- Fetch OR use local libprojectM (projectM 4.x) ----
include(FetchContent)

# If set, use local source instead of fetching.
# Example: -DPROJECTM_SOURCE_DIR=/home/mba/dev/widerup/projectm
set(PROJECTM_SOURCE_DIR "" CACHE PATH "Path to local projectM source directory (with top-level CMakeLists.txt)")

# Configure projectM build options (mirrors upstream Android workflow).
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
set(BUILD_TESTING NO CACHE BOOL "" FORCE)
set(ENABLE_SDL_UI OFF CACHE BOOL "" FORCE)

if (PROJECTM_SOURCE_DIR AND EXISTS "${PROJECTM_SOURCE_DIR}/CMakeLists.txt")
message(STATUS "Using local projectM source: ${PROJECTM_SOURCE_DIR}")

# FetchContent will treat SOURCE_DIR as the content and won't hit the network.
FetchContent_Declare(
projectm
SOURCE_DIR "${PROJECTM_SOURCE_DIR}"
)
else()
message(STATUS "Fetching projectM via Git (PROJECTM_SOURCE_DIR not set or invalid)")

FetchContent_Declare(
projectm
GIT_REPOSITORY https://github.com/projectM-visualizer/projectm.git
GIT_TAG master
)
endif()

FetchContent_MakeAvailable(projectm)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
jniwrapper
# ---- JNI wrapper ----
add_library(jniwrapper SHARED
jni.cpp
)

# Sets the library as a shared library.
SHARED
# Always produce libjniwrapper.so (no debug postfix)
set_target_properties(jniwrapper PROPERTIES
OUTPUT_NAME "jniwrapper"
DEBUG_POSTFIX ""
RELEASE_POSTFIX ""
RELWITHDEBINFO_POSTFIX ""
MINSIZEREL_POSTFIX ""
)

# Also guard against a global postfix set by a toolchain / parent project
set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "" FORCE)

# find projectM headers
if (DEFINED projectm_SOURCE_DIR)
target_include_directories(jniwrapper PRIVATE
"${projectm_SOURCE_DIR}/src/playlist/api"
)
endif()

# Provides a relative path to your source file(s).
jni.cpp)
if (DEFINED projectm_BINARY_DIR)
target_include_directories(jniwrapper PRIVATE
"${projectm_BINARY_DIR}/src/api/include"
"${projectm_BINARY_DIR}/src/playlist/include"
)
else()
message(FATAL_ERROR "projectm_BINARY_DIR not defined; cannot set build-tree include paths")
endif()

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library(
log-lib
log)
# Android + GLES
find_library(log-lib log)
find_library(android-lib android)
find_library(glesv2-lib GLESv2)
find_library(egl-lib EGL)


add_library(
projectM
SHARED
IMPORTED
target_include_directories(jniwrapper
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

set_target_properties(
projectM
PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/../../../jniLibs/armeabi-v7a/libprojectM.so)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../jniLibs/include/ )

target_link_libraries(
jniwrapper
target_link_libraries(jniwrapper
PRIVATE
${log-lib}
projectM)
${android-lib}
${glesv2-lib}
${egl-lib}
libprojectM::playlist
projectM
)
Loading