Commit graph

583 commits

Author SHA1 Message Date
Colin Cross
5b0231b027 Enforce gofmt in travis
Run gofmt -l . during travis to catch pull requests that have not had
gofmt run on them.

Change-Id: Ibfdf988a535d82721f3c4bc328b189f606f12778
2016-08-11 10:21:37 -07:00
Colin Cross
c93490c679 Parallelize cloneModules
cloneModules duplicates every module, which can be slow.  Spawn a new
goroutine for each module to spread the factory and CopyProperties calls
over multiple cpus.

Change-Id: I2597f921dadfd321ccb705aec9a904c71b75f9ef
2016-08-10 16:31:35 -07:00
Colin Cross
a028bf49ba Fix gofmt
Change-Id: I27b918b801dec25a85e65f88ab90331382ee1ec3
2016-08-10 16:31:35 -07:00
Colin Cross
49c279ab26 Parallelize BottomUpMutators
Allow BottomUpMutators to run in parallel by calling Parallel() on the
return value of RegisterBottomUpMutator.  To avoid locking, moves
updates of global state into a separate goroutine that receives updates
over channels from the mutator goroutines.

Change-Id: Ic59b612da9b406cf59ec44940f0c1dee0c051a51
2016-08-10 16:31:35 -07:00
Colin Cross
f8b5042c86 Implement EarlyMutators with BottomUpMutators
Get rid of runEarlyMutators, and implement EarlyMutators as a shim
around BottomUpMutators.  Removes mostly-duplicate code between
runEarlyMutators and runBottomUpMutator to allow parallelizing
runBottomUpMutator.

Change-Id: I66a051cb8710770b47da21d35e55aa49c84e9be8
2016-08-10 16:31:35 -07:00
Colin Cross
93c4cf6861 Revert "Add dependency visiting methods to BottomUpMutatorContext"
This reverts commit a2b2080fcd.

Dependency visiting methods conflict with the dependency adding methods
already present on BottomUpMutatorContext - mixing calls to visit
dependencies and adding dependencies produces requires hard-to-define
semantics, and complicates parallizing mutators.

Change-Id: I2f793c8db45b97f4d79badc9fe88315fe38d90cd
2016-08-10 16:31:35 -07:00
colincross
1c1ec45ebb Merge pull request #111 from colincross/visit
Reimplement VisitDirectDeps[If] on Context.walkdeps
2016-08-09 13:37:18 -07:00
colincross
1aece72b35 Merge pull request #112 from colincross/opt
Only instantiate nil struct pointers that are used
2016-08-09 12:36:18 -07:00
Colin Cross
a437135876 Only instantiate nil struct pointers that are used
unpackProperties was instantiating all nil struct pointers in any struct
that had a property set.  Check if the property is set first, and only
instantiate the struct if it was set.

This has a slight behavioral change, as now structures that only exist
through nil pointers and are never set into will not be type-checked.
This should be fixed in a later patch set that moves the type checking
to be done across all property structs once per factory before blueprint
files are loaded.

Change-Id: I0dea34d7fff76bb4fc907516a2d996e4ea2408d6
2016-08-08 17:35:29 -07:00
Colin Cross
bafd5f5a2b Reimplement VisitDirectDeps[If] in on Context.walkdeps
VisitDirectDeps[If] need to know the parent in order to support
OtherModuleDependencyTag(), remove Context.visitDirectDeps[If] and
reimplement [Module]Context.VisitDirectDeps[If] using Context.walkdeps.

Change-Id: I2faac2d100d2a0ad2a4f1d8250997eed1a7ef6f0
Test: TestVisit
2016-08-08 17:30:38 -07:00
Colin Cross
365bc6b3ea Add tests for Visit*
Change-Id: I52505ee4e23ec8b1c5763b3216788e999de9c8d3
2016-08-08 17:26:57 -07:00
Colin Cross
d7b0f60802 Allow tests to mock filesystem
Tests can call Context.MockFileSystem to pass in a map of filenames to
contents.

Change-Id: Idd67c68f7cb43bc2117cc78336347db7e2f21991
2016-08-08 17:26:57 -07:00
colincross
fd1ef9ec7a Merge pull request #110 from colincross/opt
Optimize proptools
2016-08-08 15:48:13 -07:00
Colin Cross
c3d731258a Support nil pointers to structs in properties
Allow primary builders to reduce allocations of empty structures by
allowing nil pointers to concrete struct types.  Property readers will
not recurse into nil pointers, property writers will replace the nil
pointer with a pointer to the zero value of the pointer element type.

Allows a >50% primary builder time improvement with a trivial change in
Soong.

Change-Id: If6ad674bf7bf2a694c335378a074643a97d3c50b
2016-08-05 17:19:36 -07:00
Colin Cross
aec881da86 Add option to trace goroutine execution
Passing -trace <file> on the command line produces a trace file that can
be used with go tool trace to examine concurrency.

