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