Skip to content

Commit

Permalink
fixed for android-5
Browse files Browse the repository at this point in the history
  • Loading branch information
rkhat2 committed Jul 5, 2018
1 parent 377eccf commit 2c3998e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .travis/linux/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apt-get update
apt-get install -y wget
#required
apt-get install -y build-essential git zlib1g-dev libpcre3-dev
apt-get install -y build-essential git zlib1g-dev libpcre3-dev liblz4-dev
#gcc
apt-get install -y gcc-multilib g++-multilib

Expand Down
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ foreach(module ${ANDROID_SUBMODULES})
)
endforeach()

# LZ4
m_ExternalProject_Add(LZ4
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${LZ4_SOURCE_DIR}/cmake_unofficial
BUILD_COMMAND ""
SOURCE_SUBDIR src
STEP_TARGETS configure
)

# LIBZ
m_ExternalProject_Add(LIBZ
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${LIBZ_SOURCE_DIR}/src
Expand Down Expand Up @@ -103,11 +111,15 @@ m_ExternalProject_Add(EXTRAS
STEP_TARGETS configure
)
ExternalProject_Add_StepDependencies(EXTRAS patch "${EXTERNAL_MODULES_DIR}/extras.cmake")
ExternalProject_Add_StepDependencies(EXTRAS configure libz libpcre libselinux libsparse libcutils liblog)
ExternalProject_Add_StepDependencies(EXTRAS configure liblz4 libz libpcre libselinux libsparse liblog)

# Building binaries
# ============================================================

# Build liblz4
m_build_target(liblz4 liblz4 LZ4)
add_dependencies(liblz4 LZ4-configure)

# Build libz
m_build_target(libz zlibstatic LIBZ)
add_dependencies(libz LIBZ-configure)
Expand All @@ -124,10 +136,6 @@ add_dependencies(libselinux LIBSELINUX-configure)
m_build_target(libsparse libsparse CORE)
add_dependencies(libsparse libz CORE-configure)

# Build libcutils
m_build_target(libcutils libcutils CORE)
add_dependencies(libcutils CORE-configure)

# Build liblog
m_build_target(liblog liblog CORE)
add_dependencies(liblog CORE-configure)
Expand All @@ -154,7 +162,7 @@ add_dependencies(simg2simg libsparse CORE-configure)

# mkbootfs
m_build_target(mkbootfs mkbootfs CORE)
add_dependencies(mkbootfs libcutils liblog CORE-configure)
add_dependencies(mkbootfs liblog CORE-configure)

# mkbootimg
m_build_target(mkbootimg mkbootimg CORE)
Expand All @@ -166,11 +174,11 @@ add_dependencies(unpackbootimg CORE-configure)

# make_ext4fs
m_build_target(make_ext4fs make_ext4fs EXTRAS)
add_dependencies(make_ext4fs libz libpcre libselinux libsparse libcutils liblog EXTRAS-configure)
add_dependencies(make_ext4fs liblz4 libz libpcre libselinux libsparse liblog EXTRAS-configure)

# make_ext4fs_def
m_build_target(make_ext4fs_def make_ext4fs_def EXTRAS)
add_dependencies(make_ext4fs_def libz libpcre libselinux libsparse libcutils liblog EXTRAS-configure)
add_dependencies(make_ext4fs_def liblz4 libz libpcre libselinux libsparse liblog EXTRAS-configure)

# Miscellaneous
# ============================================================
Expand Down
2 changes: 2 additions & 0 deletions CMakeModules/Default-AOSP.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# AOSP url
set(DEFAULT_LZ4_URL "https://github.com/LineageOS/android_external_lz4")
set(DEFAULT_LIBZ_URL "https://android.googlesource.com/platform/external/zlib")
set(DEFAULT_PCRE_URL "https://android.googlesource.com/platform/external/pcre")
set(DEFAULT_LIBSELINUX_URL "https://android.googlesource.com/platform/external/libselinux")
set(DEFAULT_CORE_URL "https://android.googlesource.com/platform/system/core")
set(DEFAULT_EXTRAS_URL "https://android.googlesource.com/platform/system/extras")

# AOSP branches
set(DEFAULT_LZ4_BRANCH "ab3d3ccefdd6e96f1146307138f16c4e77f0b7b4")
set(DEFAULT_LIBZ_BRANCH ${DEFAULT_AOSP_BRANCH})
set(DEFAULT_PCRE_BRANCH ${DEFAULT_AOSP_BRANCH})
set(DEFAULT_LIBSELINUX_BRANCH ${DEFAULT_AOSP_BRANCH})
Expand Down
4 changes: 4 additions & 0 deletions CMakeModules/Default-LINEAGE.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Lineage url
set(DEFAULT_LZ4_URL "https://github.com/LineageOS/android_external_lz4")
set(DEFAULT_LIBZ_URL "https://github.com/LineageOS/android_external_zlib.git")
# Lineage's PCRE not maintained. Using AOSP instead.
set(DEFAULT_PCRE_URL "https://android.googlesource.com/platform/external/pcre")
Expand All @@ -7,6 +8,7 @@ set(DEFAULT_CORE_URL "https://github.com/LineageOS/android_system_core.git")
set(DEFAULT_EXTRAS_URL "https://github.com/LineageOS/android_system_extras.git")

# Lineage branches
set(DEFAULT_LZ4_BRANCH "ab3d3ccefdd6e96f1146307138f16c4e77f0b7b4")
set(DEFAULT_LIBZ_BRANCH "e1bc5b1518b01893550e754de4366fdae1c6f89d")
set(DEFAULT_PCRE_BRANCH ${DEFAULT_AOSP_BRANCH})
set(DEFAULT_LIBSELINUX_BRANCH "2e2f4ae0697745285fff29b89c031df8f2733e4f")
Expand All @@ -16,6 +18,8 @@ set(DEFAULT_EXTRAS_BRANCH "cba516a826f4bcdf9ce4038c40e3a9cc1c906700")
set(ANDROID_URL_HINT "Check https://github.com/LineageOS/android_system_core for more branches.
Use commit hashes. Otherwise changing branches will break")

# android_external_lz4
# ab3d3ccefdd6e96f1146307138f16c4e77f0b7b4 refs/heads/cm-12.1
# android_external_zlib
# e1bc5b1518b01893550e754de4366fdae1c6f89d refs/heads/cm-12.1
# 55411b151568e5e3ca27041a9e6bb65ba3469839 refs/heads/cm-13.0
Expand Down
2 changes: 1 addition & 1 deletion CMakeModules/Default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(ALLOWED_ANDROID_REPOSITORY_SOURCE AOSP LINEAGE)
set(DEFAULT_ANDROID_REPOSITORY_SOURCE LINEAGE)

# Android libraries
set(ANDROID_SUBMODULES LIBZ PCRE LIBSELINUX CORE EXTRAS)
set(ANDROID_SUBMODULES LZ4 LIBZ PCRE LIBSELINUX CORE EXTRAS)

# Android libraries prefix directory
set(ANDROID_PREFIX_DIR ${CMAKE_SOURCE_DIR}/external/platform)
Expand Down
24 changes: 1 addition & 23 deletions ExternalModules/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ set(LIBSPARSE_SRCS
${CORE_SOURCE_DIR}/libsparse/sparse_read.c
)

# libcutil sources
set(LIBCUTILS_SRCS
${CORE_SOURCE_DIR}/libcutils/hashmap.c
${CORE_SOURCE_DIR}/libcutils/native_handle.c
${CORE_SOURCE_DIR}/libcutils/config_utils.c
${CORE_SOURCE_DIR}/libcutils/load_file.c
${CORE_SOURCE_DIR}/libcutils/strlcpy.c
${CORE_SOURCE_DIR}/libcutils/open_memstream.c
${CORE_SOURCE_DIR}/libcutils/record_stream.c
${CORE_SOURCE_DIR}/libcutils/process_name.c
${CORE_SOURCE_DIR}/libcutils/threads.c
${CORE_SOURCE_DIR}/libcutils/sched_policy.c
${CORE_SOURCE_DIR}/libcutils/iosched_policy.c
${CORE_SOURCE_DIR}/libcutils/str_parms.c
${CORE_SOURCE_DIR}/libcutils/fs_config.c
)

# liblog sources
set(LIBLOG_SRCS
${CORE_SOURCE_DIR}/liblog/logd_write.c
Expand Down Expand Up @@ -92,11 +75,6 @@ if(NOT EXISTS ${libz})
endif()
target_link_libraries(libsparse ${libz})

# libcutils
add_library(libcutils STATIC ${LIBCUTILS_SRCS})
target_include_directories(libcutils PRIVATE ${core_include})
set_target_properties(libcutils PROPERTIES OUTPUT_NAME cutils)

# liblog
add_library(liblog STATIC ${LIBLOG_SRCS})
target_include_directories(liblog PRIVATE ${core_include})
Expand Down Expand Up @@ -135,7 +113,7 @@ target_link_libraries(simg2simg libsparse)
# mkbootfs
add_executable(mkbootfs ${MKBOOTFS_SRCS})
target_include_directories(mkbootfs PRIVATE ${core_include})
target_link_libraries(mkbootfs libcutils liblog)
target_link_libraries(mkbootfs liblog)

# mkbootimg
add_executable(mkbootimg ${MKBOOTIMG_SRCS})
Expand Down
16 changes: 8 additions & 8 deletions ExternalModules/extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project("Extras" C)
# External libraries
# ============================================================

set(liblz4 "${LZ4_BINARY_DIR}/liblz4.a")

# libpcre needs to be linked after libselinux
set(libselinux "${LIBSELINUX_BINARY_DIR}/libselinux.a")
set(libpcre "${PCRE_BINARY_DIR}/libpcre.a")
Expand All @@ -13,8 +15,6 @@ set(libpcre "${PCRE_BINARY_DIR}/libpcre.a")
set(libsparse "${CORE_BINARY_DIR}/libsparse.a")
set(libz "${LIBZ_BINARY_DIR}/libz.a")

# liblog needs to be linked after libcutils
set(libcutils "${CORE_BINARY_DIR}/libcutils.a")
set(liblog "${CORE_BINARY_DIR}/liblog.a")


Expand Down Expand Up @@ -77,6 +77,10 @@ add_executable(make_ext4fs_def ${MAKE_EXT4FS_SRCS} ${MAKE_EXT4FS_DEF} ${LIBEXT4_
target_include_directories(make_ext4fs_def PRIVATE ${libselinux_include} ${libsparse_include} ${core_include})
target_compile_definitions(make_ext4fs_def PRIVATE ${make_ext4fs_definitions})

if(NOT EXISTS ${liblz4})
message(WARNING "Liblz4 is missing.
LZ4_BINARY_DIR: ${LZ4_BINARY_DIR} does not have liblz4.a")
endif()
if(NOT EXISTS ${libselinux})
message(WARNING "libselinux is missing.
LIBSELINUX_BINARY_DIR: ${LIBSELINUX_BINARY_DIR} does not have libselinux.a")
Expand All @@ -93,29 +97,25 @@ if(NOT EXISTS ${libz})
message(WARNING "Libz is missing.
LIBZ_BINARY_DIR: ${LIBZ_BINARY_DIR} does not have libz.a")
endif()
if(NOT EXISTS ${libcutils})
message(WARNING "libcutils is missing.
LIBCUTILS_BINARY_DIR: ${LIBCUTILS_BINARY_DIR} does not have libcutils.a")
endif()
if(NOT EXISTS ${liblog})
message(WARNING "liblog is missing.
LIBLOG_BINARY_DIR: ${LIBLOG_BINARY_DIR} does not have liblog.a")
endif()

target_link_libraries(make_ext4fs
${liblz4}
${libselinux}
${libpcre}
${libsparse}
${libz}
${libcutils}
${liblog}
)

target_link_libraries(make_ext4fs_def
${liblz4}
${libselinux}
${libpcre}
${libsparse}
${libz}
${libcutils}
${liblog}
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can get prebuilt binaries from [here](https://www.github.com/rkhat2/android-
* The following packages

```bash
apt-get install build-essential git zlib1g-dev libpcre3-dev
apt-get install build-essential git zlib1g-dev libpcre3-dev liblz4-dev
```

#### Clang Compiler
Expand Down

0 comments on commit 2c3998e

Please sign in to comment.