Skip to content

avoid building asio on Linux#1140

Open
wangjia184 wants to merge 1 commit intoRustAudio:masterfrom
wangjia184:master
Open

avoid building asio on Linux#1140
wangjia184 wants to merge 1 commit intoRustAudio:masterfrom
wangjia184:master

Conversation

@wangjia184
Copy link
Copy Markdown

It is causing error to rust-analyzer

@roderickvd
Copy link
Copy Markdown
Member

I'm not experiencing this issue on either my MacBook or Linux system. May you have accidentally set something like rust-analyzer.cargo.features = "all" in your editor settings, in doing so also enabling the "asio" feature?

@wangjia184
Copy link
Copy Markdown
Author

Hi @roderickvd

I am developing in docker container. The following line is in my Cargo.toml

#PipeWire media server backend. Requires libpipewire-0.3-dev (Debian/Ubuntu) or pipewire-devel (Fedora).
cpal = { path = "../cpal/", default-features = false, features = ["pipewire"] }

The project can be built in docker container successfully.
The issue is from rust analyzer, it always tries to built asio. I made several attempts, clean all cache, it does not work.

The following part is from my devcontainer.json . no rust-analyzer.cargo.features = "all"

"customizations": {
    "vscode": {
      "extensions": [
        "rust-lang.rust-analyzer",
        "tamasfe.even-better-toml",
        "kangping.protobuf",
        "rooveterinaryinc.roo-cline",
        "svelte.svelte-vscode"
      ],
      "settings": {
        "terminal.integrated.defaultProfile.linux": "bash",
        "files.watcherExclude": {
          "**/target/**": true,
          "**/.git/objects/**": true
        },
        "rust-analyzer.cargo.targetDir": true
      }
    }
  },

@roderickvd
Copy link
Copy Markdown
Member

I see: it matters whether you're working on cpal itself (like I am) or pulling it in as a dependency.

So your proposed fix is the right approach. A few small things before we merge:

  • Use CARGO_CFG_TARGET_OS instead of string-matching TARGET.
  • hat also lets you drop the redundant contains("msvc") clause (every MSVC triple already contains "windows").

Then moving it before the DOCS_RS guard, something like this:

fn main() {
  match std::env::var("CARGO_CFG_TARGET_OS") {
      Ok(os) if os != "windows" => {
          let out_dir = PathBuf::from(env::var("OUT_DIR").expect("bad path"));
          create_stub_bindings(&out_dir);
          return;
      }
      _ => {}
  }

    if std::env::var("DOCS_RS").is_ok() {
        // ...
    }

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.

2 participants