Conversation
|
Can someone please review it? |
|
oh god, I'm so sorry, I wanted to enable the windows CI on your branch, but I accidentally pushed some changes from my other branch, I'll try to have that sorted out |
There was a problem hiding this comment.
I think that generally this PR is very sound and well-made, good job!
But, before merging there are a couple of things to sort out:
- We need to resolve the issue with symlinking the assets directory, as discussed here
- One it's done I'd be nice to test the basic commands like
cargo mobile init,cargo mobile build,cargo mobile openetc. across all supported platforms, because there are changes in this PR that indirectly affect Linux and Mac as well - Update the README (add Windows to supported platforms and mention any Windows' specific caveats like
cargo mobile updatefailing)
On Windows, Path::join may makes invalid UNC path. It was fixed on nightly (rust-lang/rust#89270), but not yet on stable.
|
I think I've solved the problem of symbolic links. In addition, I fixed a path problem in stable that I missed using nightly. I've confirmed that the commands work on Windows except |
|
Once again, thank you so much for your contribution! @francesca64 may I kindly ask you to take a look? |
zeerooth
left a comment
There was a problem hiding this comment.
I wanted to merge this but I encountered a weird behaviour when testing on this branch now...
When I run cargo mobile init for the first time the project is created successfully. However, if I do it the second time, I get the following error:
ln: failed to create symbolic link '/home/radek/code/cargo-mobile-sandbox/a/gen/android/a/app/src/main/assets': No such file or directory
error: Asset dir couldn't be symlinked into Android project
Failed to create a symbolic link from "../../../../../../assets" to directory "/home/radek/code/cargo-mobile-sandbox/a/gen/android/a/app/src/main/" (file and directory clobbering enabled): `ln` command failed: Command
"ln -n -s -f ../../../../../../assets /home/radek/code/cargo-mobile-sandbox/a/gen/android/a/app/src/main/assets" didn't complete successfully, exiting with code 1.
and the gen/android/a/app/src/main directory appears to be missing.
When I then run cargo mobile init again, the project is initialized successfully.
Basically, this behaviour alternates and it needs to be fixed.
francesca64
left a comment
There was a problem hiding this comment.
Thanks for making such a massive contribution!
(and thanks to @zeerooth for thoroughly reviewing it!)
| &mut len as _, | ||
| ) | ||
| }?; | ||
| return Ok(command); |
There was a problem hiding this comment.
| return Ok(command); | |
| Ok(command) |
| } | ||
| Component::CurDir => {} | ||
| Component::ParentDir => { | ||
| if let Some(_) = buf.last() { |
There was a problem hiding this comment.
| if let Some(_) = buf.last() { | |
| if let buf.last().is_some() { |
| // %~dp0 will expand to C:\Users\MyHome\foo in code.cmd, which is completely broken. | ||
| // Running it through powershell.exe does not have this problem. | ||
| pub fn code_command() -> bossy::Command { | ||
| bossy::Command::impure("powershell.exe").with_args(&["-Command", "code"]) |
There was a problem hiding this comment.
| bossy::Command::impure("powershell.exe").with_args(&["-Command", "code"]) | |
| bossy::Command::impure_parse("powershell.exe -Command code") |
|
|
||
| pub fn command_path(name: &str) -> bossy::Result<bossy::Output> { | ||
| bossy::Command::impure("where.exe") | ||
| .add_arg(name) |
There was a problem hiding this comment.
| .add_arg(name) | |
| .with_arg(name) |
| .expect("failed to getAndroid Studio uninstaller's parent path") | ||
| .join(STUDIO_EXE_PATH); | ||
| bossy::Command::impure(application_path) | ||
| .add_arg( |
There was a problem hiding this comment.
| .add_arg( | |
| .with_arg( |
| ) | ||
| }); | ||
| if handle.is_invalid() { | ||
| return Err(runtime::Error::from_win32()); |
There was a problem hiding this comment.
You can drop the return keyword and use else to return the Ok(()) below.
| err => Err(err), | ||
| })?; | ||
| let argv: Vec<_> = NativeArgv::new(&editor_command).into(); | ||
|
|
There was a problem hiding this comment.
Extraneous newline
|
|
||
| impl Application { | ||
| pub fn detect_editor() -> Result<Self, DetectEditorError> { | ||
| let editor_command = Self::detect_associated_command(RUST_EXT).or_else(|e| match e { |
There was a problem hiding this comment.
Rename e to err and the current err arm to _
| .map(|arg| Self::replace_command_arg(arg, &path.as_ref().as_os_str())) | ||
| .collect::<Vec<_>>(); | ||
| bossy::Command::impure(&self.argv[0]) | ||
| .add_args(&args) |
There was a problem hiding this comment.
| .add_args(&args) | |
| .with_args(&args) |
|
|
||
| #[derive(Debug, Error)] | ||
| pub enum DetectEditorError { | ||
| #[error("No default editor is set: AssocQueryStringW for \".rs\" and \".txt\" both failed")] |
There was a problem hiding this comment.
Error text needs to be a high-level user-friendly description that doesn't i.e. mention function names (while still being unambiguous enough that a developer can find the source)
|
If there is any work needed for this PR to be merged, I'd be glad to help (ofc, If the author of this PR gives me permissions to, or if he is inactive, I could create a new PR that is build on top of this PR and keep his commits in the new PR) |
The following points should be noted:
cargo mobile updatehas not been tested, but it will probably fail on Windows because the running binary cannot be overwritten.