Port Android relocation packer to chromium build
[chromium-blink-merge.git] / third_party / widevine / cdm / BUILD.gn
blob3fce784ad36a59bdcca36b6239cac6b1cb12110a
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/features.gni")
6 import("//chrome/version.gni")  # TODO layering violation
7 import("//media/cdm/ppapi/cdm_adapter.gni")
9 widevine_arch = current_cpu
10 if (widevine_arch == "x86") {
11   widevine_arch = "ia32"
14 if (is_android) {
15   # Always available on Android regardless of branding.
16   widevine_cdm_version_h_file = "android/widevine_cdm_version.h"
17   widevine_cdm_binary_files = []
18 } else if (is_chrome_branded) {
19   if (is_chromeos) {
20     widevine_cdm_version_h_file =
21         "chromeos/$widevine_arch/widevine_cdm_version.h"
22     widevine_cdm_binary_files = [ "chromeos/$widevine_arch/libwidevinecdm.so" ]
23   } else if (is_linux) {
24     widevine_cdm_version_h_file = "linux/$widevine_arch/widevine_cdm_version.h"
25     widevine_cdm_binary_files = [ "linux/$widevine_arch/libwidevinecdm.so" ]
26   } else if (is_win) {
27     widevine_cdm_version_h_file = "win/$widevine_arch/widevine_cdm_version.h"
28     widevine_cdm_binary_files = [
29       "win/$widevine_arch/widevinecdm.dll",
30       "win/$widevine_arch/widevinecdm.dll.lib",
31     ]
32   } else if (is_mac) {
33     widevine_cdm_version_h_file = "mac/$widevine_arch/widevine_cdm_version.h"
34     widevine_cdm_binary_files = [ "mac/$widevine_arch/libwidevinecdm.dylib" ]
35   } else {
36     # Other platforms, use the default one.
37     widevine_cdm_version_h_file = "widevine_cdm_version.h"
38     widevine_cdm_binary_files = []
39   }
40 } else {
41   # No branding, use the default one.
42   widevine_cdm_version_h_file = "widevine_cdm_version.h"
43   widevine_cdm_binary_files = []
46 # GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h
47 copy("version_h") {
48   sources = [
49     widevine_cdm_version_h_file,
50   ]
52   # TODO(brettw) this should go into target_out_dir and callers should include
53   # it from there. This requires, however, renaming the default
54   # widevine_cdm_version.h in this directory to avoid conflicts.
55   outputs = [
56     "$root_gen_dir/widevine_cdm_version.h",
57   ]
60 # GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_binaries
61 if (widevine_cdm_binary_files == []) {
62   group("binaries") {
63     # NOP
64   }
65 } else {
66   copy("binaries") {
67     sources = widevine_cdm_binary_files
68     outputs = [
69       "$root_out_dir/{{source_file_part}}",
70     ]
72     # TODO(GYP)
73     # 'COPY_PHASE_STRIP': 'NO',
74   }
77 if (is_chrome_branded && enable_pepper_cdms) {
78   adapter_resource_file = "$target_gen_dir/widevinecdmadapter_version.rc"
80   # Produce the .rc file.
81   process_version("adapter_resources") {
82     visibility = [ ":*" ]
83     sources = [
84       "BRANDING",
85       "widevinecdmadapter.ver",
86     ]
87     output = adapter_resource_file
88   }
90   cdm_adapter("adapter") {
91     sources = [
92       adapter_resource_file,
93     ]
94     deps = [
95       ":adapter_resources",
96       ":binaries",
97       ":version_h",
98       "//ppapi/cpp",
99     ]
101     if (is_linux) {
102       ldflags =
103           [ rebase_path("$root_out_dir/libwidevinecdm.so", root_build_dir) ]
104       libs = [ "rt" ]
105     } else if (is_win) {
106       ldflags =
107           [ rebase_path("$root_out_dir/widevinecdm.dll.lib", root_build_dir) ]
108     } else if (is_mac) {
109       ldflags =
110           [ rebase_path("$root_out_dir/libwidevinecdm.dylib", root_build_dir) ]
111     }
112   }
113 } else {
114   # Placeholder when we're not compiling the adapter.
115   group("adapter") {
116   }
119 # This target exists for tests to depend on that pulls in a runtime dependency
120 # on the license server.
121 source_set("widevine_test_license_server") {
122   if (is_chrome_branded && is_linux) {
123     deps = [
124       # TODO(GYP)
125       # This target should be removed and targets should have datadeps on this target:
126       #"//third_party/widevine/test/license_server/license_server.gyp:test_license_server"
127     ]
128   }