Ticket #6529: 0001-Issue-6529-Use-prebuilt-V8-from-libadblockplus-binar.patch

File 0001-Issue-6529-Use-prebuilt-V8-from-libadblockplus-binar.patch, 10.3 KB (added by asmirnov, 2 years ago)

patch file to compile it with V8 from -binaries

  • DEPS

    From eb7cd17724e82390706447d17616ddb352829673 Mon Sep 17 00:00:00 2001
    From: Anton Smirnov <anton@adblockplus.org>
    Date: Wed, 4 Apr 2018 11:59:21 +0500
    Subject: [PATCH] Issue #6529 - Use prebuilt V8 from libadblockplus-binaries in
     Chromium
    
    First attempt to compile with V8 from -binaries.
    ---
     DEPS                                               |  44 +++----
     .../chrome/browser/ChromeTabbedActivity.java       |  23 ++--
     third_party/libadblockplus_android/BUILD.gn        | 146 +++++++++++----------
     third_party/libadblockplus_android/args.gni        |   5 +
     4 files changed, 122 insertions(+), 96 deletions(-)
     create mode 100644 third_party/libadblockplus_android/args.gni
    
    diff --git a/DEPS b/DEPS
    index 0bafefc95f0c..1149559b763f 100644
    a b hooks = [ 
    16421642    'name': 
    16431643      'vpython_common' 
    16441644  }, 
    1645   { 
     1645  #{ 
    16461646    # Clear dependencies for libadblockplus (otherwise ensure_dependencies will fail to check deps revisions) 
    1647     'name': 'libadblockplus_clear_dependencies', 
    1648     'pattern': 'dependencies', 
    1649     'condition': 'checkout_android', 
    1650     'action': [ 
    1651         'python', 
    1652         'src/third_party/libadblockplus_common/delete_dir.py', 
    1653         'src/third_party/libadblockplus/third_party/v8' 
    1654     ], 
    1655     'condition': 
    1656       'checkout_android' 
    1657   }, 
     1647  #  'name': 'libadblockplus_clear_dependencies', 
     1648  #  'pattern': 'dependencies', 
     1649  #  'condition': 'checkout_android', 
     1650  #  'action': [ 
     1651  #      'python', 
     1652  #      'src/third_party/libadblockplus_common/delete_dir.py', 
     1653  #      'src/third_party/libadblockplus/third_party/v8' 
     1654  #  ], 
     1655  #  'condition': 
     1656  #    'checkout_android' 
     1657  #}, 
    16581658  { 
    16591659    # Download dependencies for libadblockplus. 
    16601660    'name': 'libadblockplus_ensure_dependencies', 
    hooks = [ 
    16671667    'condition': 
    16681668      'checkout_android' 
    16691669  }, 
    1670   { 
     1670  #{ 
    16711671    # Prepare libadblockplus V8 dependencies (reusing Chromium V8 dependencies for building libadblockplus) 
    1672     'name': 'libadblockplus_prepare_dependencies', 
    1673     'pattern': 'dependencies', 
    1674     'action': [ 
    1675         'python', 
    1676         'src/third_party/libadblockplus/prepare_dependencies.py', 
    1677     ], 
    1678     'condition': 
    1679       'checkout_android' 
    1680   }, 
     1672  #  'name': 'libadblockplus_prepare_dependencies', 
     1673  #  'pattern': 'dependencies', 
     1674  #  'action': [ 
     1675  #      'python', 
     1676  #      'src/third_party/libadblockplus/prepare_dependencies.py', 
     1677  #  ], 
     1678  #  'condition': 
     1679  #    'checkout_android' 
     1680  #}, 
    16811681  { 
    16821682    # Download official Android NDK 
    16831683    'name': 'libadblockplus_download_ndk', 
  • chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java

    diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
    index 507e8530dd85..ea20cc91b803 100644
    a b public class ChromeTabbedActivity 
    402402 
    403403    private void initAdblock() { 
    404404        Log.w(TAG, "Adblock ChromeTabbedActivity.java: initAdblock()"); 
    405  
    406         Log.w(TAG, "Adblock: getting isolate pointer async in Thread " + java.lang.Thread.currentThread()); 
    407         long isolateProviderPtr = AdblockBridge.getInstance().getIsolateProviderNativePtr(); 
    408         Log.w(TAG, "Adblock: got isolate pointer = " + isolateProviderPtr 
    409                  + " in thread " + Thread.currentThread()); 
    410  
     405         
    411406        String basePath = getDir( 
    412407            AdblockEngine.BASE_PATH_DIRECTORY, 
    413408            Context.MODE_PRIVATE) 
    public class ChromeTabbedActivity 
    415410 
    416411        AdblockHelper 
    417412            .get() 
    418             .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME) 
    419             .useV8IsolateProvider(isolateProviderPtr); 
     413            .init(this, basePath, true, AdblockHelper.PREFERENCE_NAME); 
     414 
     415        final boolean v8_from_chromium = false; 
     416         
     417        if (v8_from_chromium) { 
     418            Log.w(TAG, "Adblock: getting isolate pointer async in Thread " + java.lang.Thread.currentThread()); 
     419            long isolateProviderPtr = AdblockBridge.getInstance().getIsolateProviderNativePtr(); 
     420            Log.w(TAG, "Adblock: got isolate pointer = " + isolateProviderPtr 
     421                     + " in thread " + Thread.currentThread()); 
     422 
     423            AdblockHelper 
     424                .get() 
     425                .useV8IsolateProvider(isolateProviderPtr); 
     426        } 
    420427 
    421428        // synchronously (blocks the UI but allows to get pointer here) 
    422429        // TODO: (improvement) do it async and wait for engine to be created 
  • third_party/libadblockplus_android/BUILD.gn

    diff --git a/third_party/libadblockplus_android/BUILD.gn b/third_party/libadblockplus_android/BUILD.gn
    index 46c52433b30d..fb8d01b7aed3 100644
    a b  
    11import("//build/config/android/rules.gni") 
    22import("//third_party/libadblockplus_common/abi.gni") 
    3  
    4 # Copy libadblockplus headers 
    5 copy("copy_libadblockplus_include") { 
    6   sources = [ "//third_party/libadblockplus/include" ] 
    7   outputs = [ "${target_out_dir}/libadblockplus-binaries/include" ] 
    8 } 
    9  
    10 # Copy libadblockplus archives (.a) for ARM/x86 
    11 copy("copy_libadblockplus_abi") { 
    12   deps = [ 
    13     "//third_party/libadblockplus:make" 
    14   ] 
    15  
    16   _arm_inputs_dir = "${target_out_dir}/../libadblockplus/build" 
    17   _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
    18    
    19   sources = [ 
    20     # = outputs of //third_party/libadblockplus:make 
    21     "${_arm_inputs_dir}/local/${libadblockplus_abi_dir}/libadblockplus.a", 
    22     "${_arm_inputs_dir}/android_${v8_abi_dir}.release/libv8_libplatform.a", 
    23   ] 
    24   outputs = [ 
    25     "${_arm_outputs_dir}/{{source_file_part}}" 
    26   ] 
    27 } 
    28  
    29 # Copy libv8.cr.so 
    30 copy("copy_libv8") { 
    31   deps = [ 
    32     "//v8:v8" 
    33   ] 
    34  
    35   _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
    36  
    37   sources = [ "${target_out_dir}/../../../libv8.cr.so" ] 
    38   outputs = [ "${_arm_outputs_dir}/libv8.cr.so" ] 
    39 } 
    40  
    41 # Copy libv8_libbase.cr.so 
    42 copy("copy_libv8_libbase") { 
    43   deps = [ 
    44     "//v8:v8_libbase" 
    45   ] 
    46  
    47   _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
    48  
    49   sources = [ "${target_out_dir}/../../../libv8_libbase.cr.so" ] 
    50   outputs = [ "${_arm_outputs_dir}/libv8_libbase.cr.so" ] 
     3import("//third_party/libadblockplus_android/args.gni") 
     4 
     5if (v8_from_chromium) { 
     6  # Copy libadblockplus headers 
     7  copy("copy_libadblockplus_include") { 
     8    sources = [ "//third_party/libadblockplus/include" ] 
     9    outputs = [ "${target_out_dir}/libadblockplus-binaries/include" ] 
     10  } 
     11 
     12  # Copy libadblockplus archives (.a) for ARM/x86 
     13  copy("copy_libadblockplus_abi") { 
     14    deps = [ 
     15      "//third_party/libadblockplus:make" 
     16    ] 
     17 
     18    _arm_inputs_dir = "${target_out_dir}/../libadblockplus/build" 
     19    _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
     20     
     21    sources = [ 
     22      # = outputs of //third_party/libadblockplus:make 
     23      "${_arm_inputs_dir}/local/${libadblockplus_abi_dir}/libadblockplus.a", 
     24      "${_arm_inputs_dir}/android_${v8_abi_dir}.release/libv8_libplatform.a", 
     25    ] 
     26    outputs = [ 
     27      "${_arm_outputs_dir}/{{source_file_part}}" 
     28    ] 
     29  } 
     30 
     31  # Copy libv8.cr.so 
     32  copy("copy_libv8") { 
     33    deps = [ 
     34      "//v8:v8" 
     35    ] 
     36 
     37    _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
     38 
     39    sources = [ "${target_out_dir}/../../../libv8.cr.so" ] 
     40    outputs = [ "${_arm_outputs_dir}/libv8.cr.so" ] 
     41  } 
     42 
     43  # Copy libv8_libbase.cr.so 
     44  copy("copy_libv8_libbase") { 
     45    deps = [ 
     46      "//v8:v8_libbase" 
     47    ] 
     48 
     49    _arm_outputs_dir = "${target_out_dir}/libadblockplus-binaries/android_${libadblockplus_abi_dir}" 
     50 
     51    sources = [ "${target_out_dir}/../../../libv8_libbase.cr.so" ] 
     52    outputs = [ "${_arm_outputs_dir}/libv8_libbase.cr.so" ] 
     53  } 
    5154} 
    5255 
    5356_cwd = rebase_path(".") 
    _abs_build_dir = rebase_path("${_build_dir}") 
    5659_abs_libadblockplus_dir = rebase_path("//third_party/libadblockplus") 
    5760_abs_sdk_dir = rebase_path("//third_party/libadblockplus_android/third_party/android_sdk") 
    5861 
    59 _libadblockplus_binaries_dir = "${target_out_dir}/libadblockplus-binaries" 
    60 _abs_libadblockplus_binaries_dir = rebase_path("${_libadblockplus_binaries_dir}") 
    61  
    6262action("clear") { 
    6363  script = "//third_party/libadblockplus_common/delete_dir.py" 
    6464  args = [ 
    action("clear") { 
    7171 
    7272# Build libadblockplus-android using Gradle 
    7373action("make") { 
    74   deps = [ 
    75     "//third_party/libadblockplus:make", 
    76     ":clear", 
    77  
    78     # from libadblockplus 
    79     ":copy_libadblockplus_include", 
    80     ":copy_libadblockplus_abi", 
    81  
    82     # from Chromium 
    83     ":copy_libv8", 
    84     ":copy_libv8_libbase", 
     74  if (v8_from_chromium) { 
     75    deps = [ 
     76      "//third_party/libadblockplus:make", 
     77 
     78      # from libadblockplus 
     79      ":copy_libadblockplus_include", 
     80      ":copy_libadblockplus_abi", 
     81 
     82      # from Chromium 
     83      ":copy_libv8", 
     84      ":copy_libv8_libbase" 
     85    ] 
     86  } else { 
     87    deps = [ ] 
     88  } 
     89 
     90  deps += [ 
     91    ":clear" 
    8592  ] 
    8693 
    8794  script = "//third_party/libadblockplus_common/subproc.py" 
    action("make") { 
    105112    "--envANDROID_HOME=${_abs_sdk_dir}", 
    106113    "--envANDROID_NDK_HOME=${_abs_libadblockplus_dir}/third_party/android-ndk-r12b", 
    107114    "--envGRADLE_BUILD_DIR=${_abs_build_dir}", 
    108  
    109     # link with libadblockplus 
    110     "--envSHARED_V8_LIB_DIR=${_abs_libadblockplus_binaries_dir}", 
    111     "--envSHARED_V8_LIB_FILENAMES=libv8.cr.so libv8_libbase.cr.so" 
    112115  ] 
     116 
     117  if (v8_from_chromium) { 
     118    _libadblockplus_binaries_dir = "${target_out_dir}/libadblockplus-binaries" 
     119    _abs_libadblockplus_binaries_dir = rebase_path("${_libadblockplus_binaries_dir}") 
     120 
     121    args += [ 
     122      # link with libadblockplus 
     123      "--envSHARED_V8_LIB_DIR=${_abs_libadblockplus_binaries_dir}", 
     124      "--envSHARED_V8_LIB_FILENAMES=libv8.cr.so libv8_libbase.cr.so" 
     125    ] 
     126  } 
    113127} 
    114128 
    115129_prebuild_dir = "${target_out_dir}/prebuild" 
  • new file third_party/libadblockplus_android/args.gni

    diff --git a/third_party/libadblockplus_android/args.gni b/third_party/libadblockplus_android/args.gni
    new file mode 100644
    index 000000000000..31c96a3fe8f5
    - +  
     1declare_args() { 
     2  # Use V8 from libadblockplus-binaries for Adblock plus SDK  
     3  # Set `true` to avoid using Chromium V8 for libadblockplus. 
     4  v8_from_chromium = true 
     5} 
     6 No newline at end of file