Commit graph

2714 commits

Author SHA1 Message Date
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
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
colincross
a745030a6c Merge pull request #38 from colincross/comment
Add convenience methods to Comment objects
2015-07-01 10:34:26 -07:00
Colin Cross
23d7aa1b68 Refactor parsing to allow reuse
Refactor parsing Blueprints and walking the Blueprints tree to
allow reuse for tasks that don't involve creating moduleInfo
structures.

Change-Id: I677857a3462999426c8306432074ea97fdcb86c8
2015-06-30 16:43:32 -07:00
Colin Cross
2108971145 Add convenience methods to Comment objects
Add String() to print out the Comment, Text() to print out the
Comment while stripping /*, //, and */, and EndLine() to return
the line number of the last line of the comment.

Change-Id: I076bc0990143acfc03c42a8cc569894fced8ee24
2015-06-30 14:33:38 -07:00
colincross
9c067caf2e Merge pull request #29 from colincross/doc
Add self-documenting support
2015-06-26 16:18:30 -07:00
colincross
7ca0374daa Merge pull request #36 from colincross/filter
Support filtering nested structures by tag
2015-06-26 16:18:11 -07:00
Colin Cross
4572edddfa Add self-documenting support
The primary builder will now generate a rule to call itself with
--docs=.bootstrap/docs/<name>.html to produce an automatically
generated documentation file.

The documentation generation process is:
 - Call each factory once to get empty property structs associated
   with the module type
 - Use reflection to determine the names of the type of each property
   struct
 - Use the bootstrap_go_package modules from reading the Blueprints files
   to find the source files for each Go package used to build the primary
   builder
 - Use the go/parser module to find the type declaration for each
   property struct
 - Extract comments for the property struct and each property declaration
 - Format all the comments into HTML

Change-Id: Icae9307cc10549a30bfc14d6922824099de5a9b0
2015-06-26 10:51:44 -07:00
Colin Cross
4adc819490 Support filtering nested structures by tag
Allow tagging a nested property structure with
`blueprint:"filter(key:\"value\")"`, which will only allow property
assignments to properites in the nested structure that are tagged
with `key:"value"`.  Moving the filter into Blueprint instead of
the project build logic allows more reliable and consistent error
messages.

Change-Id: I06bc673dde647776fc5552673bdc0cdcd7216462
2015-06-26 10:46:17 -07:00
colincross
944a7a5ed4 Merge pull request #37 from danw/runtests
Add option to build and run tests during bootstrap
2015-06-26 10:45:10 -07:00
Dan Willemsen
87ba294ceb Add option to build and run tests during bootstrap
Users that want to enable this option can use the '-t' option to
bootstrap.bash when passing '-r'. Builders that want to enable this can
set the RUN_TESTS environment variable in their bootstrap.bash.

The gotestmain tools is needed to write the main functions for the test
binaries, since 'go test' doesn't work well in this environment.

Change-Id: Iec5c2b5c9c3f5e3ba0ac8677fb88f5e963f9bd3f
2015-06-25 11:45:54 -07:00
Dan Willemsen
30a80c3e5f Create internal bootstrap Config struct
Change-Id: If5c5ce3d5c46196cf9b77ff9f5c68b8849474823
2015-06-24 22:44:37 -07:00
colincross
2a874e45a9 Merge pull request #35 from colincross/glob
Fix glob dependencies when initial non-wild path does not exist
2015-06-18 17:10:39 -07:00
colincross
202c223274 Merge pull request #31 from danw/regen-name
Support bootstrap regeneration with different filename
2015-06-18 17:09:58 -07:00
Colin Cross
7d2ee0df95 Fix glob dependencies when initial non-wild path does not exist
If the initial non-wild part of a glob path does not exist, return
the last existing part of the path as a dependency to detect if the
path is created later.

Change-Id: Ib5a39e6830cb386deed26e017279d0aac1bc9a20
2015-06-18 10:49:36 -07:00
Dan Willemsen
2527cc63a0 Support bootstrap regeneration with different filename
Change-Id: I1ebc2f6a6af1a1dce81925110a67752d45f6c02c
2015-06-10 17:56:46 -07:00
jgennis
0bcd913e87 Merge pull request #28 from jgennis/local-variant
Add CreateLocalVariations to BottupUpMutatorContext.
2015-05-19 12:55:18 -07:00
jgennis
e96faea6e6 Merge pull request #26 from colincross/clone
Add proptools.CloneEmptyProperties
2015-05-19 12:53:26 -07:00