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

ignore non-json lines in cargoBuildLog #234

Merged
merged 3 commits into from
Feb 11, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Fixed
* `buildPackage` is more tolerant of misbehaving proc macros which write to
stdout during the build

## [0.11.1] - 2023-01-21

### Changed
Expand Down
16 changes: 16 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ in
touch $out
'';

# https://github.com/ipetkov/crane/pull/234
nonJsonCargoBuildLog =
let
nonJson = ''
db_id attr "field_id" Attribute { pound_token: Pound, style: Outer, bracket_token: Bracket, path: Path { leading_colon: None, segments: [PathSegment { ident: Ident { ident: "db_id", span: #0 bytes(8250..8255) }, arguments: None }] }, tokens: TokenStream [] }
'';
in
myLib.buildPackage {
src = myLib.cleanCargoSource ./simple;
buildPhaseCargoCommand = ''
cargoBuildLog=$(mktemp cargoBuildLogXXXX.json)
cargoWithProfile build --message-format json-render-diagnostics >"$cargoBuildLog"
echo "${nonJson}" >>"$cargoBuildLog"
'';
};

# https://github.com/ipetkov/crane/discussions/203
dependencyBuildScriptPerms = myLib.cargoClippy {
src = ./dependencyBuildScriptPerms;
Expand Down
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