aboutsummaryrefslogtreecommitdiff
path: root/osp/msgs/BUILD.gn
blob: 8dcb69d53d963e2986562d544669fe9c9c292cb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

source_set("msgs") {
  sources = [
    target_gen_dir + "/osp_messages.cc",
    target_gen_dir + "/osp_messages.h",
  ]

  public_deps = [ ":cddl_gen" ]
  deps = [
    "../../third_party/abseil",
    "../../third_party/tinycbor",
  ]

  public_configs = [
    ":cddl_gen_config",
    "../../build:openscreen_include_dirs",
  ]
}

config("cddl_gen_config") {
  include_dirs = [ "$root_gen_dir" + "/" + rebase_path("../..", "//") ]
}

action("cddl_gen") {
  script = "../../tools/cddl/cddl.py"
  sources = [ "osp_messages.cddl" ]
  outputs_src = rebase_path([
                              "osp_messages.h",
                              "osp_messages.cc",
                            ],
                            "//")
  outputs = []
  foreach(o, outputs_src) {
    outputs += [ root_gen_dir + "/" + o ]
  }

  cddl_label = "../../tools/cddl:cddl($host_toolchain)"
  cddl_path = get_label_info(cddl_label, "root_out_dir") + "/cddl"
  args =
      [
        "--cddl",

        # Path should be rebased because |root_build_dir| for current toolchain
        # may be different from |root_out_dir| of cddl built on host toolchain.
        "./" + rebase_path(cddl_path, root_build_dir),
        "--header",
        outputs_src[0],
        "--cc",
        outputs_src[1],
        "--gen-dir",
        rebase_path(root_gen_dir, root_build_dir),
        "--log",
        rebase_path("cddl.log", "//"),
      ] + rebase_path(sources, root_build_dir)

  deps = [ cddl_label ]
}

source_set("unittests") {
  testonly = true

  sources = [ "messages_unittest.cc" ]

  deps = [
    ":msgs",
    "../../third_party/googletest:gtest",
  ]
}