blob: 649ee9d9edeb2992b230cf2db31afb19804052f6 [file] [log] [blame]
Andrew Scull1c02d642017-09-11 17:54:56 +01001//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// Build files need to go in these directories in order for protoc to generate
18// files with the correct paths
19subdirs = [
20 "nugget/services/avb",
21 "nugget/services/weaver",
22]
23
24cc_library_headers {
25 name: "nos_headers",
26 defaults: ["nos_shared_cc_defaults"],
27 export_include_dirs: ["nugget/include"],
28}
29
30cc_defaults {
31 name: "nos_app_defaults",
32 cflags: ["-Wno-unused-parameter"],
33 header_libs: ["nos_headers"],
34 shared_libs: ["libnos"],
35}
36
37cc_defaults {
38 name: "nos_app_service_defaults",
39 defaults: [
40 "nos_app_defaults",
41 "nos_cc_defaults",
42 ],
43 proto: { export_proto_headers: true },
44 static_libs: ["nos_proto_options"],
45 export_static_lib_headers: ["nos_proto_options"],
46}
47
48// Soong doesn't allow adding plugins to a protobuf compilation so we need to
49// invoke it directly. If we could pass a plugin, it could use insertion points
50// in the .pb.{cc,h} files rather than needing to generate new .client.{cpp,h}
51// files for each service.
52GEN_SERVICE = "$(location aprotoc) --plugin=protoc-gen-nos-client-cpp=$(location protoc-gen-nos-client-cpp) $(in) -Iexternal/protobuf/src -Iexternal/libnos/nugget/proto"
53
54GEN_SERVICE_SOURCE = GEN_SERVICE + " --nos-client-cpp_out=source:$(genDir) "
55GEN_SERVICE_HEADER = GEN_SERVICE + " --nos-client-cpp_out=header:$(genDir) "
56GEN_SERVICE_MOCK = GEN_SERVICE + " --nos-client-cpp_out=mock:$(genDir) "
57
58// The options proto is pre-generated as the Android build generates from the
59// repo root which causes the repo path to be included in the generated files.
60// Generating manually from util/protobuf means the paths are relative to the
61// protobuf root which is the expected behaviour.
62//
63// protoc --cpp_out=nugget/proto -I/usr/include -Inugget/proto nugget/proto/nugget/protobuf/options.proto
64//
65// This can't be a shared library as that causes double import of the standard
66// proto descriptors resulting an assetion failing.
67cc_library_static {
68 name: "nos_proto_options",
69 srcs: ["nugget/proto/nugget/protobuf/options.pb.cc"],
70 defaults: ["nos_shared_cc_defaults"],
71 shared_libs: ["libprotobuf-cpp-full"],
72 export_include_dirs: ["nugget/proto"],
73}