blob: 6049d44adf585261956c4a297da87fb631c104ff [file] [log] [blame]
Colin Cross0c461f12016-10-20 16:11:43 -07001// Copyright 2016 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 cc
16
17import (
Colin Cross5ff51b52017-05-02 13:34:32 -070018 "github.com/google/blueprint/proptools"
Colin Cross0c461f12016-10-20 16:11:43 -070019
20 "android/soong/android"
21)
22
Colin Cross38f794e2017-09-07 10:53:07 -070023func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, static bool) Deps {
Colin Cross0c461f12016-10-20 16:11:43 -070024 var lib string
Colin Cross0c461f12016-10-20 16:11:43 -070025
Colin Cross5ff51b52017-05-02 13:34:32 -070026 switch proptools.String(p.Proto.Type) {
Colin Cross0c461f12016-10-20 16:11:43 -070027 case "full":
28 if ctx.sdk() {
29 lib = "libprotobuf-cpp-full-ndk"
30 static = true
31 } else {
32 lib = "libprotobuf-cpp-full"
33 }
34 case "lite", "":
35 if ctx.sdk() {
36 lib = "libprotobuf-cpp-lite-ndk"
37 static = true
38 } else {
39 lib = "libprotobuf-cpp-lite"
Colin Cross0c461f12016-10-20 16:11:43 -070040 }
41 default:
Colin Cross5ff51b52017-05-02 13:34:32 -070042 ctx.PropertyErrorf("proto.type", "unknown proto type %q",
43 proptools.String(p.Proto.Type))
Colin Cross0c461f12016-10-20 16:11:43 -070044 }
45
46 if static {
47 deps.StaticLibs = append(deps.StaticLibs, lib)
48 deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, lib)
49 } else {
50 deps.SharedLibs = append(deps.SharedLibs, lib)
51 deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, lib)
52 }
53
54 return deps
55}
56
Colin Cross38f794e2017-09-07 10:53:07 -070057func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flags {
Colin Cross0c461f12016-10-20 16:11:43 -070058 flags.CFlags = append(flags.CFlags, "-DGOOGLE_PROTOBUF_NO_RTTI")
59 flags.GlobalFlags = append(flags.GlobalFlags,
Colin Cross38f794e2017-09-07 10:53:07 -070060 "-I"+android.ProtoSubDir(ctx).String(),
61 "-I"+android.ProtoDir(ctx).String(),
Colin Cross0c461f12016-10-20 16:11:43 -070062 )
63
Colin Cross38f794e2017-09-07 10:53:07 -070064 flags.protoFlags = android.ProtoFlags(ctx, p)
Colin Cross5ff51b52017-05-02 13:34:32 -070065
Colin Cross0c461f12016-10-20 16:11:43 -070066 return flags
67}