Home | History | Annotate | Download | only in third_party
      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 
      6 template("third_party") {
      7   enabled = !defined(invoker.enabled) || invoker.enabled
      8   config(target_name + "_public") {
      9     if (enabled) {
     10       cflags = []
     11       if (defined(invoker.public_defines)) {
     12         defines = invoker.public_defines
     13       }
     14       if (is_win && !is_clang) {
     15         include_dirs = invoker.public_include_dirs
     16       } else if (is_win && is_clang) {
     17         foreach(dir, invoker.public_include_dirs) {
     18           cflags += [
     19             "/imsvc",
     20             rebase_path(dir),
     21           ]
     22         }
     23       } else {
     24         foreach(dir, invoker.public_include_dirs) {
     25           cflags += [
     26             "-isystem",
     27             rebase_path(dir),
     28           ]
     29         }
     30       }
     31     } else {
     32       not_needed(invoker, "*")
     33     }
     34   }
     35 
     36   # You can't make a static_library() without object files to archive,
     37   # but we can treat targets without object files as a source_set().
     38   if (defined(invoker.sources)) {
     39     _mode = "static_library"
     40   } else {
     41     _mode = "source_set"
     42   }
     43 
     44   target(_mode, target_name) {
     45     if (enabled) {
     46       forward_variables_from(invoker, "*", [ "public_include_dirs" ])
     47       public_configs = [ ":" + target_name + "_public" ]
     48 
     49       # Warnings are just noise if we're not maintaining the code.
     50       if (is_win) {
     51         cflags = [ "/w" ]
     52       } else {
     53         cflags = [ "-w" ]
     54       }
     55     }
     56   }
     57 }
     58 
     59 set_defaults("third_party") {
     60   configs = default_configs
     61   if (!is_official_build) {
     62     # Official builds don't have warnings to begin with.
     63     configs -= [ "//gn:warnings" ]
     64   }
     65 
     66   # Don't want to to deal with this (especially /RTCc)
     67   if (sanitize == "MSVC") {
     68     configs -= [ "//gn:msvc_rtc" ]
     69   }
     70   if (is_debug) {
     71     configs += [ "//gn:optimize" ]
     72   }
     73 }
     74 
     75 template("system") {
     76   config(target_name + "_public") {
     77     forward_variables_from(invoker, "*", [])
     78   }
     79   group(target_name) {
     80     public_configs = [ ":" + target_name + "_public" ]
     81   }
     82 }
     83