summaryrefslogtreecommitdiffstats
path: root/third_party/widevine/cdm/BUILD.gn
blob: 62dad959a54c1c5b1b0499e507f6de15c0bc9130 (plain)
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
# 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/chrome_build.gni")
import("//build/config/features.gni")
import("//chrome/version.gni")  # TODO layering violation
import("//media/cdm/ppapi/cdm_adapter.gni")
import("//third_party/widevine/cdm/widevine.gni")

widevine_arch = current_cpu
if (widevine_arch == "x86") {
  widevine_arch = "ia32"
}

if (is_android) {
  # Always available on Android regardless of branding.
  widevine_cdm_version_h_file = "android/widevine_cdm_version.h"
  widevine_cdm_binary_files = []
} else if (is_chrome_branded) {
  if (is_chromeos) {
    widevine_cdm_version_h_file =
        "chromeos/$widevine_arch/widevine_cdm_version.h"
    widevine_cdm_binary_files = [ "chromeos/$widevine_arch/libwidevinecdm.so" ]
  } else if (is_linux) {
    widevine_cdm_version_h_file = "linux/$widevine_arch/widevine_cdm_version.h"
    widevine_cdm_binary_files = [ "linux/$widevine_arch/libwidevinecdm.so" ]
  } else if (is_win) {
    widevine_cdm_version_h_file = "win/$widevine_arch/widevine_cdm_version.h"
    widevine_cdm_binary_files = [
      "win/$widevine_arch/widevinecdm.dll",
      "win/$widevine_arch/widevinecdm.dll.lib",
    ]
  } else if (is_mac) {
    widevine_cdm_version_h_file = "mac/$widevine_arch/widevine_cdm_version.h"
    widevine_cdm_binary_files = [ "mac/$widevine_arch/libwidevinecdm.dylib" ]
  } else {
    # Other platforms, use the default one.
    widevine_cdm_version_h_file = "widevine_cdm_version.h"
    widevine_cdm_binary_files = []
  }
} else if (enable_widevine) {
  widevine_cdm_version_h_file = "stub/widevine_cdm_version.h"
  widevine_cdm_binary_files = []
} else {
  # No branding, use the default one.
  widevine_cdm_version_h_file = "widevine_cdm_version.h"
  widevine_cdm_binary_files = []
}

# GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h
copy("version_h") {
  sources = [
    widevine_cdm_version_h_file,
  ]

  # TODO(brettw) this should go into target_out_dir and callers should include
  # it from there. This requires, however, renaming the default
  # widevine_cdm_version.h in this directory to avoid conflicts.
  outputs = [
    "$root_gen_dir/widevine_cdm_version.h",
  ]
}

# GYP version: third_party/widevine/cdm/widevine_cdm.gyp:widevinecdm
if (widevine_cdm_binary_files != []) {
  copy("widevinecdm") {
    sources = widevine_cdm_binary_files
    outputs = [
      "$root_out_dir/{{source_file_part}}",
    ]

    # TODO(jrummell)
    # 'COPY_PHASE_STRIP': 'NO',
  }
} else if (enable_widevine && enable_pepper_cdms) {
  assert(!is_chrome_branded, "Branded Chrome should have binary files to copy.")
  assert(!is_android, "Android should not have enable_pepper_cdms.")
  shared_library("widevinecdm") {
    sources = [
      "//media/cdm/stub/stub_cdm.cc",
      "//media/cdm/stub/stub_cdm.h",
    ]

    defines = [ "CDM_IMPLEMENTATION" ]

    deps = [
      ":version_h",
      "//base",
    ]

    if (is_mac) {
      ldflags = [
        # Not to strip important symbols by -Wl,-dead_strip.
        "-Wl,-exported_symbol,_PPP_GetInterface",
        "-Wl,-exported_symbol,_PPP_InitializeModule",
        "-Wl,-exported_symbol,_PPP_ShutdownModule",
      ]
      #TODO(jrummell) Mac: 'DYLIB_INSTALL_NAME_BASE': '@loader_path',
    } else if (is_posix && !is_mac) {
      cflags = [ "-fvisibility=hidden" ]
      # Note GYP sets rpath but this is set by default on shared libraries in
      # the GN build.
    }
  }
} else {
  group("widevinecdm") {
    # NOP
  }
}

if ((is_chrome_branded || enable_widevine) && enable_pepper_cdms) {
  adapter_resource_file = "$target_gen_dir/widevinecdmadapter_version.rc"

  # Produce the .rc file.
  process_version("widevinecdmadapter_resources") {
    visibility = [ ":*" ]
    sources = [
      "BRANDING",
      "widevinecdmadapter.ver",
    ]
    output = adapter_resource_file
  }

  cdm_adapter("widevinecdmadapter") {
    sources = [
      adapter_resource_file,
    ]
    deps = [
      ":widevinecdmadapter_resources",
      ":widevinecdm",
      ":version_h",
      "//ppapi/cpp",
    ]

    if (is_linux) {
      ldflags =
          [ rebase_path("$root_out_dir/libwidevinecdm.so", root_build_dir) ]
      libs = [ "rt" ]
    } else if (is_win) {
      ldflags =
          [ rebase_path("$root_out_dir/widevinecdm.dll.lib", root_build_dir) ]
    } else if (is_mac) {
      ldflags =
          [ rebase_path("$root_out_dir/libwidevinecdm.dylib", root_build_dir) ]
    }
  }
} else {
  # Placeholder when we're not compiling the adapter.
  group("widevinecdmadapter") {
  }
}

# This target exists for tests to depend on that pulls in a runtime dependency
# on the license server.
source_set("widevine_test_license_server") {
  if (is_chrome_branded && is_linux) {
    deps = [
      # TODO(jrummell)
      # This target should be removed and targets should have datadeps on this target:
      #"//third_party/widevine/test/license_server/license_server.gyp:test_license_server"
    ]
  }
}