blob: 1f60eb94d83fa1f984d0942577619e81ddf87b1d [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"
Motomu Utsumidaaf73b2023-01-27 13:21:49 +090057 "is_debug = false"
58 "is_official_build = true"
Patrick Rohr6d722af2023-01-05 07:16:46 -080059 )
60 gn_args+=("target_cpu = \"${1}\"")
61
62 # Only set arm_use_neon on arm architectures to prevent warning from being
63 # written to json output.
64 if [[ "$1" =~ ^arm ]]; then
65 gn_args+=("arm_use_neon = false")
66 fi
67
68 # Configure gn args.
69 gn gen "${OUT_PATH}" --args="${gn_args[*]}"
70
71 # Generate desc.json.
72 local -r out_file="desc_${1}.json"
73 gn desc "${OUT_PATH}" --format=json --all-toolchains "//*" > "${out_file}"
74}
75
Motomu Utsumieb19dca2023-01-25 15:25:08 +090076apply_patches
Patrick Rohr6d722af2023-01-05 07:16:46 -080077gn_desc x86
78gn_desc x64
79gn_desc arm
80gn_desc arm64
81