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