Commit graph

14441 commits

Author SHA1 Message Date
bors
0d5370a9ae Auto merge of #12268 - epage:direct, r=weihanglo
fix(embedded): Don't create an intermediate manifest

### What does this PR try to resolve?

More immediately, this is to unblock rust-lang/rust#112601

More generally, this gets us away from hackily writing out an out-of-line manifest from an embedded manifest.  To parse the manifest, we have to write it out so our regular manifest
loading code could handle it.  This updates the manifest parsing code to
handle it.

This doesn't mean this will work everywhere in all cases though.  For
example, ephemeral workspaces parses a manifest from the SourceId and
these won't have valid SourceIds.

As a consequence, `Cargo.lock` and `CARGO_TARGET_DIR` are changing from being next to
the temp manifest to being next to the script.  This still isn't the
desired behavior but stepping stones.

### How should we test and review this PR?

A Commit at a time

### Additional information

In production code, this does not conflict with #12255 (due to #12262) but in test code, it does.
2023-06-17 08:08:50 +00:00
bors
a581ca202d Auto merge of #12258 - epage:syn, r=weihanglo
refactor(embedded): Switch to `syn` for parsing doc comments

This is a follow up to #12245 which is working to resolve #12207

The hope is this will result in more resilient comment handling, being more consistent with rustdoc.

I also hoped for less code but `syn` is doing less than I had expected, requiring us to copy code over from other parts of rust.  It seems every proc macro has to do this but there is no guide to it, so they all do it differently, only covering the cases they thought to test for.

Note that this still won't support `include_str!()`.
2023-06-17 07:21:35 +00:00
Ed Page
224d2e688d fix(cli): Make 'cargo foo.rs' behave like --manifest-path
This mirrors the logic `ArgMatchesExt::root_manifest`
2023-06-16 21:08:48 -05:00
Ed Page
5ed07925cc fix(embedded): Ensure we don't auto-discover any targets 2023-06-16 21:08:48 -05:00
Ed Page
575b9ac934 fix(embedded): Don't create an intermediate manifest
To parse the manifest, we have to write it out so our regular manifest
loading code could handle it.  This updates the manifest parsing code to
handle it.

This doesn't mean this will work everywhere in all cases though.  For
example, ephemeral workspaces parses a manifest from the SourceId and
these won't have valid SourceIds.

As a consequence, `Cargo.lock` and `CARGO_TARGET_DIR` are changing from being next to
the temp manifest to being next to the script.  This still isn't the
desired behavior but stepping stones.

This also exposes the fact that we didn't disable `autobins` like the
documentation says we should.
2023-06-16 21:08:47 -05:00
Ed Page
2c70983e8d test(embedded): Verify no autobin behavior is running 2023-06-16 21:06:01 -05:00
Ed Page
fc0bb8bf00 fix(toml)!: Prevent people parsing manifests from strings 2023-06-16 21:06:01 -05:00
Ed Page
4fe39e88c2 refactor(embedded): Be accurate in variable name 2023-06-16 21:06:00 -05:00
bors
3b5fac59a3 Auto merge of #12255 - epage:sanitize, r=weihanglo
fix(embedded): Align package name sanitization with cargo-new

### What does this PR try to resolve?

This is a follow up to #12245 which is working to resolve the tracking issue #12207

This first aligns sanitization of package names with the central package name validation logic, putting the code next to each other so they can more easily stay in sync.

Oddly enough, cargo-new is stricter than our normal package-name validation.  I went ahead and sanitized along with that as well.

In working on this, I was bothered by
- the mix of `-` and `_` in file names because of sanitization, so I made it more consistent by detecting which the user is using
- -using `_` in bins, so I switched the default to `-`

### How should we test and review this PR?

One existing test covers a variety of sanitization needs

Another existing test hit one of the other cases (`test` being reserved)

### Additional information

For implementation convenience, I changed the directory we write the manifest to.  The impact of this should be minimal since
- We reuse the full file name, so if it worked for the user it should work for us
- We should be moving away from the temp manifest in future commits
2023-06-17 01:10:59 +00:00
Ed Page
667ff78d69 refactor(embedded): Centralize placeholder
This was originally split out because before #12269, it was needed
elsewhere.
2023-06-16 19:51:54 -05:00
Ed Page
f4abdbe5f5 fix(embedded): Extend sanitization rules to cover cargo-new validation 2023-06-16 19:51:19 -05:00
bors
d93b018c20 Auto merge of #12276 - dimo414:patch-1, r=weihanglo
Clarify the default behavior of cargo-install.

