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

New Android suppport #8288

Merged
merged 1 commit into from Nov 5, 2015
Merged

New Android suppport #8288

merged 1 commit into from Nov 5, 2015

Conversation

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Oct 31, 2015

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

@eefriedman
Copy link
Contributor

eefriedman commented Oct 31, 2015

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
Contributor Author

larsbergstrom commented Oct 31, 2015

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
Contributor Author

larsbergstrom commented Oct 31, 2015

@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
Contributor

eefriedman commented Oct 31, 2015

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
Contributor Author

larsbergstrom commented Oct 31, 2015

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

@eefriedman
Copy link
Contributor

eefriedman commented Nov 1, 2015

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

@larsbergstrom
Copy link
Contributor Author

larsbergstrom commented Nov 1, 2015

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 :-/

// build.rs is not platform-specific, so we have to check the target here.
let target = env::var("TARGET").unwrap();
if !target.contains("android") {
return;

This comment has been minimized.

@eefriedman

eefriedman Nov 2, 2015

Contributor
if target.contains("android") {
    android_main()
}
@eefriedman
Copy link
Contributor

eefriedman commented Nov 2, 2015

(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
Contributor Author

larsbergstrom commented Nov 3, 2015

@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
Copy link
Contributor

mbrubeck commented Nov 3, 2015

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
Contributor Author

larsbergstrom commented Nov 3, 2015

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
Contributor Author

larsbergstrom commented Nov 3, 2015

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
Contributor Author

larsbergstrom commented Nov 3, 2015

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
Copy link
Contributor

mbrubeck commented Nov 3, 2015

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
Contributor Author

larsbergstrom commented Nov 3, 2015

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
Contributor Author

larsbergstrom commented Nov 3, 2015

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

@mbrubeck
Copy link
Contributor

mbrubeck commented Nov 4, 2015

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
Copy link
Contributor

mbrubeck commented Nov 4, 2015

r=mbrubeck, needs squash

@larsbergstrom
Copy link
Contributor Author

larsbergstrom commented Nov 4, 2015

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
Copy link
Contributor

mbrubeck commented Nov 4, 2015

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

@larsbergstrom larsbergstrom force-pushed the larsbergstrom:new_android_build branch from 11f806c to 17a6cb5 Nov 4, 2015
@larsbergstrom
Copy link
Contributor Author

larsbergstrom commented Nov 4, 2015

@bors-servo r=mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2015

📌 Commit 17a6cb5 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2015

Testing commit 17a6cb5 with merge 1ed335a...

bors-servo added 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
Contributor

bors-servo commented Nov 4, 2015

💔 Test failed - linux-rel

@jdm
Copy link
Member

jdm commented Nov 4, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2015

Testing commit 17a6cb5 with merge 0699d38...

bors-servo added 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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2015

@bors-servo bors-servo merged commit 17a6cb5 into servo:master Nov 5, 2015
1 of 3 checks passed
1 of 3 checks passed
code-review/reviewable Review in progress: all files reviewed, 5 unresolved discussions
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
homu Test successful
Details
bors-servo added 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 larsbergstrom:new_android_build branch Sep 29, 2016
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.