howardpang / androidNativeBundle

a gradle plugin that support publish c/c++ headers to 'aar' and depend those 'aar'
Apache License 2.0
71 stars 14 forks source link

build/nativelib is empty #10

Open mgood7123 opened 3 years ago

mgood7123 commented 3 years ago

AAudioTrack2

AAudioTrack2
  .cxx
    build
      .transforms
      generated
      intermediates
      nativeLib
        gradle.mk
        tmp.mk
      outputs
      tmp

#include <midifile/MidiEventList.h> // not found

include (${ANDROID_GRADLE_NATIVE_BUNDLE_PLUGIN_MK})

add_library(engine SHARED
        ardour/AudioEngine/AudioBackend.cpp
        ardour/AudioEngine/AudioEngine.cpp
        ardour/Backends/AAudio.cpp
        smallville7123/MidiMap.cpp
        smallville7123/TempoGrid.cpp
)

target_link_libraries(engine log aaudio ${ANDROID_GRADLE_NATIVE_MODULES})

build.gradle

plugins {
    id 'com.android.library'
    id 'com.ydq.android.gradle.native-aar.import'
}

// https://developer.android.com/studio/build/native-dependencies

android {
    compileSdkVersion 29 // Play requires Android Q or higher
    buildToolsVersion "29.0.3" // Play requires Android Q or higher

    defaultConfig {
        minSdkVersion 28 // Android Pie
        targetSdkVersion 29 // Play requires Android Q or higher
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++17"
            }
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
    buildFeatures {
        prefab true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation project(':AndroidDAW_SDK__MIDI')
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    //noinspection GradleDynamicVersion
    testImplementation 'junit:junit:4.+'
    api project(path: ':AAudioTrack2:VstSystem:VstManager')
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    api 'com.arthenica:mobile-ffmpeg-full-gpl:4.4'
}

AndroidDAW_SDK__MIDI

build.gradle

plugins {
    id 'com.android.library'
    id 'com.ydq.android.gradle.native-aar.export'
}

nativeBundleExport {
    headerDir = "${project.projectDir}/src/main/cpp/include"
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++17"
            }
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
    buildFeatures {
        prefab true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

structure

src
  androidTest
  main
    cpp
      include
        midifile
          Binasc.h
          MidiEvent.h
          MidiEventList.h
          MidiFile.h
          MidiMessage.h
          Options.h
        src
        CMakeLists.txt
    java
    AndroidManifest.xml

Cmake

cmake_minimum_required(VERSION 3.10.2)

project("AndroidDAW_SDK_MIDI")

set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG}   --optimize -O0 -g3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --optimize -Ofast -g0")

# https://developer.android.com/ndk/guides/asan#cmake

include(CheckIncludeFiles)

include_directories(include)

check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(humdrum.h HAVE_HUMDRUM_H)
check_include_files(sys/io.h HAVE_SYS_IO_H)

add_library(AndroidDAW_MIDI SHARED
        src/Options.cpp
        src/Binasc.cpp
        src/MidiEvent.cpp
        src/MidiEventList.cpp
        src/MidiFile.cpp
        src/MidiMessage.cpp
)
howardpang commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

mgood7123 commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

how would I reference my module?

howardpang commented 3 years ago

https://developer.android.com/studio/projects/configure-cmake the 'Include other CMake projects' may satisfy

mgood7123 commented 3 years ago

https://developer.android.com/studio/projects/configure-cmake the 'Include other CMake projects' may satisfy

seems ummm like this could be automated by the plugin, like a top level global header/libs direcory

or what you do already for maven aar's

mgood7123 commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

would It be possible to support local dependancies?

howardpang commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

would It be possible to support local dependancies?

Yes, it can do, i suggest you implement it by add 'cflag' and 'link flag' temporarily, i'm be busy recently and have few time to implement it.

mgood7123 commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

would It be possible to support local dependancies?

Yes, it can do, i suggest you implement it by add 'cflag' and 'link flag' temporarily, i'm be busy recently and have few time to implement it.

in ndk-build ? or cmake ?

howardpang commented 3 years ago

Currently, the plugin is only support maven dependency, because your two module is in the same project, it is easy to reference anthoer, so the plugin do noting when in this situation.

would It be possible to support local dependancies?

Yes, it can do, i suggest you implement it by add 'cflag' and 'link flag' temporarily, i'm be busy recently and have few time to implement it.

in ndk-build ? or cmake ?

cmake, the plugin also implement it by this way

mgood7123 commented 3 years ago

ok, so I got it working, tho slightly hacky

in applications, add

android {
    packagingOptions {
        pickFirst "**/*.so"
    }
}

to avoid a duplicate .so error during packaging of apk

in libraries, add

android {
    buildFeatures {
        prefab true
    }
}

for libraries, as an example

EXPORTED LIBRARY:

include_directories(include)
add_library(AndroidDAW_Plugin SHARED TempoGrid.cpp)

add_subdirectory(AndroidDAW_SDK_CMAKE_HELPER)
SET_PROJECT_ROOT_AndroidDAW_SDK(${CMAKE_CURRENT_SOURCE_DIR}/../../..) # MODULE ROOT

export_library_AndroidDAW_SDK(Plugin)

IMPORTED LIBRARY:

add_subdirectory(AndroidDAW_SDK_CMAKE_HELPER)
SET_PROJECT_ROOT_AndroidDAW_SDK(${CMAKE_CURRENT_SOURCE_DIR}/../../../..) # PROJECT ROOT
import_library__AndroidDAW_Plugin()

add_library(audio_player SHARED native-lib.cpp)
target_link_libraries(audio_player AndroidDAW_Plugin)

for details, see AndroidDAW_SDK_CMAKE_HELPER

https://www.github.com/mgood7123/AndroidDAW_SDK/tree/main/CMAKE_HELPER/CMakeLists.txt

edambelle commented 3 years ago

How

mgood7123 commented 3 years ago

How

what do you mean?

edambelle commented 3 years ago

I mean how to get your code and how get the file

On Thu, Mar 25, 2021, 3:21 PM mgood7123 @.***> wrote:

How

what do you mean?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/howardpang/androidNativeBundle/issues/10#issuecomment-806457937, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATLKFUZ7KOQNKN77GJ6OUTLTFLW7JANCNFSM4ZSID4DQ .

mgood7123 commented 3 years ago

I mean how to get your code and how get the file

it is literally right there in the post lol