The man page for `cargo install` is not explicit about what the default behavior is. This is important to clarify because `examples/` are typically unneeded and may not be maintained with the same care as "real" binaries, so it should be clear to users that example binaries won't be installed without directly asking for them.

Small doc-only update, hopefully this is acceptable. Please let me know if I need to seek further approval first (and, if so, apologies for the noise).
2023-06-16 10:08:08 +00:00
Michael Diamond
9624861730 Clarify the default behavior of cargo-install. 2023-06-16 00:56:29 -07:00
Ed Page
8186282f28 fix(embedded): Sanitize like we validate package names 2023-06-15 19:09:29 -05:00
Ed Page
5fd3d2d230 refactor(embedded): Centralize package name rules 2023-06-15 19:09:29 -05:00
Ed Page
b116864d79 fix(embedded): Be consistent with existing style when sanitizing 2023-06-15 19:09:28 -05:00
Ed Page
4e0ac38b52 refactor(embedded): Switch to syn for parsing doc comments
The hope is this will result in more resilient comment handling, being
more consistent with rustdoc.

I also hoped for less code but `syn` is doing less than I had expected,
requiring us to copy code over from other parts of rust.  It seems every
proc macro has to do this but there is no guide to it, so they all do it
differently, only covering the cases they thought to test for.

Note that this still won't support `include_str!()`.
2023-06-14 14:43:35 -05:00
bors
0c14026aa8 Auto merge of #12269 - epage:bin, r=weihanglo
fix(embedded): Don't append hash to bin names

### What does this PR try to resolve?

More immediately, this is to unblock rust-lang/rust#112601

The hash existed for sharing a target directory.  That code isn't
implemented yet and a per-user build cache might remove the need for it,
so let's remove it for now and more carefully weigh adding it back in.

In general, this is also the more appropriate way for a feature that would be first class.

### How should we test and review this PR?

This originally built on #12268 but now stands alone as the other PR has windows issues to work out

### Additional information
2023-06-14 18:43:05 +00:00
Ed Page
56b2812a85 fix(embedded): Don't append hash to bin names
Background: the hash existed for sharing a target directory.  That code isn't
implemented yet and a per-user build cache might remove the need for it,
so let's remove it for now and more carefully weigh adding it back in.

Immediate: This reduces the chance of hitting file length issues on Windows.

Generally: This is a bit hacky and for an official solution, we should
probably try to find a better way.  This could become more important as
single-file packages are allowed in workspaces.
2023-06-14 12:25:59 -05:00
bors
c1ccde196b Auto merge of #12267 - tokarevart:patch-1, r=ehuss
Fix version requirement example in Dependency Resolution, SemVer compatibility section

I additionally verified with `dtolnay/semver` crate (which it seems cargo itself uses) that version `1.2.0` really matches `>=1.2, <1.5` version requirement.
2023-06-14 02:53:52 +00:00
Artem Tokarev
6c450bd579
Fix version requirement syntax example 2023-06-14 07:39:32 +05:00
bors
028077394a Auto merge of #12265 - ehuss:triagebot-links, r=weihanglo
Update triagebot links.

The triagebot documentation has moved as part of https://github.com/rust-lang/rust-forge/pull/687. This updates the links to the new location.
2023-06-13 19:56:57 +00:00
bors
1356e7cddd Auto merge of #12264 - ehuss:container-poison-error, r=weihanglo
Show a better error when container tests fail.

This adds a better error message when a container test fails to build a container.

Previously the output would look something like:

```
---- ssh::ssh_key_in_config stdout ----
SSH_AGENT_PID=69284
thread 'ssh::ssh_key_in_config' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', crates/cargo-test-support/src/containers.rs:97:39
```

Now it looks like:

```
---- ssh::ssh_key_in_config stdout ----
SSH_AGENT_PID=44281
thread 'ssh::ssh_key_in_config' panicked at 'previous docker build failed, unable to run test', crates/cargo-test-support/src/containers.rs:97:51
```
2023-06-13 19:08:28 +00:00
Eric Huss
3d3168b6c2 Update triagebot links. 2023-06-13 11:44:03 -07:00
Eric Huss
75bcada1eb Show a better error when container tests fail. 2023-06-13 11:15:39 -07:00
bors
1703e06fa2 Auto merge of #12261 - weihanglo:dep-update, r=ehuss
chore: update dependencies

