blob: d9e061b012bc50a6a4e393b70736e4d1f1e9b452 [file] [log] [blame]
abarth6fc8ff02016-07-15 15:15:15 -07001# 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
Mike Klein29cb9f92020-06-19 16:25:12 -05006declare_args() {
7 third_party_isystem = true
8}
9
Ben Wagner36e67aa2020-04-02 17:17:05 -040010template("third_party_config") {
Brian Osmanc069a572018-06-19 16:05:09 -040011 enabled = !defined(invoker.enabled) || invoker.enabled
Ben Wagner36e67aa2020-04-02 17:17:05 -040012 config(target_name) {
Brian Osmanc069a572018-06-19 16:05:09 -040013 if (enabled) {
Ben Wagner36e67aa2020-04-02 17:17:05 -040014 forward_variables_from(invoker, "*", [ "include_dirs" ])
Brian Osmanc069a572018-06-19 16:05:09 -040015 cflags = []
Brian Osman8cdf5b62019-05-08 15:22:55 -040016 if (is_win) {
Ben Wagner36e67aa2020-04-02 17:17:05 -040017 include_dirs = invoker.include_dirs
Brian Osman8cdf5b62019-05-08 15:22:55 -040018 if (is_clang) {
Ben Wagner36e67aa2020-04-02 17:17:05 -040019 foreach(dir, invoker.include_dirs) {
Brian Osman8cdf5b62019-05-08 15:22:55 -040020 cflags += [
21 "/imsvc",
22 rebase_path(dir),
23 ]
24 }
Mike Klein10af5ec2019-02-11 12:18:24 -050025 }
Brian Osmanc069a572018-06-19 16:05:09 -040026 } else {
Ben Wagner36e67aa2020-04-02 17:17:05 -040027 foreach(dir, invoker.include_dirs) {
Mike Klein29cb9f92020-06-19 16:25:12 -050028 if (third_party_isystem) {
Shachar Langbeheimdb610b32019-06-11 21:26:28 +030029 cflags += [
30 "-isystem",
31 rebase_path(dir),
32 ]
33 } else {
34 cflags += [
35 "-I",
36 rebase_path(dir),
37 ]
38 }
Brian Osmanc069a572018-06-19 16:05:09 -040039 }
40 }
41 } else {
42 not_needed(invoker, "*")
Mike Klein4b167fc2016-10-11 18:13:53 -040043 }
mtklein25c81d42016-07-27 13:55:26 -070044 }
Ben Wagner36e67aa2020-04-02 17:17:05 -040045}
46
47template("third_party") {
48 enabled = !defined(invoker.enabled) || invoker.enabled
49 third_party_config(target_name + "_public") {
50 if (enabled) {
51 if (defined(invoker.public_defines)) {
52 defines = invoker.public_defines
53 }
54 include_dirs = invoker.public_include_dirs
55 } else {
56 not_needed(invoker, "*")
57 }
58 }
Kevin Lubickd5c6e162019-02-01 15:34:04 -050059
60 # You can't make a static_library() without object files to archive,
61 # but we can treat targets without object files as a source_set().
62 if (defined(invoker.sources)) {
63 _mode = "static_library"
64 } else {
65 _mode = "source_set"
66 }
67
68 target(_mode, target_name) {
Brian Osmanc069a572018-06-19 16:05:09 -040069 if (enabled) {
Ben Wagner3d9ab7e2021-03-16 14:29:20 -040070 # set_defaults(_mode) might not exist or set configs
71 if (!defined(configs)) {
72 configs = []
73 }
74 if (is_debug) {
75 configs += [ "//gn/skia:optimize" ]
76 }
77 if (sanitize == "ASAN") {
78 configs += [ "//gn/skia:recover_pointer_overflow" ]
79 }
80
81 # "*" clobbers the current scope; append to existing configs
82 forward_variables_from(invoker,
83 "*",
84 [
85 "public_include_dirs",
86 "configs",
87 ])
88 if (defined(invoker.configs)) {
89 configs += invoker.configs
90 }
Brian Osmanc069a572018-06-19 16:05:09 -040091 public_configs = [ ":" + target_name + "_public" ]
abarth6fc8ff02016-07-15 15:15:15 -070092
Brian Osmanc069a572018-06-19 16:05:09 -040093 # Warnings are just noise if we're not maintaining the code.
94 if (is_win) {
Brian Osman63d32152019-12-30 10:11:13 -050095 cflags = [ "/w" ]
Brian Osmanc069a572018-06-19 16:05:09 -040096 } else {
97 cflags = [ "-w" ]
98 }
herbb6318bf2016-09-16 13:29:57 -070099 }
mtkleinf037d482016-07-19 08:25:00 -0700100 }
101}
halcanary19a97202016-08-03 15:08:04 -0700102
Mike Klein10d665d2016-11-01 11:46:10 -0400103template("system") {
104 config(target_name + "_public") {
105 forward_variables_from(invoker, "*", [])
106 }
107 group(target_name) {
108 public_configs = [ ":" + target_name + "_public" ]
109 }
110}