Skip to content

Feat: Android support#158

Open
jaoleal wants to merge 3 commits into
sedited:masterfrom
jaoleal:android_support
Open

Feat: Android support#158
jaoleal wants to merge 3 commits into
sedited:masterfrom
jaoleal:android_support

Conversation

@jaoleal
Copy link
Copy Markdown
Contributor

@jaoleal jaoleal commented Apr 10, 2026

This pr contain 3 commits:

  1. an old version of Add MSRV Cargo-minimal.lock and Cargo-recent.lock files #150 to make CI work again flawlessly.
  2. A patch to the projects flake adding a nix-shell that give us the necessary setup for the android build, which includes the android toolchain and some environment variables. The second commit also introduces a new job on the CI that executes the building for android.
  3. Android building instructions for build.rs

This is just a PoC, the main commit is the third one and the CI job containing the android building at that point should run fine.
For more context read #156

@jaoleal jaoleal mentioned this pull request Apr 10, 2026
@sedited
Copy link
Copy Markdown
Owner

sedited commented Apr 23, 2026

This looks nice, can you rebase this?

@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented Apr 30, 2026

Changelog:

@jaoleal jaoleal force-pushed the android_support branch 6 times, most recently from a2c959f to 0f3252f Compare May 6, 2026 20:07
@jaoleal jaoleal changed the title POC: Android support Feat: Android support May 6, 2026
@jaoleal jaoleal marked this pull request as ready for review May 6, 2026 20:08
@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 6, 2026

I reduced a lot the code and i think this is the concise version to support android

@alexanderwiederin
Copy link
Copy Markdown
Collaborator

alexanderwiederin commented May 7, 2026

I don't think android is a supported target for libbitcoinkernel. Doesn't this require upstream work on bitcoin core first?

Copy link
Copy Markdown
Collaborator

@alexanderwiederin alexanderwiederin left a comment

Choose a reason for hiding this comment

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

From what I understand the ubuntu boost packages don't ship with the cmake config that core needs when cross-compiling.

Am I right that you got it working on nix locally? If so, can we stick with with only supporting the nix build for android?

Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 7, 2026

Am I right that you got it working on nix locally? If so, can we stick with with only supporting the nix build for android?

Yes, i worked all this on nix but Im not sure about leaving android building exclusively for nix, this would make it a direct dependency of the project and its not something really special that only nix can do. Besides the dependency problem, nix can drift versions because of nixpkgs releases and that can raise problems only by itself.

Therefore, i still would like for CI to keep the runner as ubuntu. Its easier for the general developer audience to replicate the build on their machine if they need

Edit: see the comment below

@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 7, 2026

Correction, I changed my mind... The idea is that the build.rs file is already bloated because of the android support additions, adding support for ubuntu bloated it even more... It looks like leaving to nix to cross-compile to android is actually a good choice, the changes stay minimal on build.rs side and it have broader support running on linux and macos machines... Ill make sure to document that somewhere and state how to make the android build.

@jaoleal jaoleal force-pushed the android_support branch 5 times, most recently from 479401e to 30f44a8 Compare May 8, 2026 00:24
@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 8, 2026

Okay the android build being exclusive for nix made things easier for this PR, the changes on build.rs are minimal... I included some inline doc comments so the reviewer can follow why each line were added.

I added a section on the readme explaining the android build but its not that explanatory in a level that one can learn how to build this lib to android, do you guys think thats needed ?

I can extend the docs to include instructions for one to reproduce it on a downstream build.rs, just tell me where to put it.
AFAIK is trivial for those using Kotlin, as mandacaru is using, to pull an already compiled shared object during build time. Thats what ill do on floresta-nix for mandacaru, ideally the CI would also offer the compiled objects too for those who might need it.

Copy link
Copy Markdown
Collaborator

@alexanderwiederin alexanderwiederin left a comment

Choose a reason for hiding this comment

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

Great to see this working.

If we land the hand-written bindings PR (#163) first, the changes in build.rs should become simpler. I would suggest we wait for it.

Comment thread libbitcoinkernel-sys/build.rs Outdated
Comment thread libbitcoinkernel-sys/build.rs
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
Comment thread .github/workflows/ci.yml
Comment thread README.md Outdated
Comment thread README.md
@sedited
Copy link
Copy Markdown
Owner

sedited commented May 20, 2026

@jaoleal I'm interested in getting this change through. Can you rebase it and address Alex' comments?

@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 20, 2026

@jaoleal I'm interested in getting this change through. Can you rebase it and address Alex' comments?

Yes, sorry for taking long... I was waiting for the bindgen pr to be merged so we had sure what that would imply here without rebasing on a pr

@alexanderwiederin alexanderwiederin linked an issue May 22, 2026 that may be closed by this pull request
@jaoleal jaoleal force-pushed the android_support branch 4 times, most recently from f1fed04 to 5387332 Compare May 23, 2026 14:40
@jaoleal
Copy link
Copy Markdown
Contributor Author

jaoleal commented May 23, 2026

Addressed suggestions @sedited @alexanderwiederin

jaoleal added 3 commits May 23, 2026 18:24
Build instructions for targeting android expecting it to be
executed in nix
Outputs and environment setup for building android.
Include CI jobs for the three new android targets, android-{aarch64, armv7, x86_64)
@jaoleal jaoleal force-pushed the android_support branch from 5387332 to d898366 Compare May 23, 2026 21:24
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.

ci: add cross-compilation job for 32-bit/Android targets

3 participants