Commit graph

2588 commits

Author SHA1 Message Date
Dan Willemsen
187a9bf7d5 Fix running travis on forked repos
If we're not on the official repo, link the directory structure around
so that go can still find the code.
2015-07-23 21:07:32 -07:00
Dan Willemsen
21b6f37cee Require ninja 1.6.0, remove workaround
The workaround no longer works with the new stage selector. We may run
bootstrap.ninja.in twice before running the next stage, but we can't
encode whether to run another ninja instance in the checked in
build.ninja.in.

This can likely be solved, but now that there's an official release with
support for multiple passes, just push up the required version.

Change-Id: I76e321912e323d60e462aabec61bdfcc7118cd5e
2015-07-22 15:51:52 -07:00
Dan Willemsen
958b3acd10 Don't print module header if nothing is defined
Modules may decide not to output any build definitions in some cases.
Clean up the ninja file by not adding headers for empty sections.

One particular usecase is my upcoming multi-stage bootstrapping -
bootstrap_go_* will not output any rules in the first stage unless it's
required to build the primary builder.

Change-Id: I6a6b54da7e1702c63bfa736bcf8daf16956f9449
2015-07-20 17:51:21 -07:00
jgennis
0894cbc1a9 Merge pull request #41 from jgennis/depfix
Fix a sub-Blueprints deps bug.
2015-07-06 17:46:47 -07:00
Jamie Gennis
7ccc2c22e2 Fix a sub-Blueprints deps bug.
This change fixes a bug where directories that could contain a Blueprints file
but currently do not were not being added as a dependency.  This meant that if
a Blueprints file were added to that directory it would not automatically get
picked up by the build.
2015-07-06 17:28:00 -07:00
colincross
0e5a7cde0a Merge pull request #40 from danw/deepcopy
Add deep Copy() for parser types
2015-07-06 13:37:33 -07:00
Dan Willemsen
38b0630a2a Add deep Copy() for parser types
Change-Id: I94bca46d6d30da683cacb0f6ea1fdf26a5a46bc8
2015-07-06 12:49:23 -07:00
colincross
91dc34a563 Merge pull request #39 from colincross/parse
Refactor parsing to allow reuse
2015-07-01 10:34:32 -07:00
colincross
a745030a6c Merge pull request #38 from colincross/comment
Add convenience methods to Comment objects
2015-07-01 10:34:26 -07:00
Colin Cross
23d7aa1b68 Refactor parsing to allow reuse
Refactor parsing Blueprints and walking the Blueprints tree to
allow reuse for tasks that don't involve creating moduleInfo
structures.

Change-Id: I677857a3462999426c8306432074ea97fdcb86c8
2015-06-30 16:43:32 -07:00
Colin Cross
2108971145 Add convenience methods to Comment objects
Add String() to print out the Comment, Text() to print out the
Comment while stripping /*, //, and */, and EndLine() to return
the line number of the last line of the comment.

Change-Id: I076bc0990143acfc03c42a8cc569894fced8ee24
2015-06-30 14:33:38 -07:00
colincross
9c067caf2e Merge pull request #29 from colincross/doc
Add self-documenting support
2015-06-26 16:18:30 -07:00
colincross
7ca0374daa Merge pull request #36 from colincross/filter
Support filtering nested structures by tag
2015-06-26 16:18:11 -07:00
Colin Cross
4572edddfa Add self-documenting support
The primary builder will now generate a rule to call itself with
--docs=.bootstrap/docs/<name>.html to produce an automatically
generated documentation file.

The documentation generation process is:
 - Call each factory once to get empty property structs associated
   with the module type
 - Use reflection to determine the names of the type of each property
   struct
 - Use the bootstrap_go_package modules from reading the Blueprints files
   to find the source files for each Go package used to build the primary
   builder
 - Use the go/parser module to find the type declaration for each
   property struct
 - Extract comments for the property struct and each property declaration
 - Format all the comments into HTML

Change-Id: Icae9307cc10549a30bfc14d6922824099de5a9b0
2015-06-26 10:51:44 -07:00
Colin Cross
4adc819490 Support filtering nested structures by tag
Allow tagging a nested property structure with
`blueprint:"filter(key:\"value\")"`, which will only allow property
assignments to properites in the nested structure that are tagged
with `key:"value"`.  Moving the filter into Blueprint instead of
the project build logic allows more reliable and consistent error
messages.

Change-Id: I06bc673dde647776fc5552673bdc0cdcd7216462
2015-06-26 10:46:17 -07:00
colincross
944a7a5ed4 Merge pull request #37 from danw/runtests
Add option to build and run tests during bootstrap
2015-06-26 10:45:10 -07:00
Dan Willemsen
87ba294ceb Add option to build and run tests during bootstrap
Users that want to enable this option can use the '-t' option to
bootstrap.bash when passing '-r'. Builders that want to enable this can
set the RUN_TESTS environment variable in their bootstrap.bash.

The gotestmain tools is needed to write the main functions for the test
binaries, since 'go test' doesn't work well in this environment.

Change-Id: Iec5c2b5c9c3f5e3ba0ac8677fb88f5e963f9bd3f
2015-06-25 11:45:54 -07:00
Dan Willemsen
30a80c3e5f Create internal bootstrap Config struct
Change-Id: If5c5ce3d5c46196cf9b77ff9f5c68b8849474823
2015-06-24 22:44:37 -07:00
colincross
2a874e45a9 Merge pull request #35 from colincross/glob
Fix glob dependencies when initial non-wild path does not exist
2015-06-18 17:10:39 -07:00
colincross
202c223274 Merge pull request #31 from danw/regen-name
Support bootstrap regeneration with different filename
2015-06-18 17:09:58 -07:00
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