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 | } |
Mike Klein | 10af5ec | 2019-02-11 12:18:24 -0500 | [diff] [blame^] | 14 | if (is_win && !is_clang) { |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 15 | include_dirs = invoker.public_include_dirs |
Mike Klein | 10af5ec | 2019-02-11 12:18:24 -0500 | [diff] [blame^] | 16 | } else if (is_win && is_clang) { |
| 17 | foreach(dir, invoker.public_include_dirs) { |
| 18 | cflags += [ |
| 19 | "/imsvc", |
| 20 | rebase_path(dir), |
| 21 | ] |
| 22 | } |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 23 | } else { |
| 24 | foreach(dir, invoker.public_include_dirs) { |
| 25 | cflags += [ |
| 26 | "-isystem", |
| 27 | rebase_path(dir), |
| 28 | ] |
| 29 | } |
| 30 | } |
| 31 | } else { |
| 32 | not_needed(invoker, "*") |
Mike Klein | 4b167fc | 2016-10-11 18:13:53 -0400 | [diff] [blame] | 33 | } |
mtklein | 25c81d4 | 2016-07-27 13:55:26 -0700 | [diff] [blame] | 34 | } |
Kevin Lubick | d5c6e16 | 2019-02-01 15:34:04 -0500 | [diff] [blame] | 35 | |
| 36 | # You can't make a static_library() without object files to archive, |
| 37 | # but we can treat targets without object files as a source_set(). |
| 38 | if (defined(invoker.sources)) { |
| 39 | _mode = "static_library" |
| 40 | } else { |
| 41 | _mode = "source_set" |
| 42 | } |
| 43 | |
| 44 | target(_mode, target_name) { |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 45 | if (enabled) { |
| 46 | forward_variables_from(invoker, "*", [ "public_include_dirs" ]) |
| 47 | public_configs = [ ":" + target_name + "_public" ] |
abarth | 6fc8ff0 | 2016-07-15 15:15:15 -0700 | [diff] [blame] | 48 | |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 49 | # Warnings are just noise if we're not maintaining the code. |
| 50 | if (is_win) { |
| 51 | cflags = [ "/w" ] |
| 52 | } else { |
| 53 | cflags = [ "-w" ] |
| 54 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 55 | } |
mtklein | f037d48 | 2016-07-19 08:25:00 -0700 | [diff] [blame] | 56 | } |
| 57 | } |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 58 | |
| 59 | set_defaults("third_party") { |
Mike Klein | d84c1e6 | 2018-09-04 10:15:58 -0400 | [diff] [blame] | 60 | configs = default_configs |
| 61 | if (!is_official_build) { |
| 62 | # Official builds don't have warnings to begin with. |
| 63 | configs -= [ "//gn:warnings" ] |
| 64 | } |
Brian Osman | 50ea3c0 | 2019-02-04 10:01:53 -0500 | [diff] [blame] | 65 | |
| 66 | # Don't want to to deal with this (especially /RTCc) |
| 67 | if (sanitize == "MSVC") { |
| 68 | configs -= [ "//gn:msvc_rtc" ] |
| 69 | } |
Mike Klein | 7ea977b | 2018-09-19 13:44:43 -0400 | [diff] [blame] | 70 | if (is_debug) { |
| 71 | configs += [ "//gn:optimize" ] |
| 72 | } |
halcanary | 19a9720 | 2016-08-03 15:08:04 -0700 | [diff] [blame] | 73 | } |
Mike Klein | 10d665d | 2016-11-01 11:46:10 -0400 | [diff] [blame] | 74 | |
| 75 | template("system") { |
| 76 | config(target_name + "_public") { |
| 77 | forward_variables_from(invoker, "*", []) |
| 78 | } |
| 79 | group(target_name) { |
| 80 | public_configs = [ ":" + target_name + "_public" ] |
| 81 | } |
| 82 | } |