1*1fa6dee9SAndroid Build Coastguard Worker// Copyright 2015 Google Inc. All rights reserved. 2*1fa6dee9SAndroid Build Coastguard Worker// 3*1fa6dee9SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*1fa6dee9SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*1fa6dee9SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*1fa6dee9SAndroid Build Coastguard Worker// 7*1fa6dee9SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*1fa6dee9SAndroid Build Coastguard Worker// 9*1fa6dee9SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*1fa6dee9SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*1fa6dee9SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*1fa6dee9SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*1fa6dee9SAndroid Build Coastguard Worker// limitations under the License. 14*1fa6dee9SAndroid Build Coastguard Worker 15*1fa6dee9SAndroid Build Coastguard Worker// Blueprint is a meta-build system that reads in Blueprints files that describe 16*1fa6dee9SAndroid Build Coastguard Worker// modules that need to be built, and produces a Ninja 17*1fa6dee9SAndroid Build Coastguard Worker// (https://ninja-build.org/) manifest describing the commands that need 18*1fa6dee9SAndroid Build Coastguard Worker// to be run and their dependencies. Where most build systems use built-in 19*1fa6dee9SAndroid Build Coastguard Worker// rules or a domain-specific language to describe the logic how modules are 20*1fa6dee9SAndroid Build Coastguard Worker// converted to build rules, Blueprint delegates this to per-project build logic 21*1fa6dee9SAndroid Build Coastguard Worker// written in Go. For large, heterogenous projects this allows the inherent 22*1fa6dee9SAndroid Build Coastguard Worker// complexity of the build logic to be maintained in a high-level language, 23*1fa6dee9SAndroid Build Coastguard Worker// while still allowing simple changes to individual modules by modifying easy 24*1fa6dee9SAndroid Build Coastguard Worker// to understand Blueprints files. 25*1fa6dee9SAndroid Build Coastguard Worker// 26*1fa6dee9SAndroid Build Coastguard Worker// Blueprint uses a bootstrapping process to allow the code for Blueprint, 27*1fa6dee9SAndroid Build Coastguard Worker// the code for the build logic, and the code for the project being compiled 28*1fa6dee9SAndroid Build Coastguard Worker// to all live in the project. Dependencies between the layers are fully 29*1fa6dee9SAndroid Build Coastguard Worker// tracked - a change to the logic code will cause the logic to be recompiled, 30*1fa6dee9SAndroid Build Coastguard Worker// regenerate the project build manifest, and run modified project rules. A 31*1fa6dee9SAndroid Build Coastguard Worker// change to Blueprint itself will cause Blueprint to rebuild, and then rebuild 32*1fa6dee9SAndroid Build Coastguard Worker// the logic, etc. 33*1fa6dee9SAndroid Build Coastguard Worker// 34*1fa6dee9SAndroid Build Coastguard Worker// A Blueprints file is a list of modules in a pseudo-python data format, where 35*1fa6dee9SAndroid Build Coastguard Worker// the module type looks like a function call, and the properties of the module 36*1fa6dee9SAndroid Build Coastguard Worker// look like optional arguments. For example, a simple module might look like: 37*1fa6dee9SAndroid Build Coastguard Worker// 38*1fa6dee9SAndroid Build Coastguard Worker// cc_library { 39*1fa6dee9SAndroid Build Coastguard Worker// name: "cmd", 40*1fa6dee9SAndroid Build Coastguard Worker// srcs: [ 41*1fa6dee9SAndroid Build Coastguard Worker// "main.c", 42*1fa6dee9SAndroid Build Coastguard Worker// ], 43*1fa6dee9SAndroid Build Coastguard Worker// deps: [ 44*1fa6dee9SAndroid Build Coastguard Worker// "libc", 45*1fa6dee9SAndroid Build Coastguard Worker// ], 46*1fa6dee9SAndroid Build Coastguard Worker// } 47*1fa6dee9SAndroid Build Coastguard Worker// 48*1fa6dee9SAndroid Build Coastguard Worker// subdirs = ["subdir1", "subdir2"] 49*1fa6dee9SAndroid Build Coastguard Worker// 50*1fa6dee9SAndroid Build Coastguard Worker// The modules from the top level Blueprints file and recursively through any 51*1fa6dee9SAndroid Build Coastguard Worker// subdirectories listed by the "subdirs" variable are read by Blueprint, and 52*1fa6dee9SAndroid Build Coastguard Worker// their properties are stored into property structs by module type. Once 53*1fa6dee9SAndroid Build Coastguard Worker// all modules are read, Blueprint calls any registered Mutators, in 54*1fa6dee9SAndroid Build Coastguard Worker// registration order. Mutators can visit each module top-down or bottom-up, 55*1fa6dee9SAndroid Build Coastguard Worker// and modify them as necessary. Common modifications include setting 56*1fa6dee9SAndroid Build Coastguard Worker// properties on modules to propagate information down from dependers to 57*1fa6dee9SAndroid Build Coastguard Worker// dependees (for example, telling a module what kinds of parents depend on it), 58*1fa6dee9SAndroid Build Coastguard Worker// or splitting a module into multiple variants (for example, one per 59*1fa6dee9SAndroid Build Coastguard Worker// architecture being compiled). After all Mutators have run, each module is 60*1fa6dee9SAndroid Build Coastguard Worker// asked to generate build rules based on property values, and then singletons 61*1fa6dee9SAndroid Build Coastguard Worker// can generate any build rules from the output of all modules. 62*1fa6dee9SAndroid Build Coastguard Worker// 63*1fa6dee9SAndroid Build Coastguard Worker// The per-project build logic defines a top level command, referred to in the 64*1fa6dee9SAndroid Build Coastguard Worker// documentation as the "primary builder". This command is responsible for 65*1fa6dee9SAndroid Build Coastguard Worker// registering the module types needed for the project, as well as any 66*1fa6dee9SAndroid Build Coastguard Worker// singletons or mutators, and then calling into Blueprint with the path of the 67*1fa6dee9SAndroid Build Coastguard Worker// root Blueprint file. 68*1fa6dee9SAndroid Build Coastguard Workerpackage blueprint 69