Patrick Rohr | 6d722af | 2023-01-05 07:16:46 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -x |
| 3 | |
| 4 | # Run this script inside a full chromium checkout. |
Patrick Rohr | 6d722af | 2023-01-05 07:16:46 -0800 | [diff] [blame] | 5 | |
| 6 | OUT_PATH="out/cronet" |
| 7 | |
| 8 | ####################################### |
Motomu Utsumi | eb19dca | 2023-01-25 15:25:08 +0900 | [diff] [blame] | 9 | # Apply patches in external/cronet. |
| 10 | # Globals: |
| 11 | # ANDROID_BUILD_TOP |
| 12 | # Arguments: |
| 13 | # None |
| 14 | ####################################### |
| 15 | function 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 Rohr | 6d722af | 2023-01-05 07:16:46 -0800 | [diff] [blame] | 33 | # Generate desc.json for a specified architecture. |
| 34 | # Globals: |
| 35 | # OUT_PATH |
| 36 | # Arguments: |
| 37 | # target_cpu, string |
| 38 | ####################################### |
| 39 | function 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 Utsumi | edf300c | 2023-01-12 17:52:21 +0900 | [diff] [blame] | 56 | "is_cronet_build = true" |
Motomu Utsumi | daaf73b | 2023-01-27 13:21:49 +0900 | [diff] [blame^] | 57 | "is_debug = false" |
| 58 | "is_official_build = true" |
Patrick Rohr | 6d722af | 2023-01-05 07:16:46 -0800 | [diff] [blame] | 59 | ) |
| 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 Utsumi | eb19dca | 2023-01-25 15:25:08 +0900 | [diff] [blame] | 76 | apply_patches |
Patrick Rohr | 6d722af | 2023-01-05 07:16:46 -0800 | [diff] [blame] | 77 | gn_desc x86 |
| 78 | gn_desc x64 |
| 79 | gn_desc arm |
| 80 | gn_desc arm64 |
| 81 | |