Description
Sub-bug of #5677
Rustpkg currently always looks for a pkg.rs
file, compiles and links it against librustpkg and runs it. This behaviour should only exist as an escape hatch for custom build logic. Most of the time, rustpkg should be able to infer what to build. The inference rules should be:
foo/lib.rs
implies compilinglib.rs
into a library with basenamefoo
foo/main.rs
implies compilingmain.rs
into a binary calledfoo
foo/test.rs
implies compilingtest.rs
into a test binary calledfoo-test
foo/bench.rs
implies compilingtest.rs
into a benchmark binary calledfoo-bench
- The presence of
pkg.rs
in the package root disables inference and does the "custom build logic" routine. - The "standard inferred build" routine is available as a library call within a
pkg.rs
script.
A sketch of the logic for inferring these things is here:
https://github.com/graydon/rust/blob/rustpkg/src/librustpkg/rustpkg.rc#L1143
It doesn't make any difference if these files are in the root of a package or in subdirs: the stem foo
for a crate is taken from immediately-containing directory name in all cases.
Test and benchmark binaries should not leave their build dirs; they should be run in-place by the install process. Mains should be installed to bin
and libraries to lib
in the corresponding install dirs.