blob: c1f8243ab1e94869dfa0a9b7965349d68227b629 [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 Cross3f40fa42015-01-30 17:27:36 -080057
Colin Cross97ba0732015-03-23 17:50:24 -070058 ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory)
Colin Cross5049f022015-03-18 13:28:46 -070059
Colin Cross82df9432015-03-24 11:16:06 -070060 ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory)
61 ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory)
62
Colin Cross3f40fa42015-01-30 17:27:36 -080063 // Mutators
64 ctx.RegisterEarlyMutator("arch", common.ArchMutator)
65 ctx.RegisterEarlyMutator("link", cc.LinkageMutator)
Colin Cross6b290692015-03-19 14:05:33 -070066 ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator)
Colin Cross3f40fa42015-01-30 17:27:36 -080067
68 // Singletons
Colin Cross9454bfa2015-03-17 13:24:18 -070069 ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton)
Colin Cross68f55102015-03-25 14:43:57 -070070 ctx.RegisterSingletonType("env", common.EnvSingleton)
Colin Cross3f40fa42015-01-30 17:27:36 -080071
72 configuration, err := config.New(srcDir)
73 if err != nil {
74 fmt.Fprintf(os.Stderr, "%s", err)
75 os.Exit(1)
76 }
77
78 // Temporary hack
79 //ctx.SetIgnoreUnknownModuleTypes(true)
80
81 bootstrap.Main(ctx, configuration, config.ConfigFileName)
82}