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.
|
|
|
|
|
2016-07-19 15:25:00 +00:00
|
|
|
template("third_party") {
|
2018-06-19 20:05:09 +00:00
|
|
|
enabled = !defined(invoker.enabled) || invoker.enabled
|
2016-07-27 20:55:26 +00:00
|
|
|
config(target_name + "_public") {
|
2018-06-19 20:05:09 +00:00
|
|
|
if (enabled) {
|
|
|
|
cflags = []
|
|
|
|
if (defined(invoker.public_defines)) {
|
|
|
|
defines = invoker.public_defines
|
|
|
|
}
|
|
|
|
if (is_win) {
|
|
|
|
include_dirs = invoker.public_include_dirs
|
|
|
|
} else {
|
|
|
|
foreach(dir, invoker.public_include_dirs) {
|
|
|
|
cflags += [
|
|
|
|
"-isystem",
|
|
|
|
rebase_path(dir),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
not_needed(invoker, "*")
|
2016-10-11 22:13:53 +00:00
|
|
|
}
|
2016-07-27 20:55:26 +00:00
|
|
|
}
|
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) {
|
|
|
|
cflags = [ "/w" ]
|
|
|
|
} 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" ]
|
|
|
|
}
|
2018-09-19 17:44:43 +00:00
|
|
|
if (is_debug) {
|
|
|
|
configs += [ "//gn:optimize" ]
|
|
|
|
}
|
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" ]
|
|
|
|
}
|
|
|
|
}
|