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

Fix #30 #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix #30 #31

wants to merge 1 commit into from

Conversation

Mygod
Copy link
Contributor

@Mygod Mygod commented Apr 24, 2020

Mygod referenced this pull request in shadowsocks/shadowsocks-android Apr 24, 2020
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.

Hrmmm... I think this is wrong if you're outputing for the current platform. We go through some effort to ensure that we don't pass the target arg to reuse as much of the existing build output.

@Mygod
Copy link
Contributor Author

Mygod commented Apr 24, 2020

What do you mean by "current platform?"

@thomcc
Copy link
Contributor

thomcc commented Apr 24, 2020

I'm going to have to do some testing on this. Also I'm not fully sure I understand the issue...

@thomcc
Copy link
Contributor

thomcc commented Apr 24, 2020

I mean that this doesn't work with the fix we have in place for #10.

Edit for clarification: target/$toolchain/$profile/... is wrong if you're on e.g. macos and doing a build for macos desktop, it would just be target/$profile/....

@thomcc
Copy link
Contributor

thomcc commented Apr 24, 2020

Sorry, my bad, I just realized this code is inside a branch that only runs for non-desktop builds. It probably still applies but I'm not really worried about people building android apps on android.

That said, I'll still need to do some testing of it before I cut a release.

@Mygod
Copy link
Contributor Author

Mygod commented Apr 24, 2020

Fixed.

@Mygod
Copy link
Contributor Author

Mygod commented Apr 27, 2020

No further comments?

@thomcc
Copy link
Contributor

thomcc commented Apr 27, 2020

Sorry, I’ve been sick, and I need to find time to test, probably later this week. I’d also like to better understand the motivation here.

@Mygod
Copy link
Contributor Author

Mygod commented Apr 28, 2020

The workaround is from rust-lang/cargo#1706 (comment), the soname flags did not seem to work for us.

@@ -190,7 +192,7 @@ open class CargoBuildTask : DefaultTask() {
environment("RUST_ANDROID_GRADLE_LINKER_WRAPPER_PY",
File(project.rootProject.buildDir, "linker-wrapper/linker-wrapper.py").path)
environment("RUST_ANDROID_GRADLE_CC", cc)
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,-soname,lib${cargoExtension.libname!!}.so")
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-o,$cargoOutputDir/lib${cargoExtension.libname!!}.so")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I wonder if we should be still setting the soname in addition to this. Do you know if the current version still ends up with the correct soname?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure.

@Mygod
Copy link
Contributor Author

Mygod commented May 5, 2020

The new patch should fix things in a simpler way. Not sure why you would want to compile non-Android binaries with this plugin though.

@ncalexan
Copy link
Member

ncalexan commented May 5, 2020

The new patch should fix things in a simpler way. Not sure why you would want to compile non-Android binaries with this plugin though.

We compile the same code for Desktop platforms to run unit tests against it -- it's really nice :)

@thomcc
Copy link
Contributor

thomcc commented May 5, 2020

I'll test this out (and cut a release assuming it works) later today or tomorrow, sorry for the delay here (I was sick, but am not anymore).

@Mygod
Copy link
Contributor Author

Mygod commented May 5, 2020

Alright but if the unit tests are written in rust, probably there is no need to bundle them into apk so I guess my patch still makes sense. :)

spec.include("lib${libname}.so")
spec.include("lib${libname}.dylib")
spec.include("${libname}.dll")
spec.include(libname!!)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, is this right for non-linux platforms? macos uses .dylib and windows uses .dll.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh maybe the issue is that I am compiling a binary to be bundled into the apk -- not a library.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, for bundling an APK that's right, but rust-android-gradle also supports being used for other situations (namely unit tests on the host machine, as discussed in comments below).

Sorry for all the trouble here!

@thomcc
Copy link
Contributor

thomcc commented May 5, 2020

Alright but if the unit tests are written in rust

@ncalexan meant android unit tests. Example: https://github.com/mozilla/application-services/blob/master/components/logins/android/src/test/java/mozilla/appservices/logins/DatabaseLoginsStorageTest.kt is testing the rust code in this crate https://github.com/mozilla/application-services/tree/master/components/logins and it "just works" and automatically builds the shared library for the current platform and runs it via robolectric.

@thomcc
Copy link
Contributor

thomcc commented May 5, 2020

Yes, this doesn't work for local unit tests. I'll update the code to the sample project in this repository that demonstrates this so that you can test against that.

Again, sorry for all the issues here.

@ncalexan
Copy link
Member

@Mygod I saw email from you a few days ago, but now I can't find the comment on GH.

I can't really tell what the issue you are trying to solve is. If I understand correctly, you are trying to put a Rust binary executable into an Android APK, and then to run that executable on a device? I have a spare half hour, I'll try to see if that can be done already.

@Mygod
Copy link
Contributor Author

Mygod commented Aug 13, 2021

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.

3 participants