rust-lang / rust-lang/rust-analyzer

[feature request + question + bug] support for `cargo ndk -t x86_64 check`

Open
#12,335 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I have a project that fails to build if not for android using the android NDK. So if I do cargo ndk -t x86_64 build it build. But since rust-analyzer uses cargo check to check for stuff, it crashes because the project is not buildable without the sdk.

I did cargo ndk -t x86_64 check and it works, returns 0 with all checked. I tried to set cargo ndk -t x86_64 check or ndk -t x86_64 check as the rust-analyzer checkOnSave command, but I get

[ERROR flycheck] Flycheck failed to run the following command: "cargo" "ndk -t x86_64 check" "--workspace" "--message-format=json" "--manifest-path" "/home/dev/project/glium_codename_app/Cargo.toml" "--target" "x86_64-linux-android" "--package=glium_codename" "--package=libcodename"
[ERROR rust_analyzer::lsp_utils] cargo check failed
Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))):
error: no such subcommand: `ndk -t x86_64 check`

Running myself the command:

cargo ndk -t x86_64 check --workspace --message-format=json --target x86_64-linux-android --package=glium_codename --package=libcodename
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] Using NDK at path: /opt/android-sdk-linux/ndk/22.1.7171670
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] Building targets: x86_64
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] Building x86_64 (x86_64-linux-android)
error: specifying multiple `--target` flags requires `-Zmultitarget`
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli] 
[2022-05-21T03:24:59Z INFO  cargo_ndk::cli]     rustup target install x86_64-linux-android

if I take out the -target x86_64-linux-android it works though. I don't know if some modification is needed on rust-analyzer or cargo-ndk.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reproducing the rust-analyzer command and the working cargo ndk -t x86_64 check command, then determine whether command construction belongs in rust-analyzer or cargo-ndk. Done means the check command accepts rust-analyzer's workspace, metadata, manifest, package, and target arguments without duplicate-target or invalid-subcommand errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.