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

Allow verbose output in ct-ng images. #909

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow verbose output in ct-ng images.
  • Loading branch information
Alexhuszagh committed Jul 4, 2022
commit ef71dbee620bf40457acca4946ec507e0cc0d394
1 change: 1 addition & 0 deletions docker/Dockerfile.arm-unknown-linux-gnueabihf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/arm-unknown-linux-gnueabihf.config /
RUN /crosstool-ng.sh arm-unknown-linux-gnueabihf.config 5
Expand Down
17 changes: 13 additions & 4 deletions docker/crosstool-ng.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/bash

set -x
set -euo pipefail
set -eo pipefail

# shellcheck disable=SC1091
. lib.sh

silence_stdout() {
if [[ "${VERBOSE}" == "1" ]]; then
"${@}"
else
"${@}" >/dev/null
fi
}

main() {
local config="${1}"
local nproc="${2}"
Expand Down Expand Up @@ -75,14 +83,15 @@ main() {
# work with any bash functions: must call a command.
timeout "${timeout}" \
su "${username}" -c \
"STOP=${step} CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc} &> /dev/null"
"STOP=${step} CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc}"
}

while download; [ $? -eq 124 ]; do
while silence_stdout download; [ $? -eq 124 ]; do
# Indicates a timeout, repeat the command.
sleep "${sleep}"
done
su "${username}" -c "CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc} &> /dev/null"
silence_stdout su "${username}" \
-c "CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc}"

popd

Expand Down
9 changes: 6 additions & 3 deletions xtask/src/build_docker_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub struct BuildDockerImage {
#[clap(long, env = "LABELS")]
pub labels: Option<String>,
/// Provide verbose diagnostic output.
#[clap(short, long)]
pub verbose: bool,
#[clap(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
/// Do not print cross log messages.
#[clap(short, long)]
pub quiet: bool,
Expand Down Expand Up @@ -113,7 +113,7 @@ pub fn build_docker_image(
}: BuildDockerImage,
engine: &docker::Engine,
) -> cross::Result<()> {
let msg_info = MessageInfo::create(verbose, quiet, color.as_deref())?;
let msg_info = MessageInfo::create(verbose != 0, quiet, color.as_deref())?;
let metadata = cargo_metadata(msg_info)?;
let version = metadata
.get_package("cross")
Expand Down Expand Up @@ -236,6 +236,9 @@ pub fn build_docker_image(
for arg in &build_arg {
docker_build.args(&["--build-arg", arg]);
}
if verbose > 1 {
docker_build.args(&["--build-arg", "VERBOSE=1"]);
}

docker_build.arg(".");

Expand Down
3 changes: 2 additions & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub fn main() -> cross::Result<()> {
target_info::target_info(args, &engine)?;
}
Commands::BuildDockerImage(args) => {
let msg_info = MessageInfo::create(args.verbose, args.quiet, args.color.as_deref())?;
let msg_info =
MessageInfo::create(args.verbose != 0, args.quiet, args.color.as_deref())?;
let engine = get_container_engine(args.engine.as_deref(), msg_info)?;
build_docker_image::build_docker_image(args, &engine)?;
}
Expand Down