Commit graph

9 commits

Author SHA1 Message Date
Cole Faust
1e62c68bfe
Separate blueprint parsing and evaluating
Before this cl, blueprint expressions were evaluated as they were
parsed. We want to add a feature to select statements where we can
bind the value of soome value from soong into a blueprint variable,
that then can be used like a regular variable in the .bp file. This
means that select statements need to hold whole unevalated expression
trees, and have the ability to evaluate them later on when the value
of the bound variable is known.

This cl doesn't implement the new select syntax, but it does split
blueprint's parsing and evaluating into two separate stages. We also
store expressions in selects and evaluate them when the select is
resolved.

I didn't do extensive performance evaluation, but a simple comparison
of the time of `touch Android.bp && m nothing` before/after this cl
showed a 1 second speedup. (That was probably just noise)

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I12f373719991afeb4aec76517153f32229d97ff2
2024-10-24 19:18:21 +02:00
Rashid Zaman
a29ee638ea bpfmt: Process all blueprint files when a directory is specified
Currently when a directory path is specified bpfmt only processes files
named "Blueprints" so change this to also process files with a `.bp`
suffix.

Test: Manual + bpfmt -d frameworks/base/services shows differences

Change-Id: I5a6356f387892934ee8e83362db13cda6156ed51
Signed-off-by: Rashid Zaman <rashidz@meta.com>
2023-08-04 01:01:55 -07:00
Hunter Knepshield
9033c957b9 Make bpfmt use exit codes even when reading from stdin.
Previously, an incantation like `bpfmt -o <$BAD_BP` would print to
stderr as expected, but then it would exit with 0. This is different
than the behavior of `bpfmt -o $BAD_BP`, which correctly exits with a
non-zero status code (in addition to printing the issues to stderr).

Test: m bpfmt; out/soong/host/linux-x86/bin/bpfmt -o <$BAD_BP; echo $?
Change-Id: I0a970cddf94fbd818525f9167d9113086b023c81
2021-02-17 20:24:50 -08:00
Colin Cross
e52c33c61c Correctly report errors in bpfmt
bpfmt was always exiting with return code 0, make it use the
exitCode recorded when reporting errors.

Also use the usage function.

Test: bpfmt -o bpfmt.go
Test: bpfmt
Test: bpfmt -h
Fixes: 113069050
Change-Id: I717d524c5f43cd36f52e33964a37324cc04c5df0
2019-05-21 11:03:00 -07:00
Colin Cross
c1d878159c Fix format issues found by go vet
Test: m checkbuild
Change-Id: I5135e0daecd20abce9a66631f5f55230168613de
2018-02-23 14:05:03 -08:00
Jeff Gaston
2ca94325bf Have bpfmt show usage when run without any arguments
This is partially in hopes of making it generally easier to use, and
partially in hopes of specifically making it less tempting to do

bpfmt Android.bp > Android.bp

which actually would just erase the contents of Android.bp

Test: bpfmt Android.bp 2>&1 | grep usage && echo ok
Bug: 67326589
Change-Id: I41c23aca6214f27dbdf55e5931f9392c318e82ed
2017-10-18 15:11:19 -07:00
Jeff Gaston
6cd6ebc768 Refactor in preparation to detect when stdout is the input file
Test: bpfmt -d Android.bp
Bug: 67326589

Change-Id: I5cd57a784848f70c7a1306161c40faa8e79cd44e
2017-10-18 15:11:18 -07:00
Jamie Gennis
6cafc2cddc Update import paths to include github 2015-03-21 01:03:36 -04:00
Colin Cross
3e8e74f276 Move blueprint/* up a directory
Make integrating with go tools easier by putting the blueprint package
files in the top level directory of the git project instead of in a
subdirectory called blueprint.

Change-Id: I35c144c5fe7ddf34e478d0c47c50b2f6c92c2a03
2015-01-23 14:23:27 -08:00
Renamed from blueprint/bpfmt/bpfmt.go (Browse further)