Commit graph

727 commits

Author SHA1 Message Date
Jeff Gaston
a12f22fb69 Move parseOne for readability
Bug: 64363847
Test: m -j
Change-Id: Ie3e973dadbff139def127b0bb05c57bafb79165b
2017-10-30 15:00:19 -07:00
Jeff Gaston
5f763d0511 Clarify context.go somewhat
in preparation to support parsing a predefined list of Blueprints files

Bug: 64363847
Test: m -j
Change-Id: I98cc98dc17ecaf69b95272d32cd83adbdb0e8c5b
2017-10-30 15:00:19 -07:00
colincross
eb6192cf66
Merge pull request #180 from colincross/createmodule
Set fields in CreateModule to match current module
2017-10-27 22:36:05 -07:00
Colin Cross
1fa1a14853 Set fields in CreateModule to match current module
When a mutator calls CreateModule, set the blueprints file and line
number to the values of the module that the mutator was visiting.

Change-Id: I4526f14a744be944e42582bc46f11a9a7b502f03
2017-10-27 16:32:15 -07:00
colincross
c63f1fd784 Merge pull request #179 from colincross/fmt
Finish switching blueprint back to the original Blueprints format
2017-10-19 15:42:22 -07:00
Colin Cross
4a0fe087b1 Finish switching blueprint back to the original Blueprints format
An ill-fated experiment with using a format that was closer to
Bazel left Blueprint preferring the original style, but documenting
and using the new style.  Update the documentation and run bpfmt -w.

Test: builds
Change-Id: I3fb70c8fa50c332da01cf5912b179c60d1638814
2017-10-19 15:33:11 -07:00
Jeff
5029114553 Merge pull request #157 from mathjeff/dedup-utils
Utils to support removing duplicate shared_libs
2017-10-19 13:41:50 -07:00
Jeff
e2b2ab6005 Merge pull request #175 from mathjeff/bpfmt-stdout
Have bpfmt show usage when run without any arguments
2017-10-19 13:40:49 -07:00
Dan Willemsen
2f769ef470 Merge pull request #178 from danw/microfactory_locking
Add file locking to microfactory
2017-10-18 16:37:39 -07: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
Dan Willemsen
987ed9ba29 Add file locking to microfactory
To prevent against multiple instances attempting to rebuild the same
executable, add a file lock to Build().

The trace file may not be consistent in this case, but everything that
reads it should be able to handle a corrupted trace file.

Test: `while true; do <microfactory-enabled executable>; done` in
parallel, and modify the code to microfactory (echo "//"
>>microfactory.go)
Change-Id: I30cb22bb9c790c57c507354127d4a5f82526a489
2017-10-18 15:11:03 -07:00
colincross
5fa3f89f2c Merge pull request #177 from colincross/docs
Fix property documentation bugs
2017-10-17 21:58:53 -07:00
Colin Cross
7311337d4c Support preformatted property documentation
Treat any property documentation lines that are indented as
preformatted.

Bug: 67909957
Test: manual inspection
Change-Id: Ib014bc301880eca02c60ed1692e49f07dca05fb3
2017-10-17 18:01:53 -07:00
Colin Cross
4ef23afc91 HTML escape property documentation
Property documentation that contained text that looked like HTML
tags was getting passed through.  Use html/template instead of
text/template so that it gets escaped automatically.

Bug: 67909957
Test: manual inspection
Change-Id: I2050c34c04d7be3cdacd5a76967a739f9f837e89
2017-10-17 18:01:53 -07:00
colincross
957b96b1ae Merge pull request #176 from colincross/commandorderonly
Allow rules to specify order-only dependencies
2017-10-17 16:35:38 -07:00
Colin Cross
47113641cd Allow rules to specify order-only dependencies
Commands that contain tools that don't affect the build results
may want an order-only dependency on the tool.  Allow rules
to specify order-only dependencies the same way they specify
implicit dependencies.

Test: builds
Change-Id: I3e0f886ae047b0fadf7a5c0dfeb9827d2c5c411d
2017-10-17 13:50:49 -07:00
colincross
afa12b4744 Merge pull request #174 from colincross/glob
Fix recursive glob on MockFs
2017-10-05 16:09:08 -07:00
Colin Cross
a4fae90d1e Fix recursive glob on MockFs
Recursive globs on MockFs were ending up in an unmocked os.Lstat
call in walkAllDirs.  Move walkAllDirs into the FileSystem interface
as ListDirsRecursive.

Also duplicate the glob tests on both the real filesystem and on
MockFs.

