Commit graph

659 commits

Author SHA1 Message Date
Colin Cross
9403b5a790 Delay allocating variationMaps until populating them
Modules are created with a nil variantionMap, which avoids allocating
an empty map if the module will never be split.
Context.addVariationDependencies constructs a variationMap to
compare against the variationMap of each variant, but constructed
an empty variationMap if no variations were specified.  A nil
map is not the same as an empty map, so consistently use a nil
map and create it when populating the first entry.

Change-Id: I48b604659f9cdb23326b504a093cdfe5a3eb4f68
2019-11-14 12:58:52 -08:00
Colin Cross
d03b59d03e Use module groups more widely
Use module groups instead of passing around the list of modules
extracted from a module group.

Test: blueprint tests
Change-Id: I02a79950c6377441c49129ebeb5f12be257df668
2019-11-14 12:58:52 -08:00
colincross
7e8c766ab8
Merge pull request #267 from colincross/maindir
Move outputs of bootstrap modules in main stage to separate directory
2019-10-17 15:51:43 -07:00
Colin Cross
16fec72dfc Move outputs of bootstrap modules in main stage to separate directory
Don't write to $buildDir/.bootstrap in the ninja file generated for
the main stage.

Test: examine main stage build.ninja file
Change-Id: I9c6183c9a434ff11d44cdd4f9844eae192ebfe03
2019-10-17 13:42:34 -07:00
colincross
2f55f24c46
Merge pull request #264 from colincross/create_module
Make CreateModule return the newly created module
2019-09-26 14:30:11 -07:00
colincross
93322c4d7b
Merge pull request #266 from colincross/filter
Add proptools.FilterPropertyStruct
2019-09-26 14:29:04 -07:00
Colin Cross
1907836ad9 Add proptools.FilterPropertyStruct
Move some code from Soong to support creating a property struct
at runtime by filtering fields out of another property struct.

Test: TestFilterPropertyStruct
Change-Id: Ic5ae390a885195bebad6f3ecb7c752c0582a60b1
2019-09-26 14:21:40 -07:00
colincross
5639ec157c
Merge pull request #265 from colincross/int_default
Add proptools.Int and proptools.IntDefault
2019-09-26 10:41:52 -07:00
Colin Cross
6af7284d08 Make CreateModule return the newly created module
Allow mutators to modify properties of the newly created module
by returning it.

Change-Id: Ia1acc70b6196195d1bad58c88ab3def70b99e42c
2019-09-25 14:53:25 -07:00
Colin Cross
66c0b13553 Add proptools.Int and proptools.IntDefault
Add proptools.Int and proptools.IntDefault that behave analogously
to proptools.String and proptools.StringDefault.

Change-Id: I41fd3417c973c9ff4a5aa6680546b4b893784745
2019-09-25 14:52:54 -07:00
colincross
884e7374fb
Merge pull request #263 from jiyongp/reverse_dep
Don't ignore local variations when creating reverse dep
2019-09-22 17:11:21 -07:00
Jiyong Park
df4ed95f43 Don't ignore local variations when creating reverse dep
This fixes a bug that reverse dependency can't be made for modules
having local variations. Previously, when module A having local variants
calls AddReverseDependency to module B having local variants, the match
is tested between the non-local variants of module A against all
variants of module B, which can never be successful.

This change fixes it by using all variants of module A when
findMatchingVariants is called for AddReverseDependency.

Test: m
Change-Id: Ib289188a5dd58c72bd6ba07e3c0f825f8b1c6b1b
2019-09-22 07:44:52 +09:00
colincross
658e01c1d7
Merge pull request #262 from skvadrik/master
Added VisitDirectDeps* methods to SingletonContext.
2019-09-21 08:17:02 -07:00
Ulya Trafimovich
811381a585 Added VisitDirectDeps* methods to SingletonContext.
A an example use case is generating the graph of module
dependencies, where modules are vertices and dependencies
are edges.

The patch was tested with a local implementation of such
a module in the Soong build system. The graph was generated
for all modules in the AOSP tree.
2019-09-20 23:58:23 +01:00
colincross
87050d9327
Merge pull request #261 from colincross/go1.13
Fix compiling binaries with go 1.13
2019-09-06 14:43:56 -07:00
Colin Cross
a2bc585afe Fix compiling binaries with go 1.13
The go compile command in go 1.13 needs -p main instead of
-p $pkgPath when compiling binaries.  This also works for older
go releases.

Also turn on travis for go 1.13.

