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
3# found in the LICENSE file.
4
5import("//build/buildflag_header.gni")
6import("//build/config/features.gni")
7import("//build/config/sanitizers/sanitizers.gni")
8import("//build/config/ui.gni")
9import("//chromecast/build/tests/cast_test.gni")
10import("//chromecast/chromecast.gni")
11import("//media/media_options.gni")
12import("//tools/grit/repack.gni")
13import("//v8/gni/v8.gni")
14
15if (chromecast_branding != "public") {
16  import("//chromecast/internal/chromecast_internal.gni")
17}
18
19if (is_android) {
20  import("//build/config/android/rules.gni")
21}
22
23declare_args() {
24  cast_test_extra_flags = ""
25  vendor_cast_media_gtest_excludes = []
26}
27
28# Depends on all non-test targets that should be built by the Chromecast
29# internal build infrastructure.
30group("all") {
31  data_deps = []
32  deps = [ "//chromecast/build:archive" ]
33  if (is_android && chromecast_branding == "public") {
34    deps += [ ":cast_shell_apk" ]
35  }
36  if (!is_android) {
37    data_deps += [ ":cast_shell" ]
38  }
39  if (is_linux || is_chromeos) {
40    deps += [
41      "//chromecast/browser/webview/client:wayland_webview_client",
42      "//chromecast/tracing",
43    ]
44  }
45  if (chromecast_branding != "public") {
46    deps += [ "//chromecast/internal:all" ]
47  }
48  if (enable_external_mojo_services) {
49    deps += [ "//chromecast/external_mojo/external_service_support:standalone_mojo_broker" ]
50  }
51
52  # No other targets should depend on this target, since it's just a convenience
53  # target for the Chromecast internal build infrastructure.
54  visibility = []
55  testonly = true
56}
57
58# This is a config which is applied on all cast_* targets (which should be all
59# code under chromecast/).
60config("cast_config") {
61  cflags = [ "-Wshadow" ]
62}
63
64config("iot_service") {
65  if (iot_service_rpath != "") {
66    ldflags = [ "-Wl,-rpath=${iot_service_rpath}" ]
67  }
68}
69
70# A list of all public test() binaries. This is an organizational target that
71# cannot be depended upon or built directly. Build cast_test_lists instead.
72cast_test_group("cast_tests") {
73  filters = []
74  tests = [
75    "//base:base_unittests",
76    "//cc:cc_unittests",
77    "//chromecast/base:cast_base_unittests",
78    "//chromecast/base/component:cast_component_unittests",
79    "//chromecast/common:cast_common_unittests",
80    "//chromecast/crypto:cast_crypto_unittests",
81    "//chromecast/device/bluetooth:cast_bluetooth_unittests",
82    "//chromecast/media:cast_media_unittests",
83    "//chromecast/metrics:cast_metrics_unittest",
84    "//chromecast/net:cast_net_unittests",
85    "//chromecast/system/reboot:cast_reboot_unittests",
86    "//content/test:content_unittests",
87    "//crypto:crypto_unittests",
88    "//media:media_unittests",
89    "//media/midi:midi_unittests",
90    "//net:net_unittests",
91    "//sql:sql_unittests",
92    "//storage:storage_unittests",
93    "//ui/base:ui_base_unittests",
94  ]
95
96  if (enable_chromecast_extensions) {
97    tests += [
98      "//chromecast/browser/accessibility/flutter:cast_accessibility_unittests",
99    ]
100  }
101
102  if (!is_cast_audio_only) {
103    tests += [ "//gpu:gpu_unittests" ]
104
105    if (use_aura) {
106      tests += [ "//chromecast/graphics:cast_graphics_unittests" ]
107    }
108  }
109
110  if (use_v4l2_codec && enable_video_capture_service) {
111    tests += [ "//media/gpu:video_encode_accelerator_unittest" ]
112  }
113
114  if (use_v4l2_codec) {
115    tests += [ "//media/gpu:video_decode_accelerator_tests" ]
116  }
117
118  if (is_linux || is_chromeos) {
119    tests += [
120      "//chromecast/crash:cast_crash_unittests",
121      "//components/exo:exo_unittests",
122      "//sandbox/linux:sandbox_linux_unittests",
123    ]
124
125    sandbox_linux_unittests_filter = {
126      test_name = "sandbox_linux_unittests"
127
128      # TODO(b/148974697): re-enable this.
129      gtest_excludes = [ "BaselinePolicy.SystemEperm" ]
130    }
131    filters += [ sandbox_linux_unittests_filter ]
132  }
133
134  if (is_linux || is_chromeos || is_fuchsia) {
135    tests += [ "//chromecast/media/cma/backend:cast_audio_backend_unittests" ]
136    cast_audio_backend_unittests_filter = {
137      test_name = "cast_audio_backend_unittests"
138
139      # --test-launcher-jobs=1 => so mixer service receiver can bind.
140      args = [
141        "--test-launcher-jobs=1",
142        "--mixer-service-endpoint=/tmp/cast_audio_backend_unittest-mixer",
143        "--mixer-service-port=12855",
144      ]
145    }
146    filters += [ cast_audio_backend_unittests_filter ]
147  }
148
149  if (is_android) {
150    tests += [ "//chromecast/media/cma/backend/android:cast_android_cma_backend_unittests" ]
151  }
152
153  cast_media_unittests_filter = {
154    test_name = "cast_media_unittests"
155
156    gtest_excludes = vendor_cast_media_gtest_excludes
157
158    # --test-launcher-jobs=1 => so internal code can bind to port
159    args = [ "--test-launcher-jobs=1" ]
160  }
161  filters += [ cast_media_unittests_filter ]
162
163  if (!is_android && !is_fuchsia) {
164    tests += [
165      ":cast_shell_browsertests",
166      ":cast_shell_unittests",
167      "//ipc:ipc_tests",
168      "//jingle:jingle_unittests",
169      "//url:url_unittests",
170    ]
171
172    cast_shell_browsertests_filter = {
173      test_name = "cast_shell_browsertests"
174
175      # --enable-local-file-accesses => to load sample media files
176      # --test-launcher-jobs=1 => so internal code can bind to port
177      args = [
178        "--no-sandbox",
179        "--enable-local-file-accesses",
180        "--test-launcher-jobs=1",
181        "--enable-hardware-overlays=",
182      ]
183
184      gtest_excludes = []
185
186      # TODO(b/112440248): This test was failing:
187      #   * On v1 and Cast Audio devices since 2017-03-15.
188      #   * On desktop builds since 2018-08-22
189      # Also see: b/36238710, b/36239051, hotlist/461351
190      gtest_excludes += [ "RendererPrelauncherTest.ReusedRenderer" ]
191
192      if (!is_cast_desktop_build) {
193        args += [ "--use-gpu-in-tests" ]
194
195        # TODO(derekjchow): Make these tests pass on Chromecast devices.
196        #    Once all of the CastMediaBlockerTest.* have been un-DISABLEd and
197        #    are running successfully, revisit these tests and see if they pass
198        #    on devices. (crbug/665118, internal b/32023194)
199        gtest_excludes += [
200          "CastMediaBlockerBrowserTest.Video_BlockUnblock",
201          "CastMediaBlockerBrowserTest.Audio_BlockUnblock",
202
203          # This browser test can only be run inside of a source checkout.
204          "CastWebContentsBrowserTest.*",
205        ]
206      }
207
208      if (!is_cast_desktop_build && !is_cast_audio_only && !enable_assistant) {
209        # TODO(mbjorge): The VideoPlaybackMp4 test is failing on v1 devices.
210        # Temporarily disable it as part of an effort to re-green the unittests.
211        # Re-enable once the tests have been fixed. Limitations in the filter
212        # system mean this is getting temporarily disabled on all video devices,
213        # though it is only failing on v1.
214        # b/36723698, hotlist/461351
215        gtest_excludes += [ "CastNavigationBrowserTest.VideoPlaybackMp4" ]
216      }
217
218      # TODO(mbjorge): Temporarily disable AudioPlaybackWavPcm because it is
219      # failing on device. As part of an effort to re-green the unittests,
220      # current (2017-03-15) failures are being disabled to get back to a
221      # green state. Re-enable once the tests have been fixed.
222      # b/36239152, hotlist/461351
223      if (enable_assistant && !is_cast_desktop_build) {
224        gtest_excludes += [ "CastNavigationBrowserTest.AudioPlaybackWavPcm" ]
225      }
226    }
227    filters += [ cast_shell_browsertests_filter ]
228
229    ipc_tests_filter = {
230      test_name = "ipc_tests"
231
232      # --test-launcher-jobs=1 => so internal code can bind to port
233      args = [ "--test-launcher-jobs=1" ]
234    }
235    filters += [ ipc_tests_filter ]
236
237    url_unittests_filter = {
238      test_name = "url_unittests"
239
240      if (target_os == "linux" && !is_cast_desktop_build) {
241        # DoAppendUTF8Invalid fails because of dcheck_always_on flag in Eng builds
242        gtest_excludes = [ "URLCanonTest.DoAppendUTF8Invalid" ]
243      }
244    }
245    filters += [ url_unittests_filter ]
246  }
247
248  base_unittests_filter = {
249    test_name = "base_unittests"
250    gtest_excludes = []
251    if (target_os == "linux") {
252      if (is_cast_desktop_build) {
253        # Disable PartitionAllocDeathTest.* (b/67975693)
254        gtest_excludes += [ "PartitionAllocDeathTest.*" ]
255      } else {
256        # Disable ProcessMetricsTest.GetNumberOfThreads (b/15610509)
257        # Disable ProcessUtilTest.* (need to define OS_ANDROID)
258        # Disable StackContainer.BufferAlignment (don't support 16-byte alignment)
259        # Disable SystemMetrics2Test.GetSystemMemoryInfo (buffers>0 can't be guaranteed)
260        # Disable PostTasksViaTaskRunner/* to green up devices (b/62246873)
261        # Disable WorkerDetaches to green up devices (b/62246873)
262        gtest_excludes += [
263          "ProcessMetricsTest.GetNumberOfThreads",
264          "ProcessUtilTest.*",
265          "StackContainer.BufferAlignment",
266          "SystemMetrics2Test.GetSystemMemoryInfo",
267          "OneTraitsExecutionModePair/ThreadPoolImplTest.PostTasksViaTaskRunner/*",
268          "TaskSchedulerWorkerTest.WorkerDetaches",
269        ]
270      }
271
272      if (is_cast_audio_only) {
273        # Also disable TimeFormattingTest on audio-only builds, since we don't
274        # include the necessary info in icudtl.dat.
275        gtest_excludes += [ "TimeFormattingTest.*" ]
276      }
277    }
278  }
279  filters += [ base_unittests_filter ]
280
281  cc_unittests_filter = {
282    test_name = "cc_unittests"
283
284    # Temporarily disable all test cases (b/113324890)
285    gtest_excludes = [ "*" ]
286
287    if (!is_cast_desktop_build) {
288      #Disable ToColorSpace/ColorTransformPixelTest*  (b/64346790)
289      #Disable ImageBackgroundFilter* (b/64346875)
290      #Disable LayerTreeHostTilesTestPartialInvalidation* (b/65844132)
291      gtest_excludes += [
292        "ToColorSpace/ColorTransformPixelTest.*",
293        "ImageBackgroundFilter.*",
294        "LayerTreeHostTilesTestPartialInvalidation.*",
295      ]
296    }
297  }
298  filters += [ cc_unittests_filter ]
299
300  content_unittests_filter = {
301    test_name = "content_unittests"
302
303    # IsSupportedVideoConfig_VP9TransferFunctions fails on all cast builds since
304    # the cast IsSupporedVideoConfigs ignore the transfer function parameter.
305    # (b/36984215).
306    gtest_excludes = [ "*.IsSupportedVideoConfig_VP9TransferFunctions" ]
307    if (is_android_things) {
308      gtest_excludes += [
309        "FontUniqueNameLookupTest.TestMatchPostScriptNameTtc",
310        "SiteInstanceTest.IsSuitableForURL",
311      ]
312    }
313    if (target_os == "linux" && !is_cast_desktop_build) {
314      # DesktopCaptureDeviceTest.*: No capture device on Eureka
315      # Disable PepperGamepadHostTest.WaitForReply (pepper not supported on Eureka)
316      # Disable RenderWidgetHostTest.Background because we disable the
317      # blacklist to enable WebGL (b/16142554)
318      gtest_excludes += [
319        "LegacyDomStorageDatabaseTest.TestCanOpenAndReadWebCoreDatabase",
320        "DesktopCaptureDeviceTest.Capture",
321        "GamepadProviderTest.PollingAccess",
322        "PepperGamepadHostTest.WaitForReply",
323        "RenderWidgetHostTest.Background",
324      ]
325    }
326    if (is_cast_audio_only) {
327      # No way to display URL's on audio only cast devices.
328      gtest_excludes += [ "NavigationEntryTest.NavigationEntryURLs" ]
329    }
330    if (enable_assistant && !is_cast_desktop_build) {
331      # Temporarily disable InvalidUUID and DefaultConstructor on assistant
332      # device builds. Cause of failure is unclear, but it's highly likely it's
333      # related to them being DEATH tests. These were passing until the
334      # is_official_build flag was enabled. These tests are considered
335      # non-critical in this context. (b/62469368)
336      gtest_excludes += [
337        "BluetoothBlocklistTest.InvalidUUID",
338        "WebBluetoothDeviceIdTest.DefaultConstructor",
339      ]
340    }
341  }
342  filters += [ content_unittests_filter ]
343
344  media_unittests_filter = {
345    test_name = "media_unittests"
346    if (target_os == "linux" && !is_cast_desktop_build) {
347      # Disable VP9 related tests (b/18593324)
348      #   PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM
349      #   PipelineIntegrationTest.BasicPlayback_VideoOnly_VP9_WebM
350      #   PipelineIntegrationTest.BasicPlayback_VP9*
351      #   PipelineIntegrationTest.P444_VP9_WebM
352      # Disable VP8A tests (b/18593324)
353      #   PipelineIntegrationTest.BasicPlayback_VP8A*
354      # Disable OpusAudioDecoderTest/AudioDecoderTest.ProduceAudioSamples/0 (unit
355      # test fails when Opus decoder uses fixed-point)
356      # Due to b/16456550, disable the following four test cases:
357      #   AudioOutputControllerTest.PlayDivertSwitchDeviceRevertClose
358      #   AudioOutputControllerTest.PlaySwitchDeviceClose
359      #   AudioStreamHandlerTest.Play
360      #   SoundsManagerTest.Play
361      # Disable AudioStreamHandlerTest.ConsecutivePlayRequests (b/16539293)
362      gtest_excludes = [
363        "AudioOutputControllerTest.PlayDivertSwitchDeviceRevertClose",
364        "AudioOutputControllerTest.PlaySwitchDeviceClose",
365        "AudioStreamHandlerTest.Play",
366        "AudioStreamHandlerTest.ConsecutivePlayRequests",
367        "PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM",
368        "PipelineIntegrationTest.BasicPlayback_VideoOnly_VP9_WebM",
369        "PipelineIntegrationTest.BasicPlayback_VP9*",
370        "PipelineIntegrationTest.P444_VP9_WebM",
371        "PipelineIntegrationTest.BasicPlayback_VP8A*",
372        "OpusAudioDecoderTest/AudioDecoderTest.ProduceAudioSamples/0",
373        "SoundsManagerTest.Play",
374      ]
375    } else if (target_os == "android" || is_cast_desktop_build) {
376      # Disable PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM (not supported)
377      gtest_excludes =
378          [ "PipelineIntegrationTest.BasicPlayback_MediaSource_VP9_WebM" ]
379    }
380  }
381  filters += [ media_unittests_filter ]
382
383  net_unittests_filter = {
384    test_name = "net_unittests"
385    if (using_sanitizer) {
386      # TODO(mbjorge): net_unittests do not complete when run with sanitizers,
387      # (in particular, TSAN and UBSAN), resulting in build machines getting stuck
388      # for many hours. Disable them for now, since these are getting run on
389      # Chromium bots anyway. (internal b/31279943)
390      gtest_excludes = [ "*" ]
391    } else if (target_os == "linux" && !is_cast_desktop_build) {
392      # Run net_unittests first to avoid random failures due to slow python startup
393      # PacFileFetcherImplTest.HttpMimeType is flaking (b/19848784)
394      # Running a batch of net_unittests has high overhead. Run tests in batches of 50 to reduce number of batches (b/23156294).
395      gtest_excludes = [ "PacFileFetcherImplTest.HttpMimeType" ]
396      args = [ "--test-launcher-batch-limit=50" ]
397    } else if (is_cast_desktop_build || target_os == "android") {
398      # CTLogVerifierTest.VerifiesValidConsistencyProofsFromReferenceGenerator
399      # times out occasionally, paricularly on the CQ bots; disable to reduce
400      # CQ flakiness (crbug/598406) (b/29415636).
401      # Running a batch of net_unittests has high overhead, so
402      # run tests in batches of 25 to reduce number of batches (b/23156294).
403      gtest_excludes = [ "CTLogVerifierTest.VerifiesValidConsistencyProofsFromReferenceGenerator" ]
404      args = [ "--test-launcher-batch-limit=25" ]
405    }
406  }
407  filters += [ net_unittests_filter ]
408}
409
410# Creates the build and run lists for all test targets.
411cast_test_group_list("cast_test_lists") {
412  build_list_path = "$root_out_dir/tests/build_test_list.txt"
413  runtime_deps_path = "$root_out_dir/tests/runtime_deps.json"
414  run_list_path = "$root_out_dir/tests/run_test_list.txt"
415
416  additional_options = [
417    "--ozone-platform=headless --test-launcher-bot-mode $cast_test_extra_flags",
418  ]
419
420  test_groups = [ ":cast_tests" ]
421
422  if (chromecast_branding != "public") {
423    test_groups += internal_cast_test_groups
424  }
425}
426
427if (is_android) {
428  cast_test_group("cast_junit_tests") {
429    test_type = "junit"
430    tests = [
431      "//base:base_junit_tests",
432      "//chromecast/base:cast_base_junit_tests",
433      "//chromecast/browser/android:cast_shell_junit_tests",
434      "//content/public/android:content_junit_tests",
435      "//net/android:net_junit_tests",
436      "//testing/android/junit:junit_unit_tests",
437      "//ui/android:ui_junit_tests",
438    ]
439  }
440
441  cast_test_group_list("cast_junit_test_lists") {
442    test_type = "junit"
443    build_list_path = "$root_out_dir/junit/build_junit_test_list.txt"
444    runtime_deps_path = "$root_out_dir/junit/runtime_deps.json"
445    run_list_path = "$root_out_dir/junit/run_junit_test_list.txt"
446    test_groups = [ ":cast_junit_tests" ]
447    if (chromecast_branding != "public") {
448      test_groups += [ "//chromecast/internal:internal_cast_junit_tests" ]
449    }
450  }
451}
452
453test("cast_shell_unittests") {
454  deps = [
455    ":cast_shell_lib",
456    "//chromecast/app:test_support",
457    "//chromecast/app:unittests",
458    "//chromecast/browser:unittests",
459    "//ui/gl:test_support",
460  ]
461}
462
463test("cast_shell_browsertests") {
464  deps = [
465    ":cast_shell_lib",
466    "//chromecast/app:test_support",
467    "//chromecast/bindings:browsertests",
468    "//chromecast/browser:browsertests",
469  ]
470
471  data_deps = [ ":chromecast_locales_pak" ]
472}
473
474group("cast_shell_lib") {
475  data_deps = [ ":cast_shell_pak" ]
476
477  deps = [
478    "//chromecast/app",
479    "//chromecast/base:default_create_sys_info",
480    "//chromecast/browser",
481    "//chromecast/common",
482    "//chromecast/renderer",
483  ]
484
485  if (chromecast_branding != "public") {
486    deps += [ "//chromecast/internal/shell" ]
487  }
488}
489
490cast_executable("cast_shell") {
491  sources = [ "app/cast_main.cc" ]
492
493  deps = [
494    ":cast_shell_lib",
495    ":chromecast_locales_pak",
496    "//chromecast/app",
497    "//content/public/app",
498  ]
499}
500
501repack("cast_shell_pak") {
502  sources = [
503    "$root_gen_dir/chromecast/app/shell_resources.pak",
504    "$root_gen_dir/components/cast/named_message_port_connector/named_message_port_connector_resources.pak",
505    "$root_gen_dir/content/app/resources/content_resources_100_percent.pak",
506    "$root_gen_dir/content/content_resources.pak",
507    "$root_gen_dir/content/dev_ui_content_resources.pak",
508    "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
509    "$root_gen_dir/net/net_resources.pak",
510    "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
511    "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
512    "$root_gen_dir/third_party/blink/public/strings/blink_strings_en-US.pak",
513    "$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
514    "$root_gen_dir/ui/resources/webui_generated_resources.pak",
515    "$root_gen_dir/ui/resources/webui_resources.pak",
516    "$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
517    "$root_gen_dir/ui/strings/ui_strings_en-US.pak",
518  ]
519
520  output = "$root_out_dir/assets/cast_shell.pak"
521
522  deps = [
523    "//chromecast/app:resources",
524    "//components/cast/named_message_port_connector:resources",
525    "//content:content_resources",
526    "//content:dev_ui_content_resources",
527    "//content/app/resources",
528    "//mojo/public/js:resources",
529    "//net:net_resources",
530    "//third_party/blink/public:resources",
531    "//third_party/blink/public:scaled_resources_100_percent",
532    "//third_party/blink/public/strings",
533    "//ui/resources",
534    "//ui/strings",
535  ]
536
537  if (enable_chromecast_extensions) {
538    sources += [
539      "$root_gen_dir/chromecast/renderer/extensions_renderer_resources.pak",
540      "$root_gen_dir/extensions/extensions_renderer_resources.pak",
541      "$root_gen_dir/extensions/extensions_resources.pak",
542      "$root_gen_dir/extensions/shell/app_shell_resources.pak",
543    ]
544    deps += [
545      "//chromecast/renderer:extensions_resources",
546      "//extensions:extensions_resources",
547      "//extensions/shell:resources",
548    ]
549  }
550
551  if (chromecast_branding != "public") {
552    sources += [ "$root_gen_dir/chromecast/internal/cast_shell_internal.pak" ]
553
554    deps += [ "//chromecast/internal:cast_shell_internal_pak" ]
555  }
556}
557
558# Intermediate targets that repack grit resources by locale. For each locale
559# in |cast_locales| (see //chromecast/chromecast.gni), all resources
560# are packed into a single .pak file in an output directory. These targets
561# should not be depended on directly; depend on ":chromecast_locales_pak"
562# instead.
563foreach(locale, cast_locales) {
564  repack("_cast_repack_${locale}") {
565    visibility = [ ":chromecast_locales_pak" ]
566    output = "$root_out_dir/chromecast_locales/${locale}.pak"
567    sources =
568        [ "$root_gen_dir/chromecast/app/chromecast_settings_${locale}.pak" ]
569    deps = [ "//chromecast/app:chromecast_settings" ]
570
571    if (chromecast_branding != "public") {
572      sources += [
573        "$root_gen_dir/chromecast/internal/castui/app_strings_${locale}.pak",
574      ]
575      deps += [ "//chromecast/internal/castui:cast_ui_app_strings" ]
576
577      if (enable_chromecast_webui) {
578        sources += [
579          "$root_gen_dir/chromecast/internal/castui/ui_localized_${locale}.pak",
580        ]
581        deps += [ "//chromecast/internal/castui:cast_ui_localized" ]
582      }
583    }
584  }
585}
586
587# A meta-target which repacks resources by locale.
588group("chromecast_locales_pak") {
589  data_deps = []
590  foreach(locale, cast_locales) {
591    data_deps += [ ":_cast_repack_${locale}" ]
592  }
593}
594
595buildflag_header("chromecast_buildflags") {
596  header = "chromecast_buildflags.h"
597  flags = [
598    "DEFAULT_COMMAND_LINE_FLAGS=\"$default_command_line_flags\"",
599    "DISABLE_SECURE_FLAC_OPUS_DECODING=$disable_secure_flac_and_opus_decoding",
600    "ENABLE_ASSISTANT=$enable_assistant",
601    "ENABLE_CAST_FRAGMENT=$enable_cast_fragment",
602    "ENABLE_CHROMECAST_EXTENSIONS=$enable_chromecast_extensions",
603    "ENABLE_EXTERNAL_MOJO_SERVICES=$enable_external_mojo_services",
604    "ENABLE_PLAYREADY=$enable_playready",
605    "ENABLE_VIDEO_CAPTURE_SERVICE=$enable_video_capture_service",
606    "ENABLE_VOLUME_TABLES_ACCESS=$enable_volume_tables_access",
607    "IS_ANDROID_APPLIANCE=$is_android_appliance",
608    "IS_ANDROID_THINGS=$is_android_things",
609    "IS_ANDROID_THINGS_NON_PUBLIC=$is_android_things_non_public",
610    "IS_CAST_AUDIO_ONLY=$is_cast_audio_only",
611    "IS_CAST_DESKTOP_BUILD=$is_cast_desktop_build",
612    "IS_SINGLE_VOLUME=$is_single_volume",
613    "SUPPORTS_MULTIZONE=$supports_multizone",
614    "USE_ANDROID_USER_AGENT=$use_android_user_agent",
615    "USE_CHROMECAST_CDMS=$use_chromecast_cdms",
616    "ENABLE_CHROMIUM_RUNTIME_CAST_RENDERER=$enable_chromium_runtime_cast_renderer",
617  ]
618}
619
620if (is_android) {
621  generate_jni_registration("cast_shell_jni_registration") {
622    targets = [ ":cast_shell_apk" ]
623    header_output = "$root_gen_dir/chromecast/android/${target_name}.h"
624  }
625
626  android_assets("cast_shell_apk_assets") {
627    sources = [ "$root_out_dir/assets/cast_shell.pak" ]
628
629    deps = [
630      ":cast_shell_apk_locale_assets",
631      ":cast_shell_pak",
632      "//third_party/icu:icu_assets",
633      "//v8:v8_external_startup_data_assets",
634    ]
635    disable_compression = true
636  }
637
638  android_assets("cast_shell_apk_locale_assets") {
639    renaming_sources = []
640    renaming_destinations = []
641
642    foreach(locale, cast_locales) {
643      renaming_sources += [ "$root_out_dir/chromecast_locales/${locale}.pak" ]
644      renaming_destinations += [ "stored-locales/${locale}.pak" ]
645    }
646
647    deps = [ ":chromecast_locales_pak" ]
648
649    treat_as_locale_paks = true
650    disable_compression = true
651  }
652
653  android_apk("cast_shell_apk") {
654    enable_lint = true
655    lint_baseline_file = "android/lint-baseline.xml"
656    lint_suppressions_file = "android/lint-suppressions.xml"
657
658    apk_name = "CastShell"
659    android_manifest = "$root_gen_dir/cast_shell_manifest/AndroidManifest.xml"
660    android_manifest_dep = "//chromecast/browser/android:cast_shell_manifest"
661
662    min_sdk_version = 21
663    target_sdk_version = 30
664
665    shared_libraries = [ "//chromecast/android:libcast_shell_android" ]
666
667    product_config_java_packages = [ "org.chromium.chromecast.shell" ]
668
669    deps = [
670      ":cast_shell_apk_assets",
671      "//base:base_java",
672      "//chromecast/android:libcast_shell_android",
673      "//chromecast/browser/android:cast_shell_java",
674      "//components/crash/core/app:chrome_crashpad_handler_named_as_so",
675    ]
676
677    loadable_modules = [ "$root_out_dir/libchrome_crashpad_handler.so" ]
678
679    command_line_flags_file = "castshell-command-line"
680    enable_multidex = true
681  }
682}
683