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

Cargo-lipo v3 compat #504

Merged
merged 2 commits into from
Jan 2, 2019
Merged

Cargo-lipo v3 compat #504

merged 2 commits into from
Jan 2, 2019

Conversation

eoger
Copy link
Contributor

@eoger eoger commented Jan 2, 2019

cargo-lipo was re-implemented in TimNN/cargo-lipo#25, this PR makes our build process compatible with this new version.

Major changes:

  • We now build the rust library in debug or release mode following the XCode's project mode.
  • We also only build the rust lipoed library for the architectures XCode is building for, instead of building every architecture.
  • There's no need to run env -i anymore to sanitize the PATH before running cargo lipo in XCode run script phase.

@eoger eoger requested a review from a team January 2, 2019 18:16
@thomcc
Copy link
Contributor

thomcc commented Jan 2, 2019

Why are we changing these paths to debug?

@eoger
Copy link
Contributor Author

eoger commented Jan 2, 2019

Why are we changing these paths to debug?

The two first changed paths don't really matter as we will grab the lib in the right folder thanks to LIBRARY_SEARCH_PATHS.

The LIBRARY_SEARCH_PATHS change is missing some context: if you open the current version of project.pbxproj, you will see that we currently have the following search paths defined:
if debug LIBRARY_SEARCH_PATHS = [release]
if release LIBRARY_SEARCH_PATHS = [release]

Copy link
Contributor

@thomcc thomcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so long as these debug paths are only used for debug builds and not release builds.

Do we need to do this for logins too?

@eoger
Copy link
Contributor Author

eoger commented Jan 2, 2019

Do we need to do this for logins too?

Nope as we can't use cargo lipo because of rust-lang/rust#55235 ☹️ (can't pass SQLCIPHER_LIB_DIR=/target/universal/...), so I'm doing a manual lipo:

shellScript = "cd \"$SRCROOT\"/../ffi\n# We can't use cargo lipo because we can't link to universal libraries :(\n# https://github.com/rust-lang/rust/issues/55235\nLIBS_ARCHS=(\"i386\" \"x86_64\" \"armv7\" \"arm64\")\nIOS_TRIPLES=(\"i386-apple-ios\" \"x86_64-apple-ios\" \"armv7-apple-ios\" \"aarch64-apple-ios\")\nfor i in \"${!LIBS_ARCHS[@]}\"; do\n LIB_ARCH=${LIBS_ARCHS[$i]}\n env -i PATH=$PATH \\\n OPENSSL_STATIC=1 \\\n OPENSSL_DIR=\"$SRCROOT\"/../../../libs/ios/$LIB_ARCH/openssl \\\n SQLCIPHER_LIB_DIR=\"$SRCROOT\"/../../../libs/ios/$LIB_ARCH/sqlcipher/lib \\\n SQLCIPHER_INCLUDE_DIR=\"$SRCROOT\"/../../../libs/ios/$LIB_ARCH/sqlcipher/include \\\n \"$HOME\"/.cargo/bin/cargo build --lib --release --target ${IOS_TRIPLES[$i]}\ndone\nmkdir -p \"$SRCROOT\"/../../../target/universal/release\nlipo -create -output \"$SRCROOT\"/../../../target/universal/release/liblogins_ffi.a \\\n\"$SRCROOT\"/../../../target/i386-apple-ios/release/liblogins_ffi.a \\\n\"$SRCROOT\"/../../../target/x86_64-apple-ios/release/liblogins_ffi.a \\\n\"$SRCROOT\"/../../../target/armv7-apple-ios/release/liblogins_ffi.a \\\n\"$SRCROOT\"/../../../target/aarch64-apple-ios/release/liblogins_ffi.a \\\n";

@eoger eoger merged commit 1fa9ec9 into master Jan 2, 2019
@eoger eoger deleted the cargo-lipo-3 branch January 2, 2019 20:22
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

Successfully merging this pull request may close these issues.

2 participants