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-06-19 21:25:12 +00:00
|
|
|
declare_args() {
|
|
|
|
third_party_isystem = true
|
|
|
|
}
|
|
|
|
|
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) {
|
2020-06-19 21:25:12 +00:00
|
|
|
if (third_party_isystem) {
|
2019-06-11 18:26:28 +00:00
|
|
|
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) {
|
2021-03-16 18:29:20 +00:00
|
|
|
# set_defaults(_mode) might not exist or set configs
|
|
|
|
if (!defined(configs)) {
|
|
|
|
configs = []
|
|
|
|
}
|
|
|
|
if (is_debug) {
|
|
|
|
configs += [ "//gn/skia:optimize" ]
|
|
|
|
}
|
|
|
|
if (sanitize == "ASAN") {
|
|
|
|
configs += [ "//gn/skia:recover_pointer_overflow" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
# "*" clobbers the current scope; append to existing configs
|
|
|
|
forward_variables_from(invoker,
|
|
|
|
"*",
|
|
|
|
[
|
|
|
|
"public_include_dirs",
|
|
|
|
"configs",
|
|
|
|
])
|
|
|
|
if (defined(invoker.configs)) {
|
|
|
|
configs += invoker.configs
|
|
|
|
}
|
2018-06-19 20:05:09 +00:00
|
|
|
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
|
|
|
|
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" ]
|
|
|
|
}
|
|
|
|
}
|