Commit graph

583 commits

Author SHA1 Message Date
colincross
f3218f61b6 Merge pull request #137 from colincross/name
Add ModuleContext method to get dependency by name
2016-12-14 21:45:11 -08:00
Colin Cross
dfb4c9f7af Add ModuleContext method to get dependency by name
Instead of forcing every mutator or module to use VisitDirectDeps
to iterate through its deps, allow it to request a dependency by
name to return the Module.

Change-Id: I18b23bffa324bb9d93a7743b6e2a19c07058c775
2016-12-14 10:42:00 -08:00
colincross
92844f0da8 Merge pull request #136 from colincross/race
Fix data race when applying replacements
2016-12-09 11:09:21 -08:00
Colin Cross
0ce142ca05 Fix data race when applying replacements
Mutator context goroutines appending directly to the global Context's
replacements list causes a data race.  Send them over a channel
instead.

The renames and replacements are local to the mutator, so move them
out of Context and into the runMutator method.

Change-Id: I797edb1e27ee29f8946c58101b40fcfb50a32eb9
2016-12-09 10:35:33 -08:00
colincross
0f1fa92e86 Merge pull request #135 from colincross/deps
Support deps and depfile properties on build statements
2016-11-22 13:51:07 -08:00
Colin Cross
aa873e1c65 Support deps and depfile properties on build statements
Ninja supports deps and depfile properties specified on build
statements, allow them to be specified in BuildParams.

