Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't build default target twice #534

Merged
merged 9 commits into from
Jan 7, 2020

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Dec 24, 2019

This is the non-breaking changes from #532. I also kept the additional documentation for existing metadata.

Copy/pasted from that PR for convenience:

Architecture Changes

This removes the duplicated 'default' build which is run twice.

  • The default build no longer passes --target to Cargo for the common case where default-target is not set. This will fix Cfg missing during build script build #440. As a side effect, it removes most of the hacking around I had to do to get proc macros to work.
  • The target for the default build is now stored in the database. As before, the default target is x86_64-unknown-linux-gnu and can be overriden with default-target = ... in Cargo.toml
  • The target for the default build is no longer run twice
  • The web server redirects requests to /:crate/:version/:default-target to /:crate/:version/, keeping the subpage if it exists.

This has been tested both by building with the new code and by building with the old code and running cratesfyi database migrate. Note that if cratesfyi database migrate is not run, the web server will panic whenever viewing a crate built with the old code.

r? @pietroalbini

Copy link
Member

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to test building crates locally, but this looks great!

The only change I'd like to see is on the dropdown menu allowing you to choose the target: with this PR, if you click the default target you'll be sent first to /:crate/:version/:default-target, and then redirected to /:crate/:version. I'd be nice to remove that redirect.

templates/about.hbs Outdated Show resolved Hide resolved
@pietroalbini
Copy link
Member

Build code also seem to work fine!

@jyn514
Copy link
Member Author

jyn514 commented Jan 7, 2020

if you click the default target you'll be sent first to /:crate/:version/:default-target, and then redirected to /:crate/:version. I'd be nice to remove that redirect.

I'm not sure how to fix this. Currently we set those links like this in templates/navigation_rustdoc.hbs:

                {{#each doc_targets}}
                <li class="pure-menu-item"><a href="/{{../../content.crate_details.name}}/{{../../content.crate_details.version}}/{{this}}/{{../../content.crate_details.target_name}}/" class="pure-menu-link">{{this}}</a></li>
                {{/each}}

We'd have to compare each doc_target to the default_target, but I don't know how to do that in handlebars. The API reference says that #if has to be passed a single value, it can't handle == or anything like that.

QuietMisdreavus and others added 4 commits January 7, 2020 08:31
The code as of the previous commit would let you navigate away from the
default, but not navigate back. This adds the default target to
`successful_targets` to add a link to the dropdown in 'Platform'.

After adding that, the link would give a 404
(because we treat paths literally when sending them to the database),
so the metadata for every crate now has to include the default target,
which allows redirecting to /:crate/:version/:module/ when visiting
/:crate/:version/:module/:default-target
this required a bit of a rearchitecture
also uses a constant instead of hardcoding the default target
Only the default build should be in target/doc.
@pietroalbini
Copy link
Member

I'm not sure how to fix this.

I'd generate a Map<TargetName, TargetUrl> from Rust and pass it to the template, sidestepping the handlebars limitations.

@jyn514
Copy link
Member Author

jyn514 commented Jan 7, 2020

I don't see a way to send a data structure to a Page, we'd have to make it part of CrateDetails.

Is it ok if we add this at a later point? It's not hurting usability, you still get sent to the right page.

@pietroalbini
Copy link
Member

I don't see a way to send a data structure to a Page, we'd have to make it part of CrateDetails.

Yep.

Is it ok if we add this at a later point? It's not hurting usability, you still get sent to the right page.

Ok, can you open an issue about that?

@jyn514
Copy link
Member Author

jyn514 commented Jan 7, 2020

Opened: #549

@pietroalbini pietroalbini merged commit 2b9f981 into rust-lang:master Jan 7, 2020
@jyn514 jyn514 deleted the one-default-target branch January 7, 2020 15:22
pietroalbini added a commit that referenced this pull request Jan 7, 2020
This reverts commit 2b9f981, reversing
changes made to 0b16db9.
@jyn514 jyn514 mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cfg missing during build script build
3 participants