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 configs += [ "../../gn/skia:recover_pointer_overflow" ] 78 79 # "*" clobbers the current scope; append to existing configs 80 forward_variables_from(invoker, 81 "*", 82 [ 83 "public_include_dirs", 84 "configs", 85 ]) 86 if (defined(invoker.configs)) { 87 configs += invoker.configs 88 } 89 public_configs = [ ":" + target_name + "_public" ] 90 91 # Warnings are just noise if we're not maintaining the code. 92 if (!defined(cflags)) { 93 cflags = [] 94 } 95 if (is_win) { 96 cflags += [ "/w" ] 97 } else { 98 cflags += [ "-w" ] 99 } 100 } 101 } 102} 103 104template("system") { 105 config(target_name + "_public") { 106 forward_variables_from(invoker, "*", []) 107 } 108 group(target_name) { 109 public_configs = [ ":" + target_name + "_public" ] 110 } 111} 112