-
Notifications
You must be signed in to change notification settings - Fork 68
/
envsetup.sh
145 lines (122 loc) · 4.62 KB
/
envsetup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
#
# envsetup.sh for buildroot YuzukiSBC
# Copyright (C) 2022 YuzukiTsuru <gloomyghost@gloomyghost.com>. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
LOCAL_COMMIT_ID=$(git rev-parse --short HEAD)
export SOURCE_PATH=$(pwd)
export BR2_PATH=$SOURCE_PATH/buildroot
echo " _____ _____ ___ __ __ _ _ _____ _____ _____ "
echo "| __ | __ |_ | | | |_ _ ___ _ _| |_|_| __| __ | |"
echo "| __ -| -| _| |_ _| | |- _| | | '_| |__ | __ -| --|"
echo "|_____|__|__|___| |_| |___|___|___|_,_|_|_____|_____|_____|"
echo -e "Commit: $LOCAL_COMMIT_ID\n"
# WSL SUpport
if [ $(uname -r | grep -c "WSL1") -eq 1 ];
then
# Not support WSL 1
echo "#### Buildroot-YuzukiSBC Not Support WSL 1 ####"
exit 1
elif [ $(uname -r | grep -c "WSL2") -eq 1 ];
then
echo "Buildroot-YuzukiSBC Now running on WSL2, setting PATH..."
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib"
fi
UpdateInfo(){
echo "************************************************************"
echo "* Update done! You may need to run sync_update after lunch.*"
echo "************************************************************"
}
FetchUpdate(){
git fetch origin master:tmp
if [ $(git diff tmp | grep -c "-") -gt 1 ];
then
read -r -p "Update found, Update to Remote? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "Now try to merge upstream..."
git merge tmp
UpdateInfo
;;
[nN][oO]|[nN])
echo "Cancel update..."
;;
*)
echo "Invalid input..."
;;
esac
else
echo "Local code all up to date! commit id:"
git rev-parse HEAD
fi
# delete the commit
git branch -d tmp
}
# Fetch latest commit.
read -r -p "Check for repository updates?[y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "Fetching remote repo data..."
FetchUpdate
;;
[nN][oO]|[nN])
echo "Cancel update check..."
;;
*)
echo "Cancel update check..."
;;
esac
# configure C compiler
export compiler=$(which gcc)
# get version code
MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
if [ $MAJOR -lt 7 ];
then
echo "#### Buildroot-YuzukiSBC Not Support GCC Version less than 7 ####"
elif [ $MAJOR -gt 12 ];
then
echo "#### Buildroot-YuzukiSBC Not Support GCC Version more than 12 ####"
else
echo "Your Host GCC Version is $MAJOR.$MINOR.$PATCHLEVEL"
fi
# Add alias
# Alias
alias lunch="cd buildroot && echo -e \"You're building on Linux\n\nLunch menu... \npick a combo by 'make xxx_defconfig':\nScaning combo...\" && make list-defconfigs"
alias lunchs="cd buildroot"
alias rebuild_kernel="touch ./output/images/a.dtb && rm ./output/images/*.dtb && make linux-rebuild -j8 && make"
alias rebuild_uboot="make uboot-rebuild -j8 && make"
alias wsl_path="export PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib\""
alias sync_kernel="rm -rf output/build/linux* && rm -rf output/build/.linux* && make"
alias sync_uboot="rm -rf output/build/uboot* && make"
alias sync_update="rm -rf output/build/linux* && rm -rf output/build/.linux* && rm -rf output/build/uboot* && rm -rf dl/uboot* && rm -rf dl/linux*"
alias mm="make"
alias m="make"
alias mkernel="rebuild_kernel"
alias rkernel="rebuild_kernel"
alias sm="make savedefconfig"
alias skernel="make linux-update-defconfig"
alias suboot="make uboot-update-defconfig"
alias muboot="rebuild_uboot"
alias ruboot="rebuild_uboot"
# For develop
alias croot="cd $BR2_PATH"
alias cconfig="cd $BR2_PATH/configs"
alias cout="cd $BR2_PATH/output"
alias cplat="cd $BR2_PATH/board"
LOCAL_COMMIT_ID=$(git rev-parse --short HEAD)
echo -e "\n"
echo "******************************************"
echo "* Setup env done! Please run lunch next. *"
echo "******************************************"