Change-Id: I7d27bca64d0f0816cb4e518e947b70bc1c0573a3
2016-08-05 14:00:30 -07:00
Colin Cross
01ee36eeea Optimize proptools
proptools cloning and extending are a significant portion of the run
time for Soong.  Optimize out calls to reflect.Type.Field(), which must
allocate a []int to store the index, by caching all the fields of each
type as it is seen, and by iterating over a slice of cached fields
instead of calling Field(i) for each one.  Also avoid calling
reflect.Value.Interface() twice on the same Value.

Change-Id: I4e13fc85f30d8614a5586283e928c0a6d7f24809
2016-08-05 14:00:30 -07:00
Dan Willemsen
9544a07d2f Merge pull request #107 from danw/moduletype
Expose ModuleType to Singletons
2016-07-27 13:42:46 -07:00
colincross
ee1ddb5704 Merge pull request #109 from colincross/defaults
Add dependency visiting methods to BottomUpMutatorContext
2016-07-27 13:10:55 -07:00
Colin Cross
a2b2080fcd Add dependency visiting methods to BottomUpMutatorContext
It can be useful for a BottomUpMutator to visit its dependencies.  Embed
all of TopDownMutatorContext into BottomUpMutatorContext.

Change-Id: I7c7262fbe3d8fa9cc0d26899eee704cc862835df
2016-07-27 10:55:14 -07:00
Dan Willemsen
c98e55b0af Expose ModuleType to Singletons
In order to implement some build statistics in Soong, expose the module
type (the string used to define the module) to singletons.

Change-Id: I441d12c7782bcf338b3654cfe907b8d2a7253594
2016-07-25 15:51:50 -07:00
Dan Willemsen
15371ad652 Merge pull request #106 from colincross/type_error
Fix error messages containing variable types
2016-07-15 17:54:25 -07:00
Colin Cross
ba5bf880bf Fix error messages containing variable types
value.Type and value.Pos changed to methods, change the users that were
not caught by error checking to use Type() or Pos().

Change-Id: I295a658c007fa2de68c89fb85ee367fbea5ed1aa
2016-07-15 16:43:42 -07:00
colincross
f9dbc3becc Merge pull request #105 from colincross/printer_panic
printer: support multiple skipped comments
2016-07-13 10:40:15 -07:00
Colin Cross
6b6735d3be printer: support multiple skipped comments
There may be multiple skipped comments in a row, convert
p.skippedComments to a list and add a test.

Change-Id: I30dcff269bee56fd51ef9513dab7c7885c44b7d7
2016-07-12 16:12:09 -07:00
colincross
2e32b2facc Merge pull request #104 from colincross/parser
More parser cleanups
2016-06-14 19:07:27 -07:00
Colin Cross
1e73794d42 Add CommentGroups
Determining which comments are contiguous is difficult once they have
been parsed into an out-of-band comment list, as any intervening nodes
are in a separate structure.  Group the comments into CommentGroups
during the parsing stage instead.

Change-Id: I9444c58e75333b7521b58dbfbd36ff29d139b6e3
2016-06-14 15:26:49 -07:00
Colin Cross
1ead6452b5 Make everything a Node
Make File, Assignment, and Module implement Node.  Nodes will be used
later for traversing a File.

Change-Id: I938a5d39d48aee7fe174180b12a2870ecf756b34
2016-06-14 15:26:49 -07:00
Colin Cross
b3d0b8dab4 Rename Pos members
Pos is going to be part of the Node interface, rename the Pos member
of structs to be more specific.

Change-Id: Ibd31119863b96d38bf8dac216e026200a54bbe18
2016-06-14 15:26:49 -07:00
Colin Cross
c32c47938f Remove blueprint/parser.Ident
It wasn't adding anything useful, and it resulted in Name.Name to get to
the identifier.  Replace Name Ident with Name string; NamePos
scanner.Position.

Change-Id: Idf9b18b31dd563a18f27c602c2d14298955af371
2016-06-14 15:26:49 -07:00
colincross
d4f49b07d1 Merge pull request #103 from colincross/parser
Refactor blueprint parser nodes to an interface
2016-06-09 11:02:39 -07:00
Colin Cross
e32cc80f20 Refactor blueprint parser nodes to an interface
Refactor the blueprint parser Value object, which contained a Type enum
and members to hold every possible type, into an interface (now called
Expression).  Rename the existing Expression object that represented a binary
operator Operator.

Also adds and fixes some new printer test cases with mulitline expressions.

Change-Id: Icf4a20f92c8c2a27f18df8ca515a9d7f282ff133
2016-06-08 14:48:53 -07:00
colincross
aedd4903a9 Merge pull request #101 from colincross/doc
bpdoc improvements
2016-06-02 15:39:50 -07:00
Colin Cross
79324963f2 Fix documentation property type for pointers
Change-Id: I7964215adb5e04f5e7a50370e3d98b51ee100ee5
2016-06-02 12:38:24 -07:00
Colin Cross
d9f6fd55dd Remove naming stutter in bpdoc
The word "doc" spread all over bpdoc is redundant and makes it harder to
differentiate the various types and variables.  Everything in bpdoc is a
doc, so remove it.  Also rename Collector to Context.

