blob: e47470359ed123571e8a0caa15ac2666f59054d2 [file] [log] [blame]
xplodwild3e9d0bb2013-08-24 17:40:37 +01001function __print_omni_functions_help() {
2cat <<EOF
3Additional OmniROM functions:
4- breakfast: Setup the build environment, but only list
5 devices we support.
6- brunch: Sets up build environment using breakfast(),
Jacob Whatleyd7acdc82017-08-31 13:17:31 -04007 and then comiles using mka() against cookies target.
xplodwild3e9d0bb2013-08-24 17:40:37 +01008- mka: Builds using SCHED_BATCH on all processors.
xplodwildcb52eae2013-08-29 20:18:18 +02009- pushboot: Push a file from your OUT dir to your phone and
10 reboots it, using absolute path.
Pulser72e23242013-09-29 09:56:55 +010011- repopick: Utility to fetch changes from Gerrit.
xplodwild3e9d0bb2013-08-24 17:40:37 +010012EOF
13}
14
Michael Bestase0756df2024-09-09 08:34:41 +030015# check to see if the supplied product is one we can build
16function 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
xplodwild3e9d0bb2013-08-24 17:40:37 +010038function brunch()
39{
40 breakfast $*
41 if [ $? -eq 0 ]; then
Jacob Whatleyd7acdc82017-08-31 13:17:31 -040042 time mka cookies
xplodwild3e9d0bb2013-08-24 17:40:37 +010043 else
44 echo "No such item in brunch menu. Try 'breakfast'"
45 return 1
46 fi
47 return $?
48}
49
50function breakfast()
51{
52 target=$1
micky38794fa4bd2024-03-13 20:32:51 -040053 local release=$2
54 local variant=$3
xplodwild3e9d0bb2013-08-24 17:40:37 +010055
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
Archi7152fc42014-02-28 19:18:54 +010066 if [ -z "$variant" ]; then
Marko Mana77da942019-10-18 20:11:42 +020067 variant="user"
Archi7152fc42014-02-28 19:18:54 +010068 fi
micky38794fa4bd2024-03-13 20:32:51 -040069 lunch omni_$target-$release-$variant
xplodwild3e9d0bb2013-08-24 17:40:37 +010070 fi
71 fi
72 return $?
73}
74
75alias bib=breakfast
76
Chirayu Desai3ac786f2013-06-30 10:04:25 +053077function 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
xplodwild3e9d0bb2013-08-24 17:40:37 +010095# Make using all available CPUs
96function mka() {
darkobasf3cc9952017-12-10 14:19:18 +000097 m "$@"
xplodwild3e9d0bb2013-08-24 17:40:37 +010098}
xplodwildcb52eae2013-08-29 20:18:18 +020099
100function 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}
Pulser72e23242013-09-29 09:56:55 +0100114
115function repopick() {
116 set_stuff_for_environment
117 T=$(gettop)
118 $T/vendor/omni/build/tools/repopick.py $@
119}
120
mikeNGe114eb02018-03-09 09:13:26 +0100121function 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
143function 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 Man57034c12018-03-09 09:14:17 +0100169# Enable SD-LLVM if available
170if [ -d $(gettop)/vendor/qcom/sdclang ]; then
171 export SDCLANG=true
frap129a111d062019-06-06 08:53:03 +0200172 export SDCLANG_PATH="vendor/qcom/sdclang/6.0/prebuilt/linux-x86_64/bin"
Marko Man57034c12018-03-09 09:14:17 +0100173 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"
frap129a111d062019-06-06 08:53:03 +0200176 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 Man57034c12018-03-09 09:14:17 +0100179fi