Skip to content

New Android suppport - #8288

Merged
bors-servo merged 1 commit into
servo:masterfrom
larsbergstrom:new_android_build
Nov 5, 2015
Merged

bors-servo merged 1 commit into
servo:masterfrom
larsbergstrom:new_android_build

Conversation

@larsbergstrom

Copy link
Copy Markdown
Contributor

r/f? @mbrubeck

No need to r+ urgently; I want to do a little bit more testing of the release build, but I'm hoping to land this bit (moving to a more sane build process) next week.

The new version of building an APK:

  1. Removes the glutin-based APK builder from the link step
  2. Adds a build.rs step to the build of the final Servo library that adds the native code required by glutin's android_rs_glue (e.g., ANativeActivity_onCreate definition)
  3. Replaces the link step with a fake-ld.sh script that instead creates a libservo.so
  4. Adds a new mach package step to build the APK that has some Rust code that builds the library from a set of in-tree build files

This setup fixes a number of problems:

  1. We can use gdb, because we use ndk-build, which adds the .gdbserver info, plus we keep around all of the build files (also required by the ndk gdb)
  2. We can add more Java code & hooks to handle Android intents
  3. We no longer have any git submodules or the awkward two-step build with android-rs-glue

Many other setups were tried (and failed). The most obvious ones is building a libservo.so from a dylib target from the servo build on Android. This doesn't work because you can't have a different default lib target on one platform than others in Cargo, and you also can't pass it in from the commandline (e.g., --lib does not have a dylib arg). Additionally, if you don't go through the intermediate libservo.rlib step (which removes unused symbols), then you end up with a TON of missing symbols because our -sys crates are super sloppy about that. I spent a few weeks beginning to clean them up, but since it's something we can't easily enforce (and new -sys packages will have this problem, too, since it's only an issue with the Android loader), it made more sense to me to just have the build set up to discard those unused bits of code before they ever get to the linker, much less the loader.

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 31, 2015
@eefriedman

Copy link
Copy Markdown
Contributor

Review status: 0 of 24 files reviewed at latest revision, 3 unresolved discussions.


.gitmodules, line 3 [r1] (raw file):
Did you mean to delete this file?


components/servo/build.rs, line 11 [r1] (raw file):
If might be a bit more clear to separate this into two functions: main() and android_main().


support/android/build-apk/Cargo.toml, line 15 [r1] (raw file):
Leftover comment?


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: 0 of 24 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/servo/build.rs, line 11 [r1] (raw file):
Will do.


support/android/build-apk/Cargo.toml, line 15 [r1] (raw file):
Thanks! I'll get it.


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

@eefriedman re "Did you mean to delete this file?"

Yup, I'm remove the last git submodule in our tree - woo-hoo!

@eefriedman

Copy link
Copy Markdown
Contributor

Err, I meant "Did you mean to delete this file, as opposed to leaving it in the tree as a zero-byte file".

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Aha, then yes, I'll delete it - that was the intent :-)

@eefriedman

Copy link
Copy Markdown
Contributor

From tidy: ./python/servo/post_build_commands.py:202: W391 blank line at end of file

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

BTW, definitely don't merge this; there's a small linker problem on Android release-only where it's stripping some of the critical public symbols (e.g., ANativeActivity_onCreate) that I still need to figure out :-/

Comment thread components/servo/build.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if target.contains("android") {
    android_main()
}

@eefriedman

Copy link
Copy Markdown
Contributor

(This looks fine in terms of style, but I don't know enough about how building for Android works to review this properly.)

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

@mbrubeck With that last fixup! (thanks to @tomaka for the hint!), we have working debug and release packages - I think this is ready to be reviewed and landed, when you have a chance.

@mbrubeck

mbrubeck commented Nov 3, 2015

Copy link
Copy Markdown
Contributor

Reviewed 17 of 24 files at r1.
Review status: 13 of 25 files reviewed at latest revision, 5 unresolved discussions.


python/servo/post_build_commands.py, line 185 [r1] (raw file):
It would be nice if this used the same logic as CommandBase.get_binary_path to determine the default if neither dev nor release is set.


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: 13 of 25 files reviewed at latest revision, 5 unresolved discussions.


python/servo/post_build_commands.py, line 185 [r1] (raw file):
Hrm, I might have to pull out the code in get_binary_path into something separate that determines if it's dev or release, then, b/c I need to know for how to set the env vars. Does that sound OK?


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: 13 of 25 files reviewed at latest revision, 5 unresolved discussions.


components/servo/build.rs, line 14 [r3] (raw file):
Fixed


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: 13 of 25 files reviewed at latest revision, 5 unresolved discussions.


.gitmodules, line 3 [r1] (raw file):
Fixed; deleted now.


Comments from the review on Reviewable.io

@mbrubeck

mbrubeck commented Nov 3, 2015

Copy link
Copy Markdown
Contributor

Reviewed 6 of 24 files at r1.
Review status: 18 of 25 files reviewed at latest revision, 6 unresolved discussions.


python/servo/post_build_commands.py, line 185 [r1] (raw file):

Hrm, I might have to pull out the code in get_binary_path into something separate

Yes, that sounds good.


support/android/apk/src/rust/glutin/MainActivity.java, line 1 [r1] (raw file):
Any reason for this package name in particular?


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: 18 of 25 files reviewed at latest revision, 6 unresolved discussions.


support/android/apk/src/rust/glutin/MainActivity.java, line 1 [r1] (raw file):
Oh! That was just a carry-over. I should make it com.mozilla.servo like I did with the default android package name. Good catch :-)


Comments from the review on Reviewable.io

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

@mbrubeck OK, set to go (modulo having to open a bunch of E-Easy issues )

@mbrubeck

mbrubeck commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

Reviewed 1 of 25 files at r1, 5 of 5 files at r2, 1 of 1 files at r3, 2 of 2 files at r4, 3 of 3 files at r5.
Review status: all files reviewed at latest revision, 5 unresolved discussions.


support/android/build-apk/src/main.rs, line 99 [r1] (raw file):
File a follow-up to reduce the duplication of this value?


Comments from the review on Reviewable.io

@mbrubeck mbrubeck added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 4, 2015
@mbrubeck

mbrubeck commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

r=mbrubeck, needs squash

@larsbergstrom

Copy link
Copy Markdown
Contributor Author

Review status: all files reviewed at latest revision, 5 unresolved discussions.


support/android/build-apk/src/main.rs, line 99 [r1] (raw file):
Duplication of which value? The line you commented on is the "android-18", but I only see it there once. Or do you mean that the target SDK platform should be passed in to build-apk from mach?


Comments from the review on Reviewable.io

@mbrubeck

mbrubeck commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

Review status: all files reviewed at latest revision, 5 unresolved discussions.


support/android/build-apk/src/main.rs, line 99 [r1] (raw file):
The string "android-18" is hard-coded in three different files. It'd be nice to have it configured in one place.


Comments from the review on Reviewable.io

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 4, 2015
@larsbergstrom

Copy link
Copy Markdown
Contributor Author

@bors-servo r=mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 17a6cb5 has been approved by mbrubeck

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Nov 4, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 17a6cb5 with merge 1ed335a...

bors-servo pushed a commit that referenced this pull request Nov 4, 2015
New Android suppport

r/f? @mbrubeck

No need to r+ urgently; I want to do a little bit more testing of the release build, but I'm hoping to land this bit (moving to a more sane build process) next week.

The new version of building an APK:
1) Removes the glutin-based APK builder from the link step
2) Adds a build.rs step to the build of the final Servo library that adds the native code required by glutin's android_rs_glue (e.g., `ANativeActivity_onCreate` definition)
3) Replaces the link step with a `fake-ld.sh` script that instead creates a libservo.so
4) Adds a new mach `package` step to build the APK that has some Rust code that builds the library from a set of in-tree build files

