Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
env: # Environt variable to pass to all tasks
CIRRUS_CLONE_DEPTH: 1 # No need to clone with whole history
CIRRUS_WORKING_DIR: "/tmp/ci" # Where to clone repo
env: # Environment variables to pass to all tasks
CIRRUS_CLONE_DEPTH: 1 # No need to clone with the whole history
CIRRUS_WORKING_DIR: "/tmp/ci" # Where to clone the aosp-builder repo

# For rclone with google drive or any cloud! After first commit pushing, login to https://cirrus-ci.com , click top left corner 3 dot menu, click repository(yourname/aosp-builder) > Repository Settings > Secured Variables > enter content of ~/.config/rclone/rclone.conf (from pc where you setup rclone) > ENCRYPT, copy that ENCRYPTED hash
# ENCRYPTED variables is unique for every repository, so you cant use my one, create you rclone config https://rclone.org/drive/#making-your-own-client-id
rclone_config: "ENCRYPTED[c1d6eeb6ba70128cbdc15e4d0317de3d347e2c94e141710c1c21345aeedd0a3c4ab10d028e4913d2602c663096dacacb]"
rclone_config: "ENCRYPTED[1858e77194cc42ac131949fbc43892123449dd5efd5f2799f2dabf5d38a67a96300b0ddd137e53f1728e6ec910e97d1c]"

task:
name: aosp # Project name
name: RMX1941-descendant # Project name
timeout_in: 120m # Otherwise it will timeout at 60m automatically, 120m highest in free account
container:
image: apon77/aosp:latest # It has built in setup environment + repo, aria2, rclone, pigz, username ci, and email ci@ci.ci [You can use your own docker image if you want, or you can use this one too!]
cpu: 10 #8 cpu for dummy build, 10 or more cpu for final build, sometimes more than 8 cpu will cause a timelock, so you wont be able to run ci again within few hours, in build script use -j8 or -j10 depending what you used here, otherwise low memory issue will happen, 16cpu highest
memory: 24G # So that we can have ram when needed, 24G highest
image: apon77/aosp:latest # It has built-in setup environment + repo, aria2, rclone, pigz, username ci, and email ci@ci.ci [You can use your own docker image if you want, or you can use this one too!]
cpu: 4 #8 or less cpu for dummy build, 8 cpu for the final build, 8cpu highest for free accounts. Don't try to use more than 8cpu as free user, you may get blocked by ci.
memory: 16G # So that we can have ram when needed, 32G highest
download_ccache_background_script: # To download ccache in background
- ./download_ccache # Ccache download script
sync_script: # To sync source
- ./sync # Source sync script
monitor_background_script: # To monitor ccache and machine status every minute, runs in background
- ./monitor # Monitor script
build_script: # Actual build script foreground
- ./build # Build script to run
- ./build # Build script to run build
upload_ccache_script: # Upload ccache to cloud foreground
- ./upload_ccache # Ccache uploading script
66 changes: 21 additions & 45 deletions build
Original file line number Diff line number Diff line change
@@ -1,55 +1,31 @@
#!/bin/bash
cd /tmp/rom # Depends on where source got synced
cd /tmp/rom

source build/envsetup.sh

lunch descendant_RMX1941-userdebug



# Normal build steps
. build/envsetup.sh
lunch aosp_mido-user
export CCACHE_DIR=/tmp/ccache
export CCACHE_EXEC=$(which ccache)
export USE_CCACHE=1
ccache -M 20G # It took only 6.4GB for mido
ccache -o compression=true # Will save times and data to download and upload ccache, also negligible performance issue
ccache -z # Clear old stats, so monitor script will provide real ccache statistics

# Next 8 lines should be run first to collect ccache and then upload, after doning it 1 or 2 times, our ccache will help to build without these 8 lines
#make api-stubs-docs || echo no problem
#make hiddenapi-lists-docs || echo no problem
#make system-api-stubs-docs || echo no problem
#make test-api-stubs-docs || echo no problem
#make aex -j10 & # I used aex build command
#sleep 85m # Lets give some space for uploading ccache
#kill %1 # better way to kill it!
#ccache -s
#and dont use below codes for first 1 or 2 times, to get ccache uploaded,
#as instructed, i got enough cccahe more than 4.5gb, tough source is not buildable, still i wanna go to final steps, my intention to collect ccache is done. Let's start final build, and get shell when bulid fails too! If source is buildable we will get a final zip file, and if not buildable, we will get a shell access to fix it. 1 minute silence for source :-(
#So, i am adding back things which i removed previously! also with my bot and tg id

# upload function for uploading rom zip file! I don't want unwanted builds in my google drive haha!
up(){
curl --upload-file $1 https://transfer.sh/$(basename $1); echo
# 14 days, 10 GB limit
}

