Don't preload rarely seen large images
[chromium-blink-merge.git] / third_party / widevine / cdm / BUILD.gn
blob99ca959879a746da01225d8181fdaf6db46740ef
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/chrome_build.gni")
6 import("//build/config/features.gni")
7 import("//chrome/version.gni")  # TODO layering violation
8 import("//media/cdm/ppapi/cdm_adapter.gni")
9 import("//third_party/widevine/cdm/widevine.gni")
11 widevine_arch = current_cpu
12 if (widevine_arch == "x86") {
13   widevine_arch = "ia32"
16 if (is_android) {
17   # Always available on Android regardless of branding.
18   widevine_cdm_version_h_file = "android/widevine_cdm_version.h"
19   widevine_cdm_binary_files = []
20 } else if (is_chrome_branded) {
21   if (is_chromeos) {
22     widevine_cdm_version_h_file =
23         "chromeos/$widevine_arch/widevine_cdm_version.h"
24     widevine_cdm_binary_files = [ "chromeos/$widevine_arch/libwidevinecdm.so" ]
25   } else if (is_linux) {
26     widevine_cdm_version_h_file = "linux/$widevine_arch/widevine_cdm_version.h"
27     widevine_cdm_binary_files = [ "linux/$widevine_arch/libwidevinecdm.so" ]
28   } else if (is_win) {
29     widevine_cdm_version_h_file = "win/$widevine_arch/widevine_cdm_version.h"
30     widevine_cdm_binary_files = [
31       "win/$widevine_arch/widevinecdm.dll",
32       "win/$widevine_arch/widevinecdm.dll.lib",
33     ]
34   } else if (is_mac) {
35     widevine_cdm_version_h_file = "mac/$widevine_arch/widevine_cdm_version.h"
36     widevine_cdm_binary_files = [ "mac/$widevine_arch/libwidevinecdm.dylib" ]
37   } else {
38     # Other platforms, use the default one.
39     widevine_cdm_version_h_file = "widevine_cdm_version.h"
40     widevine_cdm_binary_files = []
41   }
42 } else if (enable_widevine) {
43   widevine_cdm_version_h_file = "stub/widevine_cdm_version.h"
44   widevine_cdm_binary_files = []
45 } else {
46   # No branding, use the default one.
47   widevine_cdm_version_h_file = "widevine_cdm_version.h"
48   widevine_cdm_binary_files = []
51 # GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h
52 copy("version_h") {
53   sources = [
54     widevine_cdm_version_h_file,
55   ]
57   # TODO(brettw) this should go into target_out_dir and callers should include
58   # it from there. This requires, however, renaming the default
59   # widevine_cdm_version.h in this directory to avoid conflicts.
60   outputs = [
61     "$root_gen_dir/widevine_cdm_version.h",
62   ]
65 # GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevinecdm
66 if (widevine_cdm_binary_files != []) {
67   copy("widevinecdm") {
68     sources = widevine_cdm_binary_files
69     outputs = [
70       "$root_out_dir/{{source_file_part}}",
71     ]
73     # TODO(jrummell)
74     # 'COPY_PHASE_STRIP': 'NO',
75   }
76 } else if (enable_widevine && enable_pepper_cdms) {
77   assert(!is_chrome_branded, "Branded Chrome should have binary files to copy.")
78   assert(!is_android, "Android should not have enable_pepper_cdms.")
79   shared_library("widevinecdm") {
80     sources = [
81       "//media/cdm/stub/stub_cdm.cc",
82       "//media/cdm/stub/stub_cdm.h",
83     ]
85     defines = [ "CDM_IMPLEMENTATION" ]
87     deps = [
88       ":version_h",
89       "//base",
90     ]
92     if (is_mac) {
93       ldflags = [
94         # Not to strip important symbols by -Wl,-dead_strip.
95         "-Wl,-exported_symbol,_PPP_GetInterface",
96         "-Wl,-exported_symbol,_PPP_InitializeModule",
97         "-Wl,-exported_symbol,_PPP_ShutdownModule",
98       ]
99       #TODO(jrummell) Mac: 'DYLIB_INSTALL_NAME_BASE': '@loader_path',
100     } else if (is_posix && !is_mac) {
101       cflags = [ "-fvisibility=hidden" ]
102       # Note GYP sets rpath but this is set by default on shared libraries in
103       # the GN build.
104     }
105   }
106 } else {
107   group("widevinecdm") {
108     # NOP
109   }
112 if ((is_chrome_branded || enable_widevine) && enable_pepper_cdms) {
113   # Produce and compile the .rc file.
114   process_version("widevinecdmadapter_resources") {
115     visibility = [ ":*" ]
116     sources = [
117       "BRANDING",
118       "widevinecdmadapter.ver",
119     ]
120     output = "$target_gen_dir/widevinecdmadapter_version.rc"
121   }
123   cdm_adapter("widevinecdmadapter") {
124     deps = [
125       ":widevinecdmadapter_resources",
126       ":widevinecdm",
127       ":version_h",
128       "//ppapi/cpp",
129     ]
131     if (is_linux) {
132       ldflags =
133           [ rebase_path("$root_out_dir/libwidevinecdm.so", root_build_dir) ]
134       libs = [ "rt" ]
135     } else if (is_win) {
136       ldflags =
137           [ rebase_path("$root_out_dir/widevinecdm.dll.lib", root_build_dir) ]
138     } else if (is_mac) {
139       ldflags =
140           [ rebase_path("$root_out_dir/libwidevinecdm.dylib", root_build_dir) ]
141     }
142   }
143 } else {
144   # Placeholder when we're not compiling the adapter.
145   group("widevinecdmadapter") {
146   }
149 # This target exists for tests to depend on that pulls in a runtime dependency
150 # on the license server.
151 source_set("widevine_test_license_server") {
152   if (is_chrome_branded && is_linux) {
153     deps = [
154       # TODO(jrummell)
155       # This target should be removed and targets should have datadeps on this target:
156       #"//third_party/widevine/test/license_server/license_server.gyp:test_license_server"
157     ]
158   }