blob: b84b804c1637fe8636585471b1fe93d6d3deac6c [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)
Colin Cross3f40fa42015-01-30 17:27:36 -080050
Colin Cross97ba0732015-03-23 17:50:24 -070051 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 Cross3f40fa42015-01-30 17:27:36 -080054
Colin Cross97ba0732015-03-23 17:50:24 -070055 ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory)
Colin Cross5049f022015-03-18 13:28:46 -070056
Colin Cross82df9432015-03-24 11:16:06 -070057 ctx.RegisterModuleType("art_cc_library", art.ArtCCLibraryFactory)
58 ctx.RegisterModuleType("art_cc_binary", art.ArtCCBinaryFactory)
59
Colin Cross3f40fa42015-01-30 17:27:36 -080060 // Mutators
61 ctx.RegisterEarlyMutator("arch", common.ArchMutator)
62 ctx.RegisterEarlyMutator("link", cc.LinkageMutator)
Colin Cross6b290692015-03-19 14:05:33 -070063 ctx.RegisterEarlyMutator("test_per_src", cc.TestPerSrcMutator)
Colin Cross3f40fa42015-01-30 17:27:36 -080064
65 // Singletons
Colin Cross9454bfa2015-03-17 13:24:18 -070066 ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton)
Colin Cross3f40fa42015-01-30 17:27:36 -080067
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}