File: BUILD.gn

package info (click to toggle)
qtwebengine-opensource-src 5.7.1%2Bdfsg-6.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,028,096 kB
  • ctags: 1,436,736
  • sloc: cpp: 5,960,176; ansic: 3,477,727; asm: 395,492; python: 320,633; sh: 96,504; perl: 69,449; xml: 42,977; makefile: 28,408; objc: 9,962; yacc: 9,847; tcl: 5,430; lex: 2,259; ruby: 1,053; lisp: 522; awk: 497; pascal: 310; cs: 249; sed: 53
file content (317 lines) | stat: -rw-r--r-- 8,995 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/arm.gni")
import("//build/config/android/config.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//third_party/libvpx_new/libvpx_srcs.gni")
import("//third_party/yasm/yasm_assemble.gni")

# Sets the architecture name for building libvpx.
if (current_cpu == "x86") {
  cpu_arch_full = "ia32"
} else if (current_cpu == "x64") {
  if (is_msan) {
    cpu_arch_full = "generic"
  } else {
    cpu_arch_full = "x64"
  }
} else if (current_cpu == "arm") {
  if (arm_use_neon) {
    cpu_arch_full = "arm-neon"
  } else if (is_android) {
    cpu_arch_full = "arm-neon-cpu-detect"
  } else {
    cpu_arch_full = "arm"
  }
} else {
  cpu_arch_full = current_cpu
}

if (is_nacl) {
  platform_include_dir = "//third_party/libvpx_new/source/config/nacl"
} else {
  if (is_posix && !is_mac) {
    os_category = "linux"
  } else {
    os_category = current_os
  }
  platform_include_dir =
      "//third_party/libvpx_new/source/config/$os_category/$cpu_arch_full"
}

config("libvpx_config") {
  include_dirs = [
    "//third_party/libvpx_new/source/config",
    platform_include_dir,
    "//third_party/libvpx_new/source/libvpx",
    "$root_gen_dir/third_party/libvpx_new",  # Provides vpx_rtcd.h.
  ]

  if (current_cpu == "arm" && is_clang) {
    # TODO(hans) Enable integrated-as (crbug.com/124610).
    asmflags = [ "-fno-integrated-as" ]
    if (is_android) {
      rebased_android_toolchain_root =
          rebase_path(android_toolchain_root, root_build_dir)

      # Else /usr/bin/as gets picked up.
      asmflags += [ "-B${rebased_android_toolchain_root}/bin" ]
    }
  }
}

# gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come
# from a config and can't be on the target directly.
config("libvpx_warnings") {
  if (is_clang) {
    cflags = [
      # libvpx heavily relies on implicit enum casting.
      "-Wno-conversion",

      # libvpx does `if ((a == b))` in some places.
      "-Wno-parentheses-equality",

      # libvpx has many static functions in header, which trigger this warning.
      "-Wno-unused-function",
    ]
  } else if (!is_win) {
    cflags = [
      "-Wno-unused-function",
      "-Wno-sign-compare",
    ]
  }
}

# This config is applied to targets that depend on libvpx.
config("libvpx_external_config") {
  include_dirs = [ "//third_party/libvpx_new/source/libvpx" ]
}

if (current_cpu == "x86" || current_cpu == "x64") {
  yasm_assemble("libvpx_yasm") {
    if (current_cpu == "x86") {
      sources = libvpx_srcs_x86_assembly
    } else if (current_cpu == "x64") {
      sources = libvpx_srcs_x86_64_assembly
    }

    defines = [ "CHROMIUM" ]
    if (is_android) {
      # On Android, define __ANDROID__ to use alternative standard library
      # functions.
      defines += [ "__ANDROID__" ]
    }
    include_dirs = [
      platform_include_dir,
      "//third_party/libvpx_new/source/config",
      "//third_party/libvpx_new/source/libvpx",
      target_gen_dir,
    ]
  }
}

static_library("libvpx_intrinsics_mmx") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (!is_win) {
    cflags = [ "-mmmx" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_mmx
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_mmx
  }
}

static_library("libvpx_intrinsics_sse2") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (!is_win || is_clang) {
    cflags = [ "-msse2" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_sse2
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_sse2
  }
}

static_library("libvpx_intrinsics_ssse3") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (!is_win || is_clang) {
    cflags = [ "-mssse3" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_ssse3
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_ssse3
  }
}

