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 6declare_args() { 7 third_party_isystem = true 8} 9 10template("third_party_config") { 11 enabled = !defined(invoker.enabled) || invoker.enabled 12 config(target_name) { 13 if (enabled) { 14 forward_variables_from(invoker, "*", [ "include_dirs" ]) 15 cflags = [] 16 if (is_win) { 17 include_dirs = invoker.include_dirs 18 if (is_clang) { 19 foreach(dir, invoker.include_dirs) { 20 cflags += [ 21 "/imsvc", 22 rebase_path(dir), 23 ] 24 } 25 } 26 } else { 27 foreach(dir, invoker.include_dirs) { 28 if (third_party_isystem) { 29 cflags += [ 30 "-isystem", 31 rebase_path(dir), 32 ] 33 } else { 34 cflags += [ 35 "-I", 36 rebase_path(dir), 37 ] 38 } 39 } 40 } 41 } else { 42 not_needed(invoker, "*") 43 } 44 } 45} 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 } 59 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) { 69 if (enabled) { 70 # 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 } 91 public_configs = [ ":" + target_name + "_public" ] 92 93 # Warnings are just noise if we're not maintaining the code. 94 if (is_win) { 95 cflags = [ "/w" ] 96 } else { 97 cflags = [ "-w" ] 98 } 99 } 100 } 101} 102 103template("system") { 104 config(target_name + "_public") { 105 forward_variables_from(invoker, "*", []) 106 } 107 group(target_name) { 108 public_configs = [ ":" + target_name + "_public" ] 109 } 110} 111