Commit graph

121 commits

Author SHA1 Message Date
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
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
colincross
262fd82632 Merge pull request #6 from norwack/master
Fix typo
2015-03-16 10:47:37 -07:00
Norwack
da78a71a59 Fix same typo in doc.go 2015-03-16 18:31:55 +01:00
Colin Cross
72bd193edf Fix a bug in spliceModules and add tests
spliceModules was carefully reallocating the slice if necessary, and
then throwing away the reallocated slice and writing to the too-short
original slice.  Fix the bug, and add tests that would have caught it.

Change-Id: Ifc13b2025198b270c97097fd7d28cd36e460c98c
2015-03-16 00:13:59 -07:00
Colin Cross
ed5c21b1dc Add CONTRIBUTING.md file
Add file to describe the procedure for submitting patches to
Blueprint.

Change-Id: I9601b5ab47e9d1230c2b3064a590d9eac1478433
2015-03-16 00:12:49 -07:00
Norwack
7fdf32b42f Fix typo 2015-03-15 22:29:02 +01:00
colincross
96555d687e Merge pull request #5 from colincross/earlymutators
Support for early mutators
2015-03-13 19:56:52 -07:00
Colin Cross
f5e34b98ca Split "variant" terminology into "variant" and "variation"
"Variant" has been used to mean two slightly concepts in Blueprint.
The first and most obvious is a variant of a module, meaning a list
of all the ways that on version of a module differs from other
versions of the same modules, for example "arch:arm, link:static".
The other is for the specific way that a version of a module differs,
"arch:arm".

Rename all of uses of "variant" as the second meaning to "variation",
and update the documentation to clarify "variant" vs. "variation".
This modifies the build logic api to convert CreateVariants to
CreateVariations.

Change-Id: I789ef209ae6ddd39ec12e0c032f9f47f86698fe6
2015-03-13 16:02:36 -07:00
Colin Cross
65569e4375 Add early mutators
The mutators that run after dependencies are resolved can be too late
to support build logic that needs to vary the dependencies based on
the mutated axis, for example architecture.  This patch provides an
EarlyMutator interface that can be used to mutate modules before
any dependencies have been resolved.

In order for dependencies to be satisifed in a later pass, all
dependencies of a module must either have an identical variant,
must have a single variant, or must be inserted using
DynamicDependencyModuleContext.AddVariantDependency.

Change-Id: Ic6ae57e98edfd6c8c09a7788983128d3e4e992f0
2015-03-13 13:41:41 -07:00
Colin Cross
ab6d790165 Move build actions into modules
Move actionDefs from moduleGroup to moduleInfo.  This will result
in multiple build.ninja headers for a single Blueprint file module
if it has multiple variants, each one specifying the variant
used to generate the following rules.

Change-Id: I414cd4d3266da8c2e92118b295569627ddf48cdd
2015-03-12 17:36:57 -07:00
Colin Cross
7addea35a1 Iterate through modules directly
Instead of iterating through groups and then iterating through the
group's modules, iterate through the modules directly.  This will
allow circular dependencies between groups as long as the individual
modules don't have circular dependencies.  In order to maintain the
ordering of modules in a group, each module is considered to have
an implicit dependency on any earlier modules in the same group.

Change-Id: Ibce67167c7234db70ede0a6b5c2b43fb8e0bb05d
2015-03-12 17:36:57 -07:00
Colin Cross
e7daa22927 Rework the way variant names are stored
Replace the array of mutator name/variant name pairs with
a map of mutator name to variant name, and store the string
variant name separately.

Change-Id: I181c2fcb05724c8755b90aaf866fdce9ef720b01
2015-03-12 17:36:54 -07:00
Colin Cross
ed342d983c Move values from moduleGroup to moduleInfo
Move most of the contents of moduleGroup into moduleInfo.  This will
eventually reduce moduleGroup to a simple list of variants of the
same module.

Change-Id: I4289eb9953509751d7637558cd6db73373ccdf78
2015-03-12 17:22:18 -07:00
Colin Cross
6134a5c66a Relax module naming restrictions
Forcing module names to be valid ninja names is an unnecessary
restraint on the project build logic.  Allow any string as a
module name, and sanitize and uniquify the module name for use
in module-scoped variables.

Also move the module scope to be per-module instead of per-group
so that modules can use the same local variable name for each variant.

Change-Id: If44cca20712305e2c0b6d6b39daa5eace335c148
2015-03-12 17:22:18 -07:00
jgennis
50fb09375a Merge pull request #4 from colincross/bugfixes
Bugfixes
2015-03-11 16:43:58 -07:00
Colin Cross
10b54db7cc Fix panic when dependency cycle includes the first module visited
The cycle check can panic if the first call to check happens to land
on the first module in a cycle.  Print the cycle instead of panicking.

