Commit graph

2545 commits

Author SHA1 Message Date
colincross
f401db416d Merge pull request #65 from colincross/propertyerrors
Improve PropertyErrorf
2015-11-03 14:42:24 -08:00
colincross
cd206b2ca0 Merge pull request #66 from colincross/othermodule
Add OtherModuleName and OtherModuleErrorf to mutators
2015-11-03 14:42:07 -08:00
Colin Cross
8d22233f80 Add OtherModuleName and OtherModuleErrorf to mutators
TopDownMutators can visit dependencies, provide OtherModuleName and
OtherModuleErrorf so they can query and report errors on those
dependencies.
2015-11-03 14:31:39 -08:00
Colin Cross
a2ca92c962 Improve PropertyErrorf
PropertyErrorf gets called from build logic, and shouldn't panic if the
build logic reports an error on an unset property.  Fall back to using
the module position if the property wasn't set.

Also put the property name into the error message.
2015-11-03 14:31:19 -08:00
colincross
f95966fae8 Merge pull request #64 from colincross/appendproperties
Generic append properties, and *bool support
2015-11-02 18:35:09 -08:00
Colin Cross
e4b0d35966 Add proptools.TypeEqual
When appending properties, it may be necessary to determine if two
property structs are the same "type".  A simple Go type comparison is
not sufficient, as there may be interface{} values in the property
structs that contain different types.  Add proptools.TypeEqual that
returns true if they have equal types and all embedded pointers to
structs and interfaces to pointers to structs have the same nilitude and
type.
2015-11-02 15:40:55 -08:00
Colin Cross
8011768729 Add property support for pointers to bools and strings
The only append semantics for bool that result in a no-op when the zero
value is appended is to OR the two values together, but that is rarely
the desired semantics.  Add support for *bool and *string as property
types, where appending a nil pointer is a no-op.  For *bool, appending a
non-nil pointer replaces the destination with the value.  For *string,
appending a non-nil pointer appends the value.

This also provides a more reliable replacement for
ModuleContext.ContainsProperty, as the  build logic can tell that the
property was set, even if it was set by a  mutator and not by the
blueprints file, by testing against nil.

[]string already provides these semantics for lists.

Setting a *bool or *string property from a blueprints file is the same
syntax as setting a bool or a string property.
2015-11-02 13:59:12 -08:00
Colin Cross
ecca05efb2 Fix unpacking empty list
Add a test for unpacking empty list properties and fix a bug that
resulted in nil slice instead of an empty slice.
2015-10-31 21:33:32 -07:00
Colin Cross
f72ef5023c Fix bugs in CloneProperties and related functions
Add tests for CloneProperties, CloneEmptyProperties and ZeroProperties
and fix detected bugs related to nil pointers to structs and interfaces
containing nil pointers to structs.
2015-10-31 20:10:20 -07:00
Colin Cross
8169500cdd Move CloneProperties to clone.go
Move CloneProperties, CloneEmptyProperties, and ZeroProperties from
proptools/proptools.go to proptools/clone.go.
2015-10-31 20:10:20 -07:00
Colin Cross
0bc7e077eb Add helpers for extending properties to proptools
It is common for a mutator to append or prepend property structs
together.  Add helper functions to append or prepend properties in property
structs.  The append operation is defined as appending string and slices
of strings normally, OR-ing bool values, and recursing into embedded
structs, pointers to structs, and interfaces containing pointers to
structs.  Appending or prepending the zero value of a property will
always be a no-op.
2015-10-31 20:09:58 -07:00
colincross
75c938b6ed Merge pull request #63 from colincross/deprecate
Deprecate EarlyMutator and DynamicDependencies
2015-10-30 20:59:20 -07:00
Colin Cross
763b6f18fa Deprecate EarlyMutator and DynamicDependencies
DynamicDependencies can be implemented more flexibly by a
BottomUpMutator.  If there are no DynamicDependencies, then
EarlyMutators are identical to BottomUpMutators.  Deperecate both, and
reimplement DynamicDependencies inside a BottomUpMutator that is
guaranteed to be registered first.
2015-10-29 16:03:37 -07:00
jgennis
45021dcbbd Merge pull request #61 from yuchenericwu2/master
Add walkDeps to context and module_ctx.
2015-10-10 00:53:42 -07:00
Yuchen Wu
f995846a4b Added test for walkDeps. 2015-10-09 17:57:00 -07:00
Yuchen Wu
222e2458b1 Add walkDeps to context and module_ctx.
walkDeps performs a pre-order DFS (unlike visitDepsDepthFirst which is
a post-order DFS). The visit function takes in both a parent and child
node and returns a bool indicating if the child node should be
traversed.
2015-10-06 20:03:07 -07:00
Dan Willemsen
c10b5ed371 am 5aaa669b: Merge remote-tracking branch \'aosp/upstream\'
* commit '5aaa669beb3adefb167012ee6b66e476c8441723':
  Add a test runner
  Fix bugs related to local vs. inherited variables
2015-09-19 19:52:39 +00:00
Dan Willemsen
5aaa669beb Merge remote-tracking branch 'aosp/upstream' 2015-09-18 12:45:34 -07:00
colincross
e12c780957 Merge pull request #44 from colincross/local
Fix bugs related to local vs. inherited variables
2015-09-18 12:39:46 -07:00
colincross
1d92826852 Merge pull request #57 from danw/testrunner
Add a test runner
2015-09-18 10:55:28 -07:00
Dan Willemsen
c7697ce79d Add a test runner
This removes the need to use $OLDPWD when running tests, which means
that the builddir may be an absolute or relative directory. It also
filters out the "PASS" message on successful test runs to clean up our
output.

Change-Id: I4ab937c7a87b74fe997a47cc0311e2f357f9f7e9
2015-09-18 10:28:36 -07:00
Dan Willemsen
64dd0a55ed am 14735db1: Merge remote-tracking branch \'aosp/upstream\'
* commit '14735db1604c7bfc3daa9baf61573f83d18ca2d3':
  Stop using bootstrap.bash -b for separate builddir
2015-09-18 07:09:11 +00:00
Dan Willemsen
14735db160 Merge remote-tracking branch 'aosp/upstream' 2015-09-17 23:51:48 -07:00
colincross
d7f00ccf5f Merge pull request #58 from danw/builddir
Stop using bootstrap.bash -b for separate builddir
2015-09-17 23:36:47 -07:00
Dan Willemsen
991f7603cd Stop using bootstrap.bash -b for separate builddir
It's difficult for wrapping scripts to handle -b properly. Just pass
BUILDDIR instead, which is easier to handle. This still accepts -b, so
that incremental builds work across this change.
2015-09-17 23:18:03 -07:00
Dan Willemsen
d133d2e217 am ae9aa921: Merge remote-tracking branch \'aosp/upstream\'
* commit 'ae9aa9216e1b08df5c3a6cfec97b3dae9a94afbc':
  Implement plugins for bootstrap go modules
  Fix bootstrap and separate buildDir ninja cleanup
  context: Changed singletons to execute in order.
  bootstrap: Added phony rule for bootstrapManifest.
  Add new line to fatal error messages in bootstrap
  bpdoc: Cache property struct docs by full package path
2015-09-15 00:25:04 +00:00
Dan Willemsen
ae9aa9216e Merge remote-tracking branch 'aosp/upstream' 2015-09-14 16:36:46 -07:00
colincross
8282be78ee Merge pull request #49 from danw/plugins
Implement go bootstrap plugins
2015-09-14 16:01:46 -07:00
colincross
f5d4fb0626 Merge pull request #52 from kulakowski/patch-1
Add new line to fatal error messages in bootstrap
2015-09-14 16:00:28 -07:00
Dan Willemsen
fdeb724f74 Implement plugins for bootstrap go modules
Now that we have multi-stage bootstrapping, we can make the primary
builder build more dynamic. Add the concept of plugins that will be
linked and loaded into bootstrap_go_binary or bootstrap_go_package
modules. It's expected that the plugin's init() functions will do
whatever registration is necessary.

Example Blueprint definition:

    bootstrap_go_binary {
      name: "builder",
      ...
    }

    bootstrap_go_package {
      name: "plugin1",
      pluginFor: ["builder"],
    }

A package may specify more than one plugin if it will be inserted into
more than one go module.

Change-Id: I109835f444196b66fc4018c3fa36ba0875823184
2015-09-14 15:35:12 -07:00
colincross
5d353aac90 Merge pull request #55 from danw/bootstrapcleanup
Fix bootstrap and separate buildDir ninja cleanup
2015-09-14 14:02:27 -07:00
Dan Willemsen
4d6af1f89e Fix bootstrap and separate buildDir ninja cleanup
With the introduction of $buildDir in bootstrapDir, the ninja cleanup
step hasn't been able to cleanup during the bootstrap stages. The main
stage was unaffected, as long as you were using "." as your buildDir.

Change-Id: I277dd7864989f9052d96cab9ce377548a1391a80
2015-09-14 13:39:34 -07:00
colincross
9cdb70b93b Merge pull request #54 from yuchenericwu2/singleton_order
context: Changed singletons to execute in order.
2015-08-25 22:48:44 -07:00
colincross
f7ed4e4708 Merge pull request #53 from yuchenericwu2/fix_phony
bootstrap: Added phony rule for bootstrapManifest.
2015-08-25 22:47:47 -07:00
Yuchen Wu
b9103efe17 context: Changed singletons to execute in order.
Replaced map with list so that singletons will execute in the order
that they were listed.

Change-Id: I62919b14110b2b6f1f31c18f249ca64b85898ab1
2015-08-25 18:10:40 -07:00
Yuchen Wu
e4a8450909 bootstrap: Added phony rule for bootstrapManifest.
This is for stageMain and prevents build.ninja.in from being
accidentally deleted.

