Alexei Frolov | dd6fa5c | 2020-08-11 10:04:01 -0700 | [diff] [blame] | 1 | # Copyright 2020 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # the License at |
| 6 | # |
| 7 | # https://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, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
Alexei Frolov | dd6fa5c | 2020-08-11 10:04:01 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/target_types.gni") |
Wyatt Hepler | d517afc | 2021-02-03 19:40:08 -0800 | [diff] [blame] | 18 | import("$dir_pw_protobuf_compiler/proto.gni") |
Alexei Frolov | dd6fa5c | 2020-08-11 10:04:01 -0700 | [diff] [blame] | 19 | import("nanopb.gni") |
| 20 | |
| 21 | # This file defines a GN source_set for an external installation of nanopb. |
| 22 | # To use, checkout the nanopb source into a directory, then set the build arg |
| 23 | # dir_pw_third_party_nanopb to point to that directory. The nanopb library |
| 24 | # will be available in GN at "$dir_pw_third_party/nanopb". |
| 25 | if (dir_pw_third_party_nanopb != "") { |
| 26 | config("includes") { |
| 27 | include_dirs = [ dir_pw_third_party_nanopb ] |
| 28 | } |
| 29 | |
| 30 | pw_source_set("nanopb") { |
| 31 | public_configs = [ ":includes" ] |
| 32 | public = [ |
| 33 | "$dir_pw_third_party_nanopb/pb.h", |
| 34 | "$dir_pw_third_party_nanopb/pb_common.h", |
| 35 | "$dir_pw_third_party_nanopb/pb_decode.h", |
| 36 | "$dir_pw_third_party_nanopb/pb_encode.h", |
| 37 | ] |
| 38 | sources = [ |
| 39 | "$dir_pw_third_party_nanopb/pb_common.c", |
| 40 | "$dir_pw_third_party_nanopb/pb_decode.c", |
| 41 | "$dir_pw_third_party_nanopb/pb_encode.c", |
| 42 | ] |
| 43 | } |
Wyatt Hepler | d517afc | 2021-02-03 19:40:08 -0800 | [diff] [blame] | 44 | |
| 45 | pw_proto_library("proto") { |
Wyatt Hepler | 752d7d3 | 2021-03-02 09:02:23 -0800 | [diff] [blame^] | 46 | strip_prefix = "$dir_pw_third_party_nanopb/generator/proto" |
Wyatt Hepler | d517afc | 2021-02-03 19:40:08 -0800 | [diff] [blame] | 47 | sources = [ "$dir_pw_third_party_nanopb/generator/proto/nanopb.proto" ] |
Wyatt Hepler | 752d7d3 | 2021-03-02 09:02:23 -0800 | [diff] [blame^] | 48 | python_module_as_package = "nanopb_pb2" |
Wyatt Hepler | d517afc | 2021-02-03 19:40:08 -0800 | [diff] [blame] | 49 | } |
Alexei Frolov | dd6fa5c | 2020-08-11 10:04:01 -0700 | [diff] [blame] | 50 | } else { |
| 51 | group("nanopb") { |
| 52 | } |
| 53 | } |