Change-Id: I6fc1c66dcc37b1eb6b11b9e65343452af3c8538d
2015-03-11 16:09:00 -07:00
Colin Cross
62e681a288 Fix bug when copying slice to itself
If proptools.CopyProperties is passed two values that point same
slice then setting the destination slice to a new slice will
overwrite the source slice, and the properties struct that is both
the source and destination will have an empty slice.  Copy into
the new slice using a new reflect.Value, and then update the
destination.

Change-Id: I1bfcdc51e4278ea7c7ed81dafc928a5471219f05
2015-03-11 16:09:00 -07:00
Colin Cross
969c70342a Fix whitespace in parser/parser.go
Change-Id: I75875cbf60efc9aaf7c2df5709533c2c04b6fba4
2015-03-10 14:42:13 -07:00
jgennis
b96aa8b58f Merge pull request #3 from colincross/features
New features
2015-03-10 13:06:59 -07:00
jgennis
482e8cf331 Merge pull request #1 from colincross/bugfixes
Miscellaneous bugfixes
2015-03-05 17:19:29 -08:00
jgennis
40e81c3a3e Merge pull request #2 from colincross/docs
Add overall Blueprint documentation
2015-03-05 17:04:50 -08:00
Colin Cross
174ae059cc Report variant errors instead of panicing
Variant errors can be introduced by Blueprints files, so print
a module error instead of panicing.
2015-03-04 14:00:50 -08:00
Colin Cross
cb7b9ad6ca Go back to the old Blueprints file format
Switch back to:
moduleType {
    name: value,
    arch: {
        x86: {
            name: value,
        },
    },
}

This provides better consistency between properties defined at the
top level of a module and properties defined inside a map.

The parser will continue to support the other format for now, but the
printer will only produce the original format.
2015-03-04 14:00:06 -08:00
Colin Cross
d9d92cb75d Print names of files deleted by cleanup phase
Change-Id: Ia9c5408b1b159843dbc57e2e480ca2972598186d
2015-03-04 14:00:06 -08:00
Colin Cross
542fd55c38 Allow adding maps
Add support for + operator on maps.  The semantics are that keys that
exist in both maps are added with the + operator, and keys that exist
in one map are copied to the resulting map.

Change-Id: Iba9a6f886477a1eb7311272d07944800c806e368
2015-03-04 14:00:06 -08:00
Colin Cross
c7ffa30b8a Add VisitDirectDeps to module context
Change-Id: I271db2120aba1a5c99f21198f1eff6370e6e2389
2015-03-04 14:00:06 -08:00
Colin Cross
b274e6c8e5 Support += assignments
Support += assignments to variables.  Variables are now mutable
up until they are referenced, then they become immutable.  This
will allow variables to be modified in a conditional, or allow
better commenting on why parts of a variable are set.

Change-Id: Iad964da7206b493365fe3686eedd7954e6eaf9a2
2015-03-04 14:00:06 -08:00
Colin Cross
9a103c0ed4 Modify printer to be stricter about extra newlines
The printer was allowing extra newlines in odd places, for example
between a property name and the '=' in a module definition.  Make
newline location stricter by explicitly allowing newlines or
line comments.
2015-03-04 13:57:21 -08:00
Colin Cross
8900e9bd37 Exit early from generateModuleBuildActions on error
generateModuleBuildActions was continuing to call GenerateBuildActions
on all modules even after one returned an error.  This could cause a
later module to panic because it was missing information that was
supposed to be generated by the module that returned an error, hiding
the earlier error message.

If a module returns an error, stop triggering any new goroutines to
call GenerateBuildActions on later modules.
2015-03-04 13:27:39 -08:00
Colin Cross
93ef72d283 Don't fail cleanup when a file has turned into a directory
If .ninja_log contains an entry that used to be a file but is now a
non-empty directory the os.Remove call will fail.  Silently ignore
this error, if the files in the directory are abandoned the directory
will be cleaned up when the files are removed.
2015-03-04 13:27:30 -08:00
Colin Cross
11e3b0d000 Fix deadlock when there are no modules
Change-Id: Ibfc1190f2b5ac3c3445d40f1b5dd0cd782e63dfd
2015-03-04 13:27:20 -08:00
Colin Cross
e7a26ff65a Add overall Blueprint documentation
Change-Id: I27f0f010c32b3abe0107e69af830716ab728485a
2015-02-04 11:23:46 -08:00
Jamie Gennis
c4b691f2fb Add an initial README.md 2015-01-27 16:34:17 -05:00
Colin Cross
f5bd828a14 Run bpfmt -w . to reformat Blueprints file
Updates the Blueprints file to the new format and standard layout.

