2016-07-15 22:15:15 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2020-04-02 21:17:05 +00:00
|
|
|
template("third_party_config") {
|
2018-06-19 20:05:09 +00:00
|
|
|
enabled = !defined(invoker.enabled) || invoker.enabled
|
2020-04-02 21:17:05 +00:00
|
|
|
config(target_name) {
|
2018-06-19 20:05:09 +00:00
|
|
|
if (enabled) {
|
2020-04-02 21:17:05 +00:00
|
|
|
forward_variables_from(invoker, "*", [ "include_dirs" ])
|
2018-06-19 20:05:09 +00:00
|
|
|
cflags = []
|
2019-05-08 19:22:55 +00:00
|
|
|
if (is_win) {
|
2020-04-02 21:17:05 +00:00
|
|
|
include_dirs = invoker.include_dirs
|
2019-05-08 19:22:55 +00:00
|
|
|
if (is_clang) {
|
2020-04-02 21:17:05 +00:00
|
|
|
foreach(dir, invoker.include_dirs) {
|
2019-05-08 19:22:55 +00:00
|
|
|
cflags += [
|
|
|
|
"/imsvc",
|
|
|
|
rebase_path(dir),
|
|
|
|
]
|
|
|
|
}
|
2019-02-11 17:18:24 +00:00
|
|
|
}
|
2018-06-19 20:05:09 +00:00
|
|
|
} else {
|
2020-04-02 21:17:05 +00:00
|
|
|
foreach(dir, invoker.include_dirs) {
|
2019-06-11 18:26:28 +00:00
|
|
|
if (werror) {
|
|
|
|
cflags += [
|
|
|
|
"-isystem",
|
|
|
|
rebase_path(dir),
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
"-I",
|
|
|
|
rebase_path(dir),
|
|
|
|
]
|
|
|
|
}
|
2018-06-19 20:05:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
not_needed(invoker, "*")
|
2016-10-11 22:13:53 +00:00
|
|
|
}
|
2016-07-27 20:55:26 +00:00
|
|
|
}
|
2020-04-02 21:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template("third_party") {
|
|
|
|
enabled = !defined(invoker.enabled) || invoker.enabled
|
|
|
|
third_party_config(target_name + "_public") {
|
|
|
|
if (enabled) {
|
|
|
|
if (defined(invoker.public_defines)) {
|
|
|
|
defines = invoker.public_defines
|
|
|
|
}
|
|
|
|
include_dirs = invoker.public_include_dirs
|
|
|
|
} else {
|
|
|
|
not_needed(invoker, "*")
|
|
|
|
}
|
|
|
|
}
|
2019-02-01 20:34:04 +00:00
|
|
|
|
|
|
|
# You can't make a static_library() without object files to archive,
|
|
|
|
# but we can treat targets without object files as a source_set().
|
|
|
|
if (defined(invoker.sources)) {
|
|
|
|
_mode = "static_library"
|
|
|
|
} else {
|
|
|
|
_mode = "source_set"
|
|
|
|
}
|
|
|
|
|
|
|
|
target(_mode, target_name) {
|
2018-06-19 20:05:09 +00:00
|
|
|
if (enabled) {
|
|
|
|
forward_variables_from(invoker, "*", [ "public_include_dirs" ])
|
|
|
|
public_configs = [ ":" + target_name + "_public" ]
|
2016-07-19 15:25:00 +00:00
|
|
|
|
2018-06-19 20:05:09 +00:00
|
|
|
# Warnings are just noise if we're not maintaining the code.
|
|
|
|
if (is_win) {
|
2019-12-30 15:11:13 +00:00
|
|
|
cflags = [ "/w" ]
|
2018-06-19 20:05:09 +00:00
|
|
|
} else {
|
|
|
|
cflags = [ "-w" ]
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2016-07-19 15:25:00 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-03 22:08:04 +00:00
|
|
|
|
|
|
|
set_defaults("third_party") {
|
2018-09-04 14:15:58 +00:00
|
|
|
configs = default_configs
|
|
|
|
if (!is_official_build) {
|
|
|
|
# Official builds don't have warnings to begin with.
|
|
|
|
configs -= [ "//gn:warnings" ]
|
|
|
|
}
|
2019-02-04 15:01:53 +00:00
|
|
|
|
2018-09-19 17:44:43 +00:00
|
|
|
if (is_debug) {
|
|
|
|
configs += [ "//gn:optimize" ]
|
|
|
|
}
|
2020-01-31 17:07:51 +00:00
|
|
|
|
|
|
|
if (sanitize == "ASAN") {
|
|
|
|
configs += [ "//gn:recover_pointer_overflow" ]
|
|
|
|
}
|
2016-08-03 22:08:04 +00:00
|
|
|
}
|
2016-11-01 15:46:10 +00:00
|
|
|
|
|
|
|
template("system") {
|
|
|
|
config(target_name + "_public") {
|
|
|
|
forward_variables_from(invoker, "*", [])
|
|
|
|
}
|
|
|
|
group(target_name) {
|
|
|
|
public_configs = [ ":" + target_name + "_public" ]
|
|
|
|
}
|
|
|
|
}
|