• 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      } else {
17        foreach(dir, invoker.public_include_dirs) {
18          cflags += [
19            "-isystem",
20            rebase_path(dir),
21          ]
22        }
23      }
24    } else {
25      not_needed(invoker, "*")
26    }
27  }
28
29  # You can't make a static_library() without object files to archive,
30  # but we can treat targets without object files as a source_set().
31  if (defined(invoker.sources)) {
32    _mode = "static_library"
33  } else {
34    _mode = "source_set"
35  }
36
37  target(_mode, target_name) {
38    if (enabled) {
39      forward_variables_from(invoker, "*", [ "public_include_dirs" ])
40      public_configs = [ ":" + target_name + "_public" ]
41
42      # Warnings are just noise if we're not maintaining the code.
43      if (is_win) {
44        cflags = [ "/w" ]
45      } else {
46        cflags = [ "-w" ]
47      }
48    }
49  }
50}
51
52set_defaults("third_party") {
53  configs = default_configs
54  if (!is_official_build) {
55    # Official builds don't have warnings to begin with.
56    configs -= [ "//gn:warnings" ]
57  }
58  if (is_debug) {
59    configs += [ "//gn:optimize" ]
60  }
61}
62
63template("system") {
64  config(target_name + "_public") {
65    forward_variables_from(invoker, "*", [])
66  }
67  group(target_name) {
68    public_configs = [ ":" + target_name + "_public" ]
69  }
70}
71