1 // Copyright 2014 Google Inc. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "flag" 19 "path/filepath" 20 21 "github.com/google/blueprint" 22 "github.com/google/blueprint/bootstrap" 23 ) 24 25 var runAsPrimaryBuilder bool 26 var buildPrimaryBuilder bool 27 28 func init() { 29 flag.BoolVar(&runAsPrimaryBuilder, "p", false, "run as a primary builder") 30 } 31 32 type Config struct { 33 generatingPrimaryBuilder bool 34 } 35 36 func (c Config) GeneratingPrimaryBuilder() bool { 37 return c.generatingPrimaryBuilder 38 } 39 40 func (c Config) RemoveAbandonedFilesUnder() (under, exempt []string) { 41 if c.generatingPrimaryBuilder { 42 under = []string{filepath.Join(bootstrap.BuildDir, ".bootstrap")} 43 exempt = []string{filepath.Join(bootstrap.BuildDir, ".bootstrap", "build.ninja")} 44 } 45 return 46 } 47 48 func main() { 49 flag.Parse() 50 51 ctx := blueprint.NewContext() 52 if !runAsPrimaryBuilder { 53 ctx.SetIgnoreUnknownModuleTypes(true) 54 } 55 56 config := Config{ 57 generatingPrimaryBuilder: !runAsPrimaryBuilder, 58 } 59 60 bootstrap.Main(ctx, config) 61 } 62