Skip to content

Commit 489eff2

Browse files
authored
Merge pull request #624 from bswrczk/master
Small fixes, missing steps added, copy-paste-able
2 parents 8cbc0e3 + 05b9f93 commit 489eff2

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

src/docs-rs/add-dependencies.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,39 @@
22

33
Rustwide internally uses `rustops/crates-build-env` as the build environment for the crate. If you want to add a system package for crates to link to, this is place you're looking for.
44

5+
## Preconditions
6+
7+
Docker and docker-compose must be installed. For example, on Debian or Ubuntu:
8+
9+
```sh
10+
sudo apt-get install docker.io docker-compose
11+
```
12+
513
## Getting started
614

7-
First, clone the crates-build-env repo:
15+
First, clone the crates-build-env and the docs.rs repos:
16+
17+
```sh
18+
git clone https://github.com/rust-lang/crates-build-env
19+
git clone https://github.com/rust-lang/docs.rs
20+
```
21+
22+
Set the path to the directory of your crate. This must be an absolute path, not a relative path! On platforms with coreutils, you can instead use `$(realpath ../relative/path)` (relative to the docs.rs directory).
823

924
```sh
10-
git clone https://github.com/rust-lang/crates-build-env && cd crates-build-env
25+
YOUR_CRATE=/path/to/your/crate
1126
```
1227

13-
Next, add the package to `packages.txt`. This should be the name of a package in the **Ubuntu 18.04** Repositories. See [the package home page](https://packages.ubuntu.com/) for a full list/search bar, or use `apt search` locally.
28+
## Add package
29+
30+
Next, add the package to `crates-build-env/linux/packages.txt` in the correct alphabetical order. This should be the name of a package in the **Ubuntu 20.04** Repositories. See [the package home page](https://packages.ubuntu.com/) for a full list/search bar, or use `apt search` locally.
1431

1532
## Building the image
1633

1734
Now build the image. This will take a very long time, probably 10-20 minutes.
1835

1936
```sh
37+
cd crates-build-env/linux
2038
docker build --tag build-env .
2139
```
2240

@@ -25,14 +43,12 @@ docker build --tag build-env .
2543
Use the image to build your crate.
2644

2745
```sh
28-
cd /path/to/docs.rs
46+
cd ../../docs.rs
47+
cp .env.sample .env
2948
docker-compose build
30-
# NOTE: this must be an absolute path, not a relative path
31-
# On platforms with coreutils, you can instead use `$(realpath ../relative/path)`
32-
YOUR_CRATE=/path/to/your/crate
3349
# avoid docker-compose creating the volume if it doesn't exist
3450
if [ -e "$YOUR_CRATE" ]; then
35-
docker-compose run -e DOCS_RS_LOCAL_DOCKER_IMAGE=build-env \
51+
docker-compose run -e DOCSRS_DOCKER_IMAGE=build-env \
3652
-e RUST_BACKTRACE=1 \
3753
-v "$YOUR_CRATE":/opt/rustwide/workdir \
3854
web build crate --local /opt/rustwide/workdir
@@ -49,17 +65,23 @@ On line 7 of the Dockerfile, add this line: `RUN apt-get install -y your_second_
4965
Rerun the build and start the container; it should take much less time now:
5066

5167
```sh
52-
cd /path/to/crates-build-env
68+
cd ../crates-build-env/linux
5369
docker build --tag build-env .
54-
cd /path/to/docs.rs
55-
docker-compose run -e DOCS_RS_LOCAL_DOCKER_IMAGE=build-env \
70+
cd ../../docs.rs
71+
docker-compose run -e DOCSRS_DOCKER_IMAGE=build-env \
72+
-e RUST_BACKTRACE=1 \
5673
-v "$YOUR_CRATE":/opt/rustwide/workdir \
5774
web build crate --local /opt/rustwide/workdir
5875
```
5976

6077
## Run the lint script
6178

62-
Before you make a PR, run the shell script `ci/lint.sh` and make sure it passes. It ensures `packages.txt` is in order and will tell you exactly what changes you need to make if not.
79+
Before you make a PR, run the shell script `lint.sh` and make sure it passes. It ensures `packages.txt` is in order and will tell you exactly what changes you need to make if not.
80+
81+
```sh
82+
cd ../crates-build-env
83+
./lint.sh
84+
```
6385

6486
## Make a pull request
6587

0 commit comments

Comments
 (0)