From f01cae55ae58e254b3349c156f3d20d1dac3c917 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sat, 11 Jan 2020 11:41:18 -0700 Subject: [PATCH] WIP: Implement native pihelper library Signed-off-by: William Brawner --- .gitmodules | 9 ++++ libpihelper/.gitignore | 1 + libpihelper/build.gradle | 43 +++++++++++++++++++ libpihelper/src/main/AndroidManifest.xml | 5 +++ libpihelper/src/main/c/CMakeLists.txt | 27 ++++++++++++ libpihelper/src/main/c/libpihelper | 1 + libpihelper/src/main/c/pihelper-android.c | 0 .../wbrawner/libpihelper/PiHelperNative.java | 4 ++ piholeclient/build.gradle | 2 +- settings.gradle | 3 +- 10 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 100644 libpihelper/.gitignore create mode 100644 libpihelper/build.gradle create mode 100644 libpihelper/src/main/AndroidManifest.xml create mode 100644 libpihelper/src/main/c/CMakeLists.txt create mode 160000 libpihelper/src/main/c/libpihelper create mode 100644 libpihelper/src/main/c/pihelper-android.c create mode 100644 libpihelper/src/main/java/com/wbrawner/libpihelper/PiHelperNative.java diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a44d5d9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "libpihelper/src/main/c/libpihelper"] + path = libpihelper/src/main/c/libpihelper + url = git@git.wbrawner.com:/pub/git/Pi-Helper/pihelper.git +[submodule "libpihelper/src/main/c/curl"] + path = libpihelper/src/main/c/curl + url = https://github.com/curl/curl +[submodule "libpihelper/src/main/c/openssl"] + path = libpihelper/src/main/c/openssl + url = https://github.com/openssl/openssl diff --git a/libpihelper/.gitignore b/libpihelper/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/libpihelper/.gitignore @@ -0,0 +1 @@ +/build diff --git a/libpihelper/build.gradle b/libpihelper/build.gradle new file mode 100644 index 0000000..f05b584 --- /dev/null +++ b/libpihelper/build.gradle @@ -0,0 +1,43 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 29 + defaultConfig { + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + + externalNativeBuild { + cmake { + cppFlags "" + } + } + } + + externalNativeBuild { + cmake { + path "src/main/c/CMakeLists.txt" + version "3.10.2" + } + } + + 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 fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/libpihelper/src/main/AndroidManifest.xml b/libpihelper/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2d22630 --- /dev/null +++ b/libpihelper/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/libpihelper/src/main/c/CMakeLists.txt b/libpihelper/src/main/c/CMakeLists.txt new file mode 100644 index 0000000..5e86e79 --- /dev/null +++ b/libpihelper/src/main/c/CMakeLists.txt @@ -0,0 +1,27 @@ +# Set the minimum required version for cmake +cmake_minimum_required(VERSION 3.4.1) + + +set(PIHELPER_STATIC off CACHE BOOL "") +set(PIHELPER_SHARED on CACHE BOOL "") + +add_subdirectory(libpihelper) + +add_library( + pihelper + SHARED + pihelper-android.c +) + +# Include the Android logging library for native code +find_library( + log-lib + log +) + +# Link our library with the Android logging library +target_link_libraries( + pihelper + ${log-lib} + libpihelpershared +) \ No newline at end of file diff --git a/libpihelper/src/main/c/libpihelper b/libpihelper/src/main/c/libpihelper new file mode 160000 index 0000000..7e599ee --- /dev/null +++ b/libpihelper/src/main/c/libpihelper @@ -0,0 +1 @@ +Subproject commit 7e599ee5f180c0526914686826fa64b4403f09d2 diff --git a/libpihelper/src/main/c/pihelper-android.c b/libpihelper/src/main/c/pihelper-android.c new file mode 100644 index 0000000..e69de29 diff --git a/libpihelper/src/main/java/com/wbrawner/libpihelper/PiHelperNative.java b/libpihelper/src/main/java/com/wbrawner/libpihelper/PiHelperNative.java new file mode 100644 index 0000000..4b3a1bd --- /dev/null +++ b/libpihelper/src/main/java/com/wbrawner/libpihelper/PiHelperNative.java @@ -0,0 +1,4 @@ +package com.wbrawner.libpihelper; + +public class PiHelperNative { +} diff --git a/piholeclient/build.gradle b/piholeclient/build.gradle index 009b9bb..851b2b9 100644 --- a/piholeclient/build.gradle +++ b/piholeclient/build.gradle @@ -27,7 +27,7 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':libpihelper') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" diff --git a/settings.gradle b/settings.gradle index ca51868..559709c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ -include ':app', ':piholeclient' +include ':app', ':piholeclient', ':libpihelper' rootProject.name='Pi-helper' +