fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lofix: use `host-tuple` for host target subsitution (#16003)f2932725b

home-0.5.12
16.8 KiB399 linesraw
1CARGO-PACKAGE(1)
2
3NAME
4       cargo-package — Assemble the local package into a distributable
5       tarball
6
7SYNOPSIS
8       cargo package [options]
9
10DESCRIPTION
11       This command will create a distributable, compressed .crate file with
12       the source code of the package in the current directory. The resulting
13       file will be stored in the target/package directory. This performs the
14       following steps:
15
16       1. Load and check the current workspace, performing some basic checks.
17
18          o  Path dependencies are not allowed unless they have a version key.
19             Cargo will ignore the path key for dependencies in published
20             packages. dev-dependencies do not have this restriction.
21
22       2. Create the compressed .crate file.
23
24          o  The original Cargo.toml file is rewritten and normalized.
25
26          o  [patch], [replace], and [workspace] sections are removed from the
27             manifest.
28
29          o  Cargo.lock is always included. When missing, a new lock file will
30             be generated unless the --exclude-lockfile flag is used.
31             cargo-install(1) will use the packaged lock file if the --locked
32             flag is used.
33
34          o  A .cargo_vcs_info.json file is included that contains information
35             about the current VCS checkout hash if available, as well as a
36             flag if the worktree is dirty.
37
38          o  Symlinks are flattened to their target files.
39
40          o  Files and directories are included or excluded based on rules
41             mentioned in the [include] and [exclude] fields
42             <https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields>.
43
44       3. Extract the .crate file and build it to verify it can build.
45
46          o  This will rebuild your package from scratch to ensure that it can
47             be built from a pristine state. The --no-verify flag can be used
48             to skip this step.
49
50       4. Check that build scripts did not modify any source files.
51
52       The list of files included can be controlled with the include and
53       exclude fields in the manifest.
54
55       See the reference
56       <https://doc.rust-lang.org/cargo/reference/publishing.html> for more
57       details about packaging and publishing.
58
59   .cargo_vcs_info.json format
60       Will generate a .cargo_vcs_info.json in the following format
61
62           {
63            "git": {
64              "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302",
65              "dirty": true
66            },
67            "path_in_vcs": ""
68           }
69
70       dirty indicates that the Git worktree was dirty when the package was
71       built.
72
73       path_in_vcs will be set to a repo-relative path for packages in
74       subdirectories of the version control repository.
75
76       The compatibility of this file is maintained under the same policy as
77       the JSON output of cargo-metadata(1).
78
79       Note that this file provides a best-effort snapshot of the VCS
80       information. However, the provenance of the package is not verified.
81       There is no guarantee that the source code in the tarball matches the
82       VCS information.
83
84OPTIONS
85   Package Options
86       -l, --list
87           Print files included in a package without making one.
88
89       --no-verify
90           Don’t verify the contents by building them.
91
92       --no-metadata
93           Ignore warnings about a lack of human-usable metadata (such as the
94           description or the license).
95
96       --allow-dirty
97           Allow working directories with uncommitted VCS changes to be
98           packaged.
99
100       --exclude-lockfile
101           Don’t include the lock file when packaging.
102
103           This flag is not for general use. Some tools may expect a lock file
104           to be present (e.g. cargo install --locked). Consider other options
105           before using this.
106
107       --index index
108           The URL of the registry index to use.
109
110       --registry registry
111           Name of the registry to package for; see cargo publish --help for
112           more details about configuration of registry names. The packages
113           will not be published to this registry, but if we are packaging
114           multiple inter-dependent crates, lock-files will be generated under
115           the assumption that dependencies will be published to this registry.
116
117       --message-format fmt
118           Specifies the output message format. Currently, it only works with
119           --list and affects the file listing format. This is unstable and
120           requires -Zunstable-options. Valid output formats:
121
122           o  human (default): Display in a file-per-line format.
123
124           o  json: Emit machine-readable JSON information about each package.
125              One package per JSON line (Newline delimited JSON).
126                  {
127                    /* The Package ID Spec of the package. */
128                    "id": "path+file:///home/foo#0.0.0",
129                    /* Files of this package */
130                    "files" {
131                      /* Relative path in the archive file. */
132                      "Cargo.toml.orig": {
133                        /* Where the file is from.
134                           - "generate" for file being generated during packaging
135                           - "copy" for file being copied from another location.
136                        */
137                        "kind": "copy",
138                        /* For the "copy" kind,
139                           it is an absolute path to the actual file content.
140                           For the "generate" kind,
141                           it is the original file the generated one is based on.
142                        */
143                        "path": "/home/foo/Cargo.toml"
144                      },
145                      "Cargo.toml": {
146                        "kind": "generate",
147                        "path": "/home/foo/Cargo.toml"
148                      },
149                      "src/main.rs": {
150                        "kind": "copy",
151                        "path": "/home/foo/src/main.rs"
152                      }
153                    }
154                  }
155
156   Package Selection
157       By default, when no package selection options are given, the packages
158       selected depend on the selected manifest file (based on the current
159       working directory if --manifest-path is not given). If the manifest is
160       the root of a workspace then the workspaces default members are
161       selected, otherwise only the package defined by the manifest will be
162       selected.
163
164       The default members of a workspace can be set explicitly with the
165       workspace.default-members key in the root manifest. If this is not set,
166       a virtual workspace will include all workspace members (equivalent to
167       passing --workspace), and a non-virtual workspace will include only the
168       root crate itself.
169
170       -p spec…, --package spec…
171           Package only the specified packages. See cargo-pkgid(1) for the SPEC
172           format. This flag may be specified multiple times and supports
173           common Unix glob patterns like *, ? and []. However, to avoid your
174           shell accidentally expanding glob patterns before Cargo handles
175           them, you must use single quotes or double quotes around each
176           pattern.
177
178       --workspace
179           Package all members in the workspace.
180
181       --exclude SPEC…
182           Exclude the specified packages. Must be used in conjunction with the
183           --workspace flag. This flag may be specified multiple times and
184           supports common Unix glob patterns like *, ? and []. However, to
185           avoid your shell accidentally expanding glob patterns before Cargo
186           handles them, you must use single quotes or double quotes around
187           each pattern.
188
189   Compilation Options
190       --target triple
191           Package for the specified target architecture. Flag may be specified
192           multiple times. The default is the host architecture. The general
193           format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.
194
195           Possible values:
196
197           o  Any supported target in rustc --print target-list.
198
199           o  "host-tuple", which will internally be substituted by the
200              host’s target. This can be particularly useful if you’re
201              cross-compiling some crates, and don’t want to specify your
202              host’s machine as a target (for instance, an xtask in a shared
203              project that may be worked on by many hosts).
204
205           o  A path to a custom target specification. See Custom Target Lookup
206              Path
207              <https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
208              for more information.
209
210           This may also be specified with the build.target config value
211           <https://doc.rust-lang.org/cargo/reference/config.html>.
212
213           Note that specifying this flag makes Cargo run in a different mode
214           where the target artifacts are placed in a separate directory. See
215           the build cache
216           <https://doc.rust-lang.org/cargo/reference/build-cache.html>
217           documentation for more details.
218
219       --target-dir directory
220           Directory for all generated artifacts and intermediate files. May
221           also be specified with the CARGO_TARGET_DIR environment variable, or
222           the build.target-dir config value
223           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
224           target in the root of the workspace.
225
226   Feature Selection
227       The feature flags allow you to control which features are enabled. When
228       no feature options are given, the default feature is activated for every
229       selected package.
230
231       See the features documentation
232       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
233       for more details.
234
235       -F features, --features features
236           Space or comma separated list of features to activate. Features of
237           workspace members may be enabled with package-name/feature-name
238           syntax. This flag may be specified multiple times, which enables all
239           specified features.
240
241       --all-features
242           Activate all available features of all selected packages.
243
244       --no-default-features
245           Do not activate the default feature of the selected packages.
246
247   Manifest Options
248       --manifest-path path
249           Path to the Cargo.toml file. By default, Cargo searches for the
250           Cargo.toml file in the current directory or any parent directory.
251
252       --locked
253           Asserts that the exact same dependencies and versions are used as
254           when the existing Cargo.lock file was originally generated. Cargo
255           will exit with an error when either of the following scenarios
256           arises:
257
258           o  The lock file is missing.
259
260           o  Cargo attempted to change the lock file due to a different
261              dependency resolution.
262
263           It may be used in environments where deterministic builds are
264           desired, such as in CI pipelines.
265
266       --offline
267           Prevents Cargo from accessing the network for any reason. Without
268           this flag, Cargo will stop with an error if it needs to access the
269           network and the network is not available. With this flag, Cargo will
270           attempt to proceed without the network if possible.
271
272           Beware that this may result in different dependency resolution than
273           online mode. Cargo will restrict itself to crates that are
274           downloaded locally, even if there might be a newer version as
275           indicated in the local copy of the index. See the cargo-fetch(1)
276           command to download dependencies before going offline.
277
278           May also be specified with the net.offline config value
279           <https://doc.rust-lang.org/cargo/reference/config.html>.
280
281       --frozen
282           Equivalent to specifying both --locked and --offline.
283
284       --lockfile-path PATH
285           Changes the path of the lockfile from the default
286           (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock
287           (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that
288           providing --lockfile-path will ignore existing lockfile at the
289           default path, and instead will either use the lockfile from PATH, or
290           write a new lockfile into the provided PATH if it doesn’t exist.
291           This flag can be used to run most commands in read-only directories,
292           writing lockfile into the provided PATH.
293
294           This option is only available on the nightly channel
295           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
296           requires the -Z unstable-options flag to enable (see #14421
297           <https://github.com/rust-lang/cargo/issues/14421>).
298
299   Miscellaneous Options
300       -j N, --jobs N
301           Number of parallel jobs to run. May also be specified with the
302           build.jobs config value
303           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
304           the number of logical CPUs. If negative, it sets the maximum number
305           of parallel jobs to the number of logical CPUs plus provided value.
306           If a string default is provided, it sets the value back to defaults.
307           Should not be 0.
308
309       --keep-going
310           Build as many crates in the dependency graph as possible, rather
311           than aborting the build on the first one that fails to build.
312
313           For example if the current package depends on dependencies fails and
314           works, one of which fails to build, cargo package -j1 may or may not
315           build the one that succeeds (depending on which one of the two
316           builds Cargo picked to run first), whereas cargo package -j1
317           --keep-going would definitely run both builds, even if the one run
318           first fails.
319
320   Display Options
321       -v, --verbose
322           Use verbose output. May be specified twice for “very verbose”
323           output which includes extra output such as dependency warnings and
324           build script output. May also be specified with the term.verbose
325           config value
326           <https://doc.rust-lang.org/cargo/reference/config.html>.
327
328       -q, --quiet
329           Do not print cargo log messages. May also be specified with the
330           term.quiet config value
331           <https://doc.rust-lang.org/cargo/reference/config.html>.
332
333       --color when
334           Control when colored output is used. Valid values:
335
336           o  auto (default): Automatically detect if color support is
337              available on the terminal.
338
339           o  always: Always display colors.
340
341           o  never: Never display colors.
342
343           May also be specified with the term.color config value
344           <https://doc.rust-lang.org/cargo/reference/config.html>.
345
346   Common Options
347       +toolchain
348           If Cargo has been installed with rustup, and the first argument to
349           cargo begins with +, it will be interpreted as a rustup toolchain
350           name (such as +stable or +nightly). See the rustup documentation
351           <https://rust-lang.github.io/rustup/overrides.html> for more
352           information about how toolchain overrides work.
353
354       --config KEY=VALUE or PATH
355           Overrides a Cargo configuration value. The argument should be in
356           TOML syntax of KEY=VALUE, or provided as a path to an extra
357           configuration file. This flag may be specified multiple times. See
358           the command-line overrides section
359           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
360           for more information.
361
362       -C PATH
363           Changes the current working directory before executing any specified
364           operations. This affects things like where cargo looks by default
365           for the project manifest (Cargo.toml), as well as the directories
366           searched for discovering .cargo/config.toml, for example. This
367           option must appear before the command name, for example cargo -C
368           path/to/my-project build.
369
370           This option is only available on the nightly channel
371           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
372           requires the -Z unstable-options flag to enable (see #10098
373           <https://github.com/rust-lang/cargo/issues/10098>).
374
375       -h, --help
376           Prints help information.
377
378       -Z flag
379           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
380           details.
381
382ENVIRONMENT
383       See the reference
384       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
385       for details on environment variables that Cargo reads.
386
387EXIT STATUS
388       o  0: Cargo succeeded.
389
390       o  101: Cargo failed to complete.
391
392EXAMPLES
393       1. Create a compressed .crate file of the current package:
394
395              cargo package
396
397SEE ALSO
398       cargo(1), cargo-publish(1)
399