Change-Id: I45ce185aa44cfa01a7933cc6e52290a85c851641
2019-09-06 14:25:28 -07:00
Dan Willemsen
3f22fcf3a8
Merge pull request #260 from jooyunghan/fix-caller
Fix checkCalledFromInit
2019-09-06 09:36:39 -07:00
Jooyung Han
5dd43cf9b4 Fix checkCalledFromInit
This function checks if it is called from init() by looking into
callers. By the way, it may fail when init() is inlined.

To fix this, CallersFrames() is used to translate PCs into symbolic
information accounting for inlined functions.

Test: go test ./...
Change-Id: I18b3c3ffdaf71f775e3522c87607aec5df7b09c5
2019-09-05 18:10:37 +09:00
colincross
a0b59d9d29
Merge pull request #259 from colincross/default_dependency_variation
Add SetDefaultDependencyVariation
2019-08-09 12:53:48 -07:00
Jiyong Park
1e2e56dc62 Add SetDefaultDependencyVariation
SetDefaultDependencyVariation sets the variation name that will be used
when a dangling dependency is found while a module is being split. A
dangling dependency can occur if a module is split to a variant that one
of its dependencies is not split into. When the default variation is not
set, such dangling dependency is a hard error. But with the new
function, the default variation can be set and subsequent calls to
CreateVariations and its variations on the same context uses the default
variation when necessary.

(If even the default variation does not exist for the dependent module,
it is an hard error)

Note that this is different from calling SetDependencyVariation("foo")
followed by CreateVariations("foo", "bar"). In that case, regardless of
whether a dependency of the current module has the variant 'bar' or not,
only the 'foo' variant is chosen.

With SetDefaultDependencyVariation("foo") followed by
CreateVariations("foo", "bar"), 'foo' variant is used only when the
'bar' variant of the current module depends on a module that does not
have 'bar' variant.

Bug: 138103882
Test: m
Change-Id: I4520ca87487994de024fdbacda3bef6636225f0d
2019-08-09 12:49:11 -07:00
colincross
876099e5e7
Merge pull request #258 from colincross/console
Revert "Put the primary builder into the console pool"
2019-07-18 15:18:22 -07:00
Colin Cross
0e112a8b97 Revert "Put the primary builder into the console pool"
This reverts commit 8ea996f61d.

Having the primary builder hinders automatic error reporting
by separating the error message from the failure status.
2019-07-18 13:53:43 -07:00
Jaewoong Jung
72ab2b4c95
Merge pull request #257 from gyias/master
Fix/improve comments on prepending/appending props
2019-07-08 16:38:34 -07:00
Jaewoong Jung
c067251da0 Fix/improve comments on prepending/appending props
Test: N/A
Change-Id: Id95afbea7fbccddafb9f2f0e068967d5547cc469
2019-07-08 14:07:45 -07:00
colincross
1589d6586b
Merge pull request #255 from colincross/mutator_name
Add MutatorName to mutator contexts
2019-07-02 11:05:28 -07:00
Colin Cross
d8367ff746 Add MutatorName to mutator contexts
Allow querying the mutator name for debugging.

Bug: 136473661
Change-Id: I6a9f1f8cc4fd456d32cc2f2ef85a497c193d7e09
2019-07-02 10:08:55 -07:00
colincross
e3fb08a2cd
Merge pull request #252 from colincross/console
Put the primary builder into the console pool
2019-07-01 23:09:02 -07:00
Jaewoong Jung
d744b671f8
Merge pull request #254 from gyias/master
Make off-the-shelf order funcs public.
2019-06-23 18:04:15 -07:00
Jaewoong Jung
4764fa76fe Make off-the-shelf order funcs public.
These are useful outside the package too when calling
proptools.ExtendMatchingProperties.

Change-Id: I054eb105e0dd5287aff99b8be137a8b09d52492d
2019-06-22 11:22:55 -07:00
colincross
94423de307
Merge pull request #253 from colincross/optimize
Optimize ninjaString.ValueWithEscaper
2019-06-20 11:25:59 -07:00
Colin Cross
19ff727ad5 Optimize ninjaString.ValueWithEscaper
ninjaString.ValueWithEscaper is a relatively hot function,
rewrite it with strings.Builder to avoid repeated string
concatenation, which requires an allocation each time.