Change-Id: I9675874c61c3db0bf34c47498968623b8c183e95
2015-08-25 17:55:42 -07:00
George Kulakowski
4904c8ab3f Add new line to fatal error messages in bootstrap 2015-08-21 14:47:06 -07:00
colincross
db6eddb7f1 Merge pull request #51 from colincross/docs
bpdoc: Cache property struct docs by full package path
2015-08-20 15:58:51 -07:00
Colin Cross
34d3fe9f2b bpdoc: Cache property struct docs by full package path
The full package path is no longer stored in the name variable, pass the
pkg variable into getDocs and putDocs so that types with the same name
in different packages don't collide.

Change-Id: I7ecd98815487467dbaadc8a318fa43b123fc83c1
2015-08-12 18:05:41 -07:00
Colin Cross
d3c7e91d73 am 150e16ea: Merge remote-tracking branch \'aosp/upstream\'
* commit '150e16eab079358d95097f078c975d1b5933918f': (162 commits)
  Support go 1.5
  Fix bootstrap package build stage default
  Support a separate build directory
  Switch bootstrap.BinDir to a StaticVariable
  Use three stage builds
  Enhance bootstrap stage selection
  Add test suite for bootstrapping
  Switch to custom-built ninja v1.6.0
  Migrate to container-based travis infrastructure
  Fix running travis on forked repos
  Require ninja 1.6.0, remove workaround
  Don't print module header if nothing is defined
  Fix a sub-Blueprints deps bug.
  Add deep Copy() for parser types
  Refactor parsing to allow reuse
  Add convenience methods to Comment objects
  Add self-documenting support
  Support filtering nested structures by tag
  Add option to build and run tests during bootstrap
  Create internal bootstrap Config struct
  ...
2015-08-07 00:54:48 +00:00
Colin Cross
150e16eab0 Merge remote-tracking branch 'aosp/upstream'
Change-Id: I3b2df046fc8738c0c05c7b64e13667bcd1f30be8
2015-08-06 14:24:57 -07:00
colincross
f57f20c57b Merge pull request #48 from danw/go1.5
Support go 1.5
2015-08-06 13:27:00 -07:00
Dan Willemsen
c20adeac4b Support go 1.5
The go compiler and linker changed in v1.5 -- to 'go tool compile' and
'go tool link' instead of 6g and 6l. Move the selection logic to
bootstrap.bash, and have it use compile/link if 6g/6l are missing. This
way the build.ninja.in will continue working with either go 1.4 or 1.5.

Travis and the test suite will fail under 1.5, since the build.ninja.in
is still generated with 1.4, and the function names in the comments
differ between 1.4 and 1.5.
2015-08-03 16:16:24 -07:00
Colin Cross
6d8780f724 Fix bugs related to local vs. inherited variables
The Go race detector found a race condition in the parser, which
 highlighted a few related bugs. A variable could be defined but
not referenced in a Blueprints file, then appended to in multiple
subdirs= Blueprints files.  The race detector caught the multiple
writes to assignment.Referenced from the parsers for the subdirs
Blueprints files, but multiple appends would be much more serious.

To fix this, keep local and inherited variables separate in the
Scope object and export that info to the parser.  Disallow
appending to non-local variables, which was already the intended
behavior.  Only update the referenced boolean for local variables.
Together, this should prevent all writes to Assignment objects
from parsers other than the one that created them.

Also improves the error handling code and some error messages.

Change-Id: Idb4f7d2e61bbe28d90b93074764e64e60d1eba8f
2015-08-03 16:08:16 -07:00
colincross
421a699949 Merge pull request #45 from danw/builddir
Support a separate build directory
2015-08-03 16:06:16 -07:00
colincross
268404b73b Merge pull request #50 from danw/multistage-pkgfix
Fix bootstrap package build stage default
2015-08-01 21:39:34 -07:00
Dan Willemsen
735873d8c5 Fix bootstrap package build stage default
Packages were defaulting to StageBootstrap, while they need to be in
StagePrimary and they'll be moved into StageBootstrap if necessary.
2015-08-01 21:34:13 -07:00
Dan Willemsen
f0ca90124a Support a separate build directory
To provide a consistent __FILE__ behavior with cpp, we want to be able
to run with SRCDIR="." and the outputs be saved elsewhere. Other tools
within android also expect to be run from $TOP.

Change-Id: I572bce5c9086b0c3310b42065ae98cbf5a1c6399
2015-08-01 20:07:37 -07:00
Dan Willemsen
852191db67 Switch bootstrap.BinDir to a StaticVariable
API Change -- will require changes to any code using bootstrap.BinDir

This way we can put references to other variables in BinDir, and still
be used properly by other packages.

Change-Id: I497424cb254b3a170401ac9420fa0adbf8d11d1e
2015-08-01 15:46:19 -07:00
colincross
30b0f16728 Merge pull request #46 from danw/multistagebootstrap
Multi-stage bootstrapping
2015-07-30 17:24:32 -07:00