mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Shift output suppression into n2 (#2618)
After updating with tools/install-n2, you should now be able to see the last line of long-running commands like cargo invocations.
This commit is contained in:
parent
3b7c5d71ab
commit
239e964c42
15 changed files with 61 additions and 43 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3362,6 +3362,7 @@ name = "runner"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anki_io",
|
"anki_io",
|
||||||
|
"anki_process",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"camino",
|
"camino",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -110,6 +110,10 @@ impl BuildAction for GenPythonProto {
|
||||||
build.add_inputs("protoc-gen-mypy", inputs![":pyenv:protoc-gen-mypy"]);
|
build.add_inputs("protoc-gen-mypy", inputs![":pyenv:protoc-gen-mypy"]);
|
||||||
build.add_outputs("", python_outputs);
|
build.add_outputs("", python_outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BuildWheel {
|
pub struct BuildWheel {
|
||||||
|
|
|
@ -40,6 +40,14 @@ pub trait BuildAction {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_success(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> &'static str {
|
fn name(&self) -> &'static str {
|
||||||
std::any::type_name::<Self>().split("::").last().unwrap()
|
std::any::type_name::<Self>().split("::").last().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,6 +262,14 @@ impl BuildStatement<'_> {
|
||||||
if let Some(pool) = action.concurrency_pool() {
|
if let Some(pool) = action.concurrency_pool() {
|
||||||
stmt.rule_variables.push(("pool".into(), pool.into()));
|
stmt.rule_variables.push(("pool".into(), pool.into()));
|
||||||
}
|
}
|
||||||
|
stmt.rule_variables.push((
|
||||||
|
"hide_success".into(),
|
||||||
|
(action.hide_success() as u8).to_string(),
|
||||||
|
));
|
||||||
|
stmt.rule_variables.push((
|
||||||
|
"hide_last_line".into(),
|
||||||
|
(action.hide_last_line() as u8).to_string(),
|
||||||
|
));
|
||||||
|
|
||||||
stmt
|
stmt
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,10 @@ impl BuildAction for SvelteCheck {
|
||||||
let hash = simple_hash(&self.tsconfig);
|
let hash = simple_hash(&self.tsconfig);
|
||||||
build.add_output_stamp(format!("tests/svelte-check.{hash}"));
|
build.add_output_stamp(format!("tests/svelte-check.{hash}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TypescriptCheck {
|
pub struct TypescriptCheck {
|
||||||
|
@ -307,6 +311,10 @@ impl BuildAction for JestTest<'_> {
|
||||||
let hash = simple_hash(self.folder);
|
let hash = simple_hash(self.folder);
|
||||||
build.add_output_stamp(format!("tests/jest.{hash}"));
|
build.add_output_stamp(format!("tests/jest.{hash}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SqlFormat {
|
pub struct SqlFormat {
|
||||||
|
|
|
@ -137,6 +137,10 @@ impl BuildAction for PythonTypecheck {
|
||||||
let hash = simple_hash(self.folders);
|
let hash = simple_hash(self.folders);
|
||||||
build.add_output_stamp(format!("tests/python_typecheck.{hash}"));
|
build.add_output_stamp(format!("tests/python_typecheck.{hash}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PythonFormat<'a> {
|
struct PythonFormat<'a> {
|
||||||
|
@ -246,4 +250,8 @@ impl BuildAction for PythonTest {
|
||||||
let hash = simple_hash(self.folder);
|
let hash = simple_hash(self.folder);
|
||||||
build.add_output_stamp(format!("tests/python_pytest.{hash}"));
|
build.add_output_stamp(format!("tests/python_pytest.{hash}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_last_line(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ rust-version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anki_io.workspace = true
|
anki_io.workspace = true
|
||||||
|
anki_process.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
camino.workspace = true
|
camino.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::process::Command;
|
||||||
use camino::Utf8PathBuf;
|
use camino::Utf8PathBuf;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub struct BuildArtifactsArgs {
|
pub struct BuildArtifactsArgs {
|
||||||
|
@ -29,7 +29,7 @@ pub fn build_artifacts(args: BuildArtifactsArgs) {
|
||||||
fs::remove_dir_all(&build_folder).unwrap();
|
fs::remove_dir_all(&build_folder).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
run_silent(
|
run_command(
|
||||||
Command::new(&args.pyoxidizer_bin)
|
Command::new(&args.pyoxidizer_bin)
|
||||||
.args([
|
.args([
|
||||||
"--system-rust",
|
"--system-rust",
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::process::Command;
|
||||||
use camino::Utf8Path;
|
use camino::Utf8Path;
|
||||||
|
|
||||||
use super::artifacts::macos_deployment_target;
|
use super::artifacts::macos_deployment_target;
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
pub fn build_bundle_binary() {
|
pub fn build_bundle_binary() {
|
||||||
let mut features = String::from("build-mode-prebuilt-artifacts");
|
let mut features = String::from("build-mode-prebuilt-artifacts");
|
||||||
|
@ -37,5 +37,5 @@ pub fn build_bundle_binary() {
|
||||||
)
|
)
|
||||||
.env("MACOSX_DEPLOYMENT_TARGET", macos_deployment_target())
|
.env("MACOSX_DEPLOYMENT_TARGET", macos_deployment_target())
|
||||||
.env("CARGO_BUILD_TARGET", env!("TARGET"));
|
.env("CARGO_BUILD_TARGET", env!("TARGET"));
|
||||||
run_silent(&mut command);
|
run_command(&mut command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use clap::ValueEnum;
|
||||||
|
|
||||||
use crate::paths::absolute_msys_path;
|
use crate::paths::absolute_msys_path;
|
||||||
use crate::paths::unix_path;
|
use crate::paths::unix_path;
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
#[derive(Clone, Copy, ValueEnum, Debug)]
|
#[derive(Clone, Copy, ValueEnum, Debug)]
|
||||||
enum DistKind {
|
enum DistKind {
|
||||||
|
@ -58,7 +58,7 @@ fn copy_qt_from_venv(kind: DistKind, folder_root: &Utf8Path) {
|
||||||
let lib_path = folder_root.join("lib");
|
let lib_path = folder_root.join("lib");
|
||||||
fs::create_dir_all(&lib_path).unwrap();
|
fs::create_dir_all(&lib_path).unwrap();
|
||||||
let dst_path = with_slash(absolute_msys_path(&lib_path));
|
let dst_path = with_slash(absolute_msys_path(&lib_path));
|
||||||
run_silent(Command::new("rsync").args([
|
run_command(Command::new("rsync").args([
|
||||||
"-a",
|
"-a",
|
||||||
"--delete",
|
"--delete",
|
||||||
"--exclude-from",
|
"--exclude-from",
|
||||||
|
@ -70,7 +70,7 @@ fn copy_qt_from_venv(kind: DistKind, folder_root: &Utf8Path) {
|
||||||
|
|
||||||
fn copy_linux_extras(kind: DistKind, folder_root: &Utf8Path) {
|
fn copy_linux_extras(kind: DistKind, folder_root: &Utf8Path) {
|
||||||
// add README, installer, etc
|
// add README, installer, etc
|
||||||
run_silent(Command::new("rsync").args(["-a", "qt/bundle/lin/", &with_slash(folder_root)]));
|
run_command(Command::new("rsync").args(["-a", "qt/bundle/lin/", &with_slash(folder_root)]));
|
||||||
|
|
||||||
// add extra IME plugins from download
|
// add extra IME plugins from download
|
||||||
let lib_path = folder_root.join("lib");
|
let lib_path = folder_root.join("lib");
|
||||||
|
@ -84,11 +84,11 @@ fn copy_linux_extras(kind: DistKind, folder_root: &Utf8Path) {
|
||||||
DistKind::Standard => "PyQt6/Qt6/plugins",
|
DistKind::Standard => "PyQt6/Qt6/plugins",
|
||||||
DistKind::Alternate => "PyQt5/Qt5/plugins",
|
DistKind::Alternate => "PyQt5/Qt5/plugins",
|
||||||
});
|
});
|
||||||
run_silent(Command::new("rsync").args(["-a", &with_slash(src_path), &with_slash(dst_path)]));
|
run_command(Command::new("rsync").args(["-a", &with_slash(src_path), &with_slash(dst_path)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_windows_extras(folder_root: &Utf8Path) {
|
fn copy_windows_extras(folder_root: &Utf8Path) {
|
||||||
run_silent(Command::new("rsync").args([
|
run_command(Command::new("rsync").args([
|
||||||
"-a",
|
"-a",
|
||||||
"out/extracted/win_amd64_audio/",
|
"out/extracted/win_amd64_audio/",
|
||||||
&with_slash(folder_root),
|
&with_slash(folder_root),
|
||||||
|
@ -131,7 +131,7 @@ fn copy_binary_and_pylibs(folder_root: &Utf8Path) {
|
||||||
.join("../build")
|
.join("../build")
|
||||||
.join(env!("TARGET"))
|
.join(env!("TARGET"))
|
||||||
.join("release/resources/extra_files");
|
.join("release/resources/extra_files");
|
||||||
run_silent(Command::new("rsync").args([
|
run_command(Command::new("rsync").args([
|
||||||
"-a",
|
"-a",
|
||||||
"--exclude",
|
"--exclude",
|
||||||
"PyQt6",
|
"PyQt6",
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::process::Command;
|
||||||
use camino::Utf8Path;
|
use camino::Utf8Path;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub struct PyenvArgs {
|
pub struct PyenvArgs {
|
||||||
|
@ -28,7 +28,7 @@ pub fn setup_pyenv(args: PyenvArgs) {
|
||||||
let pip_sync = pyenv_bin_folder.join("pip-sync");
|
let pip_sync = pyenv_bin_folder.join("pip-sync");
|
||||||
|
|
||||||
if !pyenv_python.exists() {
|
if !pyenv_python.exists() {
|
||||||
run_silent(
|
run_command(
|
||||||
Command::new(&args.python_bin)
|
Command::new(&args.python_bin)
|
||||||
.args(["-m", "venv"])
|
.args(["-m", "venv"])
|
||||||
.args(args.venv_args)
|
.args(args.venv_args)
|
||||||
|
@ -44,7 +44,7 @@ pub fn setup_pyenv(args: PyenvArgs) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
run_silent(Command::new(pyenv_python).args([
|
run_command(Command::new(pyenv_python).args([
|
||||||
"-m",
|
"-m",
|
||||||
"pip",
|
"pip",
|
||||||
"install",
|
"install",
|
||||||
|
@ -53,5 +53,5 @@ pub fn setup_pyenv(args: PyenvArgs) {
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
run_silent(Command::new(pip_sync).args(&args.reqs));
|
run_command(Command::new(pip_sync).args(&args.reqs));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use camino::Utf8Path;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
|
||||||
use crate::paths::absolute_msys_path;
|
use crate::paths::absolute_msys_path;
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub struct RsyncArgs {
|
pub struct RsyncArgs {
|
||||||
|
@ -23,7 +23,7 @@ pub struct RsyncArgs {
|
||||||
|
|
||||||
pub fn rsync_files(args: RsyncArgs) {
|
pub fn rsync_files(args: RsyncArgs) {
|
||||||
let output_dir = absolute_msys_path(Utf8Path::new(&args.output_dir));
|
let output_dir = absolute_msys_path(Utf8Path::new(&args.output_dir));
|
||||||
run_silent(
|
run_command(
|
||||||
Command::new("rsync")
|
Command::new("rsync")
|
||||||
.current_dir(&args.prefix)
|
.current_dir(&args.prefix)
|
||||||
.arg("--relative")
|
.arg("--relative")
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::process::Output;
|
|
||||||
|
|
||||||
use anki_io::create_dir_all;
|
use anki_io::create_dir_all;
|
||||||
use anki_io::write_file;
|
use anki_io::write_file;
|
||||||
|
use anki_process::CommandExt;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ pub fn run_commands(args: RunArgs) -> Result<()> {
|
||||||
create_dir_all(&dir)?;
|
create_dir_all(&dir)?;
|
||||||
}
|
}
|
||||||
for command in commands {
|
for command in commands {
|
||||||
run_silent(&mut build_command(command, &args.env, &args.cwd));
|
run_command(&mut build_command(command, &args.env, &args.cwd));
|
||||||
}
|
}
|
||||||
if let Some(stamp_file) = args.stamp {
|
if let Some(stamp_file) = args.stamp {
|
||||||
write_file(stamp_file, b"")?;
|
write_file(stamp_file, b"")?;
|
||||||
|
@ -82,26 +82,6 @@ fn split_args(args: Vec<String>) -> Vec<Vec<String>> {
|
||||||
commands
|
commands
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Log stdout/stderr and exit if command failed; return output on success.
|
pub fn run_command(command: &mut Command) {
|
||||||
/// If OUTPUT_SUCCESS=1 is defined, output will be shown on success.
|
command.ensure_success().unwrap();
|
||||||
pub fn run_silent(command: &mut Command) -> Output {
|
|
||||||
let output = command
|
|
||||||
.output()
|
|
||||||
.unwrap_or_else(|e| panic!("failed to run command: {:?}: {e}", command));
|
|
||||||
if !output.status.success() {
|
|
||||||
println!(
|
|
||||||
"Command failed: \n{}\n{}",
|
|
||||||
String::from_utf8_lossy(&output.stdout),
|
|
||||||
String::from_utf8_lossy(&output.stderr),
|
|
||||||
);
|
|
||||||
std::process::exit(output.status.code().unwrap_or(1));
|
|
||||||
}
|
|
||||||
if std::env::var("OUTPUT_SUCCESS").is_ok() {
|
|
||||||
println!(
|
|
||||||
"{}{}",
|
|
||||||
String::from_utf8_lossy(&output.stdout),
|
|
||||||
String::from_utf8_lossy(&output.stderr)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
output
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::process::Command;
|
||||||
|
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
|
||||||
use crate::run::run_silent;
|
use crate::run::run_command;
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub struct YarnArgs {
|
pub struct YarnArgs {
|
||||||
|
@ -17,7 +17,7 @@ pub struct YarnArgs {
|
||||||
pub fn setup_yarn(args: YarnArgs) {
|
pub fn setup_yarn(args: YarnArgs) {
|
||||||
link_node_modules();
|
link_node_modules();
|
||||||
|
|
||||||
run_silent(Command::new(&args.yarn_bin).arg("install"));
|
run_command(Command::new(&args.yarn_bin).arg("install"));
|
||||||
|
|
||||||
std::fs::write(args.stamp, b"").unwrap();
|
std::fs::write(args.stamp, b"").unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cargo install --git https://github.com/evmar/n2.git --rev 715feedd746d622862601cc7c197fcb18c6b5ae8
|
cargo install --git https://github.com/ankitects/n2.git --rev 56202604d4c541524b82381162eafae4290fdd22
|
||||||
|
|
Loading…
Reference in a new issue