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

cargo-apk: Automate adb reverse port forwarding through Cargo.toml metadata #348

Merged
merged 5 commits into from
Sep 30, 2022

Conversation

Jasper-Bekkers
Copy link
Contributor

@Jasper-Bekkers Jasper-Bekkers commented Sep 15, 2022

Fixes #231

This adds a feature so we can set up reverse port forwarding from our Cargo.toml file before the app starts

[package.metadata.android.reverse_port_fwd]
"tcp:1338" = "tcp:1338"
"tcp:1339" = "tcp:1339"

Copy link
Contributor

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

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

Would be nice to have the example from the readme added in our manifest example

@Jasper-Bekkers
Copy link
Contributor Author

Updated the readme in 4638053

cargo-apk/src/manifest.rs Outdated Show resolved Hide resolved

# Set up reverse port forwarding through `adb reverse`, meaning that if the
# Android device connects to `https://localhost:1338` it will be routed to
# the localhost on the host device instead.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't strictly for http, I'd write Android device connects to `localhost` on port `1338` ....

For demonstration purposes, can we use a different source and destination purposes? e.g. it will be routed to the host on port `XYZ whatever you choose` instead.

ndk-build/src/apk.rs Outdated Show resolved Hide resolved
@MarijnS95
Copy link
Member

I still don't feel entirely confident about having this in adb, we're just building out more and more passthrough commands for adb that don't have much in common with apk building anymore, but I don't have any other alternative 😭 (i.e. a server on the host that makes itself visible to connected adb devices instead, but adb wait-for-device isn't powerful enough). A scriptable pre-apk-start might solve many such things but isn't platform-agnostic either :(

@Jasper-Bekkers
Copy link
Contributor Author

I still don't feel entirely confident about having this in adb, we're just building out more and more passthrough commands for adb that don't have much in common with apk building anymore

For us, in practice, it means a significantly smoother and less error prone workflow for launching apk's, regardless of how much it has to do with building an apk or not, for us it's fundamental to running one which is why I'm proposing adding this to this tool.

@MarijnS95
Copy link
Member

Sure, and as said above we don't really have any clean/proper alternative. At the same time we're one of the very few actively contributing to cargo-apk so I think we can bend it towards our use-cases somewhat.

I'll apply the nits above and merge this, not sure when I'll push out a new (patch) release though (cargo install --git exists, fortunately).

cargo-apk/README.md Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
@MarijnS95 MarijnS95 changed the title Make sure we can configure adb reverse in the Cargo.toml cargo-apk: Automate adb reverse port forwarding through Cargo.toml metadata Sep 30, 2022
@MarijnS95 MarijnS95 merged commit ddc2757 into rust-mobile:master Sep 30, 2022
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.

Cargo.toml should be able to set up reverse port forwarding
3 participants