Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
Colin Cross | 5ff51b5 | 2017-05-02 13:34:32 -0700 | [diff] [blame] | 18 | "github.com/google/blueprint/proptools" |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
| 22 | |
Colin Cross | 38f794e | 2017-09-07 10:53:07 -0700 | [diff] [blame] | 23 | func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, static bool) Deps { |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 24 | var lib string |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 25 | |
Colin Cross | 5ff51b5 | 2017-05-02 13:34:32 -0700 | [diff] [blame] | 26 | switch proptools.String(p.Proto.Type) { |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 27 | 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 Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 40 | } |
| 41 | default: |
Colin Cross | 5ff51b5 | 2017-05-02 13:34:32 -0700 | [diff] [blame] | 42 | ctx.PropertyErrorf("proto.type", "unknown proto type %q", |
| 43 | proptools.String(p.Proto.Type)) |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 44 | } |
| 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 Cross | 38f794e | 2017-09-07 10:53:07 -0700 | [diff] [blame] | 57 | func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flags { |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 58 | flags.CFlags = append(flags.CFlags, "-DGOOGLE_PROTOBUF_NO_RTTI") |
| 59 | flags.GlobalFlags = append(flags.GlobalFlags, |
Colin Cross | 38f794e | 2017-09-07 10:53:07 -0700 | [diff] [blame] | 60 | "-I"+android.ProtoSubDir(ctx).String(), |
| 61 | "-I"+android.ProtoDir(ctx).String(), |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 62 | ) |
| 63 | |
Colin Cross | 38f794e | 2017-09-07 10:53:07 -0700 | [diff] [blame] | 64 | flags.protoFlags = android.ProtoFlags(ctx, p) |
Colin Cross | 5ff51b5 | 2017-05-02 13:34:32 -0700 | [diff] [blame] | 65 | |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 66 | return flags |
| 67 | } |