Auto merge of #124489 - matthiaskrgr:rollup-7pa86bf, r=matthiaskrgr

Rollup of 2 pull requests

Successful merges:

 - #123734 (Inline more svg images into CSS)
 - #124473 (Port `print-cfg` run-make test to Rust-based rmake.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-04-28 19:16:32 +00:00
commit 10505a1cc9
8 changed files with 203 additions and 44 deletions

View File

@ -1133,6 +1133,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
.setting-check input:checked { .setting-check input:checked {
background-color: var(--settings-input-color); background-color: var(--settings-input-color);
border-width: 1px; border-width: 1px;
/* cross-mark image in the settings checkboxes */
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\ content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\
<path d="M7,25L17,32L33,12" fill="none" stroke="black" stroke-width="5"/>\ <path d="M7,25L17,32L33,12" fill="none" stroke="black" stroke-width="5"/>\
<path d="M7,23L17,30L33,10" fill="none" stroke="white" stroke-width="5"/></svg>'); <path d="M7,23L17,30L33,10" fill="none" stroke="white" stroke-width="5"/></svg>');
@ -1608,12 +1609,26 @@ a.tooltip:hover::after {
font-size: 0; font-size: 0;
} }
#settings-menu > a:before { #settings-menu > a:before {
content: url('wheel-63255fc4502dca9a.svg'); /* Wheel <https://www.svgrepo.com/svg/384069/settings-cog-gear> */
content: url('data:image/svg+xml,<svg width="22" height="22" viewBox="0 0 12 12" \
enable-background="new 0 0 12 12" xmlns="http://www.w3.org/2000/svg">\
<path d="M10.25,6c0-0.1243286-0.0261841-0.241333-0.0366211-0.362915l1.6077881-1.5545654l\
-1.25-2.1650391 c0,0-1.2674561,0.3625488-2.1323853,0.6099854c-0.2034912-0.1431885-0.421875\
-0.2639771-0.6494751-0.3701782L7.25,0h-2.5 c0,0-0.3214111,1.2857666-0.5393066,2.1572876\
C3.9830933,2.2634888,3.7647095,2.3842773,3.5612183,2.5274658L1.428833,1.9174805 \
l-1.25,2.1650391c0,0,0.9641113,0.9321899,1.6077881,1.5545654C1.7761841,5.758667,\
1.75,5.8756714,1.75,6 s0.0261841,0.241333,0.0366211,0.362915L0.178833,7.9174805l1.25,\
2.1650391l2.1323853-0.6099854 c0.2034912,0.1432495,0.421875,0.2639771,0.6494751,0.3701782\
L4.75,12h2.5l0.5393066-2.1572876 c0.2276001-0.1062012,0.4459839-0.2269287,0.6494751\
-0.3701782l2.1323853,0.6099854l1.25-2.1650391L10.2133789,6.362915 C10.2238159,6.241333,\
10.25,6.1243286,10.25,6z M6,7.5C5.1715698,7.5,4.5,6.8284302,4.5,6S5.1715698,4.5,6,4.5S7.5\
,5.1715698,7.5,6 S6.8284302,7.5,6,7.5z" fill="black"/></svg>');
width: 22px; width: 22px;
height: 22px; height: 22px;
} }
#sidebar-button > a:before { #sidebar-button > a:before {
/* sidebar resizer image */
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" \ content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" \
fill="none" stroke="black">\ fill="none" stroke="black">\
<rect x="1" y="1" width="20" height="20" ry="1.5" stroke-width="1.5"/>\ <rect x="1" y="1" width="20" height="20" ry="1.5" stroke-width="1.5"/>\
@ -1636,7 +1651,17 @@ a.tooltip:hover::after {
} }
#copy-path::before { #copy-path::before {
filter: var(--copy-path-img-filter); filter: var(--copy-path-img-filter);
content: url('clipboard-24048e6d87f63d07.svg'); /* clipboard <https://github.com/rust-lang/crates.io/commits/main/public/assets/copy.svg> */
content: url('data:image/svg+xml,<svg width="19" height="18" viewBox="0 0 24 25" \
xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard">\
<path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 \
0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 \
7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 \
2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/>\
<path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/>\
</svg>');
width: 19px;
height: 18px;
} }
#copy-path:hover::before { #copy-path:hover::before {
filter: var(--copy-path-img-hover-filter); filter: var(--copy-path-img-hover-filter);
@ -1837,6 +1862,7 @@ However, it's not needed with smaller screen width because the doc/code block is
/* sidebar button opens modal /* sidebar button opens modal
use hamburger button */ use hamburger button */
.src #sidebar-button > a:before, .sidebar-menu-toggle:before { .src #sidebar-button > a:before, .sidebar-menu-toggle:before {
/* hamburger button image */
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \ content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
viewBox="0 0 22 22" fill="none" stroke="black">\ viewBox="0 0 22 22" fill="none" stroke="black">\
<path d="M3,5h16M3,11h16M3,17h16" stroke-width="2.75"/></svg>'); <path d="M3,5h16M3,11h16M3,17h16" stroke-width="2.75"/></svg>');
@ -1850,6 +1876,7 @@ However, it's not needed with smaller screen width because the doc/code block is
/* src sidebar button opens a folder view */ /* src sidebar button opens a folder view */
.src #sidebar-button > a:before { .src #sidebar-button > a:before {
/* folder image */
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \ content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
viewBox="0 0 22 22" fill="none" stroke="black">\ viewBox="0 0 22 22" fill="none" stroke="black">\
<path d="M16,9v-4h-6v-1l-2,-2h-4l-2,2v16h13L21,9h-15L2,19" stroke-width="1.25"/>\ <path d="M16,9v-4h-6v-1l-2,-2h-4l-2,2v16h13L21,9h-15L2,19" stroke-width="1.25"/>\

