Commit graph

115 commits

Author SHA1 Message Date
Colin Cross
7e72337259 Reduce maximum goroutine count
Running with the data race detector enabled hits a 8192 active
goroutine limit.  Reduce the maximum number of active goroutines
by limiting parallelVisit to 1000 goroutines.  Also rewrite
cloneModule in terms of parallelVisit.

Change-Id: Icdd63648e8e010557b624e12592156490b40adb9
2018-04-10 16:51:29 -07:00
Dan Willemsen
e6d45fe39f Support go1.10
Add stubs for the new testDeps interface functions. Also removes testing
for 1.8.

Change-Id: Ice58cca20658d905df9fb87e822d7861abf60976
2018-02-27 01:49:49 -08:00
Dan Willemsen
b6c90239d6 Append / to directories in Glob results
This makes it easy for users of Glob to detect whether the match is a
file or directory. Doing the check at this level means that the filelist
file used as a dependency will be updated if a directory is replaced
with a file of the same name, or vice versa.

Change-Id: I79ebba39327218bcdcf50b393498306119de9d6c
2018-02-23 17:21:37 -08:00
Jeff Gaston
a7e408af0a prevent file=nil panic if syntax error in Blueprints
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'
Test: put a syntax error in a file and see that the
      reported error reports the location of the violation

Change-Id: Iaeedb91ea8e816cb8e9ee954f21cd6c6bc4afa48
2017-12-05 16:09:02 -08:00
Jeff Gaston
8fd9578a6a have openAndParse use return values rather than channels
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'

Change-Id: I941dfa76b94178198994a280eb40bcded891eda1
2017-12-05 15:26:57 -08:00
Jeff Gaston
5800d046c1 rename parseOneAsync to openAndParse
Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      'build/blueprint:work^^^' 'build/blueprint:work'

Change-Id: I56e08716057c3746b01b7a5e43f0223ee1f940db
2017-12-05 15:26:57 -08:00
Jeff Gaston
0e90759bfe Make ninja file deterministic even with dup module names
Bug: 65683273
Test: ./build/soong/scripts/diff_build_graphs.sh \
      --products=aosp_arm '' ''

Change-Id: I5e45b2309ba4993ba2180b5f9a4785f31e28d503
2017-12-04 17:16:21 -08:00
Jeff Gaston
f23e36690e Disallow bp 'build' includes to reference other dirs
Bug: 65683273
Test: add 'build = ["sub/nope.bp"]' to an Android.bp; notice the error

Change-Id: Ic0f171f283edda074f65a76029e660dfaab2504b
2017-12-04 17:16:21 -08:00
Jeff Gaston
3c8c3346d2 Pass ModulePath to NameInterface
To allow it to validate that the filename equals Android.bp

Bug: 65683273
Test: m -j nothing # which runs tests
Change-Id: I171dddd102590df558053b615d39c75c00b6ac6e
2017-12-04 17:16:21 -08:00
Jeff Gaston
656870fbca Have handleOneFile(child) wait for handleOneFile(parent).
Bug: 65683273
Test: m -j nothing # which runs unit tests

Change-Id: I850e78ebcdbee68637f66d81fc127f19dd28508a
2017-12-04 17:16:21 -08:00
Jeff Gaston
d70bf75491 Extract module naming into an interface
in facilitate moving name resolution to Soong

Bug: 65683273
Test: build/soong/scripts/diff_build_graphs.sh \
      --products=aosp_arm \
      'build/blueprint:work^' 'build/blueprint:work'
      # and see that the only changes were:
      # 1. adding the name_interface.go file
      # 2. changing some line numbers

Change-Id: Ifa7603cca59b3b3d592f2f146fdafe57012bd4b9
2017-11-29 12:01:09 -08:00
Jeff Gaston
9f63090a4c Support files named Android.bp in tests
Bug: 65683273
Test: m -j nothing # which runs unit tests

Change-Id: I00862cd9673719424a2b18e347c7f9fe84be2857
2017-11-20 17:03:49 -08:00
colincross
7ab9124b27
Merge pull request #183 from colincross/presingleton
Add presingletons
2017-11-07 14:50:05 -08:00
Colin Cross
5f03f11c0a Add presingletons
PreSingletons use the same interface as Singletons, but run after
parsing all the blueprint files but before running any mutators
or GenerateBuildActions.  They can be used to perform global setup,
including generating rules, that may be referenced by later
mutator or generate passes.

Test: m checkbuild
Change-Id: I4b93425a724e739f5b8843262efb8804b3bf3531
2017-11-07 13:31:33 -08:00
Jeff Gaston
3802ba9f18 No longer follow subdirs in Android.bp files
because there some symlinks named Android.bp that point to
files named Android.bp that contain <subdir> entries that
are supposed to be interpreted relative to the original
symlink. It's more convenient to just skip following subdirs.

Bug: 64363847
Test: make -j
Change-Id: Ib15f1d1c7d511191fd841b1a29ceed559dd6cdbb
2017-10-30 15:00:19 -07:00
Jeff Gaston
c3e2844dfe Support for a custom list of Blueprints files to parse
Bug: 64363847
Test: BLUEPRINT_LIST_FILE=out/.module_paths/Android.bp.list minibp