Hand-picked some dependencies to update. Looks pretty safe?

- `anyhow` 1.0.70 -> 1.0.71
- `base64` 0.21.0 -> 0.21.2
- `clap@4.2.1` 4.2.1 -> 4.3.3
- `flate2` 1.0.25 -> 1.0.26
- `git2` 0.17.1 -> 0.17.2
- `libgit2-sys` 0.15.1+1.6.4 -> 0.15.2+1.6.4
- `log` 0.4.17 -> 0.4.19
- `openssl` 111.25.3+1.1.1t -> 111.26.0+1.1.1u
- `pkg-config` 0.3.26 -> 0.3.27
- `proptest` 1.1.0 -> 1.2.0
- `pulldown-cmark` 0.9.2 -> 0.9.3
- `serde` 1.0.160 -> 1.0.164
- `serde_json` 1.0.95 -> 1.0.96
- `snapbox` 0.4.10 -> 0.4.11
- `tempfile` 3.5.0 -> 3.6.0
- `time` 0.3.20 -> 0.3.22
- `toml` 0.7.3 -> 0.7.4
- `toml_edit` 0.19.8 -> 0.19.10
- `url` 2.3.4 -> 2.4.0

### Additional information

This is a bit painful, shall we introduce some bot (dependant/renovate) to help this process.

In addition, we should have a job of `cargo update && cargo test` in our CI pipeline.
2023-06-13 18:15:01 +00:00
bors
fdc29046a2 Auto merge of #12262 - epage:flatten, r=weihanglo
refactor(embedded)

### What does this PR try to resolve?

This is trying to make it easier to have multiple active PRs touching `embedded.rs` by separating out the parts of the code that will be touched in each PR.  This is done by making the code roughly follow how the future code will be structured.

e.g. see #12255

### How should we test and review this PR?

Commit at a time.  This is just a refactor, so no tests are changed.
2023-06-13 14:40:30 +00:00
Ed Page
35a8065607 refactor(embedded): Centralize separator choice 2023-06-13 09:04:30 -05:00
Ed Page
3bbd1e5da7 refactor(embedded): Hide unused items 2023-06-13 08:57:50 -05:00
Ed Page
1df0ce5583 refactor(embedded): Decouple package name sanitization 2023-06-13 08:54:15 -05:00
Ed Page
0af1d21bc4 refactor(embedded): Flatten parsing
This is a step towards making it easier to implement multiple fixes /
features without conflicts.
2023-06-13 08:50:55 -05:00
Weihang Lo
bf06fc856f
Update dependencies
Hand-picked some dependencies to update. Looks pretty safe?

- anyhow
- base64
- clap@4.2.1
- flate2
- git2
- libgit2-sys
- log
- openssl
- pkg-config
- proptest
- pulldown-cmark
- serde
- serde_json
- snapbox
- tempfile
- time
- toml
- toml_edit
- url
2023-06-13 14:39:55 +01:00
bors
000868e055 Auto merge of #12251 - c-git:patch-1, r=weihanglo
docs: clarify the use of `default` branch instead of `main` by default

Update specifying-dependencies.md to show not specifying the branch for git doesn't always use the main branch.
2023-06-13 12:51:16 +00:00
c-git
89ca816e16
Update specifying-dependencies.md 2023-06-13 08:37:33 -04:00
bors
56bb8c49db Auto merge of #12256 - weihanglo:changelog, r=epage
docs: update changelog for 1.71 backport and 1.72
2023-06-12 20:05:27 +00:00
Weihang Lo
e3aa400e6b
changelog: update for 1.72 2023-06-12 21:00:41 +01:00
Weihang Lo
f516436f85
changelog: add 1.71 backport fix for libcurl 2023-06-12 21:00:41 +01:00
bors
f8fef7ab08 Auto merge of #12245 - epage:script, r=weihanglo
feat: Initial support for single-file packages

### What does this PR try to resolve?

This is the first step towards #12207.  In particular, this focuses on pulling in the [demo](https://github.com/epage/cargo-script-mvs) roughly as-is to serve as a baseline for further PRs.  I have a couple months of runtime (multiple times a week) using the version of the demo included here.

### How should we test and review this PR?

Commit-by-commit.  Most likely, the last (docs) commit should be done first to provide context for the others.

