From db9f81ea6aa0dd2297592dd4f0fa6ba1cc7b114e Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Sat, 18 Aug 2018 01:00:49 +0200 Subject: [PATCH] Add parted dependency (does not build yet) --- .gitmodules | 3 ++ app/build.gradle | 2 +- parted/CMakeLists.txt | 43 +++++++++++++++++++++++++++++ parted/build.gradle | 23 +++++++++++++++ parted/src/c/parted | 1 + parted/src/main/AndroidManifest.xml | 3 ++ settings.gradle | 2 +- 7 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 parted/CMakeLists.txt create mode 100644 parted/build.gradle create mode 160000 parted/src/c/parted create mode 100644 parted/src/main/AndroidManifest.xml diff --git a/.gitmodules b/.gitmodules index 46f629d..551a09e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "app/src/c/libressl"] path = dmg2img/src/c/libressl url = https://github.com/libressl-portable/portable.git +[submodule "parted/src/c/parted"] + path = parted/src/c/parted + url = https://github.com/Depau/parted.git diff --git a/app/build.gradle b/app/build.gradle index 1f0aa91..8b8b3e3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ dependencies { // implementation 'com.github.mjdev:libaums:0.5.5' implementation project(':libaums') implementation project(':dmg2img') - + implementation project(':parted') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' diff --git a/parted/CMakeLists.txt b/parted/CMakeLists.txt new file mode 100644 index 0000000..69ffe2b --- /dev/null +++ b/parted/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.4) + +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif(CCACHE_FOUND) + +include(ExternalProject) + +ExternalProject_Add(parted_build + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted" + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted/configure --prefix= --sbindir=${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/ --bindir=${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/ --libdir=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + BUILD_COMMAND ${MAKE}) + +ExternalProject_Add_Step(parted_build bootstrap + DEPENDERS configure + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted + COMMAND ./bootstrap) + +add_library(libparted-fs-resize SHARED IMPORTED) +add_dependencies(libparted-fs-resize parted_build) +set_target_properties(libparted-fs-resize PROPERTIES IMPORTED_LOCATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libparted-fs-resize.so.0.0.1) + +add_library(libparted SHARED IMPORTED) +add_dependencies(libparted parted_build) +set_target_properties(libparted PROPERTIES IMPORTED_LOCATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libparted.so.2.0.1) + +add_executable(parted IMPORTED) +add_dependencies(parted parted_build) +set_target_properties(parted PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/parted) + +add_executable(partprobe IMPORTED) +add_dependencies(partprobe parted_build) +set_target_properties(partprobe PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/partprobe) + +#ExternalProject_Add_Step(parted mkbindir +# DEPENDEES build +# COMMAND mkdir -p "${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/") + +#ExternalProject_Add_Step(parted copybin +# DEPENDEES mkbindir +# COMMAND cp /sbin/parted /sbin/partprobe "${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/") diff --git a/parted/build.gradle b/parted/build.gradle new file mode 100644 index 0000000..f2bd4f2 --- /dev/null +++ b/parted/build.gradle @@ -0,0 +1,23 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 28 + defaultConfig { + externalNativeBuild { + cmake { + targets "libparted", "libparted-fs-resize", "parted", "partprobe" + arguments "-DANDROID_PIE=ON" + } + } + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } + sourceSets { + main { + assets.srcDirs = ['src/main/assets'] + } + } +} diff --git a/parted/src/c/parted b/parted/src/c/parted new file mode 160000 index 0000000..395f8aa --- /dev/null +++ b/parted/src/c/parted @@ -0,0 +1 @@ +Subproject commit 395f8aabfecb28820006d37ec37e9ffe1d2eb1e3 diff --git a/parted/src/main/AndroidManifest.xml b/parted/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a412424 --- /dev/null +++ b/parted/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/settings.gradle b/settings.gradle index 77a9903..737c3a8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include ':app', ':libaums', ':dmg2img' +include ':app', ':libaums', ':dmg2img', ':parted' project(':libaums').projectDir = new File('libaums/libaums') \ No newline at end of file