Skip to content

Commit c7c4b73

Browse files
committed
---
yaml --- r: 80638 b: refs/heads/auto c: 9adcbac h: refs/heads/master v: v3
1 parent e51959f commit c7c4b73

File tree

167 files changed

+1108
-1810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1108
-1810
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 70152ff55722878cde684ee6462c14c65f2c4729
16+
refs/heads/auto: 9adcbac30dd229490b0eb3f794fa0cd89e5f457b
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/.gitattributes

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4
22

3-
* text=auto
3+
* text eol=lf
44
*.cpp rust
55
*.h rust
66
*.rs rust
77
src/rt/msvc/* -whitespace
88
src/rt/vg/* -whitespace
99
src/rt/linenoise/* -whitespace
1010
src/rt/jemalloc/**/* -whitespace
11-
src/rt/jemalloc/include/jemalloc/jemalloc.h.in text eol=lf
12-
src/rt/jemalloc/include/jemalloc/jemalloc_defs.h.in text eol=lf
13-
src/rt/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in text eol=lf

branches/auto/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
442442
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
443443
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
444444
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
445+
$$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
445446
$$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
446447
$$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
447448
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \

branches/auto/doc/tutorial-ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<T: Send> Unique<T> {
321321
322322
#[unsafe_destructor]
323323
impl<T: Send> Drop for Unique<T> {
324-
fn drop(&self) {
324+
fn drop(&mut self) {
325325
#[fixed_stack_segment];
326326
#[inline(never)];
327327

branches/auto/doc/tutorial-rustpkg.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
% Rust Packaging Tutorial
2+
3+
# Introduction
4+
5+
Sharing is caring. Rust comes with a tool, `rustpkg`, which allows you to
6+
package up your Rust code and share it with other people. This tutorial will
7+
get you started on all of the concepts and commands you need to give the gift
8+
of Rust code to someone else.
9+
10+
## Installing External Packages
11+
12+
First, let's try to use an external package somehow. I've made a sample package
13+
called `hello` to demonstrate how to do so. Here's how `hello` is used:
14+
15+
~~~~
16+
extern mod hello;
17+
18+
fn main() {
19+
hello::world();
20+
}
21+
~~~~
22+
23+
Easy! But if you try to compile this, you'll get an error:
24+
25+
~~~~ {.notrust}
26+
$ rustc main.rs
27+
main.rs:1:0: 1:17 error: can't find crate for `hello`
28+
main.rs:1 extern mod hello;
29+
^~~~~~~~~~~~~~~~~
30+
31+
~~~~
32+
33+
This makes sense, as we haven't gotten it from anywhere yet! Luckily for us,
34+
`rustpkg` has an easy way to fetch others' code: the `install` command. It's
35+
used like this:
36+
37+
~~~ {.notrust}
38+
$ rustpkg install pkg_id
39+
~~~
40+
41+
This will install a package named 'pkg_id' into your current Rust environment.
42+
I called it 'pkg_id' in this example because `rustpkg` calls this a 'package
43+
identifier.' When using it with an external package like this, it's often a
44+
URI fragment. You see, Rust has no central authority for packages. You can
45+
build your own `hello` library if you want, and that's fine. We'd both host
46+
them in different places and different projects would rely on whichever version
47+
they preferred.
48+
49+
To install the `hello` library, simply run this in your terminal:
50+
51+
~~~ {.notrust}
52+
$ rustpkg install github.com/steveklabnik/hello
53+
~~~
54+
55+
You should see a message that looks like this:
56+
57+
~~~ {.notrust}
58+
note: Installed package github.com/steveklabnik/hello-0.1 to /some/path/.rust
59+
~~~
60+
61+
Now, compiling our example should work:
62+
63+
~~~ {.notrust}
64+
$ rustc main.rs
65+
$ ./main
66+
Hello, world.
67+
~~~
68+
69+
Simple! That's all it takes.
70+
71+
## Workspaces
72+
73+
Before we can talk about how to make packages of your own, you have to
74+
understand the big concept with `rustpkg`: workspaces. A 'workspace' is simply
75+
a directory that has certain sub-directories that `rustpkg` expects. Different
76+
Rust projects will go into different workspaces.
77+
78+
A workspace consists of any directory that has the following
79+
directories:
80+
81+
* `src`: The directory where all the source code goes.
82+
* `build`: This directory contains all of the build output.
83+
* `lib`: The directory where any libraries distributed with the package go.
84+
* `bin`: This directory holds any binaries distributed with the package.
85+
86+
There are also default file names you'll want to follow as well:
87+
88+
* `main.rs`: A file that's going to become an executable.
89+
* `lib.rs`: A file that's going to become a library.
90+
91+
## Building your own Package
92+
93+
Now that you've got workspaces down, let's build your own copy of `hello`. Go
94+
to wherever you keep your personal projects, and let's make all of the
95+
directories we'll need. I'll refer to this personal project directory as
96+
`~/src` for the rest of this tutorial.
97+
98+
### Creating our workspace
99+
100+
~~~ {.notrust}
101+
$ cd ~/src
102+
$ mkdir -p hello/src/hello
103+
$ cd hello
104+
~~~
105+
106+
Easy enough! Let's do one or two more things that are nice to do:
107+
108+
~~~ {.notrust}
109+
$ git init .
110+
$ cat > README.md
111+
# hello
112+
113+
A simple package for Rust.
114+
115+
## Installation
116+
117+
```
118+
$ rustpkg install github.com/YOUR_USERNAME/hello
119+
```
120+
^D
121+
$ cat > .gitignore
122+
.rust
123+
build
124+
^D
125+
$ git commit -am "Initial commit."
126+
~~~
127+
128+
If you're not familliar with the `cat >` idiom, it will make files with the
129+
text you type inside. Control-D (`^D`) ends the text for the file.
130+
131+
Anyway, we've got a README and a `.gitignore`. Let's talk about that
132+
`.gitignore` for a minute: we are ignoring two directories, `build` and
133+
`.rust`. `build`, as we discussed earlier, is for build artifacts, and we don't
134+
want to check those into a repository. `.rust` is a directory that `rustpkg`
135+
uses to keep track of its own settings, as well as the source code of any other
136+
external packages that this workspace uses. This is where that `rustpkg
137+
install` puts all of its files. Those are also not to go into our repository,
138+
so we ignore it all as well.
139+
140+
Next, let's add a source file:
141+
142+
~~~
143+
#[desc = "A hello world Rust package."];
144+
#[license = "MIT"];
145+
146+
pub fn world() {
147+
println("Hello, world.");
148+
}
149+
~~~
150+
151+
Put this into `src/hello/lib.rs`. Let's talk about each of these attributes:
152+
153+
### Crate attributes for packages
154+
155+
`license` is equally simple: the license we want this code to have. I chose MIT
156+
here, but you should pick whatever license makes the most sense for you.
157+
158+
`desc` is a description of the package and what it does. This should just be a
159+
sentence or two.
160+
161+
### Building your package
162+
163+
Building your package is simple:
164+
165+
~~~ {.notrust}
166+
$ rustpkg build hello
167+
~~~
168+
169+
This will compile `src/hello/lib.rs` into a library. After this process
170+
completes, you'll want to check out `build`:
171+
172+
~~~ {.notrust}
173+
$ ls build/x86_64-unknown-linux-gnu/hello/
174+
libhello-ed8619dad9ce7d58-0.1.0.so
175+
~~~
176+
177+
This directory naming structure is called a 'build triple,' and is because I'm
178+
on 64 bit Linux. Yours may differ based on platform.
179+
180+
You'll also notice that `src/hello/lib.rs` turned into
181+
`libhello-ed8619dad9ce7d58-0.1.0.so`. This is a simple combination of the
182+
library name, a hash of its content, and the version.
183+
184+
Now that your library builds, you'll want to commit:
185+
186+
~~~ {.notrust}
187+
$ git add src
188+
$ git commit -m "Adding source code."
189+
~~~
190+
191+
If you're using GitHub, after creating the project, do this:
192+
193+
~~~ {.notrust}
194+
$ git remote add origin [email protected]:YOUR_USERNAME/hello.git
195+
$ git push origin -u master
196+
~~~
197+
198+
Now you can install and use it! Go anywhere else in your filesystem:
199+
200+
~~~ {.notrust}
201+
$ cd ~/src/foo
202+
$ rustpkg install github/YOUR_USERNAME/hello
203+
WARNING: The Rust package manager is experimental and may be unstable
204+
note: Installed package github.com/YOUR_USERNAME/hello-0.1 to /home/yourusername/src/hello/.rust
205+
~~~
206+
207+
That's it!
208+
209+
## More resources
210+
211+
There's a lot more going on with `rustpkg`, this is just to get you started.
212+
Check out [the rustpkg manual](rustpkg.html) for the full details on how to
213+
customize `rustpkg`.
214+
215+
A tag was created on GitHub specifically for `rustpkg`-related issues. You can
216+
[see all the Issues for rustpkg
217+
here](https://github.com/mozilla/rust/issues?direction=desc&labels=A-pkg&sort=created&state=open),
218+
with bugs as well as new feature plans. `rustpkg` is still under development,
219+
and so may be a bit flaky at the moment.
220+
221+
You may also want to check out [this blog
222+
post](http://tim.dreamwidth.org/1820526.html), which contains some of the early
223+
design decisions and justifications.

branches/auto/doc/tutorial.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ struct TimeBomb {
18981898
}
18991899
19001900
impl Drop for TimeBomb {
1901-
fn drop(&self) {
1901+
fn drop(&mut self) {
19021902
for _ in range(0, self.explosivity) {
19031903
println("blam!");
19041904
}
@@ -2979,13 +2979,15 @@ tutorials on individual topics.
29792979
* [The foreign function interface][ffi]
29802980
* [Containers and iterators](tutorial-container.html)
29812981
* [Error-handling and Conditions](tutorial-conditions.html)
2982+
* [Packaging up Rust code](rustpkg)
29822983

29832984
There is further documentation on the [wiki], however those tend to be even more out of date as this document.
29842985

29852986
[borrow]: tutorial-borrowed-ptr.html
29862987
[tasks]: tutorial-tasks.html
29872988
[macros]: tutorial-macros.html
29882989
[ffi]: tutorial-ffi.html
2990+
[rustpkg]: tutorial-rustpkg.html
29892991

29902992
[wiki]: https://github.com/mozilla/rust/wiki/Docs
29912993

branches/auto/man/rustpkg.1

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ This tool is a package manager for applications written in the Rust language,
1111
available at <\fBhttps://www.rust-lang.org\fR>. It provides commands to build,
1212
install and test Rust programs.
1313

14+
\fBrustpkg\fR is still a work in progress. See \fBdoc/rustpkg.md\fR in the Rust source distribution for future plans.
15+
1416
.SH COMMANDS
1517

1618
.TP
@@ -25,10 +27,6 @@ Remove all generated files from the \fIbuild\fR directory in the target's worksp
2527
Builds the specified target, and all its dependencies, and then installs the
2628
build products into the \fIlib\fR and \fIbin\fR directories of their respective
2729
workspaces.
28-
.TP
29-
\fBtest\fR
30-
Builds the module called \fItest.rs\fR in the specified workspace, and then runs
31-
the resulting executable in test mode.
3230

3331
.SS "BUILD COMMAND"
3432

@@ -58,20 +56,9 @@ of the first entry in RUST_PATH.
5856

5957
Examples:
6058

61-
$ rustpkg install git://github.com/mozilla/servo.git#1.2
59+
$ rustpkg install github.com/mozilla/servo.git#1.2
6260
$ rustpkg install rust-glfw
6361

64-
.SS "TEST COMMAND"
65-
66-
rustpkg test \fI[pkgname]\fR
67-
68-
The test command is a shortcut for the command line:
69-
70-
$ rustc --test <filename> -o <filestem>test~ && ./<filestem>test~
71-
72-
Note the suffix on the output filename (the word "test" followed by a tilde),
73-
which should ensure the file does not clash with a user-generated files.
74-
7562
.SH "ENVIRONMENT"
7663

7764
.TP
@@ -186,7 +173,7 @@ rust, rustc, rustdoc, rusti
186173
See <\fBhttps://github.com/mozilla/rust/issues\fR> for issues.
187174

188175
.SH "AUTHOR"
189-
See \fBAUTHORS.txt\fR in the rust source distribution. Graydon Hoare
176+
See \fBAUTHORS.txt\fR in the Rust source distribution. Graydon Hoare
190177
<\fI[email protected]\fR> is the project leader.
191178

192179
.SH "COPYRIGHT"

branches/auto/mk/clean.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ clean$(1)_H_$(2):
6868
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustpkg$(X_$(2))
6969
$(Q)rm -f $$(HBIN$(1)_H_$(2))/serializer$(X_$(2))
7070
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc$(X_$(2))
71+
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc_ng$(X_$(2))
7172
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rusti$(X_$(2))
7273
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rust$(X_$(2))
7374
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTPKG_$(2))
@@ -105,6 +106,7 @@ clean$(1)_T_$(2)_H_$(3):
105106
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$(X_$(2))
106107
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/serializer$(X_$(2))
107108
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc$(X_$(2))
109+
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc_ng$(X_$(2))
108110
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rusti$(X_$(2))
109111
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rust$(X_$(2))
110112
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2))

branches/auto/mk/dist.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ PKG_FILES := \
3939
libsyntax \
4040
rt \
4141
librustdoc \
42+
rustdoc_ng \
4243
rustllvm \
4344
snapshots.txt \
4445
test) \

branches/auto/mk/install.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
140140
$(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X_$(CFG_BUILD_TRIPLE)))
141141
$(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD_TRIPLE)))
142142
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD_TRIPLE)))
143+
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc_ng$(X_$(CFG_BUILD_TRIPLE)))
143144
$(Q)$(call INSTALL,$(HB2),$(PHB),rusti$(X_$(CFG_BUILD_TRIPLE)))
144145
$(Q)$(call INSTALL,$(HB2),$(PHB),rust$(X_$(CFG_BUILD_TRIPLE)))
145146
$(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD_TRIPLE)))
@@ -171,6 +172,7 @@ uninstall:
171172
$(Q)rm -f $(PHB)/rusti$(X_$(CFG_BUILD_TRIPLE))
172173
$(Q)rm -f $(PHB)/rust$(X_$(CFG_BUILD_TRIPLE))
173174
$(Q)rm -f $(PHB)/rustdoc$(X_$(CFG_BUILD_TRIPLE))
175+
$(Q)rm -f $(PHB)/rustdoc_ng$(X_$(CFG_BUILD_TRIPLE))
174176
$(Q)rm -f $(PHL)/$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE))
175177
$(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE))
176178
$(Q)for i in \
@@ -180,6 +182,7 @@ uninstall:
180182
$(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE))) \
181183
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE))) \
182184
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE))) \
185+
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTDOCNG_GLOB_$(CFG_BUILD_TRIPLE))) \
183186
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTI_GLOB_$(CFG_BUILD_TRIPLE))) \
184187
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUST_GLOB_$(CFG_BUILD_TRIPLE))) \
185188
; \

0 commit comments

Comments
 (0)