blob: 171473913184bc51bef75a94177f60f23f15c98d [file] [log] [blame]
Colin Cross8e0c5112015-01-23 14:15:10 -08001// 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
Jamie Gennis1bc967e2014-05-27 16:34:41 -070015package main
16
17import (
Jamie Gennis1bc967e2014-05-27 16:34:41 -070018 "flag"
Dan Willemsencd4e0ce2017-07-19 22:43:30 -070019 "path/filepath"
20
Jamie Gennis6cafc2c2015-03-20 22:39:29 -040021 "github.com/google/blueprint"
22 "github.com/google/blueprint/bootstrap"
Jamie Gennis1bc967e2014-05-27 16:34:41 -070023)
24
25var runAsPrimaryBuilder bool
Dan Willemsenefd2de72015-07-22 17:06:06 -070026var buildPrimaryBuilder bool
Jamie Gennis1bc967e2014-05-27 16:34:41 -070027
28func init() {
29 flag.BoolVar(&runAsPrimaryBuilder, "p", false, "run as a primary builder")
30}
31
Dan Willemsenefd2de72015-07-22 17:06:06 -070032type Config struct {
Dan Willemsenefd2de72015-07-22 17:06:06 -070033 generatingPrimaryBuilder bool
34}
Jamie Gennis1bc967e2014-05-27 16:34:41 -070035
Dan Willemsenefd2de72015-07-22 17:06:06 -070036func (c Config) GeneratingPrimaryBuilder() bool {
37 return c.generatingPrimaryBuilder
Jamie Gennis1bc967e2014-05-27 16:34:41 -070038}
39
Dan Willemsenab223a52018-07-05 21:56:59 -070040func (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
Dan Willemsencd4e0ce2017-07-19 22:43:30 -070046}
47
Jamie Gennis1bc967e2014-05-27 16:34:41 -070048func main() {
49 flag.Parse()
50
51 ctx := blueprint.NewContext()
52 if !runAsPrimaryBuilder {
53 ctx.SetIgnoreUnknownModuleTypes(true)
54 }
55
Dan Willemsenefd2de72015-07-22 17:06:06 -070056 config := Config{
Dan Willemsen1e723212017-07-18 19:37:37 -070057 generatingPrimaryBuilder: !runAsPrimaryBuilder,
Dan Willemsenefd2de72015-07-22 17:06:06 -070058 }
Jamie Gennis1bc967e2014-05-27 16:34:41 -070059
60 bootstrap.Main(ctx, config)
61}