Commit graph

578 commits

Author SHA1 Message Date
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
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
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
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
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
Dan Willemsen
d2e70839f2 Merge branch 'master' into danw/multistagebootstrap
Pull in the latest travis config

Change-Id: I71b5900237378877520a68d639260819d28d1b25
2015-07-30 16:55:34 -07:00
colincross
e13dcaafd1 Merge pull request #47 from danw/newninja
Updates to travis config -- faster; ninja v1.6.0
2015-07-30 15:58:28 -07:00
Dan Willemsen
efd2de734d Use three stage builds
This splits the current bootstrap stage into two stages:

A bootstrap stage, which like today, a reference is checked into the
tree. It just builds the "core" blueprint binaries -- minibp,
gotestmain, and choosestage. Just enough to build the next stage's ninja
file.

A primary builder stage. This builds the primary builder, the main ninja
file, and any other bootstrap binaries (bpfmt, etc).

The main advantage here is that the checked in file really only contains
references to blueprint -- not the primary builder. This will allow us
to make the primary builder more dynamic, by loading more module types
that may or may not exist in all trees.

It's even possible to reuse the build.ninja.in in the blueprint repo
directly now. We don't currently do that, since we still want to turn on
tests.

Change-Id: I18683891ed7348b0d7af93084e3a68a04fbd5dbc
2015-07-29 17:14:00 -07:00
Dan Willemsen
91a657e219 Enhance bootstrap stage selection
This simplifies the bootstrap process while making it more flexible by
moving the stage selection into a go binary(choosestage). It will now be
possible to have more than two build stages.

Now each stage has a ninja template(main.ninja.in) and a timestamp
file(main.ninja.in.timestamp). The timestamp file may be updated by any
build stage that wishes to regenerate the ninja template. If the
choosestage binaries sees that the timestamp is newer than the template,
it will choose the prior stage.

The main stage no longer writes to the source tree to update the
build.ninja.in file. This was a problem for read-only source trees.
Instead, the choosestage binary first checks to see if that file is
newer than the last bootstrap.ninja.in, copies it in place, and starts
the boostrap stage.

The bootstrap stage regenerates it's own ninja template, but that
required a loop through the main stage to actually run it. The
choosestage binary now detects if the template has changed for the
current stage, and will restart the stage.

One change is that if dependencies do get messed up, instead of silently
failing, there's a higher chance that the bootstrap step will just
continue looping, doing nothing. This can happen if the main stage
has a dependency that triggers the bootstrap stage, but the bootstrap
stage doesn't see anything required to rebuild the main ninja file. A
side effect of this requirement is that changes to test code will now
rebuild the main ninja file.

Change-Id: I9965cfba79dc0dbbd3af05f5944f7653054455a2
2015-07-23 22:06:02 -07:00
Dan Willemsen
f04c55172f Add test suite for bootstrapping
This only checks to make sure that for a given updated file, the
bootstrap stage is properly run. It doesn't actually check to make sure
that anything was rebuilt.

Change-Id: I9cb6ff1d483264da30e43d5580361d93b148f42c
2015-07-23 22:04:42 -07:00
Dan Willemsen
8cc6d75034 Switch to custom-built ninja v1.6.0 2015-07-23 21:07:32 -07:00
Dan Willemsen
4ba7307e91 Migrate to container-based travis infrastructure
http://docs.travis-ci.com/user/migrating-from-legacy/
2015-07-23 21:07:32 -07:00
Dan Willemsen
187a9bf7d5 Fix running travis on forked repos
If we're not on the official repo, link the directory structure around
so that go can still find the code.
2015-07-23 21:07:32 -07:00
Dan Willemsen
21b6f37cee Require ninja 1.6.0, remove workaround
The workaround no longer works with the new stage selector. We may run
bootstrap.ninja.in twice before running the next stage, but we can't
encode whether to run another ninja instance in the checked in
build.ninja.in.

This can likely be solved, but now that there's an official release with
support for multiple passes, just push up the required version.

Change-Id: I76e321912e323d60e462aabec61bdfcc7118cd5e
2015-07-22 15:51:52 -07:00
Dan Willemsen
958b3acd10 Don't print module header if nothing is defined
Modules may decide not to output any build definitions in some cases.
Clean up the ninja file by not adding headers for empty sections.

One particular usecase is my upcoming multi-stage bootstrapping -
bootstrap_go_* will not output any rules in the first stage unless it's
required to build the primary builder.

Change-Id: I6a6b54da7e1702c63bfa736bcf8daf16956f9449
2015-07-20 17:51:21 -07:00
jgennis
0894cbc1a9 Merge pull request #41 from jgennis/depfix
Fix a sub-Blueprints deps bug.
2015-07-06 17:46:47 -07:00
Jamie Gennis
7ccc2c22e2 Fix a sub-Blueprints deps bug.
This change fixes a bug where directories that could contain a Blueprints file
but currently do not were not being added as a dependency.  This meant that if
a Blueprints file were added to that directory it would not automatically get
picked up by the build.
2015-07-06 17:28:00 -07:00
colincross
0e5a7cde0a Merge pull request #40 from danw/deepcopy
Add deep Copy() for parser types
2015-07-06 13:37:33 -07:00
Dan Willemsen
38b0630a2a Add deep Copy() for parser types
Change-Id: I94bca46d6d30da683cacb0f6ea1fdf26a5a46bc8
2015-07-06 12:49:23 -07:00
colincross
91dc34a563 Merge pull request #39 from colincross/parse
Refactor parsing to allow reuse
2015-07-01 10:34:32 -07:00