@@ -35,15 +35,16 @@ This makes sense, as we haven't gotten it from anywhere yet! Luckily for us,
35
35
used like this:
36
36
37
37
~~~ {.notrust}
38
- $ rustpkg install fragment
38
+ $ rustpkg install pkg_id
39
39
~~~
40
40
41
- This will install a package named 'fragment' into your current Rust
42
- environment. I called it 'fragment' in this example because when using it with
43
- an external package like this, it's often a URI fragment. You see, Rust has no
44
- central authority for packages. You can build your own ` hello ` library if you
45
- want, and that's fine. We'd both host them in different places and different
46
- projects would rely on whichever version they preferred.
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.
47
48
48
49
To install the ` hello ` library, simply run this in your terminal:
49
50
@@ -71,10 +72,10 @@ Simple! That's all it takes.
71
72
72
73
Before we can talk about how to make packages of your own, you have to
73
74
understand the big concept with ` rustpkg ` : workspaces. A 'workspace' is simply
74
- a directory that has certain folders that ` rustpkg ` expects. Different Rust
75
- projects will go into different workspaces.
75
+ a directory that has certain sub-directories that ` rustpkg ` expects. Different
76
+ Rust projects will go into different workspaces.
76
77
77
- A workspace consists of any folder that has the following
78
+ A workspace consists of any directory that has the following
78
79
directories:
79
80
80
81
* ` src ` : The directory where all the source code goes.
@@ -94,11 +95,11 @@ to wherever you keep your personal projects, and let's make all of the
94
95
directories we'll need. I'll refer to this personal project directory as
95
96
` ~/src ` for the rest of this tutorial.
96
97
97
- ### Creating neccesary files
98
+ ### Creating our workspace
98
99
99
100
~~~ {.notrust}
100
101
$ cd ~/src
101
- $ mkdir -p hello/{ src/hello,build,lib,bin}
102
+ $ mkdir -p hello/src/hello
102
103
$ cd hello
103
104
~~~
104
105
@@ -125,28 +126,22 @@ $ git commit -am "Initial commit."
125
126
~~~
126
127
127
128
If you're not familliar with the ` cat > ` idiom, it will make files with the
128
- text you type insie . Control-D (` ^D ` ) ends the text for the file.
129
+ text you type inside . Control-D (` ^D ` ) ends the text for the file.
129
130
130
131
Anyway, we've got a README and a ` .gitignore ` . Let's talk about that
131
132
` .gitignore ` for a minute: we are ignoring two directories, ` build ` and
132
133
` .rust ` . ` build ` , as we discussed earlier, is for build artifacts, and we don't
133
- want to check those into a repository. ` .rust ` is a folder that ` rustpkg ` uses
134
- to keep track of its own settings, as well as the source code of any other
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
135
136
external packages that this workspace uses. This is where that `rustpkg
136
137
install` puts all of its files. Those are also not to go into our repository,
137
138
so we ignore it all as well.
138
139
139
140
Next, let's add a source file:
140
141
141
142
~~~
142
- #[link(name = "hello",
143
- vers = "0.1.0",
144
- uuid = "0028fbe0-1f1f-11e3-8224-0800200c9a66",
145
- url = "https://github.com/YOUR_USERNAME/hello")];
146
-
147
143
#[desc = "A hello world Rust package."];
148
144
#[license = "MIT"];
149
- #[crate_type = "lib"];
150
145
151
146
pub fn world() {
152
147
println("Hello, world.");
@@ -157,28 +152,12 @@ Put this into `src/hello/lib.rs`. Let's talk about each of these attributes:
157
152
158
153
### Crate attributes for packages
159
154
160
- ` crate_type ` is the simplest: we're building a library here, so we set it to
161
- ` "lib" ` . If we were making an executable of some kind, we'd set this to ` "bin" `
162
- instead.
163
-
164
155
` license ` is equally simple: the license we want this code to have. I chose MIT
165
156
here, but you should pick whatever license makes the most sense for you.
166
157
167
158
` desc ` is a description of the package and what it does. This should just be a
168
159
sentence or two.
169
160
170
- ` link ` is the big complex attribute here. It's still not too complex: ` name ` is
171
- the name of the package, and ` vers ` is the version. If you're building a
172
- library, consider using [ Semantic Versioning] ( http://semver.org/ ) as your
173
- versioning scheme. Future versions of ` rustpkg ` will assume SemVer.
174
-
175
- ` uuid ` is simply a unique identifier. You can generate a UUID by visiting [ this
176
- page] ( http://www.famkruithof.net/uuid/uuidgen ) . Just copy whatever it puts out
177
- into the value for ` uuid ` . For more on UUIDs, see
178
- [ RFC4122] ( http://www.ietf.org/rfc/rfc4122.txt ) .
179
-
180
- Finally, ` url ` is a URL where this package is located. Easy.
181
-
182
161
### Building your package
183
162
184
163
Building your package is simple:
0 commit comments