Test: glob_test.go
Change-Id: Ia6b6b5eecdd17955a49d684a0fd5e55df05cfe62
2017-10-05 16:06:15 -07:00
colincross
b67c1d433c Merge pull request #166 from colincross/create
Add TopDownMutatorContext.CreateModule
2017-09-20 14:09:15 -07:00
Dan Willemsen
05dc49bcad Merge pull request #172 from danw/go1.9
Use go1.9 instead of go1.9rc1
2017-09-13 18:18:18 -07:00
Dan Willemsen
491166d7fa Merge pull request #171 from danw/go_genrule
Expose the installed path for Go binaries
2017-09-13 18:18:09 -07:00
Dan Willemsen
b8534bf280 Use go1.9 instead of go1.9rc1
Change-Id: Id698eff8efeb723f8665c0358cdb0cfca4d5f776
2017-09-13 16:50:27 -07:00
Dan Willemsen
87f71fa623 Expose the installed path for Go binaries
In case the primary builder wants to depend on a go binary by name,
expose an interface to find the real installed path of the binary.

Most of this change is changing it so that we're storing the install
path without any ninja references.

Change-Id: I873378ebdd47d8036d3cef5aab76f036846a3db1
2017-09-13 15:30:54 -07:00
colincross
c40ef075f4 Merge pull request #158 from mathjeff/travis-link
Remove src.test after running Travis tests
2017-09-13 10:12:01 -07:00
Jeff Gaston
5f332c83ae Move generated Travis test dirs outside the tree
This should prevent the running of Travis tests from causing
a filesystem loop src.test/test_tree/blueprint -> ../..

Bug: 63100441
Test: NINJA=... ./tests/test_tree_tests.sh; stat src.test 2>/dev/null \
      && echo "src.test should not exist"

Change-Id: Ie01fe8999c738dca166e3fabde9d9391f6b70210
2017-09-12 17:58:10 -07:00
colincross
1ff2efa021 Merge pull request #170 from mathjeff/symlink-err
Clearer error in case of Android.bp being unreadable
2017-09-06 17:16:08 -07:00
Jeff Gaston
aca4220583 Clearer error in case of Android.bp being unreadable
Bug: 64600838
Test: mkdir errtest \
      && ln -s /tmp/dontexist errtest/Android.bp \
      # and add errtest to ./Android.bp \
      && m nothing \
      # and check that the error message mentions a symlink

Change-Id: I841ec12d613f61ccc3396538062bee48c8c1ca27
2017-09-01 17:29:30 -07:00
Dan Willemsen
64c10381ad Make microfactory support go build tags
This is necessary to support other go code that uses build tags to
control which files build on which platforms. For example, the
github.com/golang/protobuf/proto package includes two implementations of
pointer:

 pointer_reflect:
  // ...

  // +build appengine js

  // This file contains an implementation of proto field accesses using package reflect.
  // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
  // be used on App Engine.

 pointer_unsafe.go:
  // ...

  // +build !appengine,!js

  // This file contains the implementation of the proto field accesses using package unsafe.

Without this change, microfactory tries to include both files, which
breaks, since that enables multiple implementations of the same symbols.
This implements the logic to find the +build comments (following the
spirit of the functionality in go/build, even though they make different
choices of parsers), and the logic to match the tags to the current
system (which isn't exported as public API, so we have a simplified
version).

Since we're only parsing the comments before the import statement, this
does not significantly affect performance.

Test: Build github.com/golang/protobuf/proto
Change-Id: I10c48472d3f9f3e96b800a5d7c15450b1737002b
2017-08-23 16:34:16 -07:00
Dan Willemsen
18a0d2e9b5 Merge pull request #167 from danw/microfactory
Export microfactory as a package
2017-08-08 15:29:55 -07:00
Dan Willemsen
269248ff2d Support custom trace functions
Change-Id: I43207fd55f79d4adb783ad39eb5ee1b641ecce68
2017-08-08 13:50:44 -07:00
Dan Willemsen
5136c43117 Implement microfactory Config, Build
To make it easier to use as a package.

Change-Id: Idcb4856f34b91943a320e8281ef9e29af0faab98
2017-08-08 13:49:07 -07:00
Dan Willemsen
ff092863b3 Allow microfactory to be used as a package
In addition to running with `go run` and creating a microfactory binary,
allow microfactory to be used as a package from other go tools as well.

To allow other packages to use this, it needs to be in a non-main
package, but `go run` requires a main package. So microfactory.bash runs
a sed script before running microfactory with `go run`.

This could also be solved by using a relative import, but neither
blueprint nor microfactory currently support that.

Change-Id: I084163b14720102b3fb93a3c9d44b5d0225ff2c8
2017-08-08 13:19:26 -07:00
Dan Willemsen
f00c03da53 Stop passing path to microfactory source
It can be discovered via the existing pkg-path mappings.

Change-Id: I0b6ad7a9cccec195d602508104d6cf1e80936299
2017-08-08 13:05:02 -07:00
Colin Cross
d40859438e travis: run short tests with race detector enabled
Change-Id: I333d01547c4b8061fcc45b5079e97fa617cf0878
2017-08-01 15:12:12 -07:00
Colin Cross
874a346904 Let mutators use ctx.AddNinjaFileDeps
Propagate extra ninja file deps through mutators so that they
can use ctx.AddNinjaFileDeps.

