Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leveldown - build workaround #1

Open
jaimecbernardo opened this issue Feb 28, 2018 · 4 comments
Open

leveldown - build workaround #1

jaimecbernardo opened this issue Feb 28, 2018 · 4 comments

Comments

@jaimecbernardo
Copy link
Collaborator

jaimecbernardo commented Feb 28, 2018

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__))
@jaimecbernardo jaimecbernardo changed the title leveldown leveldown - build instructions workaround Feb 28, 2018
@jaimecbernardo jaimecbernardo changed the title leveldown - build instructions workaround leveldown - build workaround Feb 28, 2018
@jaimecbernardo
Copy link
Collaborator Author

The iOS workaround mentioned in this issue was included in leveldown, so it shouldn't be needed anymore:
Level/leveldown#447

@jaimecbernardo
Copy link
Collaborator Author

The Android workaround mentioned in this issue was included in leveldown, so it shouldn't be needed anymore: Level/leveldown#446

@blueye
Copy link

blueye commented Jun 12, 2020

@jaimecbernardo Could you tell me what compile commands did you use for leveldown on Android and iOS?

@jaimecbernardo
Copy link
Collaborator Author

Hi @blueye ,
Please check JaneaSystems/nodejs-mobile-gyp#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants