Commit graph

1430 commits

Author SHA1 Message Date
Dan Willemsen
a60c366614 Merge remote-tracking branch 'aosp/upstream' 2015-12-01 12:53:52 -08:00
Dan Willemsen
e8b63ad172 Merge pull request #84 from danw/pkgctx
Allow wrapping of PackageContext
2015-12-01 12:53:01 -08:00
Dan Willemsen
aeffbf776a Allow wrapping of PackageContext
Turn PackageContext into an interface so that build systems can wrap it
to add more custom helpers.

This does introduce an API change, though it should be fairly simple.
NewPackageContext used to provide an opaque *PackageContext struct, now it
provides a PackageContext interface.

Change-Id: I383c64a303d857ef5e0dec86ad77f791ba4c9639
2015-11-30 17:03:34 -08:00
Colin Cross
87a703257b Merge remote-tracking branch 'aosp/upstream' 2015-11-24 11:24:13 -08:00
colincross
6afb72ff1b Merge pull request #83 from colincross/embed
Support embedded anonymous property structs
2015-11-24 11:23:39 -08:00
Colin Cross
5a9f4d1db2 docs: support embedded anonymous property structs
Embedded anonymous structs have no name, use the type as the name for
now.  Eventually we should hide the name completely and put the
properties in the embedding struct.
2015-11-23 13:25:30 -08:00
Colin Cross
9d1469d559 Support embedded anonymous property structs
Allow property structs to contain anonymous embedded structs and
interfaces.  Properties in an anonymous embedded struct or interface are
treated as if they were properties in the embedding struct.
2015-11-20 17:26:52 -08:00
Colin Cross
83cedbec85 Fix ZeroProperties bug on nested interfaces
ZeroProperties was setting nested structs to their zero value, even if
they contained an interface that should be recursed into, not replaced
with nil.
2015-11-20 17:26:52 -08:00
Colin Cross
26f44b21eb Merge remote-tracking branch 'aosp/upstream' 2015-11-18 17:04:05 -08:00
colincross
5c11f817e1 Merge pull request #80 from colincross/optionalremove
Make removing abandoned files optional
2015-11-18 16:21:06 -08:00
colincross
1af8a230c7 Merge pull request #82 from colincross/builddir
Use context builddir for removing abandoned files
2015-11-18 16:20:31 -08:00
Colin Cross
a259945b74 Use context builddir for removing abandoned files
Removing abandoned files needs to know where the .ninja_log file is
stored.  Export the ninja builddir value from Context and use it to
determine the .ninja_log path in any stage.

The ninja builddir (where ninja stores its .ninja_log and .ninja_deps
files) and the bootstrap.BuildDir (where build output files are written)
are distinct, so to reduce confusion replace SetBuildDir with
SetNinjaBuildDir.
2015-11-18 16:06:19 -08:00
colincross
9bb9545db3 Merge pull request #81 from colincross/builddir
Allow multiple calls to ctx.SetBuildDir
2015-11-18 15:33:36 -08:00
Colin Cross
6d529f0e16 Make removing abandoned files optional
Build logic can now implement a RemoveAbandonedFiles, and the bootstrap
logic will only remove abandoned files if that method returns true.
Leaving the method unimplemented will result in the existing behavior of
always removing abandoned files.
2015-11-18 15:29:12 -08:00
Colin Cross
01739302cb Allow multiple calls to ctx.SetBuildDir
ctx.SetBuildDir is called by the bootstrap singleton, which is always
last.  In order to allow the primary builder to set the directory for
.ninja_log/.ninja_deps, remove the panic on multiple calls to
ctx.SetBuildDir, and always used the value passed by the first caller.
2015-11-18 15:15:41 -08:00
Dan Willemsen
e6006362da Merge pull request #78 from danw/ruledeps
Add common implicit deps to Rules
2015-11-17 17:59:43 -08:00
colincross
5b082a9edf Merge pull request #79 from colincross/enotdir
End removing directories on ENOTDIR
2015-11-17 17:49:51 -08:00
colincross
2efbb49023 Merge pull request #76 from colincross/variantmethods
Add variant methods to SingletonContext and Context
2015-11-17 17:49:11 -08:00
colincross
33c55fe809 Merge pull request #74 from dje4g/add-newline-2
Add blank line after build rules, for human readability.
2015-11-17 17:48:59 -08:00
Dan Willemsen
fce63d3c8f Add common implicit deps to Rules
For implicit dependencies that will be common to all users of a Rule,
add a new field 'CommandDeps' to the RuleParam. This is a list of
strings to be prepended to the implicit dependencies in each BuildParam.

