fork/cargo
git clone https://git.julia.blue/fork/cargo
856f1bae5
0.88.0
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 given architecture. The default is the host 192 architecture. The general format of the triple is 193 <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for 194 a list of supported targets. This flag may be specified multiple 195 times. 196 197 This may also be specified with the build.target config value 198 <https://doc.rust-lang.org/cargo/reference/config.html>. 199 200 Note that specifying this flag makes Cargo run in a different mode 201 where the target artifacts are placed in a separate directory. See 202 the build cache 203 <https://doc.rust-lang.org/cargo/reference/build-cache.html> 204 documentation for more details. 205 206 --target-dir directory 207 Directory for all generated artifacts and intermediate files. May 208 also be specified with the CARGO_TARGET_DIR environment variable, or 209 the build.target-dir config value 210 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to 211 target in the root of the workspace. 212 213 Feature Selection 214 The feature flags allow you to control which features are enabled. When 215 no feature options are given, the default feature is activated for every 216 selected package. 217 218 See the features documentation 219 <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options> 220 for more details. 221 222 -F features, --features features 223 Space or comma separated list of features to activate. Features of 224 workspace members may be enabled with package-name/feature-name 225 syntax. This flag may be specified multiple times, which enables all 226 specified features. 227 228 --all-features 229 Activate all available features of all selected packages. 230 231 --no-default-features 232 Do not activate the default feature of the selected packages. 233 234 Manifest Options 235 --manifest-path path 236 Path to the Cargo.toml file. By default, Cargo searches for the 237 Cargo.toml file in the current directory or any parent directory. 238 239 --locked 240 Asserts that the exact same dependencies and versions are used as 241 when the existing Cargo.lock file was originally generated. Cargo 242 will exit with an error when either of the following scenarios 243 arises: 244 245 o The lock file is missing. 246 247 o Cargo attempted to change the lock file due to a different 248 dependency resolution. 249 250 It may be used in environments where deterministic builds are 251 desired, such as in CI pipelines. 252 253 --offline 254 Prevents Cargo from accessing the network for any reason. Without 255 this flag, Cargo will stop with an error if it needs to access the 256 network and the network is not available. With this flag, Cargo will 257 attempt to proceed without the network if possible. 258 259 Beware that this may result in different dependency resolution than 260 online mode. Cargo will restrict itself to crates that are 261 downloaded locally, even if there might be a newer version as 262 indicated in the local copy of the index. See the cargo-fetch(1) 263 command to download dependencies before going offline. 264 265 May also be specified with the net.offline config value 266 <https://doc.rust-lang.org/cargo/reference/config.html>. 267 268 --frozen 269 Equivalent to specifying both --locked and --offline. 270 271 --lockfile-path PATH 272 Changes the path of the lockfile from the default 273 (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock 274 (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that 275 providing --lockfile-path will ignore existing lockfile at the 276 default path, and instead will either use the lockfile from PATH, or 277 write a new lockfile into the provided PATH if it doesn’t exist. 278 This flag can be used to run most commands in read-only directories, 279 writing lockfile into the provided PATH. 280 281 This option is only available on the nightly channel 282 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 283 requires the -Z unstable-options flag to enable (see #14421 284 <https://github.com/rust-lang/cargo/issues/14421>). 285 286 Miscellaneous Options 287 -j N, --jobs N 288 Number of parallel jobs to run. May also be specified with the 289 build.jobs config value 290 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to 291 the number of logical CPUs. If negative, it sets the maximum number 292 of parallel jobs to the number of logical CPUs plus provided value. 293 If a string default is provided, it sets the value back to defaults. 294 Should not be 0. 295 296 --keep-going 297 Build as many crates in the dependency graph as possible, rather 298 than aborting the build on the first one that fails to build. 299 300 For example if the current package depends on dependencies fails and 301 works, one of which fails to build, cargo package -j1 may or may not 302 build the one that succeeds (depending on which one of the two 303 builds Cargo picked to run first), whereas cargo package -j1 304 --keep-going would definitely run both builds, even if the one run 305 first fails. 306 307 Display Options 308 -v, --verbose 309 Use verbose output. May be specified twice for “very verbose” 310 output which includes extra output such as dependency warnings and 311 build script output. May also be specified with the term.verbose 312 config value 313 <https://doc.rust-lang.org/cargo/reference/config.html>. 314 315 -q, --quiet 316 Do not print cargo log messages. May also be specified with the 317 term.quiet config value 318 <https://doc.rust-lang.org/cargo/reference/config.html>. 319 320 --color when 321 Control when colored output is used. Valid values: 322 323 o auto (default): Automatically detect if color support is 324 available on the terminal. 325 326 o always: Always display colors. 327 328 o never: Never display colors. 329 330 May also be specified with the term.color config value 331 <https://doc.rust-lang.org/cargo/reference/config.html>. 332 333 Common Options 334 +toolchain 335 If Cargo has been installed with rustup, and the first argument to 336 cargo begins with +, it will be interpreted as a rustup toolchain 337 name (such as +stable or +nightly). See the rustup documentation 338 <https://rust-lang.github.io/rustup/overrides.html> for more 339 information about how toolchain overrides work. 340 341 --config KEY=VALUE or PATH 342 Overrides a Cargo configuration value. The argument should be in 343 TOML syntax of KEY=VALUE, or provided as a path to an extra 344 configuration file. This flag may be specified multiple times. See 345 the command-line overrides section 346 <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> 347 for more information. 348 349 -C PATH 350 Changes the current working directory before executing any specified 351 operations. This affects things like where cargo looks by default 352 for the project manifest (Cargo.toml), as well as the directories 353 searched for discovering .cargo/config.toml, for example. This 354 option must appear before the command name, for example cargo -C 355 path/to/my-project build. 356 357 This option is only available on the nightly channel 358 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 359 requires the -Z unstable-options flag to enable (see #10098 360 <https://github.com/rust-lang/cargo/issues/10098>). 361 362 -h, --help 363 Prints help information. 364 365 -Z flag 366 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for 367 details. 368 369ENVIRONMENT 370 See the reference 371 <https://doc.rust-lang.org/cargo/reference/environment-variables.html> 372 for details on environment variables that Cargo reads. 373 374EXIT STATUS 375 o 0: Cargo succeeded. 376 377 o 101: Cargo failed to complete. 378 379EXAMPLES 380 1. Create a compressed .crate file of the current package: 381 382 cargo package 383 384SEE ALSO 385 cargo(1), cargo-publish(1) 386