Test: blueprint tests
Change-Id: I299a0665c3f63b020ae345889fd78b91b91b215a
2017-08-01 15:12:12 -07:00
Colin Cross
af4fd215eb Add TopDownMutatorContext.CreateModule
Allow a module to create other modules as if they were specified
in a blueprint file.  CreateModule takes the name of a module type,
calls the factory function the module type, and then inserts
properties into the property structs returned by the factory.

Bug: 64161749
Test: TestCreateModule
Change-Id: Ic1903305d6b08eae1edc7f0fb4137e85544aac0f
2017-08-01 15:12:12 -07:00
Colin Cross
05b3607c37 Replace unpack's replace semantics with append
Blueprint was using "replace" semantics when unpacking properties
into property structs, meaning if a module factory pre-set property
values they would be overwritten by whatever was in the Blueprint
file.  This is different than what would happen if the same property
was updated using the Append*Properties functions in proptools, which
would use "append" semantics, which append strings and lists,
logically ORs booleans and replaces pointers to strings and booleans.
Replace unpack's semantics with append semantics for consistency.
Any previous users of pre-set properties can move to using a pointer
to a string or boolean if they want the old behavior.

Test: unpack_test.go
Test: extend_test.go
Change-Id: I02eebe80916e578938142f8e76889bd985223afc
2017-08-01 15:12:12 -07:00
Colin Cross
5fe225f5f9 Rename newModules to newVariations
The next patch will introduce creating new modules, so rename the
current variable that contains new variations of existing modules
to avoid confusion.

Test: blueprint tests
Change-Id: Ic1d3824e54e51c282a08f8ecef8fc658cc503a65
2017-08-01 15:12:12 -07:00
Colin Cross
d2f4ac1224 Rename moduleInfo.moduleProperties to properties
Remove unnecessary name duplication.

Test: blueprint tests
Change-Id: I2c65ce6a164e47e855dd3bb1c7bee957dfd422ae
2017-08-01 15:12:12 -07:00
Dan Willemsen
3048433458 Merge pull request #165 from danw/go1.9
Go 1.9 changes
2017-07-25 16:53:23 -07:00
Dan Willemsen
a4363454c8 Workaround gimme not setting GOROOT
This appears to be fixed in gimme 1.2.0, but that's not available in
Travis yet (even in the latest trusty images). This is the gimme change
to always set GOROOT:

913dd17ff3

Change-Id: Ic9024b4bbbf5c75ed162a03fe119e4db9a1cdbba
2017-07-25 16:11:14 -07:00
Dan Willemsen
91ec9f4b7a Export GOROOT for minibp / primary builder
Otherwise they'll fall back to the GOROOT embedded in the distribution,
which may not be correct.

This used to be propagated through build.ninja.in, but exporting it in
the environment should catch any other Go users too.

Change-Id: I3d6de8494b266e9b127c0a528d31df03ddc5c3a0
2017-07-25 13:05:55 -07:00
Dan Willemsen
c54c072667 Support parallel Go compiles with Go 1.9
Change-Id: I80f3ad6e563fef1b4f22e936016675262f7ce8bf
2017-07-25 11:08:20 -07:00
Dan Willemsen
53d563facb Fix build on Go 1.9
Change-Id: Ie471f396b22cd88104b4f05dbcf3677c7ffd5f08
2017-07-25 10:45:51 -07:00
Dan Willemsen
f94ab1e486 Merge pull request #164 from danw/microfactory
Simplify bootstrapping with microfactory
2017-07-24 15:28:00 -07:00
Dan Willemsen
feb1a225f2 Update documentation
Change-Id: I59daf7802a1b04961d0372c2417869ad9bd6d0b2
2017-07-24 14:02:51 -07:00
Dan Willemsen
cd4e0cebc9 Unify .ninja_log files
Having separate .ninja_log files doesn't work very well after
04d886b110
since the last successful timestamp is not recorded in the ninja log.
This was triggering the primary builder to be run twice on every build
since it was always considered out of date in the primary, then main
stages.

The two bootstrap stages already were unified when minibootstrap was
simplified, but this combines the main stage as well. This means that
we'll save some time running globs that are shared between minibp and
the primary builder as well (subdirs globs).

The cleanup code needed to be refactored, since the ninja_log will have
entries from the main stage as well. So instead of looking at everything
in the ninja log, take a string prefix to limit what we may clean.

Change-Id: I8d43168643aa8a0c6c3e48c6101eaa45d174bbe5
2017-07-24 14:02:51 -07:00
Dan Willemsen
af456eaae4 Define everything in both stages
Now that packages and binaries are only built when needed, they need to
be defined in both stages in case something building in the main stage
needs something that was defined, but didn't need to be built in the
earlier stage.

Change-Id: I67704fba1d670e82218eba5ce91f0c01896557a2
2017-07-24 14:02:51 -07:00
Dan Willemsen
f60525a63d Mark intermediates as optional
Instead of forcing things to be built alongside the primary builder,
mark all packages and binaries as optional, unless they're explicitly
marked as default.

Change-Id: Ie53c90a01b41ce886d651f9aa4c4900d1edb0157
2017-07-24 14:02:51 -07:00