[Not working] Wrap Parted autotools-based build system with CMake
This commit is contained in:
parent
c5292349bf
commit
364fad4f12
5 changed files with 193 additions and 12 deletions
15
cmake_utils/get_args.cmake
Normal file
15
cmake_utils/get_args.cmake
Normal file
|
@ -0,0 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
get_cmake_property(CACHE_VARS CACHE_VARIABLES)
|
||||
foreach(CACHE_VAR ${CACHE_VARS})
|
||||
get_property(CACHE_VAR_HELPSTRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
|
||||
if(CACHE_VAR_HELPSTRING STREQUAL "No help, variable specified on the command line.")
|
||||
get_property(CACHE_VAR_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
|
||||
if(CACHE_VAR_TYPE STREQUAL "UNINITIALIZED")
|
||||
set(CACHE_VAR_TYPE)
|
||||
else()
|
||||
set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE})
|
||||
endif()
|
||||
list(APPEND CMAKE_ARGS "-D${CACHE_VAR}${CACHE_VAR_TYPE}=${${CACHE_VAR}}")
|
||||
endif()
|
||||
endforeach()
|
120
cmake_utils/ndk_exec.cmake
Normal file
120
cmake_utils/ndk_exec.cmake
Normal file
|
@ -0,0 +1,120 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${ANDROID_NDK}/build/cmake/android.toolchain.cmake")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_TOOLCHAIN_FILE})
|
||||
|
||||
# Set up stuff for autotools build to succeed
|
||||
# Some of this code has been adapted from https://github.com/termux/termux-packages/blob/master/build-package.sh
|
||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
||||
set(NDK_HOST "aarch64-linux-android")
|
||||
elseif (ANDROID_ABI STREQUAL "armeabi-v7a")
|
||||
set(NDK_HOST "arm-linux-androideabi")
|
||||
set(CFLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb")
|
||||
elseif (ANDROID_ABI STREQUAL "x86")
|
||||
set(NDK_HOST "x86-linux-android")
|
||||
set(CFLAGS "-march=i686 -msse3 -mstackrealign -mfpmath=sse")
|
||||
elseif (ANDROID_ABI STREQUAL "x86_64")
|
||||
set(NDK_HOST "x86_64-linux-android")
|
||||
endif ()
|
||||
|
||||
if(NOT DEFINED ANDROID_HOST_TAG OR (DEFINED ANDROID_HOST_TAG AND ANDROID_HOST_TAG STREQUAL ""))
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(ANDROID_HOST_TAG linux-x86_64)
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(ANDROID_HOST_TAG darwin-x86_64)
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(ANDROID_HOST_TAG windows-x86_64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ${ANDROID_TOOLCHAIN_ROOT} MATCHES "${ANDROID_HOST_TAG}/?$")
|
||||
set(ANDROID_TOOLCHAIN_ROOT "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_HOST_TAG}")
|
||||
endif()
|
||||
|
||||
set(ENV{PATH} "${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH}")
|
||||
set(ENV{CFLAGS} "${CMAKE_C_FLAGS} -fPIE")
|
||||
set(ENV{LDFLAGS} "${ANDROID_LINKER_FLAGS} -pie")
|
||||
set(ENV{CXXFLAGS} "${CMAKE_CXX_FLAGS} -fPIE")
|
||||
set(ENV{AS} "${NDK_HOST}-as")
|
||||
set(ENV{CC} "${NDK_HOST}-gcc")
|
||||
set(ENV{CXX} "${NDK_HOST}-g++")
|
||||
set(ENV{AR} "${NDK_HOST}-ar")
|
||||
set(ENV{CPP} "${NDK_HOST}-g++")
|
||||
#set(ENV{CC_FOR_BUILD} "c")
|
||||
set(ENV{LD} "${NDK_HOST}-ld")
|
||||
set(ENV{OBJDUMP} "${NDK_HOST}-objdump")
|
||||
set(ENV{RANLIB} "${NDK_HOST}-ranlib")
|
||||
set(ENV{READELF} "${NDK_HOST}-readelf")
|
||||
set(ENV{STRIP} "${NDK_HOST}-strip")
|
||||
set(ENV{ac_cv_func_getpwent} "no")
|
||||
set(ENV{ac_cv_func_getpwnam} "no")
|
||||
set(ENV{ac_cv_func_getpwuid} "no")
|
||||
set(ENV{ac_cv_func_sigsetmask} "no")
|
||||
set(ENV{ac_cv_func_calloc_0_nonnull} "yes")
|
||||
set(ENV{ac_cv_func_chown_works} "yes")
|
||||
set(ENV{ac_cv_func_getgroups_works} "yes")
|
||||
set(ENV{ac_cv_func_malloc_0_nonnull} "yes")
|
||||
set(ENV{ac_cv_func_realloc_0_nonnull} "yes")
|
||||
set(ENV{am_cv_func_working_getline} "yes")
|
||||
set(ENV{gl_cv_func_dup2_works} "yes")
|
||||
set(ENV{gl_cv_func_fcntl_f_dupfd_cloexec} "yes")
|
||||
set(ENV{gl_cv_func_fcntl_f_dupfd_works} "yes")
|
||||
set(ENV{gl_cv_func_fnmatch_posix} "yes")
|
||||
set(ENV{gl_cv_func_getcwd_abort_bug} "no")
|
||||
set(ENV{gl_cv_func_getcwd_null} "yes")
|
||||
set(ENV{gl_cv_func_getcwd_path_max} "yes")
|
||||
set(ENV{gl_cv_func_getcwd_posix_signature} "yes")
|
||||
set(ENV{gl_cv_func_gettimeofday_clobber} "no")
|
||||
set(ENV{gl_cv_func_gettimeofday_posix_signature} "yes")
|
||||
set(ENV{gl_cv_func_link_works} "yes")
|
||||
set(ENV{gl_cv_func_lstat_dereferences_slashed_symlink} "yes")
|
||||
set(ENV{gl_cv_func_malloc_0_nonnull} "yes")
|
||||
set(ENV{gl_cv_func_memchr_works} "yes")
|
||||
set(ENV{gl_cv_func_mkdir_trailing_dot_works} "yes")
|
||||
set(ENV{gl_cv_func_mkdir_trailing_slash_works} "yes")
|
||||
set(ENV{gl_cv_func_mkfifo_works} "yes")
|
||||
set(ENV{gl_cv_func_mknod_works} "yes")
|
||||
set(ENV{gl_cv_func_realpath_works} "yes")
|
||||
set(ENV{gl_cv_func_select_detects_ebadf} "yes")
|
||||
set(ENV{gl_cv_func_snprintf_posix} "yes")
|
||||
set(ENV{gl_cv_func_snprintf_retval_c99} "yes")
|
||||
set(ENV{gl_cv_func_snprintf_truncation_c99} "yes")
|
||||
set(ENV{gl_cv_func_stat_dir_slash} "yes")
|
||||
set(ENV{gl_cv_func_stat_file_slash} "yes")
|
||||
set(ENV{gl_cv_func_strerror_0_works} "yes")
|
||||
set(ENV{gl_cv_func_symlink_works} "yes")
|
||||
set(ENV{gl_cv_func_tzset_clobber} "no")
|
||||
set(ENV{gl_cv_func_unlink_honors_slashes} "yes")
|
||||
set(ENV{gl_cv_func_unlink_honors_slashes} "yes")
|
||||
set(ENV{gl_cv_func_vsnprintf_posix} "yes")
|
||||
set(ENV{gl_cv_func_vsnprintf_zerosize_c99} "yes")
|
||||
set(ENV{gl_cv_func_wcwidth_works} "yes")
|
||||
set(ENV{gl_cv_func_working_getdelim} "yes")
|
||||
set(ENV{gl_cv_func_working_mkstemp} "yes")
|
||||
set(ENV{gl_cv_func_working_mktime} "yes")
|
||||
set(ENV{gl_cv_func_working_strerror} "yes")
|
||||
set(ENV{gl_cv_header_working_fcntl_h} "yes")
|
||||
set(ENV{gl_cv_C_locale_sans_EILSEQ} "yes")
|
||||
|
||||
string(REPLACE <NDK_HOST> "${NDK_HOST}" COMMAND "${COMMAND}")
|
||||
|
||||
message("NDK EXEC: ${COMMAND}")
|
||||
message("CWD: ${CWD}")
|
||||
separate_arguments(CMD UNIX_COMMAND "${COMMAND}")
|
||||
message("SPLIT CMD: ${CMD}")
|
||||
|
||||
if(CWD)
|
||||
message("ndkexec has cwd")
|
||||
execute_process(
|
||||
COMMAND ${CMD}
|
||||
WORKING_DIRECTORY ${CWD}
|
||||
)
|
||||
else()
|
||||
message("ndkexec no cwd")
|
||||
execute_process(
|
||||
COMMAND ${CMD}
|
||||
)
|
||||
endif()
|
|
@ -1,27 +1,76 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
# Use ccache if available
|
||||
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)
|
||||
|
||||
|
||||
project(parted_build)
|
||||
include(ExternalProject)
|
||||
|
||||
set(AUTOMAKE_DUCTTAPE_SRC ${PROJECT_BINARY_DIR}/parted_src)
|
||||
|
||||
include(../cmake_utils/get_args.cmake)
|
||||
|
||||
list(APPEND CMAKE_ARGS "-DCMAKE_HOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}")
|
||||
|
||||
set(BOOTSTRAP_ARGS ${CMAKE_ARGS})
|
||||
|
||||
list(APPEND CMAKE_ARGS "-DCWD=${AUTOMAKE_DUCTTAPE_SRC}")
|
||||
|
||||
set(CONFIG_ARGS ${CMAKE_ARGS})
|
||||
set(MAKE_ARGS ${CMAKE_ARGS})
|
||||
set(INSTALL_ARGS ${CMAKE_ARGS})
|
||||
|
||||
list(APPEND BOOTSTRAP_ARGS "-DCWD=${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted")
|
||||
list(APPEND BOOTSTRAP_ARGS "-DCOMMAND=${AUTOMAKE_DUCTTAPE_SRC}/bootstrap")
|
||||
list(APPEND BOOTSTRAP_ARGS "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_utils/ndk_exec.cmake")
|
||||
|
||||
list(APPEND CONFIG_ARGS "-DCOMMAND:STRING=${AUTOMAKE_DUCTTAPE_SRC}/configure --disable-dependency-tracking --host=<NDK_HOST> --disable-rpath --disable-static --disable-nls --enable-shared --prefix=<INSTALL_DIR> --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}")
|
||||
list(APPEND CONFIG_ARGS "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_utils/ndk_exec.cmake")
|
||||
|
||||
list(APPEND MAKE_ARGS "-DCOMMAND=make")
|
||||
list(APPEND MAKE_ARGS "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_utils/ndk_exec.cmake")
|
||||
|
||||
list(APPEND INSTALL_ARGS "-DCOMMAND:STRING=make install")
|
||||
list(APPEND INSTALL_ARGS "-P" "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_utils/ndk_exec.cmake")
|
||||
|
||||
|
||||
get_cmake_property(_variableNames VARIABLES)
|
||||
list (SORT _variableNames)
|
||||
foreach (_variableName ${_variableNames})
|
||||
message(STATUS "${_variableName}=${${_variableName}}")
|
||||
endforeach()
|
||||
|
||||
ExternalProject_Add(parted_build
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted"
|
||||
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted/configure --prefix=<INSTALL_DIR> --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})
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${CONFIG_ARGS}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} ${MAKE_ARGS}
|
||||
BUILD_ALWAYS True
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} ${INSTALL_ARGS})
|
||||
|
||||
ExternalProject_Add_Step(parted_build bootstrap
|
||||
COMMAND true)
|
||||
#${CMAKE_COMMAND} ${BOOTSTRAP_ARGS})
|
||||
|
||||
ExternalProject_Add_Step(parted_build rmoldsrc
|
||||
DEPENDEES bootstrap
|
||||
COMMAND rm -Rf ${AUTOMAKE_DUCTTAPE_SRC})
|
||||
|
||||
ExternalProject_Add_Step(parted_build copysrc
|
||||
DEPENDERS configure
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted
|
||||
COMMAND ./bootstrap)
|
||||
DEPENDEES rmoldsrc
|
||||
COMMAND cp -R ${CMAKE_CURRENT_SOURCE_DIR}/src/c/parted ${AUTOMAKE_DUCTTAPE_SRC})
|
||||
|
||||
|
||||
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)
|
||||
|
@ -34,10 +83,6 @@ 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 <INSTALL_DIR>/sbin/parted <INSTALL_DIR>/sbin/partprobe "${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/bin/${ANDROID_ABI}/")
|
||||
add_executable(dummy
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/c/dummy.c)
|
||||
add_dependencies(dummy parted_build)
|
|
@ -5,7 +5,7 @@ android {
|
|||
defaultConfig {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
targets "libparted", "libparted-fs-resize", "parted", "partprobe"
|
||||
targets "libparted", "libparted-fs-resize", "parted", "partprobe", "dummy"
|
||||
arguments "-DANDROID_PIE=ON"
|
||||
}
|
||||
}
|
||||
|
|
1
parted/src/c/dummy.c
Normal file
1
parted/src/c/dummy.c
Normal file
|
@ -0,0 +1 @@
|
|||
int main() {}
|
Loading…
Reference in a new issue