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
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
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
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
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
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.
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
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
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.
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.
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.
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
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
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
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
bpmodify can be used to add or remove dependencies or other strings
from selected modules in Blueprint files.
Change-Id: I0df3762976e74bf46fd2922bbd48b46e526b7951
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
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
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
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
Assignments to arbitrary variables are now supported in Blueprint
files. Variables cannot be reassigned, and they stay in scope for
the remainder of the current Blueprint file and any subdirs Blueprint
files. Variables can be used in place of a value in properites or
as an entry in a list.
Change-Id: I04447e4c541304ded802bb82d1ca4ce07d5d95d2
Allow properties structs to contain exported int and uint fields,
but only if they are tagged with blueprint:"mutated". These fields
will be copied by CopyProperties in order to propagate through
cloning during mutations, but can only be set by Mutators and not
by Blueprint files.
Change-Id: Ic462385799c77667e392f4928d02d424c8f8d900
A future patch will rewrite context and module_ctx to support multiple
variants of a single module. This requires adding a layer of indirection
between the module defined in a Blueprint file and the Module object
built by the build logic.
What used to be called a moduleInfo struct is now a moduleGroup struct,
and contains the generic information taken from the Blueprint file.
Inside the moduleGroup struct is a list of moduleInfo structs, which
contain a logicModule pointer to the Module object returned by the
ModuleFactory function from the build logic. moduleInfo also contains
the name of the variant, as well as the dependencies after they have
been resolved from Blueprint string dependencies to dependencies on
a specific Module.
Change-Id: Id4d516ffc13381c3ce07b80eaf32d9090ae43703
CopyProperties expects to interfaces in a struct to be an
interface to a pointer to a struct, but expects to be called
on a struct. When a struct contains an interface, dereference
it twice with Elem() before calling CopyProperties on it.
Change-Id: I0d10aff87729273a025ab6d86239fd60662a20c0
DynamicDependerModuleContext is really a base module context used
by multiple types of ModuleContext interfaces. Rename it to
BaseModuleContext, and create a new DynamicDependerModuleContext
that just wraps it.
Change-Id: Ibb402e1d680d50ed15d6548e99b32cc0b5b52b12
Walk the dependency tree once in order to create a list of modules
such that that any module is guaranteed to be later in the list than
any of its dependencies. Allows easily walking the tree in child-first
or parent-first order by walking the list in forward or reverse order.
Change-Id: I8f2013ebf700d1bc4c41b7898742a426f032ea2f
The closures in parseNinjaString seem to confuse go's escape
analysis, causing it to allocate a new stateFunc object on the
heap for every character in the string. Convert the state
functions to normal functions, and pass a pointer to a state
object to provide access to the variables that were in the
closure.
The range iteration on the input string was iterating over
UTF-8 runes, when all of the rune comparisons for state
changes only look at ASCII bytes. Switch to iterating
over bytes, stringState will pass through multi-byte
characters in strings untouched.
Together this reduces the time spent in parseNinjaString by
>50%, and the overall execution time by >20%.
Change-Id: I4c926b52b883d51e2f12a1673d03fcc2cfe83445
ninjaString's Eval() does not currently check if all of the variables
referenced by the Ninja string being evaluated are present in the
map provided by the caller. This commit adds such a check.
Change-Id: I15cf3c44cc1eedaf6f93a9533b8cdcbffd74992c
This change makes the Context.visitDepsDepthFirstIf() method descend into
modules for which the predicate is false rather than skipping their entire
sub-DAG.
Change-Id: I50564c69a714d5e199e1a51a8aa24162b0dc6f11
Call PreGenerateBuildActions on each module that implments it after
resolving dependencies but before calling GenerateBuildActions on
any module. This allows the build logic to propagate top-down
information, for example what variants of a library need to be
compiled for the binaries it is used in.
Change-Id: I2737504fa9d1a2b42ef747497de32c1c5129233d
This change makes removeAbandonedFiles perform some of the string substitutions
that are done by the bootstrap script before considering whether a built target
still exists. It fixes a bug where the bootstrap manifest would get deleted
and subsequently regenerated, resulting in more re-bootstrap iterations than
was necessary.
Change-Id: I946c883dcc31fb77496f64d2573b395ad2cf095d