Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1 | // Copyright 2015 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 | "fmt" |
| 20 | "os" |
| 21 | "path/filepath" |
| 22 | |
| 23 | "blueprint" |
| 24 | "blueprint/bootstrap" |
| 25 | |
| 26 | "android/soong/cc" |
| 27 | "android/soong/common" |
| 28 | "android/soong/config" |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame^] | 29 | "android/soong/genrule" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | func main() { |
| 33 | flag.Parse() |
| 34 | |
| 35 | // The top-level Blueprints file is passed as the first argument. |
| 36 | srcDir := filepath.Dir(flag.Arg(0)) |
| 37 | |
| 38 | ctx := blueprint.NewContext() |
| 39 | |
| 40 | // Module types |
| 41 | ctx.RegisterModuleType("cc_library_static", cc.NewCCLibraryStatic) |
| 42 | ctx.RegisterModuleType("cc_library_shared", cc.NewCCLibraryShared) |
| 43 | ctx.RegisterModuleType("cc_library", cc.NewCCLibrary) |
| 44 | ctx.RegisterModuleType("cc_object", cc.NewCCObject) |
| 45 | ctx.RegisterModuleType("cc_binary", cc.NewCCBinary) |
Dan Albert | c403f7c | 2015-03-18 14:01:18 -0700 | [diff] [blame] | 46 | ctx.RegisterModuleType("cc_test", cc.NewCCTest) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 47 | |
| 48 | ctx.RegisterModuleType("toolchain_library", cc.NewToolchainLibrary) |
| 49 | |
| 50 | ctx.RegisterModuleType("cc_library_host_static", cc.NewCCLibraryHostStatic) |
| 51 | ctx.RegisterModuleType("cc_library_host_shared", cc.NewCCLibraryHostShared) |
| 52 | ctx.RegisterModuleType("cc_binary_host", cc.NewCCBinaryHost) |
| 53 | |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame^] | 54 | ctx.RegisterModuleType("gensrcs", genrule.NewGenSrcs) |
| 55 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 56 | // Mutators |
| 57 | ctx.RegisterEarlyMutator("arch", common.ArchMutator) |
| 58 | ctx.RegisterEarlyMutator("link", cc.LinkageMutator) |
| 59 | |
| 60 | // Singletons |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 61 | ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 62 | |
| 63 | configuration, err := config.New(srcDir) |
| 64 | if err != nil { |
| 65 | fmt.Fprintf(os.Stderr, "%s", err) |
| 66 | os.Exit(1) |
| 67 | } |
| 68 | |
| 69 | // Temporary hack |
| 70 | //ctx.SetIgnoreUnknownModuleTypes(true) |
| 71 | |
| 72 | bootstrap.Main(ctx, configuration, config.ConfigFileName) |
| 73 | } |