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 | |
Colin Cross | 70b4059 | 2015-03-23 12:57:34 -0700 | [diff] [blame] | 23 | "github.com/google/blueprint" |
| 24 | "github.com/google/blueprint/bootstrap" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 25 | |
Colin Cross | 82df943 | 2015-03-24 11:16:06 -0700 | [diff] [blame^] | 26 | "android/soong/art" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 27 | "android/soong/cc" |
| 28 | "android/soong/common" |
| 29 | "android/soong/config" |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 30 | "android/soong/genrule" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | func main() { |
| 34 | flag.Parse() |
| 35 | |
| 36 | // The top-level Blueprints file is passed as the first argument. |
| 37 | srcDir := filepath.Dir(flag.Arg(0)) |
| 38 | |
| 39 | ctx := blueprint.NewContext() |
| 40 | |
| 41 | // Module types |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 42 | ctx.RegisterModuleType("cc_library_static", cc.CCLibraryStaticFactory) |
| 43 | ctx.RegisterModuleType("cc_library_shared", cc.CCLibrarySharedFactory) |
| 44 | ctx.RegisterModuleType("cc_library", cc.CCLibraryFactory) |
| 45 | ctx.RegisterModuleType("cc_object", cc.CCObjectFactory) |
| 46 | ctx.RegisterModuleType("cc_binary", cc.CCBinaryFactory) |
| 47 | ctx.RegisterModuleType("cc_test", cc.CCTestFactory) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 48 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 49 | ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 50 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 51 | ctx.RegisterModuleType("cc_library_host_static", cc.CCLibraryHostStaticFactory) |
| 52 | ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory) |
| 53 | ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 54 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 55 | ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory) |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 56 | |
Colin Cross | 82df943 | 2015-03-24 11:16:06 -0700 | [diff] [blame^] | 57 | ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory) |
| 58 | ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory) |
| 59 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 60 | // Mutators |
| 61 | ctx.RegisterEarlyMutator("arch", common.ArchMutator) |
| 62 | ctx.RegisterEarlyMutator("link", cc.LinkageMutator) |
Colin Cross | 6b29069 | 2015-03-19 14:05:33 -0700 | [diff] [blame] | 63 | ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 64 | |
| 65 | // Singletons |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 66 | ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 67 | |
| 68 | configuration, err := config.New(srcDir) |
| 69 | if err != nil { |
| 70 | fmt.Fprintf(os.Stderr, "%s", err) |
| 71 | os.Exit(1) |
| 72 | } |
| 73 | |
| 74 | // Temporary hack |
| 75 | //ctx.SetIgnoreUnknownModuleTypes(true) |
| 76 | |
| 77 | bootstrap.Main(ctx, configuration, config.ConfigFileName) |
| 78 | } |