Commit graph

3018 commits

Author SHA1 Message Date
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
Jamie Gennis
6a5825efe2 Add CreateLocalVariations to BottupUpMutatorContext.
Change-Id: I6cc0afae699cf03f84a70e5582cf554642bbd481
2015-05-19 11:26:11 -07:00
colincross
e491e9cd35 Merge pull request #27 from wangying1015/small-fix
Fix insertion to Context.moduleNinjaNames
2015-05-15 22:02:24 -07:00
Ying Wang
fe7f7c46e1 Fix insertion to Context.moduleNinjaNames
Don't put nil to c.moduleNinjaNames[ninjaName].

Change-Id: I393c584931b702e63663e14263d365582abe8ce7
2015-05-15 18:31:34 -07:00
Colin Cross
802e9759cd Add proptools.CloneEmptyProperties
Modules that want properties that vary by variant often need to create
zeroed copies of property structs.  Add CloneEmptyProperties to proptools
that is the equivalent of calling CloneProperties and then ZeroProperties,
but is much faster because it directly creates zeroed objects.

Saves 200ms in Context.ParseBlueprintsFiles and Context.ResolveDependencies
in one case, which will be valuble when we start parsing Blueprints files
for cases where we are not regenerating the manifest, for example when
generating documentation or doing context-aware bpfmt.

Change-Id: I3d4a6af2f393886d95f27d15afc1a455d8dd5fc6
2015-05-14 15:55:10 -07:00
jgennis
36bb07cf3c Merge pull request #25 from colincross/fardependency
Add support for "far dependencies"
2015-05-11 15:38:26 -07:00
jgennis
8bb532fa1e Merge pull request #22 from colincross/build
Add support for build= magic variable to specify sub-Blueprints files
2015-05-11 14:58:36 -07:00
Colin Cross
8948623d44 Add support for "far dependencies"
AddVariationDependencies is used to add dependency modules that
have the same variations as the depending module, but with additional
variataions.  It cannot be used to add a dependency that is unrelated
to the depending module, for example a dependency on a code generator
that needs to run on the host to generate a target source file.

Add AddFarVariationDependencies, which adds a dependency on a module
that contains all the passed variations, but ignores the variations
of the depending module, as well as any unspecified variations on
the dependency module.

Change-Id: Ief696ec85cf33ad5fb187227d215c1c2e894f962
2015-05-08 11:14:54 -07:00
jgennis
f0545a48de Merge pull request #24 from colincross/glob
pathtools.Glob bugfixes and features
2015-04-30 10:37:46 -07:00
Colin Cross
5d6d4c7efb Add GlobWithExcludes to pathtools
Add GlobWithExcludes, which takes a pattern and a list of exclude
patterns, and returns all files that match the pattern but do not
match any exclude patterns.

Change-Id: I8b94b3ba5a37409071b475b9a4035f52f47863f1
2015-04-29 22:31:44 -07:00
Colin Cross
7bac3c6cf2 Add recursive glob support to pathtools.Glob
Recursive globs are supported by passing ** in any single non-final
path element.  For example, path/**/*.java will find all files named
*.java under "path".

Change-Id: Ifebd76f8959289f7d0d378504053c1c6b88cdeed
2015-04-29 22:31:40 -07:00
Colin Cross
2939422b3e Support subname= to change name of sub Blueprints files
Setting the "subname" variable will modify the name of Blueprints
files searched in sub directories.  If the specified name is not
found it will fall back to trying "Blueprints".  The subname
variable stays in scope for all subdirectories.

Change-Id: If3c8ac54735042076fb264d33719d9ea4b8934b3
2015-04-27 14:04:14 -07:00
Colin Cross
4b793e5798 Rewrite pathtools.Glob to track partially-matched directories
The directory structure:
  a/
    a
  b/
    b
With the glob pattern */a would previously return []string{"a"} for
dirs, but it needs to return []string{"a", "b"} in order to re-run
the generator if a file called "a" is created inside b/.

Rewrite Glob to manually recurse through path elements, only calling
filepath.Glob for a pattern with wilds in the last element of the
path, and add the globbed directory to the dirs list each time.

Also add tests and test data for pathtools.Glob.

Change-Id: Ibbdb2f99809ea0826d4fa82066cf84103005ef57
2015-04-24 11:11:15 -07:00
Colin Cross
1fef536ea6 Add support for build= variable
build is a magic variable that acts similarly to subdirs, but specifies
files to build instead of subdirs.  Using files provides a few advantages:
files can be named something more appropriate for the project than
"Blueprints", whatever you want instead of Blueprints, and multiple
Blueprints files can exist in the same directory.