Before:
BenchmarkNinjaString_Value/constant/1-72       	100000000	        11.9 ns/op
BenchmarkNinjaString_Value/constant/10-72      	100000000	        18.9 ns/op
BenchmarkNinjaString_Value/constant/100-72     	50000000	        22.1 ns/op
BenchmarkNinjaString_Value/constant/1000-72    	30000000	        39.3 ns/op
BenchmarkNinjaString_Value/variable/1-72       	20000000	        95.1 ns/op
BenchmarkNinjaString_Value/variable/10-72      	10000000	       223 ns/op
BenchmarkNinjaString_Value/variable/100-72     	 3000000	       437 ns/op
BenchmarkNinjaString_Value/variable/1000-72    	 2000000	       948 ns/op
BenchmarkNinjaString_Value/variables/1-72      	10000000	       161 ns/op
BenchmarkNinjaString_Value/variables/2-72      	 5000000	       368 ns/op
BenchmarkNinjaString_Value/variables/3-72      	 3000000	       560 ns/op
BenchmarkNinjaString_Value/variables/4-72      	 2000000	       795 ns/op
BenchmarkNinjaString_Value/variables/5-72      	 1000000	      1004 ns/op
BenchmarkNinjaString_Value/variables/10-72     	 1000000	      2275 ns/op
BenchmarkNinjaString_Value/variables/100-72    	   50000	     39667 ns/op
BenchmarkNinjaString_Value/variables/1000-72   	    1000	   2146592 ns/op

After:
BenchmarkNinjaString_Value/constant/1-72       	200000000	        11.3 ns/op
BenchmarkNinjaString_Value/constant/10-72      	100000000	        17.2 ns/op
BenchmarkNinjaString_Value/constant/100-72     	50000000	        21.7 ns/op
BenchmarkNinjaString_Value/constant/1000-72    	30000000	        38.3 ns/op
BenchmarkNinjaString_Value/variable/1-72       	20000000	        91.8 ns/op
BenchmarkNinjaString_Value/variable/10-72      	10000000	       199 ns/op
BenchmarkNinjaString_Value/variable/100-72     	 5000000	       377 ns/op
BenchmarkNinjaString_Value/variable/1000-72    	 2000000	       855 ns/op
BenchmarkNinjaString_Value/variables/1-72      	10000000	       141 ns/op
BenchmarkNinjaString_Value/variables/2-72      	 5000000	       312 ns/op
BenchmarkNinjaString_Value/variables/3-72      	 5000000	       362 ns/op
BenchmarkNinjaString_Value/variables/4-72      	 3000000	       417 ns/op
BenchmarkNinjaString_Value/variables/5-72      	 2000000	       621 ns/op
BenchmarkNinjaString_Value/variables/10-72     	 2000000	       837 ns/op
BenchmarkNinjaString_Value/variables/100-72    	  200000	      9141 ns/op
BenchmarkNinjaString_Value/variables/1000-72   	   20000	     95094 ns/op

Test: ninja_strings_test.go
Change-Id: I6c61e747d8e67f7f1e6cff0cc0c705745301a35f
2019-06-20 11:05:58 -07:00
Colin Cross
4f6631f74f Remove go 1.9 testing
strings.Builder is not in go 1.9.

Change-Id: If605026850af2819d2a31bb920837150e5031a71
2019-06-20 11:05:58 -07:00
Colin Cross
8ea996f61d Put the primary builder into the console pool
The primary builder should always be running on its own with no
other processes running in parallel, so put it in the console
pool so that it can print to stdout without buffering.

Bug: 80165685
Test: build with print in Soong
Change-Id: If34ecdb5fa18de7e47c4cd6965d551c504850176
2019-06-19 14:39:41 -07:00
colincross
a466306423
Merge pull request #250 from gyias/master
Skip mutated struct properties in bpdoc.
2019-06-05 18:44:15 -07:00
Jaewoong Jung
bd0f6c3488 Skip mutated struct properties in bpdoc.
This change fixes a bug where the `blueprint:mutated` tag was ignored
when used for struct or interface properties. It also fixes a dormant
ExcludeByTag func bug.

Test: m soong_docs, properties_test.go, bpdoc_test.go
Change-Id: I926de2aa203ec552ced897174e9b78e817701a7d
2019-06-05 16:52:47 -07:00
colincross
e263995312
Merge pull request #251 from colincross/glob
Avoid exiting with errors in bpglob
2019-06-03 16:26:23 -07:00
Colin Cross
c708e1c9e3 Avoid exiting with errors in bpglob
bpglob is only used as a helper to check if the primary builder
needs to rerun due to the results of a glob changing.  A recent
change to glob support in pathtools made a glob format that was
accidentally previously accepted into an error.  If the bad
syntax was used in the most recent primary builder run, and
then an incremental build is performed after picking up the
change that made the syntax invalid, then bpglob will attempt
to rerun before the primary builder, see the now-invalid syntax,
and fail.  This will prevent the primary builder from rerunning,
which would have updated the bpglob rule with a corrected glob
syntax (or failed in the primary builder if the Blueprints file
still had the invalid glob syntax).