static_library("libvpx_intrinsics_sse4_1") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (!is_win || is_clang) {
    cflags = [ "-msse4.1" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_sse4_1
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_sse4_1
  }
}

static_library("libvpx_intrinsics_avx") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (is_win) {
    cflags = [ "/arch:AVX" ]
  } else {
    cflags = [ "-mavx" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_avx
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_avx
  }
}

static_library("libvpx_intrinsics_avx2") {
  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  if (is_win) {
    cflags = [ "/arch:AVX2" ]
  } else {
    cflags = [ "-mavx2" ]
  }
  if (current_cpu == "x86") {
    sources = libvpx_srcs_x86_avx2
  } else if (current_cpu == "x64") {
    sources = libvpx_srcs_x86_64_avx2
  }
}

if (cpu_arch_full == "arm-neon-cpu-detect") {
  static_library("libvpx_intrinsics_neon") {
    configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
    configs += [ ":libvpx_config" ]
    configs += [ ":libvpx_warnings" ]
    cflags = [ "-mfpu=neon" ]
    sources = libvpx_srcs_arm_neon_cpu_detect_neon
  }
}

# Converts ARM assembly files to GAS style.
if (current_cpu == "arm") {
  action_foreach("convert_arm_assembly") {
    script = "//third_party/libvpx_new/run_perl.py"
    if (cpu_arch_full == "arm-neon") {
      sources = libvpx_srcs_arm_neon_assembly
    } else if (cpu_arch_full == "arm-neon-cpu-detect") {
      sources = libvpx_srcs_arm_neon_cpu_detect_assembly
    } else {
      sources = libvpx_srcs_arm_assembly
    }
    outputs = [
      "$target_gen_dir/{{source_name_part}}.S",
    ]
    args = [
      "-s",
      rebase_path(
          "//third_party/libvpx_new/source/libvpx/build/make/ads2gas.pl",
          root_build_dir),
      "-i",
      "{{source}}",
      "-o",
      rebase_path("$target_gen_dir/{{source_name_part}}.S"),
    ]
  }

  static_library("libvpx_assembly_arm") {
    sources = get_target_outputs(":convert_arm_assembly")
    configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
    configs += [ ":libvpx_config" ]
    configs += [ ":libvpx_warnings" ]
    if (cpu_arch_full == "arm-neon" || cpu_arch_full == "arm-neon-cpu-detect") {
      asmflags = [ "-mfpu=neon" ]
    }
    deps = [
      ":convert_arm_assembly",
    ]
  }
}

static_library("libvpx_new") {
  if (!is_debug && is_win) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  if (is_nacl) {
    sources = libvpx_srcs_generic
  } else if (current_cpu == "x86") {
    sources = libvpx_srcs_x86
  } else if (current_cpu == "x64") {
    if (is_msan) {
      sources = libvpx_srcs_generic
    } else {
      sources = libvpx_srcs_x86_64
    }
  } else if (current_cpu == "mipsel") {
    sources = libvpx_srcs_mips
  } else if (current_cpu == "arm") {
    if (arm_use_neon) {
      sources = libvpx_srcs_arm_neon
    } else if (is_android) {
      sources = libvpx_srcs_arm_neon_cpu_detect
    } else {
      sources = libvpx_srcs_arm
    }
  } else if (current_cpu == "arm64") {
    sources = libvpx_srcs_arm64
  }

  configs += [ ":libvpx_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  configs += [ ":libvpx_warnings" ]
  deps = []
  if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
    deps += [
      ":libvpx_intrinsics_avx",
      ":libvpx_intrinsics_avx2",
      ":libvpx_intrinsics_mmx",
      ":libvpx_intrinsics_sse2",
      ":libvpx_intrinsics_sse4_1",
      ":libvpx_intrinsics_ssse3",
      ":libvpx_yasm",
    ]
  }
  if (cpu_arch_full == "arm-neon-cpu-detect") {
    deps += [ ":libvpx_intrinsics_neon" ]
  }
  if (is_android) {
    deps += [ "//third_party/android_tools:cpu_features" ]
  }
  if (current_cpu == "arm") {
    deps += [ ":libvpx_assembly_arm" ]
  }

  public_configs = [ ":libvpx_external_config" ]
}