Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DataEraserC committed Dec 8, 2023
1 parent e5d5e4b commit 8b0f5ca
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 0 deletions.
49 changes: 49 additions & 0 deletions flake/android_builder_fhs_shell/Build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export DEV_DIR=$(dirname "$(readlink -f "$0")")
cd $DEV_DIR || yes
export PATH=$DEV_DIR/toolchains/clang-aosp/bin:$PATH
export GCC_32=CROSS_COMPILE_ARM32=$DEV_DIR/toolchains/gcc-32/bin/arm-linux-androideabi-
export GCC_64=CROSS_COMPILE=$DEV_DIR/toolchains/gcc-64/bin/aarch64-linux-android-
export KERNEL_SOURCE=https://github.com/Nobooooody/android_kernel_motorola_sm8250
export KERNEL_SOURCE_BRANCH=0warning0error_lineage-20
export KERNEL_CONFIG=vendor/lineageos_pstar_lxc_docker_defconfig
export KERNEL_IMAGE_NAME=Image
export ARCH=arm64
export EXTRA_CMDS="LD=ld.lld LOCALVERSION=-test_kernel"

# Clang
## Custom
export USE_CUSTOM_CLANG=false
export CUSTOM_CLANG_SOURCE=
export CUSTOM_CLANG_BRANCH=

### if your set USE CUSTOM CLANG to false than DO NOT CHANGE CUSTOM CMDS
export CUSTOM_CMDS="CLANG_TRIPLE=aarch64-linux-gnu-"

## AOSP
export CLANG_BRANCH=android13-release
export CLANG_VERSION=r450784d

# GCC
export ENABLE_GCC_ARM64=true
export ENABLE_GCC_ARM32=false

# KernelSU flags
export ENABLE_KERNELSU=true
export KERNELSU_TAG=main

# Configuration
export DISABLE_CC_WERROR=false
export ADD_KPROBES_CONFIG=true
export ADD_OVERLAYFS_CONFIG=false

# Ccache
export ENABLE_CCACHE=true

# DTBO image
export NEED_DTBO=false

# Build boot images
export BUILD_BOOT_IMG=true
export SOURCE_BOOT_IMAGE=https://mirrorbits.lineageos.org/full/pstar/20230530/boot.img
make -j$(nproc --all) CC=clang O=out ARCH=$ARCH $EXTRA_CMDS $CUSTOM_CMDS $GCC_64 $GCC_32 $KERNEL_CONFIG
make -j$(nproc --all) CC=clang O=out ARCH=$ARCH $EXTRA_CMDS $CUSTOM_CMDS $GCC_64 $GCC_32
12 changes: 12 additions & 0 deletions flake/android_builder_fhs_shell/Download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mkdir toolchains
cd toolchains
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/android13-release/clang-r450784d.tar.gz
mkdir clang-aosp
tar -C clang-aosp/ -zxvf clang-r450784d.tar.gz
mkdir gcc-64
wget -O gcc-aarch64.tar.gz https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-13.0.0_r0.102.tar.gz
tar -C gcc-64/ -zxvf gcc-aarch64.tar.gz
mkdir gcc-32
wget -O gcc-arm.tar.gz https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/+archive/refs/tags/android-13.0.0_r0.102.tar.gz
tar -C gcc-32/ -zxvf gcc-arm.tar.gz
git clone https://android.googlesource.com/platform/system/tools/mkbootimg tools -b master-kernel-build-2022 --depth=1
27 changes: 27 additions & 0 deletions flake/android_builder_fhs_shell/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions flake/android_builder_fhs_shell/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
description = "My-Android build environment";
nixConfig.bash-prompt = "[nix(Android_Builder)] ";
inputs = {nixpkgs.url = "github:nixos/nixpkgs/23.11";};

outputs = {
self,
nixpkgs,
} @ inputs: let
system = "x86_64-linux";
pkgs =
import nixpkgs
{
inherit system;
config = {
permittedInsecurePackages = ["python-2.7.18.7"];
};
};
in {
devShells.${system}.default = let
android_builder_fhs_env = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs:
with pkgs; [
bc
git
gitRepo
gnupg
python2
curl
procps
openssl
gnumake
nettools
# For nixos < 19.03, use `androidenv.platformTools`
androidenv.androidPkgs_9_0.platform-tools
jdk
schedtool
util-linux
m4
gperf
perl
libxml2
zip
unzip
bison
flex
lzop
python3
];
multiPkgs = pkgs:
with pkgs; [
zlib
ncurses
];
runScript = "bash";
profile = ''
export FHS=1
export ALLOW_NINJA_ENV=true
export USE_CCACHE=1
export ANDROID_JAVA_HOME=${pkgs.jdk.home}
# export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
export DEV_DIR=/home/nixos/Development
export SOURCE_DIR=/home/nixos/Documents/code/android_kernel_motorola_sm8250
cd $DEV_DIR || yes
export PATH=$DEV_DIR/toolchains/clang-aosp/bin:$PATH
export GCC_32=CROSS_COMPILE_ARM32=$DEV_DIR/toolchains/gcc-32/bin/arm-linux-androideabi-
export GCC_64=CROSS_COMPILE=$DEV_DIR/toolchains/gcc-64/bin/aarch64-linux-android-
export KERNEL_SOURCE=https://github.com/Nobooooody/android_kernel_motorola_sm8250
export KERNEL_SOURCE_BRANCH=0warning0error_lineage-20
export KERNEL_CONFIG=vendor/lineageos_pstar_lxc_docker_defconfig
export KERNEL_IMAGE_NAME=Image
export ARCH=arm64
export EXTRA_CMDS="LD=ld.lld LOCALVERSION=-test_kernel"
# Clang
## Custom
export USE_CUSTOM_CLANG=false
export CUSTOM_CLANG_SOURCE=
export CUSTOM_CLANG_BRANCH=
### if your set USE CUSTOM CLANG to false than DO NOT CHANGE CUSTOM CMDS
export CUSTOM_CMDS="CLANG_TRIPLE=aarch64-linux-gnu-"
## AOSP
export CLANG_BRANCH=android13-release
export CLANG_VERSION=r450784d
# GCC
export ENABLE_GCC_ARM64=true
export ENABLE_GCC_ARM32=false
# KernelSU flags
export ENABLE_KERNELSU=true
export KERNELSU_TAG=main
# Configuration
export DISABLE_CC_WERROR=false
export ADD_KPROBES_CONFIG=true
export ADD_OVERLAYFS_CONFIG=false
# Ccache
export ENABLE_CCACHE=true
# DTBO image
export NEED_DTBO=false
# Build boot images
export BUILD_BOOT_IMG=true
cd $SOURCE_DIR || yes
'';
extraOutputsToInstall = ["dev"];
};
in
pkgs.mkShell {
name = "My-Android build environment";
buildInputs = [
android_builder_fhs_env
];
shellHook = ''
echo "Welcome in $name"
exec android-env
'';
};
};
}
File renamed without changes.
File renamed without changes.

0 comments on commit 8b0f5ca

Please sign in to comment.