-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathcargo-package.md
139 lines (95 loc) · 3.29 KB
/
cargo-package.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# cargo-package(1)
{{~*set command="package"}}
{{~*set actionverb="Package"}}
{{~*set noall=true}}
{{~*set multitarget=true}}
## NAME
cargo-package --- Assemble the local package into a distributable tarball
## SYNOPSIS
`cargo package` [_options_]
## DESCRIPTION
This command will create a distributable, compressed `.crate` file with the
source code of the package in the current directory. The resulting file will
be stored in the `target/package` directory. This performs the following
steps:
1. Load and check the current workspace, performing some basic checks.
- Path dependencies are not allowed unless they have a version key. Cargo
will ignore the path key for dependencies in published packages.
`dev-dependencies` do not have this restriction.
2. Create the compressed `.crate` file.
- The original `Cargo.toml` file is rewritten and normalized.
- `[patch]`, `[replace]`, and `[workspace]` sections are removed from the
manifest.
- `Cargo.lock` is automatically included if the package contains an
executable binary or example target. {{man "cargo-install" 1}} will use the
packaged lock file if the `--locked` flag is used.
- A `.cargo_vcs_info.json` file is included that contains information
about the current VCS checkout hash if available (not included with
`--allow-dirty`).
3. Extract the `.crate` file and build it to verify it can build.
- This will rebuild your package from scratch to ensure that it can be
built from a pristine state. The `--no-verify` flag can be used to skip
this step.
4. Check that build scripts did not modify any source files.
The list of files included can be controlled with the `include` and `exclude`
fields in the manifest.
See [the reference](../reference/publishing.html) for more details about
packaging and publishing.
### .cargo_vcs_info.json format
Will generate a `.cargo_vcs_info.json` in the following format
```javascript
{
"git": {
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
},
"path_in_vcs": ""
}
```
`path_in_vcs` will be set to a repo-relative path for packages
in subdirectories of the version control repository.
## OPTIONS
### Package Options
{{#options}}
{{#option "`-l`" "`--list`" }}
Print files included in a package without making one.
{{/option}}
{{#option "`--no-verify`" }}
Don't verify the contents by building them.
{{/option}}
{{#option "`--no-metadata`" }}
Ignore warnings about a lack of human-usable metadata (such as the description
or the license).
{{/option}}
{{#option "`--allow-dirty`" }}
Allow working directories with uncommitted VCS changes to be packaged.
{{/option}}
{{/options}}
{{> section-package-selection }}
### Compilation Options
{{#options}}
{{> options-target-triple }}
{{> options-target-dir }}
{{/options}}
{{> section-features }}
### Manifest Options
{{#options}}
{{> options-manifest-path }}
{{> options-locked }}
{{/options}}
### Miscellaneous Options
{{#options}}
{{> options-jobs }}
{{> options-keep-going }}
{{/options}}
### Display Options
{{#options}}
{{> options-display }}
{{/options}}
{{> section-options-common }}
{{> section-environment }}
{{> section-exit-status }}
## EXAMPLES
1. Create a compressed `.crate` file of the current package:
cargo package
## SEE ALSO
{{man "cargo" 1}}, {{man "cargo-publish" 1}}