mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Maintain some nightly features and CI (#3934)
* remove `doc_auto_cfg` removed in favor of `doc_cfg` which is already present * fix optimization flags the fix targets the change to panic_abort in rust-lang/rust#146974 Incidentally, this led me to realize that some RUSTFLAGS were being ignored, due to the exclusivity of env variables vs config options (see ref). With this change, all config options are read from toml files instead of env variables. reference: https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags use old optimization flags for master branch before this change * skip example paths that don't contain a Cargo.toml
This commit is contained in:
parent
85050f50fb
commit
bb031eb68f
@ -6,7 +6,3 @@ runner = 'wasmtime -W unknown-imports-trap=y'
|
||||
|
||||
[target.wasm32-unknown-unknown]
|
||||
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
|
||||
|
||||
# This section needs to be last.
|
||||
# GitHub Actions modifies this section.
|
||||
[unstable]
|
||||
|
||||
13
.github/workflows/size-cmp.yml
vendored
13
.github/workflows/size-cmp.yml
vendored
@ -32,10 +32,15 @@ jobs:
|
||||
|
||||
- name: Write Optimisation Flags
|
||||
run: |
|
||||
echo 'build-std = ["std", "panic_abort"]' >> .cargo/config.toml
|
||||
echo 'build-std-features = ["panic_immediate_abort"]' >> .cargo/config.toml
|
||||
echo '[build]' >> .cargo/config.toml
|
||||
echo 'rustflags = ["-Cpanic=abort"]' >> .cargo/config.toml
|
||||
if [ -x ci/write-min-size-flags.sh ] ; then
|
||||
ci/write-min-size-flags.sh
|
||||
else
|
||||
# this branch is a fallback used only for compatibility with earlier commits
|
||||
# in the repository and other branches and can be removed in the future.
|
||||
echo 'build-std = ["std", "panic_abort"]' >> .cargo/config.toml
|
||||
echo '[build]' >> .cargo/config.toml
|
||||
echo 'rustflags = ["-Cpanic=abort"]' >> .cargo/config.toml
|
||||
fi
|
||||
|
||||
- name: Setup toolchain
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
|
||||
@ -4,6 +4,7 @@ members = [
|
||||
"tools/*",
|
||||
"examples/*",
|
||||
]
|
||||
exclude = ["examples/.cargo"]
|
||||
default-members = [
|
||||
"packages/*",
|
||||
]
|
||||
|
||||
2
ci/write-min-size-flags.sh
Executable file
2
ci/write-min-size-flags.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
cat examples/.cargo/min-size-config.toml >> examples/.cargo/dummy-min-size-config.toml
|
||||
7
examples/.cargo/config.toml
Normal file
7
examples/.cargo/config.toml
Normal file
@ -0,0 +1,7 @@
|
||||
# this include is a bit of a hack: due to the unstable nature of the feature,
|
||||
# this file only gets included on nightly, hence it can specify "nightly only"
|
||||
# rustflags and options
|
||||
include = ["unstable.toml", "dummy-min-size-config.toml"]
|
||||
|
||||
[unstable]
|
||||
config-include = true
|
||||
2
examples/.cargo/dummy-min-size-config.toml
Normal file
2
examples/.cargo/dummy-min-size-config.toml
Normal file
@ -0,0 +1,2 @@
|
||||
# This file is intentionally left empty.
|
||||
# It gets filled by `min-size-config.toml` in some cases by CI
|
||||
6
examples/.cargo/min-size-config.toml
Normal file
6
examples/.cargo/min-size-config.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[unstable]
|
||||
build-std = ["core", "std", "panic_abort"]
|
||||
build-std-features = ["optimize_for_size"]
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")']
|
||||
rustflags = ["-Zunstable-options", "-Cpanic=immediate-abort", "--cfg", "nightly_yew"]
|
||||
2
examples/.cargo/unstable.toml
Normal file
2
examples/.cargo/unstable.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[target.wasm32-unknown-unknown]
|
||||
rustflags = ["--cfg", "nightly_yew"]
|
||||
@ -1,7 +1,6 @@
|
||||
#![allow(clippy::needless_doctest_main)]
|
||||
#![doc(html_logo_url = "https://yew.rs/img/logo.png")]
|
||||
#![cfg_attr(documenting, feature(doc_cfg))]
|
||||
#![cfg_attr(documenting, feature(doc_auto_cfg))]
|
||||
#![cfg_attr(nightly_yew, feature(fn_traits, unboxed_closures))]
|
||||
|
||||
//! # Yew Framework - API Documentation
|
||||
|
||||
@ -33,7 +33,7 @@ fn main() -> ExitCode {
|
||||
let path = entry.path();
|
||||
|
||||
// Skip if not a directory
|
||||
if !path.is_dir() {
|
||||
if should_skip_path(&path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -81,27 +81,19 @@ fn main() -> ExitCode {
|
||||
}
|
||||
}
|
||||
|
||||
fn should_skip_path(path: &Path) -> bool {
|
||||
!path.is_dir() || !path.join("Cargo.toml").exists()
|
||||
}
|
||||
|
||||
fn build_example(path: &Path, output_dir: &Path, example: &str) -> bool {
|
||||
let public_url_prefix = env::var("PUBLIC_URL_PREFIX").unwrap_or_default();
|
||||
|
||||
let dist_dir = output_dir.join(example);
|
||||
|
||||
let uses_rand = has_rand_dependency(path);
|
||||
|
||||
let rustflags = format!(
|
||||
"--cfg nightly_yew{}",
|
||||
if uses_rand {
|
||||
" --cfg getrandom_backend=\"wasm_js\""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
);
|
||||
|
||||
// Run trunk build command
|
||||
let status = Command::new("trunk")
|
||||
.current_dir(path)
|
||||
.arg("build")
|
||||
.env("RUSTFLAGS", rustflags)
|
||||
.arg("--release")
|
||||
.arg("--dist")
|
||||
.arg(&dist_dir)
|
||||
@ -137,17 +129,3 @@ fn build_example(path: &Path, output_dir: &Path, example: &str) -> bool {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check if the crate has a rand dependency
|
||||
fn has_rand_dependency(path: &Path) -> bool {
|
||||
let cargo_toml_path = path.join("Cargo.toml");
|
||||
|
||||
if !cargo_toml_path.exists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
match fs::read_to_string(&cargo_toml_path) {
|
||||
Ok(content) => content.contains("rand = ") || content.contains("rand =\n"),
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user