Skip to content

Commit d834c0d

Browse files
committed
docs: Sketch out rustpkg manual
1 parent 05f9586 commit d834c0d

File tree

18 files changed

+117
-21
lines changed

18 files changed

+117
-21
lines changed

doc/rustpkg.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
26+
Each workspace may contain one or more packages.
27+
28+
# Package structure
29+
30+
A valid workspace must contain each of the following subdirectories:
31+
32+
* 'src/': contains one subdirectory per package. Each subdirectory contains source files for a given package.
33+
34+
For example, if `foo` is a workspace containing the package `bar`,
35+
then `foo/src/bar/main.rs` could be the `main` entry point for
36+
building a `bar` executable.
37+
* 'lib/': `rustpkg install` installs libraries into a target-specific subdirectory of this directory.
38+
39+
For example, on a 64-bit machine running Mac OS X,
40+
if `foo` is a workspace containing the package `bar`,
41+
rustpkg will install libraries for bar to `foo/lib/x86_64-apple-darwin/`.
42+
The libraries will have names of the form `foo/lib/x86_64-apple-darwin/libbar-[hash].dylib`,
43+
where [hash] is a hash of the package ID.
44+
* 'bin/': `rustpkg install` installs executable binaries into a target-specific subdirectory of this directory.
45+
46+
For example, on a 64-bit machine running Mac OS X,
47+
if `foo` is a workspace, containing the package `bar`,
48+
rustpkg will install executables for `bar` to
49+
`foo/bin/x86_64-apple-darwin/`.
50+
The executables will have names of the form `foo/bin/x86_64-apple-darwin/bar`.
51+
* 'build/': `rustpkg build` stores temporary build artifacts in a target-specific subdirectory of this directory.
52+
53+
For example, on a 64-bit machine running Mac OS X,
54+
if `foo` is a workspace containing the package `bar` and `foo/src/bar/main.rs` exists,
55+
then `rustpkg build` will create `foo/build/x86_64-apple-darwin/bar/main.o`.
56+
57+
# Package identifiers
58+
59+
A package identifier identifies a package uniquely.
60+
A package can be stored in a workspace on the local file system,
61+
or on a remote Web server, in which case the package ID resembles a URL.
62+
For example, `github.com/mozilla/rust` is a package ID
63+
that would refer to the git repository browsable at `http://github.com/mozilla/rust`.
64+
65+
## Source files
66+
67+
rustpkg searches for four different fixed filenames in order to determine the crates to build:
68+
69+
* `main.rs`: Assumed to be a main entry point for building an executable.
70+
* `lib.rs`: Assumed to be a library crate.
71+
* `test.rs`: Assumed to contain tests declared with the `#[test]` attribute.
72+
* `bench.rs`: Assumed to contain benchmarks declared with the `#[bench]` attribute.
73+
74+
# Custom build scripts
75+
76+
A file called `pkg.rs` at the root level in a workspace is called a *package script*.
77+
If a package script exists, rustpkg executes it to build the package
78+
rather than inferring crates as described previously.
79+
80+
# Command reference
81+
82+
## build
83+
84+
`rustpkg build foo` searches for a package with ID `foo`
85+
and builds it in any workspace(s) where it finds one.
86+
Supposing such packages are found in workspaces X, Y, and Z,
87+
the command leaves behind files in `X`'s, `Y`'s, and `Z`'s `build` directories,
88+
but not in their `lib` or `bin` directories.
89+
90+
## clean
91+
92+
`rustpkg clean foo` deletes the contents of `foo`'s `build` directory.
93+
94+
## install
95+
96+
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`,
97+
and then installs them either into `foo`'s `lib` and `bin` directories,
98+
or into the `lib` and `bin` subdirectories of the first entry in `RUST_PATH`.
99+
100+
## test
101+
102+
`rustpkg test foo` builds `foo`'s `test.rs` file if necessary,
103+
then runs the resulting test executable.

mk/docs.mk

Lines changed: 14 additions & 0 deletions
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

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)