Home | History | Annotate | Download | only in config
      1 # =============================================================================
      2 # BUILD FLAGS
      3 # =============================================================================
      4 #
      5 # This block lists input arguments to the build, along with their default
      6 # values. GN requires listing them explicitly so it can validate input and have
      7 # a central place to manage the build flags.
      8 #
      9 # If a value is specified on the command line, it will overwrite the defaults
     10 # given here, otherwise the default will be injected into the root scope.
     11 #
     12 # KEEP IN ALPHABETICAL ORDER and write a good description for everything.
     13 # Use "is_*" names for intrinsic platform descriptions and build modes, and
     14 # "use_*" names for optional features libraries, and configurations.
     15 declare_args() {
     16   is_android = 0
     17   is_component_build = 1
     18   is_chromeos = 0
     19   is_debug = 1
     20   is_ios = 0
     21   use_ash = 0
     22   use_aura = 0
     23   use_ozone = 0
     24 }
     25 
     26 # =============================================================================
     27 # SOURCES FILTERS
     28 # =============================================================================
     29 #
     30 # These patterns filter out platform-specific files when assigning to the
     31 # sources variable. The magic variable |sources_assignment_filter| is applied
     32 # to each assignment or appending to the sources variable and matches are
     33 # automatcally removed.
     34 #
     35 # We define lists of filters for each platform for all builds so they can
     36 # be used by individual targets if necessary (a target can always change
     37 # sources_assignment_filter on itself if it needs something more specific).
     38 #
     39 # Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
     40 # boundary = end of string or slash) are supported, and the entire string
     41 # muct match the pattern (so you need "*.cc" to match all .cc files, for
     42 # example).
     43 
     44 windows_sources_filters = [
     45   "*_win.cc",
     46   "*_win.h",
     47   "*_win_unittest.cc",
     48   "*\bwin/*",
     49 ]
     50 mac_sources_filters = [
     51   "*_mac.h",
     52   "*_mac.cc",
     53   "*_mac.mm",
     54   "*_mac_unittest.h",
     55   "*_mac_unittest.cc",
     56   "*_mac_unittest.mm",
     57   "*\bmac/*",
     58   "*_cocoa.h",
     59   "*_cocoa.cc",
     60   "*_cocoa.mm",
     61   "*_cocoa_unittest.h",
     62   "*_cocoa_unittest.cc",
     63   "*_cocoa_unittest.mm",
     64   "*\bcocoa/*",
     65 ]
     66 ios_sources_filters = [
     67   "*_ios.h",
     68   "*_ios.cc",
     69   "*_ios.mm",
     70   "*_ios_unittest.h",
     71   "*_ios_unittest.cc",
     72   "*_ios_unittest.mm",
     73   "*\bios/*",
     74 ]
     75 objective_c_sources_filters = [
     76   "*.mm",
     77 ]
     78 linux_sources_filters = [
     79   "*_linux.h",
     80   "*_linux.cc",
     81   "*_linux_unittest.h",
     82   "*_linux_unittest.cc",
     83   "*\blinux/*",
     84 ]
     85 android_sources_filters = [
     86   "*_android.h",
     87   "*_android.cc",
     88   "*_android_unittest.h",
     89   "*_android_unittest.cc",
     90   "*\bandroid/*",
     91 ]
     92 posix_sources_filters = [
     93   "*_posix.h",
     94   "*_posix.cc",
     95   "*_posix_unittest.h",
     96   "*_posix_unittest.cc",
     97   "*\bposix/*",
     98 ]
     99 
    100 # Construct the full list of sources we're using for this platform.
    101 sources_assignment_filter = []
    102 if (is_win) {
    103   sources_assignment_filter += posix_sources_filters
    104 } else {
    105   sources_assignment_filter += windows_sources_filters
    106 }
    107 if (!is_mac) {
    108   sources_assignment_filter += mac_sources_filters
    109 }
    110 if (!is_ios) {
    111   sources_assignment_filter += ios_sources_filters
    112 }
    113 if (!is_mac && !is_ios) {
    114   sources_assignment_filter += objective_c_sources_filters
    115 }
    116 if (!is_linux) {
    117   sources_assignment_filter += linux_sources_filters
    118 }
    119 if (!is_android) {
    120   sources_assignment_filter += android_sources_filters
    121 }
    122 
    123 # This is the actual set.
    124 set_sources_assignment_filter(sources_assignment_filter)
    125 
    126 # =============================================================================
    127 # SYSTEM CONFIG
    128 # =============================================================================
    129 
    130 is_nacl = 0
    131 
    132 # =============================================================================
    133 # BUILD OPTIONS
    134 # =============================================================================
    135 
    136 if (is_component_build) {
    137   component_mode = "shared_library"
    138 } else {
    139   component_mode = "static_library"
    140 }
    141 
    142 # =============================================================================
    143 # TARGET DEFAULTS
    144 # =============================================================================
    145 #
    146 # Set up the default configuration for every build target of the given type.
    147 # The values configured here will be automatically set on the scope of the
    148 # corresponding target. Target definitions can add or remove to the settings
    149 # here as needed.
    150 
    151 # Holds all configs used for making native executables and libraries, to avoid
    152 # duplication in each target below.
    153 native_compiler_configs = [
    154   "//build/config:my_msvs",  # TODO(brettw) eraseme
    155 
    156   "//build/config/compiler:compiler",
    157   "//build/config/compiler:chromium_code",
    158   "//build/config/compiler:default_warnings",
    159   "//build/config/compiler:no_rtti",
    160   "//build/config/compiler:runtime_library",
    161 ]
    162 if (is_win) {
    163   native_compiler_configs += "//build/config/win:sdk"
    164 } else if (is_mac) {
    165   # TODO(brettw) this should be in an if (is_clang) block instead but I haven't
    166   # written an is_clang flag yet.
    167   native_compiler_configs += "//build/config/clang:find_bad_constructs"
    168 }
    169 
    170 if (is_debug) {
    171   native_compiler_configs += "//build/config:debug"
    172 } else {
    173   native_compiler_configs += "//build/config:release"
    174 }
    175 
    176 set_defaults("executable") {
    177   configs = native_compiler_configs
    178   if (is_mac) {
    179     configs += "//build/config/mac:mac_dynamic_flags"
    180   }
    181 }
    182 
    183 set_defaults("static_library") {
    184   configs = native_compiler_configs
    185 }
    186 
    187 set_defaults("shared_library") {
    188   configs = native_compiler_configs
    189   if (is_mac) {
    190     configs += "//build/config/mac:mac_dynamic_flags"
    191   }
    192 }
    193 
    194 # ==============================================================================
    195 # TOOLCHAIN SETUP
    196 # ==============================================================================
    197 
    198 if (is_win) {
    199   set_default_toolchain("//build/config/win:32")
    200 } else if (is_mac) {
    201   set_default_toolchain("//build/config/mac:clang")
    202 }
    203