Change-Id: Ia616d789ee27e7c94d9be231bdb248d45b2b7f39
2016-06-02 12:38:24 -07:00
Colin Cross
017ed2e27b Fix govet issues
Change-Id: I4fb957ed10270ae3c17b458fcc7d7e11cea61417
2016-06-02 12:38:24 -07:00
Dan Willemsen
92077ac024 Merge pull request #100 from danw/blueprint_tools
Add blueprint_go_binary for user-run tools
2016-05-26 12:59:12 -07:00
Dan Willemsen
be275236ac Add blueprint_go_binary for user-run tools
Move these tools from $buildDir/.bootstrap/bin to $buildDir/bin
(configurable by the primary builder).

Also delay building them until the main stage, and give them a phony
target "blueprint_tools".
2016-05-26 10:09:35 -07:00
colincross
0499fc9e1e Merge pull request #99 from colincross/static
Support ExtendProperties that can append or prepend
2016-05-05 23:36:26 +00:00
Colin Cross
75c4701ed2 Support ExtendProperties that can append or prepend
ExtendProperties is the same as AppendProperties or PrependProperties,
but takes a function that determines whether each property should be
appended or prepended.

Change-Id: I26e400d56d75a88bab9c27c382ee5321bc623ee5
2016-05-05 16:23:19 -07:00
colincross
bfeb5df158 Merge pull request #98 from colincross/deptag
Add dependency tags, clone all modules after mutators, support AddInterVariantDependency
2016-04-12 15:19:55 -07:00
Colin Cross
f1875466fc Support dependencies between variants
Variants of a module may need to depend on other variants, for example
to reuse results between variants.  Support AddInterVariantDependency to
add an explicit dependency from one variant to another, along with a
dependency tag.  Both modules must have just been returned by a call to
CreateVariants.

Change-Id: I8f4878f94ced74dd00cfac8303b15ef70cdebf36
2016-04-12 14:52:46 -07:00
Colin Cross
2c1f3d1b28 Add support for dependency tags
Primary builder logic is becoming complicated due to the two pass nature
of mutators that add dependencies and GenerateBuildActions that handle
the dependencies.  The reason why the dependency was added is lost by
the time GenerateBuildActions is called, resulting in build logic that
has to recreate all the dependencies and try to match them up to the
modules returned by VisitDirectDeps.

Change the API of AddDependency to take a DependencyTag interface, which
is satisifed by anything that embeds BaseDependencyTag.  Mutators and
GenerateBuildActions that call VisitDirectDeps can pass each Module to
ctx.OtherModuleDependencyTag to retreive the DependencyTag that was
passed when adding the dependency.

Change-Id: I0814dcd26d1670302d340b77e8dc8704ed7b60bf
2016-04-12 14:52:46 -07:00
Colin Cross
910242b9a6 Clone all modules between mutators and GenerateBuildActions
A common pattern in mutators is to set a property on a module to be used
later in GenerateBuildActions.  A common anti-pattern is to set a member
variable instead of a property.  Setting member variables will appear to
work until a mutator calls CreateVariations after the member variable is
set.  The first variant will have the member variables, but any other
variants will have zero values for all member variables.

To catch this common case early, replace all modules with clones after
running all the mutators but before GenerateBuildActions.

This catches the anti-pattern used in bootstrap, replace the buildStage
member variable with a property.

Change-Id: I6ff37580783a6227ebba2b46d577b443566a79bb
2016-04-12 14:52:46 -07:00
Dan Willemsen
97f6b9b61d Merge pull request #97 from danw/eval
Add SingletonContext.Eval to evaluate ninja strings
2016-03-29 20:19:48 -07:00
Dan Willemsen
4bb62762eb Add SingletonContext.Eval to evaluate ninja strings
Our use case is to write out some configuration variables to give to our
legacy build system. But in order to do that, we either need to keep a
Go copy of all of the configuration, and still have all the calls to
convert them to ninja variables, or evaluate our ninja variables.

Change-Id: If9dda305ed41bc8aabe57dd750a74d8b9af1d1a4
2016-03-28 14:14:15 -07:00
Dan Willemsen
eba92c77e0 Merge pull request #96 from TKilbourn/master
Fix package names for executables.
2016-03-23 21:34:03 -07:00
Tim Kilbourn
a664b0a7d6 Fix package names for executables.
Go 1.6 fixed a bug where compiling with the -pack flag allowed non-main
packages to link.
https://github.com/golang/go/issues/13468

This change uses package main for choosestage and gotestmain.
2016-03-23 20:57:43 -07:00
colincross
4a9ea51800 Merge pull request #94 from yuchenericwu2/master
walkDeps: Fixed bug on non-walked, visited deps.
2016-03-03 15:58:39 -08:00
Yuchen Wu
c02745a845 walkDeps: Fixed bug on non-walked, visited deps.
visited map was not being updated when the dependency was being
visited, only if it was being walked. This led to cases where
duplicate traversals were possible.
2016-03-03 15:53:50 -08:00
Dan Willemsen
24d8100167 Merge pull request #93 from danw/docptrs
docs: Allow propery structs to contain non-struct ptrs
2016-01-13 15:27:12 -08:00