View File

@ -1 +0,0 @@
<svg width="19" height="18" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard"><path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/><path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/></svg>

Before

Width:  |  Height:  |  Size: 576 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" enable-background="new 0 0 22 22" viewBox="0 0 27.434 29.5"><path d="M27.316 18.39a2.696 2.696 0 0 0-.98-1.46 1.62 1.62 0 0 1-.016-.762l.035-.176v-1.191c0-1.246-.003-1.278-.046-1.473a1.717 1.717 0 0 1 .007-.805c.477-.343.829-.859.997-1.472.257-.957.074-2.094-.508-3.117l-.594-1.032c-.746-1.304-1.965-2.117-3.18-2.117-.379 0-.75.078-1.086.235a1.958 1.958 0 0 1-.855-.391l-.102-.082-.117-.063-1.855-1.07-.094-.055-.106-.043c-.378-.156-.66-.41-.77-.554C17.919 1.172 16.349 0 14.297 0h-1.155c-2.043 0-3.61 1.152-3.75 2.723-.114.14-.391.382-.758.527l-.102.04-.094.05-1.94 1.066-.134.074-.117.094a2.019 2.019 0 0 1-.832.403 2.518 2.518 0 0 0-1.008-.211c-1.199 0-2.414.82-3.168 2.14l-.59 1.032c-.41.718-.64 1.523-.64 2.257-.004.953.36 1.758 1.012 2.258.035.152.058.445-.016.785-.04.168-.063.282-.063 1.563 0 1.148 0 1.148.016 1.261l.008.075.015.074c.075.344.047.64.012.8-.644.5-1.004 1.302-.992 2.259.008.726.238 1.52.648 2.242l.59 1.027c.758 1.332 1.965 2.16 3.149 2.16.324 0 .644-.062.937-.187.168.039.492.156.813.418l.11.086.124.07 2.047 1.156.102.059.105.043c.363.144.648.379.766.52.164 1.519 1.718 2.632 3.746 2.632h1.156c2.035 0 3.598-1.133 3.746-2.672.117-.144.402-.394.773-.55l.114-.047.101-.063 1.961-1.156.106-.063.097-.078c.309-.246.653-.37.832-.398.313.136.66.21 1.016.21 1.2 0 2.41-.82 3.164-2.14l.594-1.031c.59-1.028.777-2.164.52-3.117Zm-2.043 2.247-.59 1.031c-.437.766-1.105 1.25-1.636 1.25a.7.7 0 0 1-.371-.094 1.146 1.146 0 0 0-.567-.129c-.593 0-1.382.297-2.007.797l-1.961 1.156c-1.016.426-1.848 1.293-1.848 1.93 0 .64-.898 1.16-1.996 1.16H13.14c-1.102 0-2-.515-2-1.14 0-.63-.832-1.477-1.852-1.887l-2.047-1.16c-.637-.512-1.426-.813-2.008-.813-.199 0-.379.035-.515.114a.648.648 0 0 1-.332.085c-.52 0-1.18-.5-1.621-1.273l-.59-1.031c-.543-.953-.555-1.98-.024-2.285.532-.305.782-1.434.551-2.504V14.8c0-1.09.02-1.18.02-1.18.238-1.074-.008-2.203-.551-2.516-.54-.304-.54-1.34.008-2.293l.59-1.03c.437-.766 1.101-1.255 1.636-1.255a.73.73 0 0 1 .364.094c.152.086.343.125.566.125.594 0 1.379-.297 2.004-.793l1.945-1.066c1.02-.407 1.856-1.278 1.856-1.934 0-.656.898-1.191 2-1.191h1.156c1.098 0 1.996.543 1.996 1.21 0 .669.832 1.555 1.848 1.973L20 6.012c.617.492 1.402.777 2.012.777.242 0 .453-.047.62-.14a.79.79 0 0 1 .403-.102c.55 0 1.223.476 1.652 1.23l.59 1.032c.543.953.52 2.004-.062 2.336-.574.332-.86 1.48-.625 2.554 0 0 .008.04.008 1.102v1.011c-.215 1.051.07 2.176.636 2.5.567.325.586 1.368.04 2.325Zm0 0"/><path d="M13.61 7.61a7.084 7.084 0 0 0-7.083 7.085 7.085 7.085 0 1 0 14.168 0A7.088 7.088 0 0 0 13.61 7.61Zm0 12.41a5.33 5.33 0 0 1-5.325-5.325 5.33 5.33 0 0 1 5.324-5.32 5.327 5.327 0 0 1 5.325 5.32 5.328 5.328 0 0 1-5.325 5.325Zm0 0"/><path d="M13.684 9.906a4.722 4.722 0 0 0-4.72 4.719 4.722 4.722 0 0 0 4.72 4.719 4.724 4.724 0 0 0 4.714-4.719 4.724 4.724 0 0 0-4.714-4.719Zm0 7.676a2.954 2.954 0 1 1 0-5.91 2.953 2.953 0 0 1 2.953 2.953 2.957 2.957 0 0 1-2.953 2.957Zm0 0"/></svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -99,8 +99,6 @@ static_files! {
src_script_js => "static/js/src-script.js", src_script_js => "static/js/src-script.js",
storage_js => "static/js/storage.js", storage_js => "static/js/storage.js",
scrape_examples_js => "static/js/scrape-examples.js", scrape_examples_js => "static/js/scrape-examples.js",
wheel_svg => "static/images/wheel.svg",
clipboard_svg => "static/images/clipboard.svg",
copyright => "static/COPYRIGHT.txt", copyright => "static/COPYRIGHT.txt",
license_apache => "static/LICENSE-APACHE.txt", license_apache => "static/LICENSE-APACHE.txt",
license_mit => "static/LICENSE-MIT.txt", license_mit => "static/LICENSE-MIT.txt",

