blob: 6d1a4f2075686f56422702959162e0287c3cbc7c [file] [log] [blame]
Patrick Rohr6d722af2023-01-05 07:16:46 -08001#!/bin/bash
2set -x
3
4# Run this script inside a full chromium checkout.
Patrick Rohr6d722af2023-01-05 07:16:46 -08005
6OUT_PATH="out/cronet"
7
8#######################################
Motomu Utsumieb19dca2023-01-25 15:25:08 +09009# Apply patches in external/cronet.
10# Globals:
11# ANDROID_BUILD_TOP
12# Arguments:
13# None
14#######################################
15function apply_patches() {
16 local -r patch_root="${ANDROID_BUILD_TOP}/external/cronet/patches"
17
18 local upstream_patches
19 upstream_patches=$(ls "${patch_root}/upstream-next")
20 local patch
21 for patch in ${upstream_patches}; do
22 git am --3way "${patch_root}/upstream-next/${patch}"
23 done
24
25 local local_patches
26 local_patches=$(ls "${patch_root}/local")
27 for patch in ${local_patches}; do
28 git am --3way "${patch_root}/local/${patch}"
29 done
30}
31
32#######################################
Patrick Rohr6d722af2023-01-05 07:16:46 -080033# Generate desc.json for a specified architecture.
34# Globals:
35# OUT_PATH
36# Arguments:
37# target_cpu, string
38#######################################
39function gn_desc() {
40 local -a gn_args=(
41 "target_os = \"android\""
42 "enable_websockets = false"
43 "disable_file_support = true"
44 "disable_brotli_filter = false"
45 "is_component_build = false"
46 "use_crash_key_stubs = true"
47 "use_partition_alloc = false"
48 "include_transport_security_state_preload_list = false"
49 "use_platform_icu_alternatives = true"
50 "default_min_sdk_version = 19"
51 "use_errorprone_java_compiler = true"
52 "enable_reporting = true"
53 "use_hashed_jni_names = true"
54 "treat_warnings_as_errors = false"
55 "enable_base_tracing = false"
Motomu Utsumiedf300c2023-01-12 17:52:21 +090056 "is_cronet_build = true"
Patrick Rohr6d722af2023-01-05 07:16:46 -080057 )
58 gn_args+=("target_cpu = \"${1}\"")
59
60 # Only set arm_use_neon on arm architectures to prevent warning from being
61 # written to json output.
62 if [[ "$1" =~ ^arm ]]; then
63 gn_args+=("arm_use_neon = false")
64 fi
65
66 # Configure gn args.
67 gn gen "${OUT_PATH}" --args="${gn_args[*]}"
68
69 # Generate desc.json.
70 local -r out_file="desc_${1}.json"
71 gn desc "${OUT_PATH}" --format=json --all-toolchains "//*" > "${out_file}"
72}
73
Motomu Utsumieb19dca2023-01-25 15:25:08 +090074apply_patches
Patrick Rohr6d722af2023-01-05 07:16:46 -080075gn_desc x86
76gn_desc x64
77gn_desc arm
78gn_desc arm64
79