Change-Id: I1bfb67ab106c2a61fbe6f8201195efc3f8ff5566
2015-01-26 16:56:10 -08:00
Colin Cross
8e0c51192a Add license headers and LICENSE file
Change-Id: I6f7c7374093c0745ee4aa677480376a06648b358
2015-01-23 14:23:27 -08:00
Colin Cross
3e8e74f276 Move blueprint/* up a directory
Make integrating with go tools easier by putting the blueprint package
files in the top level directory of the git project instead of in a
subdirectory called blueprint.

Change-Id: I35c144c5fe7ddf34e478d0c47c50b2f6c92c2a03
2015-01-23 14:23:27 -08:00
Colin Cross
6bb4af9e20 Update parser and printer to use new Blueprint format
Updates the standard format from:
module_type {
    property: "value",
}
to:
module_type(
    property = "value",
}

The parser will accept both formats for now, so all files can be
updated to the new format using bpfmt -w .

Change-Id: I9566cf1bd3cd66c6cbf3d4bd9dac1f04b9112927
2015-01-23 13:41:51 -08:00
Colin Cross
a434b3fd69 Keep dependencies in order
Don't sort the dependencies, keep them in the order they were in the
Blueprints file and use a set to prevent adding duplicates to the list.

Change-Id: Icade91d035ccfb12c26ba0584144c1723607019c
2015-01-23 13:41:51 -08:00
Colin Cross
3793062859 Rebootstrap for changes to any bootstrap go binaries
The final build.ninja can't contain a rules to build the primary
builder or it will create a circular dependency, so rules for all
bootstrap go packages and binaries are replaced with phony targets
that trigger a re-bootstrap to rebuild.  Add all bootstrap go
binaries to the dependencies that trigger a rebuild so that they
all get rebuilt.

Also fix the phony rule generation to include rules for the
intermediate files of bootstrap go binaries so that they don't
get deleted by the cleanup phase when the primary builder runs.

Change-Id: Id0cc287789f74cc4b21b062086723712b57ee051
2015-01-23 13:41:51 -08:00
Colin Cross
41c397af78 Initial bpmodify tool
bpmodify can be used to add or remove dependencies or other strings
from selected modules in Blueprint files.

Change-Id: I0df3762976e74bf46fd2922bbd48b46e526b7951
2015-01-23 13:41:51 -08:00
Colin Cross
5ad47f47fc Initial bpfmt tool
bpfmt is based off gofmt, and formats a blueprint file to a standard
format.

Change-Id: I060c1b6030bc937a8db217eaed237d8792c29565
2015-01-23 13:41:51 -08:00
Colin Cross
d1facc1ce7 Return comment and position information from parser
Return comment info from parser, which will be used later for
pretty printing a parsed Blueprint file.  Also add more position
information to the AST.

Change-Id: I3cf0ba8ea4ba5b931d032098ae5fdc350806ed98
2015-01-23 13:41:51 -08:00
Colin Cross
691a60dd98 Parallelize GenerateBuildActions
Modify the Generate phase to call GenerateBuildActions inside a
goroutine to allow parallization.  All modules from a single
moduleGroup are called from a single goroutine, and the goroutines
that processed all dependencies must have finished, so the only
change to the semantics of GenerateBuildActions implementations
is around access to globals.  Locks are added to the lazily
created package context variables and to the live tracker.

Reduces run time by ~33%.

Change-Id: I62a515acf86f1dcecb093ded83444b920ff603be
2015-01-23 13:41:51 -08:00
Colin Cross
7ad621c2b4 Parallelize Blueprints file parsing
Parse multiple Blueprints files simultaneously by using a goroutine
to read the file, call the module factory, parse the properties,
and look for subdirectories.  Requires module factories to be
reentrant, but otherwise does not change any build logic semantics.

Change-Id: Ia07579917a2b6fd064cedbfff655c23d706da718
2015-01-23 13:41:50 -08:00
Colin Cross
1455a0f7b1 Remove pregenerate pass
PreGenerateBuildActions is no longer used by the build logic, remove it.

Change-Id: I621c26e796d2bf6cdc587770a8f9572a769bc705
2015-01-23 13:41:50 -08:00
Colin Cross
80ad04d5f8 Add FinalModule and VisitAllModuleVariants to ModuleContext
Allows modules to determine if they are the last of their variants
to build, and to visit each variant to collect shared information.

Change-Id: I396f0c9d43e0e9b1901822d6dd9c6ad6380ad582
2015-01-23 13:41:50 -08:00