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

build: add execute of bear tool on top of build #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsarzy
Copy link
Contributor

@jsarzy jsarzy commented Mar 3, 2023

Description

If bear executable is available, execute it on top of build to generate compilation database. The database is stored in _build/$TARGET as compile_commands.json.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: ia32-generic-qemu

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

If `bear` executable is available, execute it on top of build to
generate compilation database. The database is stored in
_build/$TARGET as compile_commands.json.

JIRA: CI-127
@jsarzy
Copy link
Contributor Author

jsarzy commented Mar 3, 2023

I'm goin to add bear to phoenixrtos/build image.

@jsarzy jsarzy marked this pull request as ready for review March 3, 2023 13:11
@jsarzy jsarzy requested a review from nalajcie March 3, 2023 13:11
Copy link
Member

@nalajcie nalajcie left a comment

Choose a reason for hiding this comment

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

some nitpicks

@@ -103,6 +103,22 @@ for i in "${ARGS[@]}"; do
esac;
done

if ! command -v /bin/bear &> /dev/null; then
echo "'bear' executable not found. Compilation database will not be built"
elif [ -z "${DO_NOT_EXEC_BEAR+x}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

i think +x should not be needed (you're setting it to non-empty string), but this is also ok (just less common so more knowledge of how bash works is needed)

elif [ -z "${DO_NOT_EXEC_BEAR+x}" ]; then
b_log "Running bear on top of build script"

OUTPUT_FILE=_build/"$TARGET"/compile_commands.json
Copy link
Member

Choose a reason for hiding this comment

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

maybe put full value in "

Suggested change
OUTPUT_FILE=_build/"$TARGET"/compile_commands.json
OUTPUT_FILE="_build/$TARGET/compile_commands.json"

b_log "Running bear on top of build script"

OUTPUT_FILE=_build/"$TARGET"/compile_commands.json

Copy link
Member

Choose a reason for hiding this comment

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

maybe: ln -sf "$OUTPUT_FILE" ./compile_commands.json to provide compilation database in project root for other tools to reuse it.

Also: if You do it, there is no need to pass OUTPUT_FILE to the bear directly (will be handled by symlink).

If You decide on doing the global symlink please add it to .gitignore and probably clean it up on clean command

@@ -103,6 +103,22 @@ for i in "${ARGS[@]}"; do
esac;
done

if ! command -v /bin/bear &> /dev/null; then
Copy link
Member

Choose a reason for hiding this comment

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

not sure if this (re-exec) shouldn't be a first thing in the file. If build.project would contain eg. CFLAGS="$CFLAGS -O2" we will append -O2 twice (source + export + re-exec + second source)

Copy link
Member

Choose a reason for hiding this comment

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

also: don't assume bear is installed in bin

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.

2 participants