Description
leveldown
iOS
For building leveldown for iOS, you need to add settings similar to the ones you have on macOS.
1 - Add a line for iOS after the mac line in deps/snappy/snappy.gyp
https://github.com/Level/leveldown/blob/8b03831f1d826c326c14555e471f45bffd817fe9/deps/snappy/snappy.gyp#L6 :
, ['OS=="android"', {'os_include': 'linux'}]
, ['OS=="mac"', {'os_include': 'mac'}]
, ['OS=="ios"', {'os_include': 'mac'}] # Add this line to use mac includes for ios
, ['OS=="solaris"', {'os_include': 'solaris'}]
2 - Add a section in deps/leveldb/leveldb.gyp
https://github.com/Level/leveldown/blob/8b03831f1d826c326c14555e471f45bffd817fe9/deps/leveldb/leveldb.gyp#L131-L144 similar to the one for macOS:
, ['OS == "ios"', {
'defines': [
'OS_IOS=1'
]
, 'libraries': []
, 'ccflags': []
, 'xcode_settings': {
'WARNING_CFLAGS': [
'-Wno-sign-compare'
, '-Wno-unused-variable'
, '-Wno-unused-function'
]
}
}]
3 - Add a || defined(OS_IOS)
next to every defined(OS_MACOSX)
check in deps/leveldb/leveldb-1.20/port/port_posix.h https://github.com/Level/leveldown/blob/8b03831f1d826c326c14555e471f45bffd817fe9/deps/leveldb/leveldb-1.20/port/port_posix.h
- This line should be
#if defined(OS_MACOSX) || defined(OS_IOS)
- This line should be
#if defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\
- This line should be
#if defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_FREEBSD) ||\
android
leveldown builds out of the box for the Android armv7 architecture.
For x86
, the NDK doesn't seem to be able to provide 128 bit intrinsics, so you need to replace this line in deps/snappy/snappy-1.1.4/snappy.cc
https://github.com/Level/leveldown/blob/8b03831f1d826c326c14555e471f45bffd817fe9/deps/snappy/snappy-1.1.4/snappy.cc#L98
Replace:
#ifdef __SSE2__
with
#if defined(__SSE2__) && !(defined(__ANDROID__) && defined(__i386__))