blob: 7ff4c6071c5b456a298adfb37949cb519bec696c [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
micky387de088872024-10-12 10:40:41 -040015CLANG_VERSION=$(build/soong/scripts/get_clang_version.py)
16export LLVM_AOSP_PREBUILTS_VERSION="${CLANG_VERSION}"
17
Michael Bestase0756df2024-09-09 08:34:41 +030018# check to see if the supplied product is one we can build
19function 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 Bestas3709af72024-09-09 10:19:31 +030037 _get_build_var_cached TARGET_DEVICE > /dev/null
Michael Bestase0756df2024-09-09 08:34:41 +030038 # hide successful answers, but allow the errors to show
39}
40
xplodwild3e9d0bb2013-08-24 17:40:37 +010041function brunch()
42{
43 breakfast $*
44 if [ $? -eq 0 ]; then
Jacob Whatleyd7acdc82017-08-31 13:17:31 -040045 time mka cookies
xplodwild3e9d0bb2013-08-24 17:40:37 +010046 else
47 echo "No such item in brunch menu. Try 'breakfast'"
48 return 1
49 fi
50 return $?
51}
52
53function breakfast()
54{
55 target=$1
micky38794fa4bd2024-03-13 20:32:51 -040056 local release=$2
57 local variant=$3
xplodwild3e9d0bb2013-08-24 17:40:37 +010058
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
Archi7152fc42014-02-28 19:18:54 +010069 if [ -z "$variant" ]; then
Marko Mana77da942019-10-18 20:11:42 +020070 variant="user"
Archi7152fc42014-02-28 19:18:54 +010071 fi
micky38794fa4bd2024-03-13 20:32:51 -040072 lunch omni_$target-$release-$variant
xplodwild3e9d0bb2013-08-24 17:40:37 +010073 fi
74 fi
75 return $?
76}
77
78alias bib=breakfast
79
Chirayu Desai3ac786f2013-06-30 10:04:25 +053080function fixup_common_out_dir() {
Michael Bestas3709af72024-09-09 10:19:31 +030081 common_out_dir=$(_get_build_var_cached OUT_DIR)/target/common
82 target_device=$(_get_build_var_cached TARGET_DEVICE)
Chirayu Desai3ac786f2013-06-30 10:04:25 +053083 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
xplodwild3e9d0bb2013-08-24 17:40:37 +010098# Make using all available CPUs
99function mka() {
darkobasf3cc9952017-12-10 14:19:18 +0000100 m "$@"
xplodwild3e9d0bb2013-08-24 17:40:37 +0100101}
xplodwildcb52eae2013-08-29 20:18:18 +0200102
103function 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}
Pulser72e23242013-09-29 09:56:55 +0100117
118function repopick() {
119 set_stuff_for_environment
120 T=$(gettop)
121 $T/vendor/omni/build/tools/repopick.py $@
122}
123
mikeNGe114eb02018-03-09 09:13:26 +0100124function 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
146function 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 Man57034c12018-03-09 09:14:17 +0100172# Enable SD-LLVM if available
173if [ -d $(gettop)/vendor/qcom/sdclang ]; then
174 export SDCLANG=true
frap129a111d062019-06-06 08:53:03 +0200175 export SDCLANG_PATH="vendor/qcom/sdclang/6.0/prebuilt/linux-x86_64/bin"
Marko Man57034c12018-03-09 09:14:17 +0100176 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"
frap129a111d062019-06-06 08:53:03 +0200179 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 Man57034c12018-03-09 09:14:17 +0100182fi