A new variable is used instead of putting filenames into subdirs to avoid
unexpected behavior when a glob matches both files and directories.

subdirs= and build= entries that don't match any directories or files
are now reported as errors.

Change-Id: Id329504ace251eab4ccea1081a3c8665a4c52f5a
2015-04-20 17:25:17 -07:00
Colin Cross
63d5d4d9e4 Fix formatting
gofmt -w .

Change-Id: If9cf0b7bd810f899edffcd2edf361fa83245bd2a
2015-04-20 16:41:55 -07:00
jgennis
efe578a605 Merge pull request #21 from jgennis/rbase
Adding a builtinPool type
2015-04-16 10:17:16 -07:00
Ken Oslund
4b9a0514cd Adding a builtinPool type
This implements the Pool interface. An instance of a builtinPool
is created for the Console pool.

Change-Id: I03334c25495dc573aef2c0e62415352a0b10d6fd
2015-04-16 13:10:19 -04:00
colincross
adccb7fccb Merge pull request #19 from colincross/performance
Performance improvements
2015-04-15 12:20:36 -07:00
Colin Cross
5bdb4ca1a5 Set GOMAXPROCS to number of CPUs
Apparently Go only allows a single thread to be executing by default,
so the increase in performance seen when concurrency was added to
Blueprint was entirely due to scheduling goroutines while the
executing goroutine was blocked in a syscall.  Whoops.

Set GOMAXPROCS to the number of CPUs.  Reduces wall thime by >2x on
one workload.

Change-Id: Ib5fc7761c09a076fc5a1b7f08f5ccf034304477c
2015-04-15 11:03:17 -07:00
Colin Cross
8c1c6c03f8 Pre-allocate ninjaString slices
Naively pre-allocate ninjaString slices by counting $ characters as
an estimate of how many variables will be needed.  Saves 5% cpu time
on one workload.

Change-Id: Ib3a41df559d728b2db047f6dbbf9eb06d7045303
2015-04-15 11:03:17 -07:00
Colin Cross
7bf6f62130 Replace ReplaceExtension regexp with manual string operations
regexp is overkill for a simple extension replacement, just find
the last '.' and add the new extension after it.  Saves 5% cpu time
on one workload.

Change-Id: Ic299c9ec5132d15bbea2c9c7778c000d6fdf509a
2015-04-15 11:03:06 -07:00
Colin Cross
8ac0a812f1 Optimize ninja_writer
Prebuild a string of all spaces to avoid calling strings.Repeat for
every indented line.  Replace appendWithWrap function with a class
that handles counting bytes on a line as they are written instead of
buffering lines, and avoids extra string concatenations by providing
a function that implicitly adds a space.  Saves 10% wall time on one
workload.

Change-Id: I571d70366ee5db21c40c1c98d0fe92d640efefab
2015-04-15 11:03:06 -07:00
jgennis
75de3e8e1d Merge pull request #20 from colincross/unique
Fix makeUniquePackageNames
2015-04-14 22:44:22 -07:00
jgennis
82a6f6fa87 Merge pull request #18 from colincross/ninjastring
Fix bug in parseNinjaString
2015-04-14 22:32:06 -07:00
jgennis
503b811a8e Merge pull request #17 from jgennis/rbase
Upstreaming some changes
2015-04-14 22:30:00 -07:00
Jamie Gennis
c7988251aa Always update deps after bottom-up mutators run.
This fixes a bug where a split module could be reached by subsequent
mutator passes, but it is no longer in module group's list of modules.

Change-Id: I74c3d849ed2614dcdb6f54a6760122b933bb84c2
2015-04-14 23:35:47 -04:00
Michael Beardsworth
1ec445369f Add support for arbitrary globs in subdirs
Change-Id: I874535483266622213dbcfe3c84875f41a136b9f
2015-04-14 23:34:34 -04:00
Jean-Francois Dupuis
418d5c5278 Add function to return list of globbed file
Change-Id: If501246dc4d7d5b877cc2f871f8786f47c200d00
2015-04-14 23:34:30 -04:00
Christian Zander
c4d07d8fb5 Make WriteDepFile escape spaces and special characters
This commit makes deptools.WriteDepFile() escape spaces and the
following set of special characters in the dependencies it
writes to files used as Ninja depfiles: \, #, *, [, |.  Without this
change, dependencies with paths including any of the above may not
function as intended.

Change-Id: I3560a34de930932422200985fb479515a21d9508
2015-04-14 23:34:24 -04:00
Colin Cross
0d44125b02 Fix makeUniquePackageNames
makeUniquePackageNames never assigned to pkgs, so all packages
were using their short names, even if another package had the
same short name.