Naming is hard.  I came up with these terms just so we can have ways to refer to them.  Feedback is welcome.
- `-Zscript`  for this general feature (not great but didn't want to spend too long coming up with a throwaway name)
- "single-file package": Rust code and a cargo manifest in a single file
- "embedded manifest": the explicit manifest inside of a single-file package
- "manifest command": when we interpret `cargo <name>` as referring to a single-file package, and similar to "built-in commands" and "external commands".

Keep in mind that this is a very hacky solution with many deficiencies and is mostly starting as a baseline for implementing and reviewing those improvements, including
- Switching from `regex` to `syn` for extracting manifests for greater resilience
- Matching `cargo new`s logic when sanitizing the inferred package name
- Allowing `cargo <name>` to also be a `Cargo.toml` file (for consistency in where manifests are accepted)
- Allowing single-file packages to be used wherever a manifest is accepted

To minimize conflict pain, I would ask that we consider what feedback can be handled in a follow up (though still mention it!).  It'll be much easier creating multiple, independent PRs once this baseline is merged to address concerns.

### Additional information

The only affect for people on stable is that they may get a warning if they have an external subcommand that will be shadowed when this feature is implemented.  This will allow us to collect feedback, without blocking people, so we can have an idea of how "safe" our precedence scheme is for interpreting `cargo <name>`.

As of right now, aliases with a `.` in them will be ignored (well, technically their suffix will be exposed as an alias).    We directly inject the name into a lookup string into the config  that uses `.` as the separator, so we drill down until we get to the leaf element.  Ideally, we would be generating / parsing the lookup key using TOML key syntax so we can better report that this won't be supported after this change :)
2023-06-12 18:50:24 +00:00
bors
18a28a1c6a Auto merge of #12224 - Muscraft:test-z-flags-sorted, r=weihanglo
test(z-flags): Verify `-Z` flags list is sorted

#12182 made it so that `unstable_cli_options!` was sorted, but had no way to make sure it would stay sorted in the future.

In [this thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Sorting.20features!.20and.20ensuring.20it.20stays.20sorted), I proposed that a test should be added that would fail if the list is not sorted, this PR adds that test.

If the list is not sorted the test output looks like this:
![Screenshot from 2023-06-02 10-17-08](https://github.com/rust-lang/cargo/assets/23045215/f22cf5f3-4411-44ec-ac5a-991165d5e0a1)
2023-06-11 15:49:44 +00:00
c-git
8a1d6fd2db
Record results from testing
Update specifying-dependencies.md to show not specifying the branch for git doesn't always use the main branch.
2023-06-10 10:26:06 -04:00
Ed Page
6b0b5a8a51 docs(unstable): Expand on manifest commands so far
This is written to reflect the current implementation though some parts
might read a little weird because I didn't want to write throw-away
documentation for when we change this.  For example, single-file
packages are currently only supported in `cargo <command>` and not as
manifest paths but this will change.
2023-06-09 22:03:18 -05:00
Ed Page
33c9d8e2fd feat(cli): Pull in cargo-script-mvs core logic
This is no where near the implementation we want but I think we should
develop incrementally on top of what we already have.

See https://github.com/epage/cargo-script-mvs/tree/main
2023-06-09 22:03:18 -05:00
Ed Page
c421e0bf3a refactor(cli): Align the two run's params 2023-06-09 22:03:17 -05:00
Ed Page
2bd9f144f8 refactor(cli): Pull out run error handling 2023-06-09 22:02:57 -05:00
Ed Page
3c15d24960 fix(cli): Warn on stable for precedence changes
This will give us a window to collect feedback on if this affects
anyone.
2023-06-09 22:02:54 -05:00
bors
928b9561c1 Auto merge of #12248 - weihanglo:source-refactor, r=epage
refactor: registry data kinds cleanup
2023-06-10 01:29:50 +00:00
Weihang Lo
008501a6ef
refactor: reuse calls to try_old_curl macro
At least doc duplicate can be eliminiated
2023-06-10 01:04:46 +01:00
Weihang Lo
cdd96496cb
refactor: extract config.json as a constant 2023-06-10 00:01:22 +01:00
Weihang Lo
665d9a0a65
refactor: inline make_dep_prefix
It is not used anywhere other than in module `registry::download`.
2023-06-09 22:24:25 +01:00
Weihang Lo
768708f504
refactor: remove leftover of #6880
The relevant part was removed in 1daff03f1f
LAST_UPDATED_FILE was never used even before #6880.
They were just leftover during the PR updates.
2023-06-09 20:28:46 +01:00