Skip to content

Conversation

@andyross
Copy link
Contributor

[Following discussion in #10342 #10383 #10385 . The "right way" turns out to be a pretty simple change to a simple script. Note that this is only tested piecewise, as I don't know how to run the backend that actually needs srcmap and was running a copy of the script manually. Also presumably needs documentation somewhere.]

srcmap: Augment to allow project-specified repository maps

The heuristics in this script don't match all possible projects, and
in particular the west tool used by sound-open-firmware doesn't
conform to its expectations (and can provide this info in a more
authoritative way regardless).

Allow the project to emit a "$SRC/srcmap.json" file in its build
image, and use that where present instead of trying to guess.

andyross added 2 commits May 25, 2023 09:07
The heuristics in this script don't match all possible projects, and
in particular the west tool used by sound-open-firmware doesn't
conform to its expectations (and can provide this info in a more
authoritative way regardless).

Allow the project to emit a "$SRC/srcmap.json" file in its build
image, and use that where present instead of trying to guess.

Signed-off-by: Andy Ross <andyross@google.com>
West knows the source layout authoritatively, but doesn't quite match
the rules expected by srcmap.  Generate the JSON for it instead.

Signed-off-by: Andy Ross <andyross@google.com>
@andyross
Copy link
Contributor Author

@jonathanmetzman
Copy link
Contributor

Do we need this to support your project? Sorry if I wasn't clear in past discussions, but I want to avoid modifying our infra, even if it means forcing a few users to do the same hack in the future.

@jonathanmetzman
Copy link
Contributor

I really appreciate your willingness to help though!

Copy link

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to support your project?

This PR looks like a smart way to support ANY project where the git structure is anything slightly off the most basic "git clone http://project".

Sorry if I wasn't clear in past discussions, but I want to avoid modifying our infra, even if it means forcing a few users to do the same hack in the future.

Letting projects emit their own SRCMAP looks to me like the best way to "avoid infra modifications" by "forcing users" to adjust to oss-fuzz / SRCMAP expectations.

Moreover it seems very reliable, killing all risk of false negatives. Either the SRCMAP is there and then the information is correct, or SRCMAP is missing and the whole thing fails. No scanning of the wrong version because "origin" points at the wrong branch.

My 2 cents.

echo " \"type\": \"git\","
echo " \"url\": \"$url\","
echo " \"rev\": \"$rev\""
echo -n " }"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cat <<EOFJSON
"$SRC/sof/$dir": {
 ...
}
EOFJSON

west list -f '{path} {url} {sha}' | sed 1d | while read dir url rev; do

# Silly logic to suppress trailing comma
if [ "$FIRST_REC" = yes ]; then
Copy link

@marc-hb marc-hb May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use jq -n -f trailing_commas.json > clean.json to remove trailing commas.

As a bonus it will pretty-print.

https://github.com/stedolan/jq/wiki/FAQ#processing-not-quite-valid-json

@andyross
Copy link
Contributor Author

andyross commented Jul 3, 2024

close ancient PR

@andyross andyross closed this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants