Commit graph

749 commits

Author SHA1 Message Date
Dan Willemsen
44d336bdb3 Add go.mod for go1.11 module support
This allows using the various go commands without a GOPATH.

Change-Id: I428ad3a4e884b68615e6e73168c5a844bad7c4d4
2018-07-21 13:02:56 -07:00
colincross
46d1070798
Merge pull request #214 from colincross/matchdirs
Support trailing slash in pathtools.Match patterns
2018-07-14 10:12:41 -07:00
Colin Cross
c0c3b0f946 Support trailing slash in pathtools.Match patterns
pathtools.Match was trimming the trailing slash from patterns.  Make
it handle a trailing slash by first confirming that both the pattern
and name either both have or both do not have a trailing slash, and
then trimming it from both.

Bug: 111389216
Test: TestMatch in glob_test.go
Change-Id: I743e00c14d885de5b5a060aa9e2b22c81dc7e09d
2018-07-13 21:20:03 -07:00
Dan Willemsen
f7d50937a2
Merge pull request #213 from danw/bpglob_bootstrap
Run globs during earlier bootstrap phases
2018-07-06 11:35:30 -07:00
Dan Willemsen
ab223a512b Run globs during earlier bootstrap phases
Instead of sometimes re-running minibp/the primary builder during the
next phase, run bpglob earlier to check dependencies.

We've run into issues where the environment is slightly different
between bootstrapping phase and the main build phase. It's also a
problem because our primary builder (Soong) exports information used by
another tool (Kati) that runs in between the bootstrapping phases and
the main phase. When Soong would run in the main phase, it could get out
of sync, and would require the build to be run again.

To do this, add a "subninja" include a build-globs.ninja file to each
build.ninja file. The first time, this will be an empty file, but we'll
always run minibp / the primary builder anyway. When the builder runs,
in addition to writing a dependency file, write out the
build-globs.ninja file with the rules to run bpglob.

Since bpglob may need to be run very early, before it would normally be
built, build it with microfactory.

Change-Id: I89fcd849a8729e892f163d40060ab90b5d4dfa5d
2018-07-06 10:39:38 -07:00
colincross
9cbbb8b91d
Merge pull request #212 from loganchien/stop-mixed-syntax
Emit errors on mixed property syntax
2018-06-25 21:25:59 -07:00
Logan Chien
3deba3df45 Emit errors on mixed property syntax
This commit refines `compat` condition in `parseProperty()` so that a
module definition would either use the new syntax or the old syntax,
but not something in the between, such as

    cc_library {
        name: "bad_example",
        srcs= ["bad.c"],
    }

Test: lunch aosp_arm64-userdebug; make  # runs unit test
Change-Id: If2d3e5d55edccc28d314d99b83b0f54e5c53ac35
2018-06-26 12:20:08 +08:00
colincross
3b3bd2aac0
Merge pull request #211 from colincross/multiple_deps
Prevent duplicate visit calls in WalkDeps
2018-06-21 14:53:13 -07:00
Colin Cross
526e02f0c6 Prevent duplicate visit calls in WalkDeps
WalkDeps was following every possible path through the dependency
tree, which can be enormous.  Modify it to only call visit for
any particular (child, parent) pair once for each direct dependency
by not recursing into child if visitDown returns true but child
has already been visited.

Test: TestWalkDeps, TestWalkDepsDuplicates
Change-Id: Ieef28399bd10e744417cdeb661dfa04fbeb4ec60
2018-06-21 13:41:42 -07:00
colincross
cd0310f225
Merge pull request #210 from colincross/multiple_deps
Allow multiple dependencies on the same module
2018-06-20 15:18:21 -07:00
Colin Cross
9607a9f248 Allow multiple dependencies on the same module
Allow adding multiple dependencies on the same module.  Adds a flag
to Context.walkDeps to determine whether dependencies should be
visited multiple times, and clarifies the behavior of
VisitDepsDepthFirst (continues to visit each module once, even if
there are multiple dependencies on it) and VisitDirectDeps (may
visit a module multiple times).

Test: TestWalkDepsDuplicates, TestVisit
Change-Id: I58afbe90490aca102d242d63e185386e1fe55d73
2018-06-20 14:10:18 -07:00
Dan Willemsen
3a16825a7c
Merge pull request #209 from danw/multiline_indent
Improve indentation for multi-line expressions
2018-05-07 18:11:20 -07:00
Dan Willemsen
d2c8162ca9 Improve indentation for multi-line expressions
When someone used a multiline string:

    cmd: "..." +
         "...",

bpfmt used to print this out as:

    cmd: "..." +
    "...",

This change doesn't do the quote alignment like I see in some of our
user-created instances of this, but it does indent a single level:

    cmd: "..." +
        "...",

Test: unit tests
Test: Compared bpfmt results before and after across AOSP
Change-Id: I61bf790be9d08a187857b2725facf71e8b38e372
2018-05-07 16:15:33 -07:00
Dan Willemsen
1e428e0c05
Merge pull request #208 from danw/microfactory_race
Disable parallel compilation when using race detector
2018-04-30 15:54:15 -07:00
Dan Willemsen
db29636ba2 Disable parallel compilation when using race detector
These options aren't compatible with one another.

Change-Id: I1ec52b8fa8465edd551bcd1c20a9a902a5669e52
2018-04-30 14:44:22 -07:00
colincross
bb58119655
Merge pull request #207 from colincross/nameinterface
Return an error when renaming a module that doesn't exist
2018-04-16 15:23:56 -07:00
Colin Cross
61fa603f92 Return an error when renaming a module that doesn't exist
Misusing Rename was causing a nil pointer derefernece, return
an error if group was not found in s.modules.

Bug: 77922456
Change-Id: I7e7b20b1595d569ae07c755bd29d701e0e5dab78
2018-04-16 14:44:41 -07:00
colincross
148f9f316e
Merge pull request #205 from colincross/goroutine
Reduce maximum goroutine count
2018-04-10 17:28:48 -07:00
colincross
e0d935660b
Merge pull request #206 from colincross/booldefault
Add proptools.BoolDefault and proptools.StringDefault
2018-04-10 17:28:36 -07:00
colincross
4106611b26
Merge pull request #204 from colincross/modify_text
Add Patch and PatchList for making textual changes
2018-04-10 16:54:24 -07:00
Colin Cross
de3ef3a66e Add proptools.BoolDefault and proptools.StringDefault
I get the logic wrong every time I try to make a *bool property
that defaults to true.

Change-Id: Idc409921c3a4baecf611acf348176f261712cb92
2018-04-10 16:51:47 -07:00
Colin Cross
7e72337259 Reduce maximum goroutine count
Running with the data race detector enabled hits a 8192 active
goroutine limit.  Reduce the maximum number of active goroutines
by limiting parallelVisit to 1000 goroutines.  Also rewrite
cloneModule in terms of parallelVisit.

Change-Id: Icdd63648e8e010557b624e12592156490b40adb9
2018-04-10 16:51:29 -07:00
Colin Cross
957b39cba5 Add Patch and PatchList for making textual changes
Patch and PatchList provide an API for making changes to substrings
of a Blueprint file by parsing the AST and using the token positions
to perform text replacements.

Test: modify_test.go
Change-Id: Ibb8993221982b54602ba5a05486198fab8d35a67
2018-04-10 16:50:39 -07:00
Colin Cross
fdeaf881f4 Make End() return the position after the node
End() was previously only used to determine if a comment was within
a Node, so it used the expedient definition of the position of the
last token in the node.  In the next patch it will be used for
capturing substrings of the Blueprint file, so make it point to
the character after the last token instead.

Also add tests for it.

Test: parser_test.go
Change-Id: Icaff3915b41e251ef9d0aad5615021bf37406aee
2018-04-10 16:43:51 -07:00
Dan Willemsen
ff2c5b4cc8
Merge pull request #203 from danw/numcpu_cap
Cap the number of cpus for Go compiles
2018-03-02 16:02:06 -08:00
Dan Willemsen
f75f4e9b7b
Merge pull request #202 from danw/go1.10_goroot
Try to make GOROOT relative in Go 1.10
2018-03-02 15:59:17 -08:00
Dan Willemsen
20c343b89e Cap the number of cpus for Go compiles
When passing "-c" to the Go compiler, any time this value changes, we'd
force all of the Go compiles to rebuild. This could trigger a
substantial portion of the tree to rebuild (anything that transitive
depends on a Go helper tool).

We're running into issues when moving output directories between
multiple GCE machines with different core counts, but are otherwise
identical. This could also hit users moving/mounting disks between
machines, though changes to other host tools can make an impact too.

On my 48-core machine, I get a ~15% benefit from going from -c 1 to -c
48, but also ~12% benefit from going from -c 1 to -c 8. So this will
still let us scale somewhat, but prevent rebuilds when transitioning
between machines that are more likely building Android.
2018-03-02 15:32:22 -08:00
Dan Willemsen
a1e6eeeb44 Try to make GOROOT relative in Go 1.10
In Go 1.10, runtime.GOROOT() will attempt to find the current location
of the go binaries, instead of using the GOROOT_FINAL that was baked
into the binaries. This means that GOROOT() will usually return an
absolute path.

We avoid putting absolute paths into the ninja file, since any change to
the paths would then cause all of the actions including it to rebuild.
Since we've got a decent number of build tools in Android using Go now,
this causes us to rebuild a decent portion of the tree.

Instead of passing the GOROOT around manually in a side channel, just
let the Go 1.10 detection do its thing, and always try to turn the
result into a relative path.
2018-03-02 15:29:35 -08:00
Dan Willemsen
774db4a8aa
Merge pull request #201 from danw/go1.10
Support go1.10
2018-02-27 10:50:20 -08:00
Dan Willemsen
e6d45fe39f Support go1.10
Add stubs for the new testDeps interface functions. Also removes testing
for 1.8.

