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

make it possible to cross-compile for iOS and Android targets #285

Merged

Conversation

eranrund
Copy link
Contributor

Heya,

This PR makes it possible to cross-compile this crate to Android and iOS, both simulator and real hardware. I have tested it and the resulting code works flawlessly (tested on iPhone 7, iPhone XS, Nexus6P, iPhone simulator and Android simulator).

Building for iOS is as simple as cargo build --target i386-apple-ios/x86_64-apple-ios/armv7-apple-ios armv7s-apple-ios/aarch64-apple-ios

Android is more complicated and requires a bunch of environment variables. For example, on my machine, this is what I used for aarch64-linux-android:

	PATH=$(PATH):$(NDK_HOME)/toolchains/llvm/prebuilt/darwin-x86_64/bin \
	LDFLAGS=-stdlib=libstdc++ \
	CFLAGS="-Wno-unused-command-line-argument -DMDB_USE_ROBUST=0" \
	CXXFLAGS="-Wno-unused-command-line-argument" \
	CXX=aarch64-linux-android26-clang++ \
	CC=aarch64-linux-android26-clang \
	ISYSROOT=$(NDK_HOME)/toolchains/llvm/prebuilt/darwin-x86_64/sysroot \
	ISYSTEM=$(NDK_HOME)/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/aarch64-linux-android \
	CMAKE_TARGET_OVERRIDE=aarch64-linux-android26 \
	cargo build --target aarch64-linux-android --release

@BusyJay
Copy link
Member

BusyJay commented Feb 13, 2019

Cool, LGTM, @overvenus PTAL

@Hoverbear
Copy link
Contributor

@eranrund Seems you need to run cargo fmt before the CI can pass. Can you please do that?

// We don't need to generate install targets.
config.define("gRPC_INSTALL", "false");
// We don't need to build csharp target.
config.define("gRPC_BUILD_CSHARP_EXT", "false");
// We don't need to build codegen target.
config.define("gRPC_BUILD_CODEGEN", "false");
// We don't need to build benchmarks.
config.define("gRPC_BENCHMARK_PROVIDER", "none");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this improve build times as well? 😍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does result in less unnecessary code being built :)

@eranrund
Copy link
Contributor Author

Done!

@ice1000
Copy link
Contributor

ice1000 commented Feb 14, 2019

Restarted Travis failed build.

@BusyJay BusyJay merged commit fbef8c5 into tikv:master Feb 14, 2019
@ice1000 ice1000 added the Build Compilation, environment label Feb 14, 2019
@eranrund
Copy link
Contributor Author

Thanks for merging! Any idea when we could expect this in a release?

@Hoverbear
Copy link
Contributor

What do you think @BusyJay?

@BusyJay
Copy link
Member

BusyJay commented Feb 15, 2019

@overvenus Maybe we can schedule a release next week. Several bugs are fixed since 0.4.2.

@eranrund
Copy link
Contributor Author

That would be awesome ^_^
Thanks for maintaining this project!

@overvenus
Copy link
Member

Hi @eranrund, #288 brings this PR in v0.4.4.

@eranrund
Copy link
Contributor Author

Sweet. Thank you all for moving quickly!

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

Successfully merging this pull request may close these issues.

None yet

5 participants