View File

@ -219,7 +219,6 @@ run-make/prefer-rlib/Makefile
run-make/pretty-print-to-file/Makefile run-make/pretty-print-to-file/Makefile
run-make/pretty-print-with-dep-file/Makefile run-make/pretty-print-with-dep-file/Makefile
run-make/print-calling-conventions/Makefile run-make/print-calling-conventions/Makefile
run-make/print-cfg/Makefile
run-make/print-target-list/Makefile run-make/print-target-list/Makefile
run-make/profile/Makefile run-make/profile/Makefile
run-make/prune-link-args/Makefile run-make/prune-link-args/Makefile

View File

@ -1,37 +0,0 @@
# needs-llvm-components: x86 arm
include ../tools.mk
all: default output_to_file
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64
$(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc
$(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos
$(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu
$(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) target_abi=
$(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) eabihf
output_to_file:
# Backend-independent, printed by rustc_driver_impl/src/lib.rs
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt
$(CGREP) windows < $(TMPDIR)/cfg.txt
# Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
$(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt
$(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt
# Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
$(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt
$(CGREP) reference-types < $(TMPDIR)/target-features.txt
# Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
$(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt
$(CGREP) generic < $(TMPDIR)/target-cpus.txt
ifdef IS_WINDOWS
default:
$(RUSTC) --print cfg | $(CGREP) windows
else
default:
$(RUSTC) --print cfg | $(CGREP) unix
endif

View File

@ -0,0 +1,106 @@
//! This checks the output of `--print=cfg`
//!
//! Specifically it checks that output is correctly formatted
//! (ie. no duplicated cfgs, values are between "", names are not).
//!
//! It also checks that some targets have the correct set cfgs.
extern crate run_make_support;
use std::collections::HashSet;
use std::ffi::OsString;
use std::io::BufRead;
use std::iter::FromIterator;
use run_make_support::{rustc, tmp_dir};
struct PrintCfg {
target: &'static str,
includes: &'static [&'static str],
disallow: &'static [&'static str],
}
fn main() {
check(PrintCfg {
target: "x86_64-pc-windows-gnu",
includes: &["windows", "target_arch=\"x86_64\""],
disallow: &["unix"],
});
check(PrintCfg {
target: "i686-pc-windows-msvc",
includes: &["windows", "target_env=\"msvc\""],
disallow: &["unix"],
});
check(PrintCfg {
target: "i686-apple-darwin",
includes: &["unix", "target_os=\"macos\"", "target_vendor=\"apple\""],
disallow: &["windows"],
});
check(PrintCfg {
target: "i686-unknown-linux-gnu",
includes: &["unix", "target_env=\"gnu\""],
disallow: &["windows"],
});
check(PrintCfg {
target: "arm-unknown-linux-gnueabihf",
includes: &["unix", "target_abi=\"eabihf\""],
disallow: &["windows"],
});
}
fn check(PrintCfg { target, includes, disallow }: PrintCfg) {
fn check_(output: &str, includes: &[&str], disallow: &[&str]) {
let mut found = HashSet::<String>::new();
let mut recorded = HashSet::<String>::new();
for l in output.lines() {
assert!(l == l.trim());
if let Some((left, right)) = l.split_once('=') {
assert!(right.starts_with("\""));
assert!(right.ends_with("\""));
assert!(!left.contains("\""));
} else {
assert!(!l.contains("\""));
}
assert!(recorded.insert(l.to_string()), "duplicated: {}", &l);
assert!(!disallow.contains(&l), "found disallowed: {}", &l);
if includes.contains(&l) {
assert!(found.insert(l.to_string()), "duplicated (includes): {}", &l);
}
}
let should_found = HashSet::<String>::from_iter(includes.iter().map(|s| s.to_string()));
let diff: Vec<_> = should_found.difference(&found).collect();
assert!(
diff.is_empty(),
"expected: {:?}, found: {:?} (~ {:?})",
&should_found,
&found,
&diff
);
}
// --print=cfg
{
let output = rustc().target(target).print("cfg").run();
let stdout = String::from_utf8(output.stdout).unwrap();
check_(&stdout, includes, disallow);
}
// --print=cfg=PATH
{
let tmp_path = tmp_dir().join(format!("{target}.cfg"));
let mut print_arg = OsString::from("--print=cfg=");
print_arg.push(tmp_path.as_os_str());
let output = rustc().target(target).arg(print_arg).run();
let output = std::fs::read_to_string(&tmp_path).unwrap();
check_(&output, includes, disallow);
}
}

View File

@ -0,0 +1,68 @@
//! This checks the output of some `--print` options when
//! output to a file (instead of stdout)
extern crate run_make_support;
use std::ffi::OsString;
use run_make_support::{rustc, target, tmp_dir};
struct Option<'a> {
target: &'a str,
option: &'static str,
includes: &'static [&'static str],
}
fn main() {
// Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
check(Option {
target: &target(),
option: "relocation-models",
includes: &["dynamic-no-pic"],
});
// Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
check(Option {
target: "wasm32-unknown-unknown",
option: "target-features",
includes: &["reference-types"],
});
// Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
check(Option {
target: "wasm32-unknown-unknown",
option: "target-cpus",
includes: &["generic"],
});
}
fn check(args: Option) {
fn check_(output: &str, includes: &[&str]) {
for i in includes {
assert!(output.contains(i), "output doesn't contains: {}", i);
}
}
// --print={option}
let stdout = {
let output = rustc().target(args.target).print(args.option).run();
String::from_utf8(output.stdout).unwrap()
};
// --print={option}=PATH
let output = {
let tmp_path = tmp_dir().join(format!("{}.txt", args.option));
let mut print_arg = OsString::from(format!("--print={}=", args.option));
print_arg.push(tmp_path.as_os_str());
let _output = rustc().target(args.target).arg(print_arg).run();
std::fs::read_to_string(&tmp_path).unwrap()
};
check_(&stdout, args.includes);
check_(&output, args.includes);
assert_eq!(&stdout, &output);
}