xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 1 | function __print_omni_functions_help() { |
| 2 | cat <<EOF |
| 3 | Additional OmniROM functions: |
| 4 | - breakfast: Setup the build environment, but only list |
| 5 | devices we support. |
| 6 | - brunch: Sets up build environment using breakfast(), |
Jacob Whatley | d7acdc8 | 2017-08-31 13:17:31 -0400 | [diff] [blame] | 7 | and then comiles using mka() against cookies target. |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 8 | - mka: Builds using SCHED_BATCH on all processors. |
xplodwild | cb52eae | 2013-08-29 20:18:18 +0200 | [diff] [blame] | 9 | - pushboot: Push a file from your OUT dir to your phone and |
| 10 | reboots it, using absolute path. |
Pulser | 72e2324 | 2013-09-29 09:56:55 +0100 | [diff] [blame] | 11 | - repopick: Utility to fetch changes from Gerrit. |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 12 | EOF |
| 13 | } |
| 14 | |
micky387 | de08887 | 2024-10-12 10:40:41 -0400 | [diff] [blame] | 15 | CLANG_VERSION=$(build/soong/scripts/get_clang_version.py) |
| 16 | export LLVM_AOSP_PREBUILTS_VERSION="${CLANG_VERSION}" |
| 17 | |
Michael Bestas | e0756df | 2024-09-09 08:34:41 +0300 | [diff] [blame] | 18 | # check to see if the supplied product is one we can build |
| 19 | function check_product() |
| 20 | { |
| 21 | local T=$(gettop) |
| 22 | if [ ! "$T" ]; then |
| 23 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 24 | return |
| 25 | fi |
| 26 | if (echo -n $1 | grep -q -e "^omni_") ; then |
| 27 | CUSTOM_BUILD=$(echo -n $1 | sed -e 's/^omni_//g') |
| 28 | else |
| 29 | CUSTOM_BUILD= |
| 30 | fi |
| 31 | export CUSTOM_BUILD |
| 32 | TARGET_PRODUCT=$1 \ |
| 33 | TARGET_RELEASE=$2 \ |
| 34 | TARGET_BUILD_VARIANT= \ |
| 35 | TARGET_BUILD_TYPE= \ |
| 36 | TARGET_BUILD_APPS= \ |
Michael Bestas | 3709af7 | 2024-09-09 10:19:31 +0300 | [diff] [blame] | 37 | _get_build_var_cached TARGET_DEVICE > /dev/null |
Michael Bestas | e0756df | 2024-09-09 08:34:41 +0300 | [diff] [blame] | 38 | # hide successful answers, but allow the errors to show |
| 39 | } |
| 40 | |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 41 | function brunch() |
| 42 | { |
| 43 | breakfast $* |
| 44 | if [ $? -eq 0 ]; then |
Jacob Whatley | d7acdc8 | 2017-08-31 13:17:31 -0400 | [diff] [blame] | 45 | time mka cookies |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 46 | else |
| 47 | echo "No such item in brunch menu. Try 'breakfast'" |
| 48 | return 1 |
| 49 | fi |
| 50 | return $? |
| 51 | } |
| 52 | |
| 53 | function breakfast() |
| 54 | { |
| 55 | target=$1 |
micky387 | 94fa4bd | 2024-03-13 20:32:51 -0400 | [diff] [blame] | 56 | local release=$2 |
| 57 | local variant=$3 |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 58 | |
| 59 | if [ $# -eq 0 ]; then |
| 60 | # No arguments, so let's have the full menu |
| 61 | lunch |
| 62 | else |
| 63 | echo "z$target" | grep -q "-" |
| 64 | if [ $? -eq 0 ]; then |
| 65 | # A buildtype was specified, assume a full device name |
| 66 | lunch $target |
| 67 | else |
| 68 | # This is probably just the omni model name |
Archi | 7152fc4 | 2014-02-28 19:18:54 +0100 | [diff] [blame] | 69 | if [ -z "$variant" ]; then |
Marko Man | a77da94 | 2019-10-18 20:11:42 +0200 | [diff] [blame] | 70 | variant="user" |
Archi | 7152fc4 | 2014-02-28 19:18:54 +0100 | [diff] [blame] | 71 | fi |
micky387 | 94fa4bd | 2024-03-13 20:32:51 -0400 | [diff] [blame] | 72 | lunch omni_$target-$release-$variant |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 73 | fi |
| 74 | fi |
| 75 | return $? |
| 76 | } |
| 77 | |
| 78 | alias bib=breakfast |
| 79 | |
Chirayu Desai | 3ac786f | 2013-06-30 10:04:25 +0530 | [diff] [blame] | 80 | function fixup_common_out_dir() { |
Michael Bestas | 3709af7 | 2024-09-09 10:19:31 +0300 | [diff] [blame] | 81 | common_out_dir=$(_get_build_var_cached OUT_DIR)/target/common |
| 82 | target_device=$(_get_build_var_cached TARGET_DEVICE) |
Chirayu Desai | 3ac786f | 2013-06-30 10:04:25 +0530 | [diff] [blame] | 83 | if [ ! -z $ANDROID_FIXUP_COMMON_OUT ]; then |
| 84 | if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then |
| 85 | mv ${common_out_dir} ${common_out_dir}-${target_device} |
| 86 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 87 | else |
| 88 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 89 | mkdir -p ${common_out_dir}-${target_device} |
| 90 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 91 | fi |
| 92 | else |
| 93 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 94 | mkdir -p ${common_out_dir} |
| 95 | fi |
| 96 | } |
| 97 | |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 98 | # Make using all available CPUs |
| 99 | function mka() { |
darkobas | f3cc995 | 2017-12-10 14:19:18 +0000 | [diff] [blame] | 100 | m "$@" |
xplodwild | 3e9d0bb | 2013-08-24 17:40:37 +0100 | [diff] [blame] | 101 | } |
xplodwild | cb52eae | 2013-08-29 20:18:18 +0200 | [diff] [blame] | 102 | |
| 103 | function pushboot() { |
| 104 | if [ ! -f $OUT/$* ]; then |
| 105 | echo "File not found: $OUT/$*" |
| 106 | return 1 |
| 107 | fi |
| 108 | |
| 109 | adb root |
| 110 | sleep 1 |
| 111 | adb wait-for-device |
| 112 | adb remount |
| 113 | |
| 114 | adb push $OUT/$* /$* |
| 115 | adb reboot |
| 116 | } |
Pulser | 72e2324 | 2013-09-29 09:56:55 +0100 | [diff] [blame] | 117 | |
| 118 | function repopick() { |
| 119 | set_stuff_for_environment |
| 120 | T=$(gettop) |
| 121 | $T/vendor/omni/build/tools/repopick.py $@ |
| 122 | } |
| 123 | |
mikeNG | e114eb0 | 2018-03-09 09:13:26 +0100 | [diff] [blame] | 124 | function aospremote() |
| 125 | { |
| 126 | if ! git rev-parse --git-dir &> /dev/null |
| 127 | then |
| 128 | echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." |
| 129 | return 1 |
| 130 | fi |
| 131 | git remote rm aosp 2> /dev/null |
| 132 | local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##") |
| 133 | # Google moved the repo location in Oreo |
| 134 | if [ $PROJECT = "build/make" ] |
| 135 | then |
| 136 | PROJECT="build" |
| 137 | fi |
| 138 | if (echo $PROJECT | grep -qv "^device") |
| 139 | then |
| 140 | local PFX="platform/" |
| 141 | fi |
| 142 | git remote add aosp https://android.googlesource.com/$PFX$PROJECT |
| 143 | echo "Remote 'aosp' created" |
| 144 | } |
| 145 | |
| 146 | function cafremote() |
| 147 | { |
| 148 | if ! git rev-parse --git-dir &> /dev/null |
| 149 | then |
| 150 | echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up." |
| 151 | return 1 |
| 152 | fi |
| 153 | git remote rm caf 2> /dev/null |
| 154 | local PROJECT=$(pwd -P | sed -e "s#$ANDROID_BUILD_TOP\/##; s#-caf.*##; s#\/default##") |
| 155 | # Google moved the repo location in Oreo |
| 156 | if [ $PROJECT = "build/make" ] |
| 157 | then |
| 158 | PROJECT="build" |
| 159 | fi |
| 160 | if [[ $PROJECT =~ "qcom/opensource" ]]; |
| 161 | then |
| 162 | PROJECT=$(echo $PROJECT | sed -e "s#qcom\/opensource#qcom-opensource#") |
| 163 | fi |
| 164 | if (echo $PROJECT | grep -qv "^device") |
| 165 | then |
| 166 | local PFX="platform/" |
| 167 | fi |
| 168 | git remote add caf https://source.codeaurora.org/quic/la/$PFX$PROJECT |
| 169 | echo "Remote 'caf' created" |
| 170 | } |
| 171 | |
Marko Man | 57034c1 | 2018-03-09 09:14:17 +0100 | [diff] [blame] | 172 | # Enable SD-LLVM if available |
| 173 | if [ -d $(gettop)/vendor/qcom/sdclang ]; then |
| 174 | export SDCLANG=true |
frap129 | a111d06 | 2019-06-06 08:53:03 +0200 | [diff] [blame] | 175 | export SDCLANG_PATH="vendor/qcom/sdclang/6.0/prebuilt/linux-x86_64/bin" |
Marko Man | 57034c1 | 2018-03-09 09:14:17 +0100 | [diff] [blame] | 176 | export SDCLANG_LTO_DEFS="vendor/qcom/sdclang/sdllvm-lto-defs.mk" |
| 177 | export SDCLANG_CONFIG="vendor/qcom/sdclang/sdclang.json" |
| 178 | export SDCLANG_AE_CONFIG="vendor/qcom/sdclang/sdclangAE.json" |
frap129 | a111d06 | 2019-06-06 08:53:03 +0200 | [diff] [blame] | 179 | export SDCLANG_COMMON_FLAGS="-O3 -Wno-user-defined-warnings -Wno-vectorizer-no-neon -Wno-unknown-warning-option \ |
| 180 | -Wno-deprecated-register -Wno-tautological-type-limit-compare -Wno-sign-compare -Wno-gnu-folding-constant \ |
| 181 | -mllvm -arm-implicit-it=always -Wno-inline-asm -Wno-unused-command-line-argument -Wno-unused-variable" |
Marko Man | 57034c1 | 2018-03-09 09:14:17 +0100 | [diff] [blame] | 182 | fi |