Change-Id: Id7f8cb1ab3a6684b3f8265d77bb32413957f1c93
2017-10-30 15:00:19 -07:00
Jeff Gaston
a12f22fb69 Move parseOne for readability
Bug: 64363847
Test: m -j
Change-Id: Ie3e973dadbff139def127b0bb05c57bafb79165b
2017-10-30 15:00:19 -07:00
Jeff Gaston
5f763d0511 Clarify context.go somewhat
in preparation to support parsing a predefined list of Blueprints files

Bug: 64363847
Test: m -j
Change-Id: I98cc98dc17ecaf69b95272d32cd83adbdb0e8c5b
2017-10-30 15:00:19 -07:00
colincross
b67c1d433c Merge pull request #166 from colincross/create
Add TopDownMutatorContext.CreateModule
2017-09-20 14:09:15 -07:00
Jeff Gaston
aca4220583 Clearer error in case of Android.bp being unreadable
Bug: 64600838
Test: mkdir errtest \
      && ln -s /tmp/dontexist errtest/Android.bp \
      # and add errtest to ./Android.bp \
      && m nothing \
      # and check that the error message mentions a symlink

Change-Id: I841ec12d613f61ccc3396538062bee48c8c1ca27
2017-09-01 17:29:30 -07:00
Colin Cross
874a346904 Let mutators use ctx.AddNinjaFileDeps
Propagate extra ninja file deps through mutators so that they
can use ctx.AddNinjaFileDeps.

Test: blueprint tests
Change-Id: I299a0665c3f63b020ae345889fd78b91b91b215a
2017-08-01 15:12:12 -07:00
Colin Cross
af4fd215eb Add TopDownMutatorContext.CreateModule
Allow a module to create other modules as if they were specified
in a blueprint file.  CreateModule takes the name of a module type,
calls the factory function the module type, and then inserts
properties into the property structs returned by the factory.

Bug: 64161749
Test: TestCreateModule
Change-Id: Ic1903305d6b08eae1edc7f0fb4137e85544aac0f
2017-08-01 15:12:12 -07:00
Colin Cross
5fe225f5f9 Rename newModules to newVariations
The next patch will introduce creating new modules, so rename the
current variable that contains new variations of existing modules
to avoid confusion.

Test: blueprint tests
Change-Id: Ic1d3824e54e51c282a08f8ecef8fc658cc503a65
2017-08-01 15:12:12 -07:00
Colin Cross
d2f4ac1224 Rename moduleInfo.moduleProperties to properties
Remove unnecessary name duplication.

Test: blueprint tests
Change-Id: I2c65ce6a164e47e855dd3bb1c7bee957dfd422ae
2017-08-01 15:12:12 -07:00
Colin Cross
4a02a3019a Cap concurrency when parsing blueprint files
Darwin has a default limit of 256 open files per process.  Parsing
too many blueprint files in parallel can hit the limit.  Cap the
concurrency at 200.

Test: manual testing with limit set to 32
Change-Id: Ic64d21d2c0ffd7c86bf3f02fb51216ee5684a80c
2017-05-16 10:55:29 -07:00
Dan Willemsen
978c4aa92f Improve error messages when dependency variants are missing
Instead of just saying:

error: .../Android.bp:48:1: dependency "libc++" of "libtest" missing variant "arch:android_arm_armv7-a, link:shared, vndk:"

Include a list of currently existing variants:

error: .../Android.bp:48:1: dependency "libc++" of "libtest" missing variant:
  arch:android_arm_armv7-a, link:shared, vndk:
available variants:
  arch:android_arm_armv7-a, link:shared
  arch:linux_x86, link:shared
  arch:linux_x86_64, link:shared
  arch:windows_x86, link:shared
  arch:windows_x86_64, link:shared

This still isn't the best experience for users, but it at least provides
enough information for someone more familiar with the build to
understand the problem.
2017-03-20 14:23:43 -07:00
Colin Cross
080c1336b5 Add Context.VisitDirectDeps
Context already has VisitDepsDepthFirst[If], add VisitDirectDeps[If].

Change-Id: Id550bc14275db230c19fd6ca14b67b305dd7d96b
2017-03-17 13:46:47 -07:00
Nan Zhang
346b2d0d80 Added a check in BP level for BaseDependencyTag
It is not allowed to directly use BaseDependencyTag as customized
user dependency tag passed down to BP since it might cause issues
that different type of modules will be mixed when fetched based on
Tag.
2017-03-10 16:39:27 -08:00
Colin Cross
b519a7e1b6 Add globbing to filesystem mocking
Add globbing to filesystem mocking so that more code can be tested
against the mock.  Also moves the filesystem mock to pathtools,
and renames pathtools.GlobWithExcludes to pathtools.Glob, replacing
the existing pathtools.Glob.

Test: blueprint tests
Change-Id: I722df8121bc870c4a861d7c249245c57dcb607be
2017-02-02 16:48:06 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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