OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
| 5 import("//build/config/sanitizers/sanitizers.gni") |
5 import("//third_party/openh264/openh264_args.gni") | 6 import("//third_party/openh264/openh264_args.gni") |
6 import("//third_party/openh264/openh264_sources.gni") | 7 import("//third_party/openh264/openh264_sources.gni") |
| 8 import("//third_party/yasm/yasm_assemble.gni") |
7 | 9 |
8 # Config shared by all openh264 targets. | 10 # Config shared by all openh264 targets. |
9 config("config") { | 11 config("config") { |
10 cflags = [] | 12 cflags = [] |
11 defines = [] | 13 defines = [] |
12 | 14 |
13 # GCC and clang flags. MSVS (is_win && !is_clang) does not use cflags. | 15 # GCC and clang flags. MSVS (is_win && !is_clang) does not use cflags. |
14 if (!is_win || is_clang) { | 16 if (!is_win || is_clang) { |
15 cflags += [ | 17 cflags += [ |
16 "-Wno-format", | 18 "-Wno-format", |
17 "-Wno-header-hygiene", | 19 "-Wno-header-hygiene", |
18 "-Wno-unused-function", | 20 "-Wno-unused-function", |
19 "-Wno-unused-value", | 21 "-Wno-unused-value", |
20 ] | 22 ] |
21 } | 23 } |
22 | 24 |
23 # Platform-specific defines. | 25 # Platform-specific defines. |
24 if (is_android) { | 26 if (is_android) { |
25 # Android NDK is necessary for its cpufeatures and this define is what | 27 # Android NDK is necessary for its cpufeatures and this define is what |
26 # OpenH264 code uses to check if it should be used. | 28 # OpenH264 code uses to check if it should be used. |
27 defines += [ "ANDROID_NDK" ] | 29 defines += [ "ANDROID_NDK" ] |
28 } | 30 } |
29 } | 31 } |
30 | 32 |
| 33 # YASM assembly is only checked to be working on Windows and Linux. |
| 34 # Mac is known to fail certain tests when building, but actual assembly |
| 35 # is believed to work. |
| 36 # MSAN builds are flaky with assembler. crbug.com/685168 |
| 37 |
| 38 use_assembler = (is_win || is_linux) && |
| 39 (target_cpu == "x86" || target_cpu == "x64") && !is_msan |
| 40 |
| 41 # This IF statement will make the targets visible only on specific builds, |
| 42 # which will lead to failures on other platforms if accidentally invoked. |
| 43 if (use_assembler) { |
| 44 yasm_assemble("openh264_common_yasm") { |
| 45 include_dirs = openh264_common_include_dirs |
| 46 sources = openh264_common_sources_asm_x86 |
| 47 if (target_cpu == "x86") { |
| 48 defines = [ "X86_32" ] |
| 49 } else { # x64 |
| 50 if (is_mac) { |
| 51 defines = [ |
| 52 "PREFIX", |
| 53 "UNIX64", |
| 54 ] |
| 55 } else if (is_win) { |
| 56 defines = [ "WIN64" ] |
| 57 } else if (is_linux) { |
| 58 defines = [ "UNIX64" ] |
| 59 } |
| 60 } |
| 61 } |
| 62 |
| 63 yasm_assemble("openh264_processing_yasm") { |
| 64 include_dirs = openh264_processing_include_dirs |
| 65 include_dirs += [ "./src/codec/common/x86" ] |
| 66 sources = openh264_processing_sources_asm_x86 |
| 67 if (target_cpu == "x86") { |
| 68 defines = [ "X86_32" ] |
| 69 } else { # x64 |
| 70 if (is_mac) { |
| 71 defines = [ |
| 72 "PREFIX", |
| 73 "UNIX64", |
| 74 ] |
| 75 } else if (is_win) { |
| 76 defines = [ "WIN64" ] |
| 77 } else if (is_linux) { |
| 78 defines = [ "UNIX64" ] |
| 79 } |
| 80 } |
| 81 } |
| 82 |
| 83 yasm_assemble("openh264_encoder_yasm") { |
| 84 include_dirs = openh264_encoder_include_dirs |
| 85 include_dirs += [ "./src/codec/common/x86" ] |
| 86 sources = openh264_encoder_sources_asm_x86 |
| 87 if (target_cpu == "x86") { |
| 88 defines = [ "X86_32" ] |
| 89 } else { # x64 |
| 90 if (is_mac) { |
| 91 defines = [ |
| 92 "PREFIX", |
| 93 "UNIX64", |
| 94 ] |
| 95 } else if (is_win) { |
| 96 defines = [ "WIN64" ] |
| 97 } else if (is_linux) { |
| 98 defines = [ "UNIX64" ] |
| 99 } |
| 100 } |
| 101 } |
| 102 } # if (is_win || is_linux) |
| 103 |
31 source_set("common") { | 104 source_set("common") { |
32 sources = openh264_common_sources | 105 sources = openh264_common_sources |
33 include_dirs = openh264_common_include_dirs | 106 include_dirs = openh264_common_include_dirs |
34 | 107 |
35 configs -= [ "//build/config/compiler:chromium_code" ] | 108 configs -= [ "//build/config/compiler:chromium_code" ] |
36 configs += [ "//build/config/compiler:no_chromium_code" ] | 109 configs += [ "//build/config/compiler:no_chromium_code" ] |
37 configs += [ ":config" ] | 110 configs += [ ":config" ] |
38 deps = [] | 111 deps = [] |
| 112 if (use_assembler) { |
| 113 defines = [ "X86_ASM" ] |
| 114 deps += [ ":openh264_common_yasm" ] |
| 115 } |
39 if (is_android) { | 116 if (is_android) { |
40 deps += [ | 117 deps += [ |
41 # Defines "android_get/setCpu..." functions. The original OpenH264 build | 118 # Defines "android_get/setCpu..." functions. The original OpenH264 build |
42 # files replaces these using macros for "wels_..." versions of the same | 119 # files replaces these using macros for "wels_..." versions of the same |
43 # functions. We do not have access to these and use the <cpu-features.h> | 120 # functions. We do not have access to these and use the <cpu-features.h> |
44 # ones instead. | 121 # ones instead. |
45 "//third_party/android_tools:cpu_features", | 122 "//third_party/android_tools:cpu_features", |
46 ] | 123 ] |
47 } | 124 } |
48 } | 125 } |
49 | 126 |
50 source_set("processing") { | 127 source_set("processing") { |
51 sources = openh264_processing_sources | 128 sources = openh264_processing_sources |
52 include_dirs = openh264_processing_include_dirs | 129 include_dirs = openh264_processing_include_dirs |
53 | 130 |
54 configs -= [ "//build/config/compiler:chromium_code" ] | 131 configs -= [ "//build/config/compiler:chromium_code" ] |
55 configs += [ "//build/config/compiler:no_chromium_code" ] | 132 configs += [ "//build/config/compiler:no_chromium_code" ] |
56 configs += [ ":config" ] | 133 configs += [ ":config" ] |
57 deps = [ | 134 deps = [ |
58 ":common", | 135 ":common", |
59 ] | 136 ] |
| 137 if (use_assembler) { |
| 138 defines = [ "X86_ASM" ] |
| 139 deps += [ ":openh264_processing_yasm" ] |
| 140 } |
60 } | 141 } |
61 | 142 |
62 source_set("encoder") { | 143 source_set("encoder") { |
63 sources = openh264_encoder_sources | 144 sources = openh264_encoder_sources |
64 include_dirs = openh264_encoder_include_dirs | 145 include_dirs = openh264_encoder_include_dirs |
65 | 146 |
66 configs -= [ "//build/config/compiler:chromium_code" ] | 147 configs -= [ "//build/config/compiler:chromium_code" ] |
67 configs += [ "//build/config/compiler:no_chromium_code" ] | 148 configs += [ "//build/config/compiler:no_chromium_code" ] |
68 configs += [ ":config" ] | 149 configs += [ ":config" ] |
69 | 150 |
70 # TODO: Remove after fixing always-true condition | 151 # TODO: Remove after fixing always-true condition |
71 # third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp:142. | 152 # third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp:142. |
72 if (is_clang) { | 153 if (is_clang) { |
73 configs -= [ "//build/config/clang:extra_warnings" ] | 154 configs -= [ "//build/config/clang:extra_warnings" ] |
74 } | 155 } |
75 deps = [ | 156 deps = [ |
76 ":common", | 157 ":common", |
77 ":processing", | 158 ":processing", |
78 ] | 159 ] |
| 160 if (use_assembler) { |
| 161 defines = [ "X86_ASM" ] |
| 162 deps += [ ":openh264_encoder_yasm" ] |
| 163 } |
79 } | 164 } |
OLD | NEW |