-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from dakkar/dakkar-tweaks
Some tweaks
- Loading branch information
Showing
3 changed files
with
285 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# How to build | ||
|
||
* clone this repository | ||
* call the build scripts from a separate directory | ||
|
||
For example: | ||
|
||
git clone https://github.com/phhusson/treble_experimentations | ||
mkdir Lineage; cd Lineage | ||
bash ../treble_experimentations/build-rom.sh android-8.1 lineage | ||
|
||
## More flexible build script | ||
|
||
(this has been tested much less) | ||
|
||
bash ../treble_experimentations/build-dakkar.sh rr \ | ||
arm-aonly-gapps-su \ | ||
arm64-ab-go-nosu | ||
|
||
The script should provide a help message if you pass something it | ||
doesn't understand | ||
|
||
# Conventions for commit messages: | ||
|
||
* `[UGLY]` Please make this patch disappear as soon as possible | ||
* `[master]` tag means that the commit should be dropped in a future | ||
rebase | ||
* `[device]` tag means this change is device-specific workaround | ||
* `::device name::` will try to describe which devices are concerned | ||
by this change | ||
* `[userfriendly]` This commit is NOT used for hardware support, but | ||
to make the rom more user friendly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
## set defaults | ||
|
||
rom_fp="$(date +%y%m%d)" | ||
|
||
myname="$(basename "$0")" | ||
if [[ $(uname -s) = "Darwin" ]];then | ||
jobs=$(sysctl -n hw.ncpu) | ||
elif [[ $(uname -s) = "Linux" ]];then | ||
jobs=$(nproc) | ||
fi | ||
|
||
## handle command line arguments | ||
|
||
function help() { | ||
cat <<EOF | ||
Syntax: | ||
$myname [-j 2] <rom type> <variant>... | ||
Options: | ||
-j number of parallel make workers (defaults to $jobs) | ||
ROM types: | ||
aosp80 | ||
aosp81 | ||
carbon | ||
lineage | ||
rr | ||
Variants are dash-joined combinations of (in order): | ||
* processor type | ||
* "arm" for ARM 32 bit | ||
* "arm64" for ARM 64 bit | ||
* A or A/B partition layout ("aonly" or "ab") | ||
* GApps selection | ||
* "vanilla" to not include GApps | ||
* "gapps" to include opengapps | ||
* "go" to include gapps go | ||
* SU selection ("su" or "nosu") | ||
for example: | ||
* arm-aonly-vanilla-nosu | ||
* arm64-ab-gapps-su | ||
EOF | ||
} | ||
|
||
function get_rom_type() { | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
aosp80) | ||
mainrepo="https://android.googlesource.com/platform/manifest" | ||
mainbranch="android-vts-8.0_r4" | ||
localManifestBranch="master" | ||
treble_generate="" | ||
extra_make_options="" | ||
;; | ||
aosp81) | ||
mainrepo="https://android.googlesource.com/platform/manifest" | ||
mainbranch="android-8.1_r29" | ||
localManifestBranch="android-8.1" | ||
treble_generate="" | ||
extra_make_options="" | ||
;; | ||
carbon) | ||
mainrepo="https://github.com/CarbonROM/android" | ||
mainbranch="cr-6.1" | ||
localManifestBranch="android-8.1" | ||
treble_generate="carbon" | ||
extra_make_options="WITHOUT_CHECK_API=true" | ||
;; | ||
lineage) | ||
mainrepo="https://github.com/LineageOS/android.git" | ||
mainbranch="lineage-5.1" | ||
localManifestBranch="android-8.1" | ||
treble_generate="lineage" | ||
extra_make_options="WITHOUT_CHECK_API=true" | ||
;; | ||
rr) | ||
mainrepo="https://github.com/ResurrectionRemix/platform_manifest.git" | ||
mainbranch="oreo" | ||
localManifestBranch="android-8.1" | ||
treble_generate="rr" | ||
extra_make_options="WITHOUT_CHECK_API=true" | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
function parse_options() { | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-j) | ||
jobs="$2"; | ||
shift; | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
declare -A processor_type_map | ||
processor_type_map[arm]=arm | ||
processor_type_map[arm64]=arm64 | ||
|
||
declare -A partition_layout_map | ||
partition_layout_map[aonly]=a | ||
partition_layout_map[ab]=b | ||
|
||
declare -A gapps_selection_map | ||
gapps_selection_map[vanilla]=v | ||
gapps_selection_map[gapps]=g | ||
gapps_selection_map[go]=o | ||
|
||
declare -A su_selection_map | ||
su_selection_map[su]=S | ||
su_selection_map[nosu]=N | ||
|
||
function parse_variant() { | ||
local -a pieces | ||
IFS=- pieces=( $1 ) | ||
|
||
local processor_type=${processor_type_map[${pieces[0]}]} | ||
local partition_layout=${partition_layout_map[${pieces[1]}]} | ||
local gapps_selection=${gapps_selection_map[${pieces[2]}]} | ||
local su_selection=${su_selection_map[${pieces[3]}]} | ||
|
||
if [[ -z "$processor_type" || -z "$partition_layout" || -z "$gapps_selection" || -z "$su_selection" ]]; then | ||
>&2 echo "Invalid variant '$1'" | ||
>&2 help | ||
exit 2 | ||
fi | ||
|
||
echo "treble_${processor_type}_${partition_layout}${gapps_selection}${su_selection}-userdebug" | ||
} | ||
|
||
declare -a variant_codes | ||
declare -a variant_names | ||
function get_variants() { | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
*-*-*-*) | ||
variant_codes[${#variant_codes[*]}]=$(parse_variant "$1") | ||
variant_names[${#variant_names[*]}]="$1" | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
## function that actually do things | ||
|
||
function init_release() { | ||
mkdir -p release/"$rom_fp" | ||
} | ||
|
||
function init_main_repo() { | ||
repo init -u "$mainrepo" -b "$mainbranch" | ||
} | ||
|
||
function clone_or_checkout() { | ||
local dir="$1" | ||
local repo="$2" | ||
|
||
if [[ -d "$dir" ]];then | ||
( | ||
cd "$dir" | ||
git fetch | ||
git reset --hard | ||
git checkout origin/"$localManifestBranch" | ||
) | ||
else | ||
git clone https://github.com/phhusson/"$repo" "$dir" -b "$localManifestBranch" | ||
fi | ||
} | ||
|
||
function init_local_manifest() { | ||
clone_or_checkout .repo/local_manifests treble_manifest | ||
} | ||
|
||
function init_patches() { | ||
if [[ -n "$treble_generate" ]]; then | ||
clone_or_checkout patches treble_patches | ||
|
||
# We don't want to replace from AOSP since we'll be applying | ||
# patches by hand | ||
rm -f .repo/local_manifests/replace.xml | ||
|
||
# should I do this? will it interfere with building non-gapps images? | ||
# rm -f .repo/local_manifests/opengapps.xml | ||
fi | ||
} | ||
|
||
function sync_repo() { | ||
repo sync -c -j "$jobs" --force-sync | ||
} | ||
|
||
function patch_things() { | ||
if [[ -n "$treble_generate" ]]; then | ||
rm -f device/*/sepolicy/common/private/genfs_contexts | ||
( | ||
cd device/phh/treble | ||
git clean -fdx | ||
bash generate.sh "$treble_generate" | ||
) | ||
bash "$(dirname "$0")/apply-patches.sh" patches | ||
else | ||
( | ||
cd device/phh/treble | ||
git clean -fdx | ||
bash generate.sh | ||
) | ||
repo manifest -r > release/"$rom_fp"/manifest.xml | ||
bash "$(dirname "$0")"/list-patches.sh | ||
cp patches.zip release/"$rom_fp"/patches.zip | ||
fi | ||
} | ||
|
||
function build_variant() { | ||
lunch "$1" | ||
make $extra_make_options BUILD_NUMBER="$rom_fp" installclean | ||
make $extra_make_options BUILD_NUMBER="$rom_fp" -j "$jobs" systemimage | ||
make $extra_make_options BUILD_NUMBER="$rom_fp" vndk-test-sepolicy | ||
cp "$OUT"/system.img release/"$rom_fp"/system-"$2".img | ||
} | ||
|
||
parse_options "$@" | ||
get_rom_type "$@" | ||
get_variants "$@" | ||
|
||
if [[ -z "$mainrepo" || ${#variant_codes[*]} -eq 0 ]]; then | ||
>&2 help | ||
exit 1 | ||
fi | ||
|
||
init_release | ||
init_main_repo | ||
init_local_manifest | ||
init_patches | ||
sync_repo | ||
patch_things | ||
|
||
. build/envsetup.sh | ||
|
||
for (( idx=0; idx < ${#variant_codes[*]}; idx++ )); do | ||
build_variant "${variant_codes[$idx]}" "${variant_names[$idx]}" | ||
done |