blob: 01740d1cd08fca3c87015ae6fe8f19709e497e44 [file] [log] [blame]
Colin Cross3f40fa42015-01-30 17:27:36 -08001// 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
15package main
16
17import (
18 "flag"
19 "fmt"
20 "os"
21 "path/filepath"
22
Colin Cross70b40592015-03-23 12:57:34 -070023 "github.com/google/blueprint"
24 "github.com/google/blueprint/bootstrap"
Colin Cross3f40fa42015-01-30 17:27:36 -080025
Colin Cross82df9432015-03-24 11:16:06 -070026 "android/soong/art"
Colin Cross3f40fa42015-01-30 17:27:36 -080027 "android/soong/cc"
28 "android/soong/common"
29 "android/soong/config"
Colin Cross5049f022015-03-18 13:28:46 -070030 "android/soong/genrule"
Colin Cross2fe66872015-03-30 17:20:39 -070031 "android/soong/java"
Colin Cross3f40fa42015-01-30 17:27:36 -080032)
33
34func main() {
35 flag.Parse()
36
37 // The top-level Blueprints file is passed as the first argument.
38 srcDir := filepath.Dir(flag.Arg(0))
39
40 ctx := blueprint.NewContext()
41
42 // Module types
Colin Cross97ba0732015-03-23 17:50:24 -070043 ctx.RegisterModuleType("cc_library_static", cc.CCLibraryStaticFactory)
44 ctx.RegisterModuleType("cc_library_shared", cc.CCLibrarySharedFactory)
45 ctx.RegisterModuleType("cc_library", cc.CCLibraryFactory)
46 ctx.RegisterModuleType("cc_object", cc.CCObjectFactory)
47 ctx.RegisterModuleType("cc_binary", cc.CCBinaryFactory)
48 ctx.RegisterModuleType("cc_test", cc.CCTestFactory)
Colin Cross3f40fa42015-01-30 17:27:36 -080049
Colin Cross97ba0732015-03-23 17:50:24 -070050 ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
Dan Albertbe961682015-03-18 23:38:50 -070051 ctx.RegisterModuleType("ndk_prebuilt_library", cc.NdkPrebuiltLibraryFactory)
52 ctx.RegisterModuleType("ndk_prebuilt_static_stl", cc.NdkPrebuiltStaticStlFactory)
53 ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory)
Colin Cross3f40fa42015-01-30 17:27:36 -080054
Colin Cross97ba0732015-03-23 17:50:24 -070055 ctx.RegisterModuleType("cc_library_host_static", cc.CCLibraryHostStaticFactory)
56 ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory)
57 ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory)
Colin Cross1f8f2342015-03-26 16:09:47 -070058 ctx.RegisterModuleType("cc_test_host", cc.CCTestHostFactory)
Colin Cross3f40fa42015-01-30 17:27:36 -080059
Colin Cross97ba0732015-03-23 17:50:24 -070060 ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory)
Colin Cross5049f022015-03-18 13:28:46 -070061
Colin Cross82df9432015-03-24 11:16:06 -070062 ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory)
63 ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory)
64
Colin Cross2fe66872015-03-30 17:20:39 -070065 ctx.RegisterModuleType("java_library", java.JavaLibraryFactory)
66 ctx.RegisterModuleType("java_library_static", java.JavaLibraryFactory)
67 ctx.RegisterModuleType("java_library_host", java.JavaLibraryHostFactory)
68 ctx.RegisterModuleType("java_binary", java.JavaBinaryFactory)
69 ctx.RegisterModuleType("java_binary_host", java.JavaBinaryHostFactory)
70 ctx.RegisterModuleType("prebuilt_java_library", java.JavaPrebuiltFactory)
71
Colin Cross3f40fa42015-01-30 17:27:36 -080072 // Mutators
73 ctx.RegisterEarlyMutator("arch", common.ArchMutator)
74 ctx.RegisterEarlyMutator("link", cc.LinkageMutator)
Colin Cross6b290692015-03-19 14:05:33 -070075 ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator)
Colin Cross3f40fa42015-01-30 17:27:36 -080076
77 // Singletons
Colin Cross9454bfa2015-03-17 13:24:18 -070078 ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton)
Colin Cross68f55102015-03-25 14:43:57 -070079 ctx.RegisterSingletonType("env", common.EnvSingleton)
Colin Cross3f40fa42015-01-30 17:27:36 -080080
81 configuration, err := config.New(srcDir)
82 if err != nil {
83 fmt.Fprintf(os.Stderr, "%s", err)
84 os.Exit(1)
85 }
86
87 // Temporary hack
88 //ctx.SetIgnoreUnknownModuleTypes(true)
89
90 bootstrap.Main(ctx, configuration, config.ConfigFileName)
91}