summaryrefslogtreecommitdiffstats
path: root/mandoline/app/android/BUILD.gn
blob: be021ea509a0942bd488aa2cf0cc01f1d21f366c (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
# Copyright 2015 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.

assert(is_android)

import("//third_party/mojo/src/mojo/public/mojo.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//mojo/generate_mojo_shell_assets_list.gni")

mandoline_assets_dir = "$root_build_dir/mandoline_assets"

group("android") {
  deps = [
    ":mandoline_apk",
  ]
}

executable("mandoline_runner") {
  deps = [
    "//mojo/common",
    "//mojo/environment:chromium",
    "//mojo/runner:mojo_runner_lib",
  ]

  sources = [
    "../core_services_initialization.cc",
    "mandoline_context_init.cc",
  ]

  # On android, the executable is also the native library used by the apk.
  # It means dynamic symbols must be preserved and exported.
  ldflags = [ "-Wl,--export-dynamic" ]
}

copy("copy_mandoline_runner") {
  deps = [
    ":mandoline_runner",
  ]
  sources = [
    "$root_out_dir/exe.stripped/mandoline_runner",
  ]
  outputs = [
    "$root_out_dir/lib.stripped/libmandoline_runner.so",
  ]
}

copy_ex("copy_mandoline_assets") {
  clear_dir = true
  dest = mandoline_assets_dir
  deps = [
    "//components/html_viewer",
    "//components/view_manager",
    "//components/view_manager/surfaces",
    "//mandoline/services/core_services",
    "//mojo/runner:bootstrap",
    "//mojo/runner:bootstrap_java",
    "//mojo/services/network",
  ]
  sources = [
    "$root_out_dir/core_services.mojo",
    "$root_out_dir/lib.stripped/libbootstrap.so",
    "$root_out_dir/network_service.mojo",
    "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
    "$root_out_dir/surfaces_service.mojo",
  ]

  if (use_aura) {
    deps += [
      "//mandoline/ui/browser",
      "//mandoline/ui/omnibox",
    ]

    sources += [
      "$root_out_dir/browser",
      "$root_out_dir/omnibox",
    ]
  }

  # Directories can't be specified as sources so pass manually to the script.
  args =
      [ "--files=" + rebase_path("$root_out_dir/html_viewer", root_build_dir) ]
}

generate_mojo_shell_assets_list("build_mandoline_assets") {
  deps = [
    ":copy_mandoline_assets",
  ]
  dir = mandoline_assets_dir
}

android_apk("mandoline_apk") {
  apk_name = "Mandoline"

  android_manifest = "apk/AndroidManifest.xml"

  native_libs = [ "libmandoline_runner.so" ]

  asset_location = mandoline_assets_dir

  deps = [
    ":build_mandoline_assets",
    ":copy_mandoline_runner",
    "//mojo/runner:java",
    "//mojo/runner:resources",
    "//base:base_java",
    "//components/view_manager:view_manager_java",
    "//third_party/android_tools:google_play_services_default_resources",
  ]
}