This setup fixes a number of problems:
1) We can use gdb, because we use `ndk-build`, which adds the .gdbserver info, plus we keep around all of the build files (also required by the ndk gdb)
2) We can add more Java code & hooks to handle Android intents
3) We no longer have any git submodules or the awkward two-step build with android-rs-glue

Many other setups were tried (and failed). The most obvious ones is building a libservo.so from a `dylib` target from the servo build on Android. This doesn't work because you can't have a different default lib target on one platform than others in Cargo, and you also can't pass it in from the commandline (e.g., --lib does not have a dylib arg). Additionally, if you don't go through the intermediate libservo.rlib step (which removes unused symbols), then you end up with a TON of missing symbols because our -sys crates are super sloppy about that. I spent a few weeks beginning to clean them up, but since it's something we can't easily enforce (and new -sys packages will have this problem, too, since it's only an issue with the Android loader), it made more sense to me to just have the build set up to discard those unused bits of code before they ever get to the linker, much less the loader.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8288)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 4, 2015
@jdm

jdm commented Nov 4, 2015

Copy link
Copy Markdown
Member

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 17a6cb5 with merge 0699d38...

bors-servo pushed a commit that referenced this pull request Nov 5, 2015
New Android suppport

r/f? @mbrubeck

No need to r+ urgently; I want to do a little bit more testing of the release build, but I'm hoping to land this bit (moving to a more sane build process) next week.

The new version of building an APK:
1) Removes the glutin-based APK builder from the link step
2) Adds a build.rs step to the build of the final Servo library that adds the native code required by glutin's android_rs_glue (e.g., `ANativeActivity_onCreate` definition)
3) Replaces the link step with a `fake-ld.sh` script that instead creates a libservo.so
4) Adds a new mach `package` step to build the APK that has some Rust code that builds the library from a set of in-tree build files

This setup fixes a number of problems:
1) We can use gdb, because we use `ndk-build`, which adds the .gdbserver info, plus we keep around all of the build files (also required by the ndk gdb)
2) We can add more Java code & hooks to handle Android intents
3) We no longer have any git submodules or the awkward two-step build with android-rs-glue

Many other setups were tried (and failed). The most obvious ones is building a libservo.so from a `dylib` target from the servo build on Android. This doesn't work because you can't have a different default lib target on one platform than others in Cargo, and you also can't pass it in from the commandline (e.g., --lib does not have a dylib arg). Additionally, if you don't go through the intermediate libservo.rlib step (which removes unused symbols), then you end up with a TON of missing symbols because our -sys crates are super sloppy about that. I spent a few weeks beginning to clean them up, but since it's something we can't easily enforce (and new -sys packages will have this problem, too, since it's only an issue with the Android loader), it made more sense to me to just have the build set up to discard those unused bits of code before they ever get to the linker, much less the loader.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8288)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 5, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 17a6cb5 into servo:master Nov 5, 2015
bors-servo pushed a commit to servo/saltfs that referenced this pull request Nov 5, 2015
Add the new packaging step to the nightly builder

This should wait for servo/servo#8288 to land; I'll ping the review then.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/154)
<!-- Reviewable:end -->
@larsbergstrom
larsbergstrom deleted the new_android_build branch September 29, 2016 10:41
mbrubeck added a commit to mbrubeck/servo that referenced this pull request Sep 20, 2017
Added in servo#8288 for Android support, but should be unnecessary in current
Rust (which uses `alloc_jemalloc` by default on Android and Linux).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants