1# Copyright 2013 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
5# This file is meant to add more loadable libs into Chrome_apk.
6#
7# This is useful when building Chrome_apk with some loadable modules which are
8# not included in Chrome_apk.
9# As an example, when building Chrome_apk with
10# libpeer_target_type=loadable_module,
11# the libpeerconnection.so is not included in Chrome_apk. To add the missing
12# lib, follow the steps below:
13# - Run gyp:
14#     GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" CHROMIUM_GYP_FILE="build/android/chrome_with_libs.gyp" build/gyp_chromium
15# - Build chrome_with_libs:
16#     ninja (or make) chrome_with_libs
17#
18# This tool also allows replacing the loadable module with a new one via the
19# following steps:
20# - Build Chrome_apk with the gyp define:
21#     GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" build/gyp_chromium
22#     ninja (or make) Chrome_apk
23# - Replace libpeerconnection.so with a new one:
24#     cp the_new_one path/to/libpeerconnection.so
25# - Run gyp:
26#     GYP_DEFINES="$GYP_DEFINES libpeer_target_type=loadable_module" CHROMIUM_GYP_FILE="build/android/chrome_with_libs.gyp" build/gyp_chromium
27# - Build chrome_with_libs:
28#     ninja (or make) chrome_with_libs
29{
30  'targets': [
31    {
32      # An "All" target is required for a top-level gyp-file.
33      'target_name': 'All',
34      'type': 'none',
35      'dependencies': [
36        'chrome_with_libs',
37      ],
38    },
39    {
40      'target_name': 'chrome_with_libs',
41      'type': 'none',
42      'variables': {
43        'intermediate_dir': '<(PRODUCT_DIR)/prebuilt_libs/',
44        'chrome_unsigned_path': '<(PRODUCT_DIR)/chrome_apk/Chrome-unsigned.apk',
45        'chrome_with_libs_unsigned': '<(intermediate_dir)/Chrome-with-libs-unsigned.apk',
46        'chrome_with_libs_final': '<(PRODUCT_DIR)/apks/Chrome-with-libs.apk',
47      },
48      'dependencies': [
49        '<(DEPTH)/clank/native/framework/clank.gyp:chrome_apk'
50      ],
51      'copies': [
52        {
53          'destination': '<(intermediate_dir)/lib/<(android_app_abi)',
54          'files': [
55            '<(PRODUCT_DIR)/libpeerconnection.so',
56          ],
57        },
58      ],
59      'actions': [
60        {
61          'action_name': 'put_libs_in_chrome',
62          'variables': {
63            'inputs': [
64              '<(intermediate_dir)/lib/<(android_app_abi)/libpeerconnection.so',
65            ],
66            'input_apk_path': '<(chrome_unsigned_path)',
67            'output_apk_path': '<(chrome_with_libs_unsigned)',
68            'libraries_top_dir%': '<(intermediate_dir)',
69          },
70          'includes': [ 'create_standalone_apk_action.gypi' ],
71        },
72        {
73          'action_name': 'finalize_chrome_with_libs',
74          'variables': {
75            'input_apk_path': '<(chrome_with_libs_unsigned)',
76            'output_apk_path': '<(chrome_with_libs_final)',
77          },
78          'includes': [ 'finalize_apk_action.gypi'],
79        },
80      ],
81    }],
82}
83