abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame] | 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 | |
mtklein | f037d48 | 2016-07-19 08:25:00 -0700 | [diff] [blame] | 6 | template("third_party") { |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 7 | enabled = !defined(invoker.enabled) || invoker.enabled |
mtklein | 25c81d4 | 2016-07-27 13:55:26 -0700 | [diff] [blame] | 8 | config(target_name + "_public") { |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 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, "*") |
Mike Klein | 4b167fc | 2016-10-11 18:13:53 -0400 | [diff] [blame] | 26 | } |
mtklein | 25c81d4 | 2016-07-27 13:55:26 -0700 | [diff] [blame] | 27 | } |
mtklein | f037d48 | 2016-07-19 08:25:00 -0700 | [diff] [blame] | 28 | source_set(target_name) { |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 29 | if (enabled) { |
| 30 | forward_variables_from(invoker, "*", [ "public_include_dirs" ]) |
| 31 | public_configs = [ ":" + target_name + "_public" ] |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame] | 32 | |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 33 | # Warnings are just noise if we're not maintaining the code. |
| 34 | if (is_win) { |
| 35 | cflags = [ "/w" ] |
| 36 | } else { |
| 37 | cflags = [ "-w" ] |
| 38 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 39 | } |
mtklein | f037d48 | 2016-07-19 08:25:00 -0700 | [diff] [blame] | 40 | } |
| 41 | } |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 42 | |
| 43 | set_defaults("third_party") { |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 44 | configs = default_configs - [ "//gn:warnings" ] |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 45 | } |
Mike Klein | 10d665d | 2016-11-01 11:46:10 -0400 | [diff] [blame] | 46 | |
| 47 | template("system") { |
| 48 | config(target_name + "_public") { |
| 49 | forward_variables_from(invoker, "*", []) |
| 50 | } |
| 51 | group(target_name) { |
| 52 | public_configs = [ ":" + target_name + "_public" ] |
| 53 | } |
| 54 | } |