• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6template("third_party") {
7  enabled = !defined(invoker.enabled) || invoker.enabled
8  config(target_name + "_public") {
9    if (enabled) {
10      cflags = []
11      if (defined(invoker.public_defines)) {
12        defines = invoker.public_defines
13      }
14      if (is_win) {
15        include_dirs = invoker.public_include_dirs
16        if (is_clang) {
17          foreach(dir, invoker.public_include_dirs) {
18            cflags += [
19              "/imsvc",
20              rebase_path(dir),
21            ]
22          }
23        }
24      } else {
25        foreach(dir, invoker.public_include_dirs) {
26          if (werror) {
27            cflags += [
28              "-isystem",
29              rebase_path(dir),
30            ]
31          } else {
32            cflags += [
33              "-I",
34              rebase_path(dir),
35            ]
36          }
37        }
38      }
39    } else {
40      not_needed(invoker, "*")
41    }
42  }
43
44  # You can't make a static_library() without object files to archive,
45  # but we can treat targets without object files as a source_set().
46  if (defined(invoker.sources)) {
47    _mode = "static_library"
48  } else {
49    _mode = "source_set"
50  }
51
52  target(_mode, target_name) {
53    if (enabled) {
54      forward_variables_from(invoker, "*", [ "public_include_dirs" ])
55      public_configs = [ ":" + target_name + "_public" ]
56
57      # Warnings are just noise if we're not maintaining the code.
58      if (is_win) {
59        cflags = [ "/w" ]
60      } else {
61        cflags = [ "-w" ]
62      }
63    }
64  }
65}
66
67set_defaults("third_party") {
68  configs = default_configs
69  if (!is_official_build) {
70    # Official builds don't have warnings to begin with.
71    configs -= [ "//gn:warnings" ]
72  }
73
74  if (is_debug) {
75    configs += [ "//gn:optimize" ]
76  }
77
78  if (sanitize == "ASAN") {
79    configs += [ "//gn:recover_pointer_overflow" ]
80  }
81}
82
83template("system") {
84  config(target_name + "_public") {
85    forward_variables_from(invoker, "*", [])
86  }
87  group(target_name) {
88    public_configs = [ ":" + target_name + "_public" ]
89  }
90}
91