Skip to content

Maybe xbuild should respect [lib] name field when available #227

@shadow3aaa

Description

@shadow3aaa

Problem

xbuild assumes library artifacts are always named after the package name, completely ignoring the name field in the [lib] section of Cargo.toml. This forces crates that need both binary and library targets (common for cross-platform apps) to set the [lib] name identical to the package name, which triggers the following warning:

warning: output filename collision.
The bin target `example` in package `example v0.1.0` has the same output filename as the lib target `example` in package `example v0.1.0`.
Colliding filename is: ...
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
warning: output filename collision.
The bin target `example` in package `example v0.1.0` has the same output filename as the lib target `example` in package `example v0.1.0`.

If using a different lib name to avoid this, xbuild fails at the packaging stage with "failed to locate bin":

$ x build --platform android
[1/3] Fetch precompiled artifacts
[2/3] Build rust
   Compiling example v0.1.0
    Finished `dev` profile [optimized + debuginfo] target(s) in 1m 10s
[2/3] Build rust `example` [71108ms]
[3/3] Create apk
Error: failed to locate bin target/x/debug/android/arm64/cargo/aarch64-linux-android/debug/libexample.so

Expected Behavior

xbuild should check the name field in the [lib] section of Cargo.toml and use it to locate library artifacts instead of always using the package name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions