Home | History | Annotate | Download | only in minibp
      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 	"github.com/google/blueprint"
     20 	"github.com/google/blueprint/bootstrap"
     21 )
     22 
     23 var runAsPrimaryBuilder bool
     24 var buildPrimaryBuilder bool
     25 
     26 func init() {
     27 	flag.BoolVar(&runAsPrimaryBuilder, "p", false, "run as a primary builder")
     28 	flag.BoolVar(&buildPrimaryBuilder, "build-primary", false, "build the primary builder")
     29 }
     30 
     31 type Config struct {
     32 	generatingBootstrapper   bool
     33 	generatingPrimaryBuilder bool
     34 }
     35 
     36 func (c Config) GeneratingBootstrapper() bool {
     37 	return c.generatingBootstrapper
     38 }
     39 
     40 func (c Config) GeneratingPrimaryBuilder() bool {
     41 	return c.generatingPrimaryBuilder
     42 }
     43 
     44 func main() {
     45 	flag.Parse()
     46 
     47 	ctx := blueprint.NewContext()
     48 	if !runAsPrimaryBuilder {
     49 		ctx.SetIgnoreUnknownModuleTypes(true)
     50 	}
     51 
     52 	config := Config{
     53 		generatingBootstrapper:   !runAsPrimaryBuilder && !buildPrimaryBuilder,
     54 		generatingPrimaryBuilder: !runAsPrimaryBuilder && buildPrimaryBuilder,
     55 	}
     56 
     57 	bootstrap.Main(ctx, config)
     58 }
     59