Add a cmake option BUILD_ANDROID

And skip components not applicable on Android

* fuse: Android's kernel do support fuse, but there's no libfuse.
  Instead, those who need fuse, like the /system/bin/sdcard daemon,
  talks to the kernel directly.
* udev: Android doesn't use udev. They use ueventd instead.
This commit is contained in:
Yen Chi Hsuan 2017-04-13 21:27:56 +08:00
parent 600b660812
commit 357243f047
3 changed files with 14 additions and 3 deletions

View File

@ -31,6 +31,7 @@ enable_language(ASM-ATT)
option(FRAMEWORK_COREAUDIO "Enable audio-related functionality" OFF)
option(FRAMEWORK_APPKIT "Enable AppKit development code" OFF)
option(BUILD_ANDROID "Target Android platforms" OFF)
add_subdirectory(src)
@ -78,6 +79,8 @@ InstallSymlink(/Volumes/SystemRoot/lib64 ${CMAKE_INSTALL_PREFIX}/libexec/darling
InstallSymlink(/Volumes/SystemRoot/usr/share/zoneinfo ${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/share/zoneinfo)
# Our udev rules, so /dev/mach has 0666 permissions
install(DIRECTORY etc/udev DESTINATION /etc)
if(NOT BUILD_ANDROID)
# Our udev rules, so /dev/mach has 0666 permissions
install(DIRECTORY etc/udev DESTINATION /etc)
endif(NOT BUILD_ANDROID)

View File

@ -86,7 +86,10 @@ add_subdirectory(kernel)
add_subdirectory(libc)
add_definitions(-D_LIBC_NO_FEATURE_VERIFICATION)
add_subdirectory(external/darling-dmg)
if(NOT BUILD_ANDROID)
# Android is lack of libfuse
add_subdirectory(external/darling-dmg)
endif(NOT BUILD_ANDROID)
add_subdirectory(libm)
add_subdirectory(libmacho)
add_subdirectory(libgcc)

View File

@ -9,6 +9,11 @@ endif(COMMAND cmake_policy)
enable_language(C ASM)
if(BUILD_ANDROID)
list(APPEND CMAKE_MODULE_PATH "$ENV{ANDROID_NDK}/build/cmake")
include(android.toolchain)
endif(BUILD_ANDROID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Ttext-segment,0x400000 -Wl,-Tbss,0x410000 -Wl,-Tdata,0x420000")