Skip to content

Commit

Permalink
fix: ignore non-json lines in cargoBuildLog
Browse files Browse the repository at this point in the history
Fixes issues with non-json values in cargoBuildLog: rust-lang/cargo#8179
  • Loading branch information
felschr committed Feb 10, 2023
1 parent 8c34e5e commit f211020
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/setupHooks/installFromCargoBuildLogHook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function installFromCargoBuildLog() (

echo searching for bins/libs to install from cargo build log at ${log}

local logs
logs=$(jq -R 'fromjson?' <"${log}")

local select_non_test='select(.reason == "compiler-artifact" and .profile.test == false)'
local select_bins="${select_non_test} | .executable | select(.!= null)"
local select_lib_files="${select_non_test}"'
Expand All @@ -29,12 +32,12 @@ function installFromCargoBuildLog() (
rmdir --ignore-fail-on-non-empty "${loc}"
}

jq -r <"${log}" "${select_bins}" | installArtifacts "${dest}/bin"
echo "${logs}" | jq -r "${select_bins}" | installArtifacts "${dest}/bin"

command cargo metadata --format-version 1 | jq '.workspace_members[]' | (
while IFS= read -r ws_member; do
local select_member_libs="select(.package_id == ${ws_member}) | ${select_lib_files}"
jq -r <"${log}" "${select_member_libs}" | installArtifacts "${dest}/lib"
echo "${logs}" | jq -r "${select_member_libs}" | installArtifacts "${dest}/lib"
done
)

Expand Down

0 comments on commit f211020

Please sign in to comment.