This lets us have the dependencies declared next to where they are used,
instead of duplicated in areas that may be far apart.

I looked at passing this information down to ninja too, but it only
saves us a few percent of ninja file, and requires a modification to the
ninja file format.

Change-Id: Ifd910dee1506d4e32a76ed06206f853c4caec622
2015-11-17 17:08:05 -08:00
Colin Cross
24ad587138 Add variant methods to SingletonContext and Context
Add VisitAllModuleVariants, PrimaryModule, and FinalModule to
SingletonContext so singletons and tools can deal with modules with
multiple variants.
2015-11-17 16:47:50 -08:00
Colin Cross
ca3817145c End removing directories on ENOTDIR
An abandoned directory may have been replaced with a file, give up on
removing the directory on ENOTDIR.
2015-11-17 16:35:22 -08:00
colincross
ff7104f98d Merge pull request #75 from colincross/go15
Update travis to use go 1.5
2015-11-17 15:13:17 -08:00
colincross
f5df83e7ee Merge pull request #72 from dje4g/build-rule-comments
Support comments in build rules.
2015-11-09 13:12:26 -08:00
Colin Cross
a2cd69899f Update travis to use go 1.5
Update .travis.yml to specify go 1.5.1, and update build.ninja.in to
include the new in line function names used by go 1.5.
2015-11-09 12:56:38 -08:00
Doug Evans
9c1cbb4a04 Add blank line after build rules, for human readability. 2015-11-09 11:37:39 -08:00
Doug Evans
fcc6739e34 Support comments in build rules.
Tested: sh tests/test.sh
2015-11-08 12:21:58 -08:00
Colin Cross
2652d6ce04 Merge remote-tracking branch 'aosp/upstream' 2015-11-04 11:05:51 -08:00
colincross
a17f759660 Merge pull request #69 from colincross/depserrors
Don't rely on deps property position
2015-11-04 11:04:37 -08:00
Colin Cross
7fcb7b00e4 Don't rely on deps property position
Dependency errors were prefixed with ??? because they were associated
with the position of the "deps" property, which is often not used.  Use
the position of the module instead.
2015-11-03 17:33:29 -08:00
colincross
d130c11bc7 Merge pull request #67 from colincross/reversedependencies
Sort reverse dependencies
2015-11-03 17:32:55 -08:00
colincross
eeb5f95873 Merge pull request #68 from colincross/selfdep
Print useful error for self-dependency
2015-11-03 17:32:47 -08:00
Colin Cross
045a597603 Print useful error for self-dependency
beforeInModuleList panic'd when checking if a variant was before itself
in the module list.  Return a real error instead of calling
beforeInModuleList, and also fix beforeInModuleList to return false for
the same module.
2015-11-03 17:00:26 -08:00
Colin Cross
8d8a7af4af Sort reverse dependencies
AddReverseDependencies would add modules the target's dependency list in
a non-deterministic order based on the order the modules were parsed.
Redefine AddReverseDependencies to collect dependencies until the end of
the mutator and then add them sorted by name.
2015-11-03 16:41:29 -08:00
Colin Cross
cf8c2b60f3 Merge remote-tracking branch 'aosp/upstream' 2015-11-03 14:43:02 -08:00
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