tg(){
bot_api=1692865707:AAHvKZogI5sUGtqjd2sZvNl8tib0Q_xcYkY # Your tg bot api, dont use my one haha
your_telegram_id=$1 # No need to touch
msg=$2 # No need to touch
curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" --data "text=$msg&chat_id=${your_telegram_id}"
}
ccache -M 10G
ccache -o compression=true
ccache -z

id=571213272 # Your telegram id
make init
make sepolicy

# Build command! j10 for 10 cpu, j8 for 8 cpu, otherwise memeroy will end up even its 24G
# Upload rom zip file if succeed to build! Send notification to tg! And send shell to tg if build fails!
make nad &
sleep 75m
kill %1
ccache -s

# Let's compile by parts! Coz of ram issue!
make api-stubs-docs || echo no problem
make hiddenapi-lists-docs || echo no problem
make system-api-stubs-docs || echo no problem
make test-api-stubs-docs || echo no problem
up(){
time rclone copy $1 aosp:ccache/ccache-ci2 -P
}

make aex -j10 \
&& send_zip=$(up out/target/product/mido/*zip) && tg $id "Build Succeed!
$send_zip" \
|| tmate -S /tmp/tmate.sock new-session -d && tmate -S /tmp/tmate.sock wait tmate-ready && send_shell=$(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}') && tg $id "Build Failed" && tg $id "$send_shell" && ccache -s && sleep 2h
ccache -s # Let's print ccache statistics finally
ccache -s

7 changes: 5 additions & 2 deletions download_ccache
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash
# Lets see machine specifications and environments

set -evx

df -h
free -h
nproc
cat /etc/os*
env

# So, we get upto 59% build complete, and also got ccache uploaded, inspite of previous commit error (because i shared rclone_config content), ccache still got uploaded, and can be accessed from anywhere by this:- https://roms.apon77.workers.dev/ccache/ci3/ccache.tar.gz my drive index helped here! So, now lets use it to download ccache for 2nd build, and also collect ccache 2nd time too, becasue 59% is not enough to collect enough cccahe.
url=https://roms.apon77.workers.dev/ccache/ci3/ccache.tar.gz # Where cccahe is located, use your ones, from where you want to download ccache!
# So, we get upto 100% build complete, and also got ccache uploaded, inspite of previous commit error (because i shared rclone_config content), ccache still got uploaded, and can be accessed from anywhere by this:- https://roms.apon77.workers.dev/ccache/ci3/ccache.tar.gz my drive index helped here! So, now lets use it to download ccache for 2nd build, and also collect ccache 2nd time too, becasue 59% is not enough to collect enough cccahe.
url=https://yellow-butterfly-09f4.sundramsayss.workers.dev/cirrus/ # Where cccahe is located, use your ones, from where you want to download ccache!

cd /tmp # Where to download cccahe
time aria2c $url -x16 -s50 # Using aria2c for speed haha, ccache will be at /tmp/ccache.tar.gz since my file name is ccache.tar.gz
Expand Down
6 changes: 3 additions & 3 deletions sync
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ cd /tmp/rom

# Repo init command, that -device,-mips,-darwin,-notdefault part will save you more time and storage to sync, add more according to your rom and choice. Optimization is welcomed! Let's make it quit, and with depth=1 so that no unnecessary things.
# I want to sync aex source!
repo init -q --no-repo-verify --depth=1 -u git://github.com/AospExtended/manifest.git -b 11.x -g default,-device,-mips,-darwin,-notdefault
repo init -q --no-repo-verify --depth=1 https://github.com/descendant-xi/manifests.git -b eleven-staging -g default,-device,-mips,-darwin,-notdefault

# Clone local manifest! So that no need to manually git clone repos or change hals, you can use normal git clone or rm and re clone, they will cost little more time, and you may get timeout! Let's make it quit and depth=1 too.
# My local manifest can do all clone, and removing or changing repository i need, so lets use it! I am lazy to manually git clone!
git clone https://github.com/Apon77Lab/android_.repo_local_manifests.git --depth 1 -b aex .repo/local_manifests
git clone https://github.com/Yasundram/local_manifest --depth 1 -b desc .repo/local_manifests

# Sync source with -q, no need unnecessary messages, you can remove -q if want! try with -j30 first, if fails, it will try again with -j8
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j 30 || repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j 8
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j 30 || repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8
2 changes: 1 addition & 1 deletion upload_ccache
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ time com ccache 1 # Compression level 1, its enough

mkdir -p ~/.config/rclone
echo "$rclone_config" > ~/.config/rclone/rclone.conf # Write rclone config found from env variable, so that cloud storage can be used to upload ccache
time rclone copy ccache.tar.gz apon:ccache/ci3 -P # apon is my rclone config name (first line without [] of ~/.config/rclone/rclone.conf file from rclone setupped pc), ccache/ci2 is where ccache will be saved in my cloud, use yours one
time rclone copy ccache.tar.gz root:cirrus -P # apon is my rclone config name (first line without [] of ~/.config/rclone/rclone.conf file from rclone setupped pc), ccache/ci2 is where ccache will be saved in my cloud, use yours one