BUILDCONFIG.gn (4431B)
1 # ============================================================================= 2 # PLATFORM SELECTION 3 # ============================================================================= 4 # 5 # There are two main things to set: "os" and "cpu". The "toolchain" is the name 6 # of the GN thing that encodes combinations of these things. 7 # 8 # Users typically only set the variables "target_os" and "target_cpu" in "gn 9 # args", the rest are set up by our build and internal to GN. 10 # 11 # There are three different types of each of these things: The "host" 12 # represents the computer doing the compile and never changes. The "target" 13 # represents the main thing we're trying to build. The "current" represents 14 # which configuration is currently being defined, which can be either the 15 # host, the target, or something completely different (like nacl). GN will 16 # run the same build file multiple times for the different required 17 # configuration in the same build. 18 # 19 # This gives the following variables: 20 # - host_os, host_cpu, host_toolchain 21 # - target_os, target_cpu, default_toolchain 22 # - current_os, current_cpu, current_toolchain. 23 # 24 # Note the default_toolchain isn't symmetrical (you would expect 25 # target_toolchain). This is because the "default" toolchain is a GN built-in 26 # concept, and "target" is something our build sets up that's symmetrical with 27 # its GYP counterpart. Potentially the built-in default_toolchain variable 28 # could be renamed in the future. 29 # 30 # When writing build files, to do something only for the host: 31 # if (current_toolchain == host_toolchain) { ... 32 33 if (target_os == "") { 34 target_os = host_os 35 } 36 if (target_cpu == "") { 37 target_cpu = host_cpu 38 } 39 if (current_cpu == "") { 40 current_cpu = target_cpu 41 } 42 if (current_os == "") { 43 current_os = target_os 44 } 45 46 # ============================================================================= 47 # PLATFORM SELECTION 48 # ============================================================================= 49 # 50 # There are two main things to set: "os" and "cpu". The "toolchain" is the name 51 # of the GN thing that encodes combinations of these things. 52 # 53 # Users typically only set the variables "target_os" and "target_cpu" in "gn 54 # args", the rest are set up by our build and internal to GN. 55 # 56 # There are three different types of each of these things: The "host" 57 # represents the computer doing the compile and never changes. The "target" 58 # represents the main thing we're trying to build. The "current" represents 59 # which configuration is currently being defined, which can be either the 60 # host, the target, or something completely different (like nacl). GN will 61 # run the same build file multiple times for the different required 62 # configuration in the same build. 63 # 64 # This gives the following variables: 65 # - host_os, host_cpu, host_toolchain 66 # - target_os, target_cpu, default_toolchain 67 # - current_os, current_cpu, current_toolchain. 68 # 69 # Note the default_toolchain isn't symmetrical (you would expect 70 # target_toolchain). This is because the "default" toolchain is a GN built-in 71 # concept, and "target" is something our build sets up that's symmetrical with 72 # its GYP counterpart. Potentially the built-in default_toolchain variable 73 # could be renamed in the future. 74 # 75 # When writing build files, to do something only for the host: 76 # if (current_toolchain == host_toolchain) { ... 77 78 declare_args() { 79 is_debug = true 80 system_include_dirs = [] 81 system_lib_dirs = [] 82 } 83 84 # Options 85 use_strip = !is_debug 86 87 # All binary targets will get this list of configs by default. 88 _shared_binary_target_configs = [ 89 "//build:compiler_std", 90 "//build:compiler_warnings", 91 ] 92 93 # Optimisations and debug/release mode. 94 if (is_debug) { 95 _shared_binary_target_configs += [ "//build:debug" ] 96 _shared_binary_target_configs += [ "//build:no_optimize" ] 97 _shared_binary_target_configs += [ "//build:symbols" ] 98 } else { 99 _shared_binary_target_configs += [ "//build:release" ] 100 _shared_binary_target_configs += [ "//build:optimize" ] 101 _shared_binary_target_configs += [ "//build:no_symbols" ] 102 } 103 104 # Apply that default list to the binary target types. 105 set_defaults("executable") { 106 configs = _shared_binary_target_configs 107 } 108 set_defaults("static_library") { 109 configs = _shared_binary_target_configs 110 } 111 set_defaults("shared_library") { 112 configs = _shared_binary_target_configs 113 } 114 set_defaults("source_set") { 115 configs = _shared_binary_target_configs 116 } 117 118 set_default_toolchain("//build/toolchain:clang")