Change-Id: I46eac5571350426f1419908def21f7d042f8739a
2016-11-22 13:40:45 -08:00
colincross
8c5b1d1f60 Merge pull request #134 from colincross/glob
Fix optional_subdirs globbing
2016-11-14 17:38:00 -08:00
Colin Cross
08e4954a8c Fix optional_subdirs globbing
Bypassing c.glob() and using filepath.Glob() directly for non-glob
paths does not add dependencies on directories that contain missing
files.  For optional_subdirs, this means no dependency is added to
rerun the primary builder when an Android.bp file is added to an
optional_subdirs directory.  Always use c.glob(), for the non-optional
case it will not insert any dependencies if the file exists (as tested
by glob_test.go's no-wild tests), and if the file doesn't exist the
len(matches) == 0 will error out.

Change-Id: I370479c6e89f5ff590897702e256256a4dca6952
2016-11-14 15:41:41 -08:00
colincross
36518a6115 Merge pull request #133 from colincross/glob
Add better error message when stat returns nil
2016-11-05 15:05:07 -07:00
Colin Cross
ced59eeaf1 Add better error message when stat returns nil
Sometimes os.Stat on a path seems to return nil after filepath.Glob
returned the path as valid.  Return the error message to see why.

Bug: 32676828
Test: builds
Change-Id: Ieedddb673b4d641e5de08778febeb3d8ea025c0d
2016-11-05 14:52:57 -07:00
colincross
09e03f31f6 Merge pull request #131 from colincross/glob
Import globbing from Soong
2016-11-03 14:23:56 -07:00
Colin Cross
127d2eae8b Import globbing from Soong
Add globbing with dependency checking to blueprint.  Calling
ModuleContext.GlobWithDeps or SingletonContext.GlobWithDeps will return
a list of files that match the globs, while also adding efficient
dependencies to rerun the primary builder if a file that matches the
glob is added or removed.

Also use the globbing support for optional_subdirs=, subdirs= and build=
lines in blueprints files.  The globbing slightly changes the behavior
of subname= lines, it no longer falls back to looking for a file called
"Blueprints".  Blueprint files that need to include a subdirectory with
a different name can use build= instead of subdir= to directly include
them.  The Blueprints file is updated to reset subname="Blueprints" in
case we want to include subdirectories inside blueprint and the primary
builder has changed the subname.

Also adds a new test directory that contains a simple primary builder
tree to test regeneration for globbing, and runs the tests in travis.

Change-Id: I83ce525fd11e11579cc58ba5308d01ca8eea7bc6
2016-11-03 13:54:03 -07:00
Dan Willemsen
b589835c0d Merge pull request #132 from danw/bootstrap
Fix Soong glob regeneration and other bootstrap cleanups
2016-11-02 16:12:36 -07:00
Dan Willemsen
9bd6b38617 Refactor test running to improve parallelism
Before this change, we would ensure that tests for a package were run
before anything used that package, even just to compile. With this
change, we'll let other packages compile, but still run the tests in
dependency order, and before the binaries are finally installed.

This shrinks our initial build time from ~9 seconds to ~5 seconds on my
machine. Most of the improvements come from building the "real" package
and the test package in parallel.

Change-Id: I935670feecadacbf09b250bcaa1659a3599edc58
2016-11-02 13:10:27 -07:00
Dan Willemsen
460c80eb12 Clean up unnecessary dependencies
Other than cleaning up the code, the only change in behavior is to run
the docs build in parallel with the primary builder, saving about a
second on a Soong bootstrap (10s -> 9s).

Change-Id: Iaff51d6d1a37af842f294f12db11d5774d48d440
2016-11-02 13:10:27 -07:00
Dan Willemsen
b6d88a4f0a Allow build.ninja regeneration (fix Soong globs)
Soong (and soon, Blueprint) embeds the results of filesystem globs into
the build.ninja, and uses a helper tool to detect when the glob changes
and we need to rebuild the build.ninja file. This is more flexible than
listing the affected directories in the depfiles, since it can check to
see if a file we actually cared about was added, instead of re-running
anytime any file was added/removed (which happens on atomic file
modifications as well).

My recent bootstrap simplification broke this, since the helper rules
are in the main build.ninja, but I removed the ability to regenerate
that file from itself. So keep the current model, but add a rule into
the primary and main stages that allow themselves to re-run their
generator and write out a new build.ninja file if necessary. The actual
build rules of the generator aren't necessary, since we already built
them in the previous stage.

Change-Id: Ib51245920b2ec3ee5306c0c269361a5a8733caa8
2016-11-02 13:10:27 -07:00
Dan Willemsen
a2d14b7a40 Merge pull request #130 from danw/implicit_outputs
Support implicit outputs
2016-11-01 10:08:48 -07:00
Dan Willemsen
3692331afe Cleanup outfile args in bootstrap/bootstrap.go
This would have been a case for implicit outputs, but these just aren't
needed anymore.
2016-10-31 17:36:53 -07:00
Dan Willemsen
5c43e07937 Support implicit outputs
Added in Ninja 1.7, for outputs that will not show up in $out.
2016-10-31 17:36:49 -07:00
colincross
52798022db Merge pull request #128 from colincross/name
Modify module name handling
2016-10-12 13:47:21 -07:00
Colin Cross
9cfd198dd8 Add ReplaceDependencies
ReplaceDependencies allows a module to replace dependencies on a
matching variant of a target module with itself.

Change-Id: I22946dec23c38ed5e1ad23b87121d72668268c01
2016-10-12 13:33:37 -07:00
Colin Cross
c4e5b8157b Add Rename
Allow modules to be renamed by mutators.  This will allow modules to
dynamically adapt to the presence or absence of modules with the same
name.  For example, if a source module does not exist, a prebuilt module
could rename itself to the name of the source module so that
dependenices on the module name are satisified.

Change-Id: I44004604c6d9db041bb7d38fe6c1ca877bc7d6f1
2016-10-12 13:33:37 -07:00
Colin Cross
b3f96c3306 Add OtherModuleExists
Allow dependency modifying mutators to check if another module exists
based on its name.  Allows primary builders to have custom handling for
missing-module errors, for example by falling back to another module.

Change-Id: I04ddd66be43c514f1f8928e15b2a79cadebcfc17
2016-10-12 13:33:37 -07:00
Colin Cross
0b7e83e11a Ask primary builder for module names
Remove the assumed Name and Deps properties.  Instead, ask the Module
for the Name, and require them to use the existing replacements for
Deps.

Change-Id: I729045d86277686078b3aa0bba71c67d612ead2c
2016-10-12 13:33:37 -07:00
colincross
53d4357592 Merge pull request #127 from colincross/memprofile
Add support for memory profiling
2016-10-12 11:16:42 -07:00
colincross
b2bee4ee14 Merge pull request #126 from colincross/errors
Improve error reporting
2016-10-12 11:16:29 -07:00
Colin Cross
2c62844274 Improve error reporting
Report module name and variant and property names in errors.

Change-Id: I747f840402497b2c92bf8c565d7c50af33e6ab0e
2016-10-12 11:14:18 -07:00
Colin Cross
2ecec57e47 Add support for memory profiling
Add -memprofile argument to support capturing a heap profile, and -nogc
to disable the garbage collector to see all allocations.

Change-Id: I0d4c5f2bf79786aed4b2af4be112ecf0a2810a91
2016-10-12 11:12:54 -07:00
colincross
ad914cea1a Merge pull request #125 from colincross/build_deps
Add dependency on build= blueprint files
2016-10-11 10:31:12 -07:00
Colin Cross
2458712c0b Add dependency on build= blueprint files
Blueprint files included with build= statements were not adding a
dependency to cause regenerating when they were changed.

Bug: 32085516
Test: touch external/boringssl/sources.bp && mmma -j external/boringssl
Change-Id: Id4fdf3b6788ae5c1e94547dc63ec6b55424a66a0
2016-10-11 10:03:14 -07:00
colincross
888b21f87b Merge pull request #124 from colincross/escape
Add proptools functions to escape strings
2016-09-29 15:49:14 -07:00
Colin Cross
41ca49ff91 Add proptools functions to escape strings
Blueprint properties that end up as command line arguments need to be
both ninja and shell escaped.  Provide helpers that primary builders can
use to appropriately escape them.

Change-Id: Ifd697d87edb1c6f0a910377835c391bbe8f95b42
2016-09-29 14:31:40 -07:00
Dan Willemsen
f5909d9cb5 Merge pull request #122 from danw/structof
Support structures built with StructOf
2016-09-09 13:24:50 -07:00
Dan Willemsen
ec5ba986ae Support structures built with StructOf
In Go 1.7, all generated types (including StructOf) are marked as
unexported types. This is not a problem with regular named fields, since
the whether the field is exported is based on the name, not the type.
But for unnamed (anonymous) fields, there is no name, and it falls back
to whether the type is exported or not. When the field isn't exported,
we're unable to use reflection to set the value.

Special case fields named "BlueprintEmbed" to act like exported unnamed
fields during unpacking. There is no functionality lost here, since code
can not directly access these runtime generated fields.

Structures embedded in the source shouldn't be affected by this change,
unless they happen to use the "BlueprintEmbed" field, which is not a
normal field name due to the capitalization.

Change-Id: I53f3b32b2286c47b2bb1918d6008d0180ad0605e
2016-09-09 13:19:47 -07:00
Dan Willemsen
4a35b51495 Merge pull request #121 from danw/simple_bootstrap
Simplify bootstrap
2016-08-31 00:43:41 -07:00
Dan Willemsen
7d0dddd84d Simplify bootstrap
tl;dr: Read if you don't use the wrapper or use SKIP_NINJA

Previously, we were relying on the ninja behavior of restarting the
build when the build.ninja file was updated to switch between different
bootstrap stages. But that means that every step that could produce a
build.ninja must pass in order to switch to a different stage. That
wasn't a big problem when we had a two stage build -- there was very
little that could fail in the second stage before we chose to go back to
the first stage. But when we had a three stage build, it was possible to
get into a state (usually during development) where you were in the
second stage, but the build was failing because the first stage needed
to be run. This was fixed in d79f1af742
by adding a wrapper that always started building at the first stage.

But this kept all of the complexity of using ninja restarts without any
of the benefits, so this change removes that complexity and just runs
each stage sequentially in the wrapper. So the wrapper is now required.

Since we're no longer going through choosestage, we can also skip the
template parsing for the later stages that don't need to be templated --
this can save a couple of seconds for large files.

In addition to all of the above, this also lets Soong reduce the number
of times the main ninja file is loaded. We had been running the wrapper
once (3 stages), then running ninja again after combining the
Soong-generated build.ninja with the Kati-generated build.ninja. This
change lets us removing the intermediate parsing of Soong's build.ninja,
so that we only execute ninja 3 times per build. It also lets us have
dependencies on pools or rules from Kati in the primary builder, since
we're never executing the main build.ninja without the Kati build.ninja.

The wrapper has a new option, NINJA to provide the path to ninja. This
used to be hardcoded to `ninja`, and will still default to that. But
we'll be running the first two bootstrap stages with $NINJA even if
SKIP_NINJA is set.

The wrapper passes "-w dupbuild=err" to ninja now -- this really should
always be turned on if you care about reliable builds.

Change-Id: I6f656b74eb3d064b8b9e69d1d6dac1129d72b747
2016-08-30 17:26:56 -07:00
colincross
3fc513f94c Merge pull request #120 from colincross/builtin
Add NewBuiltinRule and NewBuiltinPool
2016-08-29 15:22:12 -07:00
Colin Cross
e0e473efb4 Add NewBuiltinRule and NewBuiltinPool
Allow Blueprint build statements and rules to reference rules and pools
defined outside of Blueprint.

Change-Id: I48644497d16a4c2bab88db400dbe7f7fe169d933
2016-08-29 15:12:33 -07:00
colincross
b9fb0ad53d Merge pull request #119 from colincross/extend
Relax type requirements when extending properties
2016-08-22 16:01:27 -07:00
Colin Cross
bf2adbfee2 Relax type requirements when extending properties
Allow using ExtendMatchingProperties to extend pointer to a struct or an
interface containing a pointer to a struct using a struct, and
vice-versa.

Also fixes a pre-existing bug where extending a nested structure could
fail if there were multiple possible destnations and some of them did
not have a matching nested property.

Change-Id: I6e69d78eb6595ba7dd2603e3aa7dd8de3f292744
2016-08-22 15:35:17 -07:00
colincross
7fda24e54b Merge pull request #118 from mortonfox/patch-1
Update link to Ninja
2016-08-17 22:45:39 -07:00
Morton Fox
ebb354179b Update link to Ninja 2016-08-18 00:48:20 -04:00
colincross
e412f09f7e Merge pull request #117 from colincross/variant
Elide empty variations
2016-08-15 12:22:37 -07:00
colincross
087b721ea8 Merge pull request #115 from colincross/parallel
Parallelize TopDownMutators
2016-08-11 17:10:59 -07:00
Colin Cross
badc8817fa Elide empty variations
Don't add a "_" to the variant name if the variation name is empty.  For
example, when splitting a variant with name "foo" into variations "" and
"bar", the new variants would be named "foo" and "foo_bar" instead of
"foo_" and "foo_bar".

Change-Id: I82342d57e2a8e9f2d65a7d8d2872dcb7b3512899
2016-08-11 17:03:26 -07:00
colincross
45f63e414a Merge pull request #116 from colincross/fix
Fix error reporting in parallel mutators
2016-08-11 16:58:40 -07:00
Colin Cross
0fff742172 Fix error reporting in parallel mutators
runMutators was sending the wrong value into errsCh, hiding all errors.
parallelVisit had a data race on error, send the cancel signal over a
channel instead of writing to a bool from a goroutine.

Change-Id: I18919d71464c094db5846badbfac80f99366d70c
2016-08-11 15:41:57 -07:00
Colin Cross
3702ac7531 Parallelize TopDownMutators
Convert parallelVisitAllBottomUp into a generic parallelVisit that takes
a visitOrderer to select top down or bottom up.  Combine
runTopDownMutator and runBottomUpMutator into runMutators that takes a
mutatorDirection to select the visitOrderer for parallelVisit and which
function pointer in the mutatorInfo to run.  Optimize out the
updateDependencies to only run if dependencies have been modified to
avoid running it after TopDownMutators that cannot modify dependencies.

Change-Id: Ib00302db1108ebab2ce8e01b20aa026140d382a4
2016-08-11 14:40:53 -07:00
colincross
056963fe71 Merge pull request #113 from colincross/parallel
Add concurrency to BottomUpMutators and cloneModules
2016-08-11 11:18:15 -07:00
colincross
fcaf58b591 Merge pull request #114 from colincross/gofmt
Enforce gofmt in travis
2016-08-11 11:17:39 -07:00