Skip to content

Commit 2871f4d

Browse files
committed
auto merge of #6015 : catamorphism/rust/rustpkg-doc-second-try, r=catamorphism
r? @graydon Only change from the version that you read is that I addressed your comment about `RUST_PATH`.
2 parents 3867470 + 4508da2 commit 2871f4d

File tree

18 files changed

+122
-21
lines changed

18 files changed

+122
-21
lines changed

doc/rustpkg.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
% Rustpkg Reference Manual
2+
3+
# Introduction
4+
5+
This document is the reference manual for the Rustpkg packaging and build tool for the Rust programming language.
6+
7+
## Disclaimer
8+
9+
Rustpkg is a work in progress, as is this reference manual.
10+
If the actual behavior of rustpkg differs from the behavior described in this reference,
11+
that reflects either an incompleteness or a bug in rustpkg.
12+
13+
# Package searching
14+
15+
rustpkg searches for packages using the `RUST_PATH` environment variable,
16+
which is a colon-separated list (semicolon-separated on Windows) of directories.
17+
18+
Each directory in this list is a *workspace* for rustpkg.
19+
20+
`RUST_PATH` implicitly contains an entry for `./.rust` (as well as
21+
`../.rust`, `../../.rust`,
22+
and so on for every parent of `.` up to the filesystem root).
23+
That means that if `RUST_PATH` is not set,
24+
then rustpkg will still search for workspaces in `./.rust` and so on.
25+
`RUST_PATH` also implicitly contains an entry for the system path:
26+
`/usr/local` or the equivalent on Windows.
27+
This entry comes after the implicit entries for `./.rust` and so on.
28+
Finally, the last implicit entry in `RUST_PATH` is `~/.rust`
29+
or the equivalent on Windows.
30+
31+
Each workspace may contain one or more packages.
32+
33+
# Package structure
34+
35+
A valid workspace must contain each of the following subdirectories:
36+
37+
* 'src/': contains one subdirectory per package. Each subdirectory contains source files for a given package.
38+
39+
For example, if `foo` is a workspace containing the package `bar`,
40+
then `foo/src/bar/main.rs` could be the `main` entry point for
41+
building a `bar` executable.
42+
* 'lib/': `rustpkg install` installs libraries into a target-specific subdirectory of this directory.
43+
44+
For example, on a 64-bit machine running Mac OS X,
45+
if `foo` is a workspace containing the package `bar`,
46+
rustpkg will install libraries for bar to `foo/lib/x86_64-apple-darwin/`.
47+
The libraries will have names of the form `foo/lib/x86_64-apple-darwin/libbar-[hash].dylib`,
48+
where [hash] is a hash of the package ID.
49+
* 'bin/': `rustpkg install` installs executable binaries into a target-specific subdirectory of this directory.
50+
51+
For example, on a 64-bit machine running Mac OS X,
52+
if `foo` is a workspace, containing the package `bar`,
53+
rustpkg will install executables for `bar` to
54+
`foo/bin/x86_64-apple-darwin/`.
55+
The executables will have names of the form `foo/bin/x86_64-apple-darwin/bar`.
56+
* 'build/': `rustpkg build` stores temporary build artifacts in a target-specific subdirectory of this directory.
57+
58+
For example, on a 64-bit machine running Mac OS X,
59+
if `foo` is a workspace containing the package `bar` and `foo/src/bar/main.rs` exists,
60+
then `rustpkg build` will create `foo/build/x86_64-apple-darwin/bar/main.o`.
61+
62+
# Package identifiers
63+
64+
A package identifier identifies a package uniquely.
65+
A package can be stored in a workspace on the local file system,
66+
or on a remote Web server, in which case the package ID resembles a URL.
67+
For example, `github.com/mozilla/rust` is a package ID
68+
that would refer to the git repository browsable at `http://github.com/mozilla/rust`.
69+
70+
## Source files
71+
72+
rustpkg searches for four different fixed filenames in order to determine the crates to build:
73+
74+
* `main.rs`: Assumed to be a main entry point for building an executable.
75+
* `lib.rs`: Assumed to be a library crate.
76+
* `test.rs`: Assumed to contain tests declared with the `#[test]` attribute.
77+
* `bench.rs`: Assumed to contain benchmarks declared with the `#[bench]` attribute.
78+
79+
# Custom build scripts
80+
81+
A file called `pkg.rs` at the root level in a workspace is called a *package script*.
82+
If a package script exists, rustpkg executes it to build the package
83+
rather than inferring crates as described previously.
84+
85+
# Command reference
86+
87+
## build
88+
89+
`rustpkg build foo` searches for a package with ID `foo`
90+
and builds it in any workspace(s) where it finds one.
91+
Supposing such packages are found in workspaces X, Y, and Z,
92+
the command leaves behind files in `X`'s, `Y`'s, and `Z`'s `build` directories,
93+
but not in their `lib` or `bin` directories.
94+
95+
## clean
96+
97+
`rustpkg clean foo` deletes the contents of `foo`'s `build` directory.
98+
99+
## install
100+
101+
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`,
102+
and then installs them either into `foo`'s `lib` and `bin` directories,
103+
or into the `lib` and `bin` subdirectories of the first entry in `RUST_PATH`.
104+
105+
## test
106+
107+
`rustpkg test foo` builds `foo`'s `test.rs` file if necessary,
108+
then runs the resulting test executable.

mk/docs.mk

+14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ doc/rust.pdf: doc/rust.tex
8181
endif
8282
endif
8383

84+
DOCS += doc/rustpkg.html
85+
doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css doc/manual.css
86+
@$(call E, pandoc: $@)
87+
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
88+
"$(CFG_PANDOC)" \
89+
--standalone --toc \
90+
--section-divs \
91+
--number-sections \
92+
--from=markdown --to=html \
93+
--css=rust.css \
94+
--css=manual.css \
95+
--include-before-body=doc/version_info.html \
96+
--output=$@
97+
8498
######################################################################
8599
# Node (tutorial related)
86100
######################################################################

src/librustpkg/testsuite/pass/simple-lib/simple-lib.rc

-21
This file was deleted.

0 commit comments

Comments
 (0)