dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 487 forks source link

Android NDK 16b #364

Open paulocoutinhox opened 6 years ago

paulocoutinhox commented 6 years ago

Hi,

Always that i change the NDK to 16b i got:

inni-support/support-lib/jni/djinni_support.cpp
  In file included from /Users/paulo/Developer/workspaces/cpp/ubook-library-core/vendor/dependency-djinni-support/support-lib/jni/djinni_support.cpp:18:
  In file included from /Users/paulo/Developer/workspaces/cpp/ubook-library-core/vendor/dependency-djinni-support/support-lib/jni/djinni_support.hpp:21:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/memory:72:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/iosfwd:40:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/postypes.h:40:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/cwchar:44:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sysroot/usr/include/wchar.h:33:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sysroot/usr/include/stdio.h:42:
  In file included from /Users/paulo/Developer/android-ndk-r16b/sysroot/usr/include/sys/types.h:36:
  /Users/paulo/Developer/android-ndk-r16b/sysroot/usr/include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
  #include <asm/types.h>
           ^~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

Can you make an update to NDK 16b?

artwyman commented 6 years ago

I haven't tried an NDK so new, so no direct experience. Sounds like the header includes within the NDK are messed up. I know newer NDKs have deprecated GCC, so this might be related to that.

paulocoutinhox commented 6 years ago

Solution to migrate: https://android.googlesource.com/platform/ndk/+/ndk-release-r16/docs/UnifiedHeadersMigration.md

paulocoutinhox commented 6 years ago

I solve the problem with this code in my CMakeLists.txt:

set(USE_NDK_UNIFIED_HEADERS TRUE) # TRUE or FALSE

if (${USE_NDK_UNIFIED_HEADERS})
    if (${ANDROID_ABI} STREQUAL "x86_64")
        include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android)
    elseif (${ANDROID_ABI} STREQUAL "x86")
        include_directories(${ANDROID_SYSROOT}/usr/include/i686-linux-android)
    elseif (${ANDROID_ABI} STREQUAL "arm64-v8a")
        include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
    elseif (${ANDROID_ABI} MATCHES "^armeabi(-v7a)?$")
        include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
    elseif (${ANDROID_ABI} STREQUAL "mips")
        include_directories(${ANDROID_SYSROOT}/usr/include/mipsel-linux-android)
    elseif (${ANDROID_ABI} STREQUAL "mips64")
        include_directories(${ANDROID_SYSROOT}/usr/include/mips64el-linux-android)
    endif()
endif()

But i dont know if djinni need changes, because in my tests i dont need change djinni and compile all tests with NDK16b without problems.