Change-Id: Ice58cca20658d905df9fb87e822d7861abf60976
2018-02-27 01:49:49 -08:00
Dan Willemsen
77dc4de53e
Merge pull request #200 from danw/glob_dirs
Append / to directories in Glob results
2018-02-26 14:10:21 -08:00
Dan Willemsen
b6c90239d6 Append / to directories in Glob results
This makes it easy for users of Glob to detect whether the match is a
file or directory. Doing the check at this level means that the filelist
file used as a dependency will be updated if a directory is replaced
with a file of the same name, or vice versa.

Change-Id: I79ebba39327218bcdcf50b393498306119de9d6c
2018-02-23 17:21:37 -08:00
colincross
cd3b7aed33
Merge pull request #198 from colincross/glob
Fix glob cache conflict when excludes=nil and excludes=[]string{}
2018-02-23 14:23:37 -08:00
colincross
f12def88ce
Merge pull request #199 from colincross/vet
Fix format issues found by go vet
2018-02-23 14:23:17 -08: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
Colin Cross
54cb95a53f Fix glob cache conflict when excludes=nil and excludes=[]string{}
Performing the same glob twice, once with excludes=nil and once
with excludes=[]string{} would hit the same entry in the glob
cache (since the glob filename would be the same), but fail
the verifyGlob check because DeepEqual considers []string(nil)
and []string{} to be different.  Use a manual array check
instead.

Test: glob_test.go
Change-Id: If0d4fe80163a871077b7276e1b4a3e888a4a4898
2018-02-23 14:03:56 -08:00
Dan Willemsen
759bb61dd5
Merge pull request #196 from danw/ninja_deps
Store build.ninja deps in .ninja_deps
2017-12-18 12:26:58 -08:00
Dan Willemsen
2d9b59bc20 Store build.ninja deps in .ninja_deps
We're already going to load the .ninja_deps file, so we may as well use
it. These are the only two files in our build that don't.

Test: dump the .ninja_deps file, see the dependencies
2017-12-18 09:14:16 -08:00
colincross
7b8405f9c0
Merge pull request #195 from colincross/docs
Give primary builder more control over automated documentation
2017-12-11 19:27:42 -08:00
colincross
ee8fe641e9
Merge pull request #193 from colincross/glob
Limit length of glob result file names
2017-12-11 16:33:22 -08:00
Colin Cross
28b2843b78 Allow primary builder to stop bootstrap early
Allow the primary builder to stop bootstrap between
ResolveDependencies and PrepareBuildActions so that it can
use the build graph to write customized documentation.

Change-Id: I67ee5e6e438a0c2c3ec844c4c453d223971e60a2
2017-12-11 16:31:41 -08:00
Colin Cross
5eb116a46e Move auto-generated docs to main stage
Move the docs to the main stage and make a phony rule to build
them.  This will allow the primaray builder to choose not to
build them so that it can use its own rule instead.

Change-Id: Ib788f74717ccdcd85c2e5b6a581cc744d439341a
2017-12-11 16:31:41 -08:00
Colin Cross
92639f3fbb Refactor bpdoc
Separate the extraction of documentation-related info from writing
it out so that the primary builder can choose to write it out in
a customized format.

Change-Id: If2c91d6f13b8cea2e9e1cca75d8c2d684ad7f6df
2017-12-11 16:31:41 -08:00
Colin Cross
c581620795 Fix import list in singleton_ctx.go
Otherwise my editor keeps fixing it for me.

Change-Id: I2795a26b9a4f0dd7bf20edd146fc28425a60e89c
2017-12-11 16:31:41 -08:00
Colin Cross
741e14ebb9 Limit length of glob result file names
Glob names were appending every excluded file, which could result
in too many / characters for ninja to handle.  Use a hash if the
result contains too many / characters.

Change-Id: I88920f0596df49639a6c2b4f8af47ea8fdc1ee5a
2017-12-08 10:12:42 -08:00
Jeff
7a88d0db4d
Merge pull request #192 from mathjeff/propagate-syntax-errors
Fix propagating syntax errors to the user
2017-12-05 17:03:28 -08:00
Jeff
6b60fcefa3
Merge pull request #182 from mathjeff/microfactory-cmd-err
Update microfactory compile error message to show the command that fa…
2017-12-05 16:37:10 -08:00
Jeff Gaston
a7e408af0a prevent file=nil panic if syntax error in Blueprints
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'
Test: put a syntax error in a file and see that the
      reported error reports the location of the violation

Change-Id: Iaeedb91ea8e816cb8e9ee954f21cd6c6bc4afa48
2017-12-05 16:09:02 -08:00
Jeff Gaston
8fd9578a6a have openAndParse use return values rather than channels
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'

Change-Id: I941dfa76b94178198994a280eb40bcded891eda1
2017-12-05 15:26:57 -08:00
Jeff Gaston
5800d046c1 rename parseOneAsync to openAndParse
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'

Change-Id: I56e08716057c3746b01b7a5e43f0223ee1f940db
2017-12-05 15:26:57 -08:00