blob: 23bcb561d9b089ec79d6d94af43d246db1e206e8 [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 Cross3f40fa42015-01-30 17:27:36 -080031)
32
33func 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 Cross97ba0732015-03-23 17:50:24 -070042 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 Cross3f40fa42015-01-30 17:27:36 -080048
Colin Cross97ba0732015-03-23 17:50:24 -070049 ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
Dan Albertbe961682015-03-18 23:38:50 -070050 ctx.RegisterModuleType("ndk_prebuilt_library", cc.NdkPrebuiltLibraryFactory)
51 ctx.RegisterModuleType("ndk_prebuilt_static_stl", cc.NdkPrebuiltStaticStlFactory)
52 ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory)
Colin Cross3f40fa42015-01-30 17:27:36 -080053
Colin Cross97ba0732015-03-23 17:50:24 -070054 ctx.RegisterModuleType("cc_library_host_static", cc.CCLibraryHostStaticFactory)
55 ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory)
56 ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory)
Colin Cross1f8f2342015-03-26 16:09:47 -070057 ctx.RegisterModuleType("cc_test_host", cc.CCTestHostFactory)
Colin Cross3f40fa42015-01-30 17:27:36 -080058
Colin Cross97ba0732015-03-23 17:50:24 -070059 ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory)
Colin Cross5049f022015-03-18 13:28:46 -070060
Colin Cross82df9432015-03-24 11:16:06 -070061 ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory)
62 ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory)
63
Colin Cross3f40fa42015-01-30 17:27:36 -080064 // Mutators
65 ctx.RegisterEarlyMutator("arch", common.ArchMutator)
66 ctx.RegisterEarlyMutator("link", cc.LinkageMutator)
Colin Cross6b290692015-03-19 14:05:33 -070067 ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator)
Colin Cross3f40fa42015-01-30 17:27:36 -080068
69 // Singletons
Colin Cross9454bfa2015-03-17 13:24:18 -070070 ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton)
Colin Cross68f55102015-03-25 14:43:57 -070071 ctx.RegisterSingletonType("env", common.EnvSingleton)
Colin Cross3f40fa42015-01-30 17:27:36 -080072
73 configuration, err := config.New(srcDir)
74 if err != nil {
75 fmt.Fprintf(os.Stderr, "%s", err)
76 os.Exit(1)
77 }
78
79 // Temporary hack
80 //ctx.SetIgnoreUnknownModuleTypes(true)
81
82 bootstrap.Main(ctx, configuration, config.ConfigFileName)
83}