Change-Id: I5420f7839efd25362d6c5d85265399ce7b29ddb2
2015-04-14 18:02:20 -07:00
Colin Cross
b247893deb Fix misparsed $ after variable name
If a $ sign occurs after a variable name, the ninja string parser
fails to check if it is a $$ or a ${.  Go to the
parseDollarStartState instead of the parseDollarState.

Since it is not yet known if the $ is the beginning of a new
variable (${ or $<alphanumeric>) or a string ($$), an empty string
separator cannot be added to the ninjaString strings list.  Instead,
add functions to push strings or variables onto the ninjaString,
and automatically add the blank separator if two variables are
pushed in a row.

Change-Id: Ia1cae6259b1d7e4f633f61b9eadb2a2028bbd5f0
2015-04-14 16:21:53 -07:00
colincross
e28dbe4d0c Merge pull request #16 from ciarand/patch-1
Indent code block in doc.go
2015-04-11 20:08:01 -07:00
Ciaran Downey
88489409ea Indent code block in doc.go 2015-04-11 09:52:11 -07:00
jgennis
11bcca9098 Merge pull request #15 from colincross/cycle
Fix cycle printing
2015-03-31 15:28:10 -07:00
Colin Cross
0e4607e788 Fix cycle printing
The patch "Fix panic when dependency cycle includes the first
module visited" caused cycles to print incorrectly by initializing
the current module to be the last module in the cycle, when it
should be the first module in the cycle.

Change-Id: Iaf939283a48faa4cc6eeb9b19aed57993575a687
2015-03-24 16:42:56 -07:00
jgennis
91d25f2c55 Merge pull request #12 from jgennis/master
Update import paths to include github
2015-03-23 12:16:48 -07:00
Jamie Gennis
aefb6570ee Add .travis.yml to configure CI 2015-03-21 03:12:46 -04:00
Jamie Gennis
6cafc2cddc Update import paths to include github 2015-03-21 01:03:36 -04:00
jgennis
4dfe36d029 Merge pull request #11 from colincross/bpfmt
bpfmt fixes
2015-03-20 17:44:48 -07:00
jgennis
4063fb386e Merge pull request #10 from colincross/mutator
Add error checking for calling CreateVariations with no variants
2015-03-20 17:39:40 -07:00
Colin Cross
96e5670496 Allow parsing Blueprints files without evaluating
Running bpfmt or bpmodify on a Blueprints file that references
variables defined in a parent Blueprints file causes parse errors
on unknown variables.  Modify the parser to parse in two modes,
parser.Parse and parser.ParseAndEval.  The first parses without
attempting to evaluate variables and expressions, the second
performs a full evaluation.

Change-Id: Ic11948ea77c8e65379d7260591ada15db0e4f5b9
2015-03-20 16:55:32 -07:00
Colin Cross
85398a916a Simplify printer whitespace and newline handling
Trying to handle all the whitespace and newline printing inside
printToken got overly complicated, and resulted in a few bugs in
the layout around comments and indentation that were hard to fix.
Rewrite the whitespace and newline handling to be handled directly
by the object printers, using requestSpace() to ensure whitespace
is inserted and requestNewline() to ensure a newline is inserted.

Also fixes unnecessarily left aligning all comments that contain
indentation, and fixes accidentally unindenting comments that are
the last token in their indented block.

Change-Id: I18707802726107cf0b6ec7de9b542d0ec1d2c0dd
2015-03-20 16:55:32 -07:00
Colin Cross
f4d18a685d Add error checking for calling CreateVariations with no variants
Calling CreateVariations with no variants will corrupt the
modules list with a module with nil logicModule, panic early
with a useful message instead.

Change-Id: Ic5c921efcba70c54efb5bb21a9626b2999376a69
2015-03-18 17:43:15 -07:00
jgennis
bc21793f6c Merge pull request #9 from colincross/createvariations
Document subtle behavior in createVariations
2015-03-16 11:56:07 -07:00
jgennis
f7b78666ba Merge pull request #8 from colincross/splicemodules
Fix a bug in spliceModules and add tests
2015-03-16 11:55:33 -07:00
jgennis
8db1fd58ca Merge pull request #7 from colincross/contributing
Add CONTRIBUTING.md file
2015-03-16 11:54:50 -07:00
Colin Cross
21e078a44a Document subtle behavior in createVariations
createVariations relies on reusing the logicModule for the first
variant in order to replace the original module in the global module
map, which prevents leaving old split modules around in the global
module map.  Add comments to explain the behavior.

Change-Id: Ia06d7fa4bc777e807241996d4e8bf977e641d741
2015-03-16 10:57:54 -07:00