Avoid exiting with an error in bpglob.  Instead, write the
error to the output file along with a timestamp so that it is
always dirty, forcing the primary builder to rerun.

Bug: 129411151
Test: m nothing
Change-Id: Ib680570c33662f3c0f1f72425d60a963ed841ba6
2019-05-31 15:38:12 -07:00
colincross
abd66e6c82
Merge pull request #247 from colincross/mutator_ctx
Improve module, mutator and singleton contexts
2019-05-21 11:26:19 -07:00
colincross
2201ee55db
Merge pull request #248 from colincross/match
Simplify pathtools.Match
2019-05-21 11:26:10 -07:00
colincross
8ac6d8fcd9
Merge pull request #249 from colincross/bpfmt
Correctly report errors in bpfmt
2019-05-21 11:25:51 -07:00
Colin Cross
e52c33c61c Correctly report errors in bpfmt
bpfmt was always exiting with return code 0, make it use the
exitCode recorded when reporting errors.

Also use the usage function.

Test: bpfmt -o bpfmt.go
Test: bpfmt
Test: bpfmt -h
Fixes: 113069050
Change-Id: I717d524c5f43cd36f52e33964a37324cc04c5df0
2019-05-21 11:03:00 -07:00
Colin Cross
322cc01803 Report creating modules in errors on created modules
Bug: 133172285
Change-Id: I0782c722f5877508691868f96dbf7dc0bed3f9f4
2019-05-20 15:09:48 -07:00
Colin Cross
7bcc256dac Move module and singleton godoc from the implementation to the interface
The interface is visible in godoc, not the implementation, so
move the documentation onto the interface methods.

Test: view godoc
Change-Id: I3460003eed6bf57d8ae4dabe70ab306f049a0060
2019-05-20 15:08:39 -07:00
Colin Cross
99bdb2ab4f Consolidate mutator contexts
Move most of the mutator context methods into BaseModuleContext
so they are available to both top down and bottom up mutators.
Only CreateModule is unique to TopDownMutatorContext, and the
dependency and variation adding methods are unique to the
BottomUpMutatorContext.

The dependency visiting methods are now available on
BottomUpMutatorContext, which requires delaying making newly
added dependencies visible to maintain the invariant that
the mutator has been called on the dependency before the
dependency can be visited by its parents.

Test: m checkbuild
Change-Id: Ie14afc02ac76d0b5a66b0e52de2aa9e17fd1bec0
2019-05-20 14:58:14 -07:00
Colin Cross
818af3bfe0 Fix panic message in SingletonContext.VisitAllModules
The panic should be printing the module info string from the
moduleInfo, not trying to Stringify the Module interface.

Test: manual
Change-Id: I1a2b7c15c4216518c76b909b25d50ac2eb7d1baa
2019-05-20 14:58:06 -07:00
Colin Cross
a26ae89903 Simplify pathtools.Match
filepath.Match has always supported hierarchical patterns (a/*),
so pathtools.Match can be significantly simplified by reusing
filepath.Match directly instead of recursively stepping through
the path elements using filepath.Match on each one.

Test: glob_test.go
Change-Id: I8af59ee880f0402609b994922bafb1961fcabcf3
2019-05-20 14:57:36 -07:00
Colin Cross
a4cc6837db Add more pathtools.Match test cases
Add some more test cases for pathtools.Match before making
signficant changes to it.

Test: glob_test.go
Change-Id: I2eeb5ebf03fb645a2053852a1a9f4e368d22084a
2019-05-20 14:57:31 -07:00
Dan Willemsen
19ef680bc4
Merge pull request #246 from roman-mazur/patch-1
Fix Ninja build system site link
2019-03-23 07:40:25 -07:00
Roman Mazur
4d772202dc
Fix Ninja build system site link 2019-03-23 16:31:07 +02:00
Jaewoong Jung
08ab48903b
Merge pull request #244 from gyias/master
bpdoc preformatted text improvments
2019-03-11 14:25:29 -07:00