-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc_devel
224 lines (197 loc) · 5.4 KB
/
.bashrc_devel
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
###
## A script to setup some needed variables and functions for KDE 4 development.
## This should normally go in the ~/.bashrc file of your kde development user.
CURRENT_SHELL=$(echo $0)
prepend() { [ -d "$2" ] && eval $1=\"$2\$\{$1:+':'\$$1\}\" && export $1 ; }
# This will make the debug output prettier
export KDE_COLOR_DEBUG=1
export QTEST_COLORED=1
# Make
# Tell many scripts how to switch from source dir to build dir:
export OBJ_REPLACEMENT="s#$KDE_SRC#$KDE_BUILD#"
# Set up make
if [[ "$OSTYPE" == "linux-gnu" ]]; then
export MAKEFLAGS="-j$(cat /proc/cpuinfo | grep processor | wc -l) $MAKEFLAGS"
elif [[ "$OSTYPE" == "darwin"* ]]; then
export MAKEFLAGS="-j$(sysctl -n hw.ncpu) $MAKEFLAGS"
fi
# Use makeobj instead of make, to automatically switch to the build dir.
# If you don't have makeobj, install the package named kdesdk-scripts or
# kdesdk, or check out kdesdk/scripts from svn, or just don't set the alias
# yet.
if hash makeobj 2> /dev/null; then
if hash ionice 2> /dev/null; then
alias make='nice ionice -c 3 makeobj'
else
alias make='nice makeobj'
fi
fi
##
# A function to easily build the current directory of KDE.
#
# This builds only the sources in the current ~/{src,build}/KDE subdirectory.
# Usage: cs KDE/kdebase && cmakekde
# will build/rebuild the sources in ~/src/KDE/kdebase
#
function cmakekde {
# get srcFolder for current dir
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
# we are in the src folder, change to build directory
# Alternatively, we could just use makeobj in the commands below...
current=`pwd`
if [ "$srcFolder" = "$current" ]; then
cb
fi
cmake "$srcFolder" \
-G "Ninja" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX=$KDEDIR \
-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DQT_FORCE_ASSERTS -DQT_MESSAGELOGCONTEXT" -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -g -DQT_FORCE_ASSERTS -DQT_MESSAGELOGCONTEXT" \
$* \
# -DCMAKE_BUILD_TYPE=Debug \
make install
RETURN=$?
cs
return ${RETURN}
}
function qmakekde {
# get srcFolder for current dir
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
# we are in the src folder, change to build directory
# Alternatively, we could just use makeobj in the commands below...
current=`pwd`
if [ "$srcFolder" = "$current" ]; then
cb
fi
qmake "$srcFolder" \
CONFIG-=release CONFIG+=debug \
PREFIX=$KDEDIR $*
make install
RETURN=$?
cs
return ${RETURN}
}
function cd() {
if test -z "$1"; then
builtin cd
elif test -z "$2"; then
builtin cd "$1"
else
builtin cd "$1" "$2"
fi
_f=`findup .build-config.sh`
if test -n "$_f" -a "$_lastf" != "$_f"; then
echo "Loading $_f"
_lastf="$_f"
source "$_f"
# renew makeobj sed
export OBJ_REPLACEMENT="s#$KDE_SRC#$KDE_BUILD#"
fi
}
##
# Get build dir of the current working-directory or $1, if set
#
function getbuilddir {
if test -n "$1"; then
dir="$1"
else
dir="$PWD"
fi
echo $dir | sed -e s,$KDE_SRC,$KDE_BUILD,
}
##
# A function to easily change to the build directory.
# Usage: cb KDE/kdebase
# will change to $KDE_BUILD/KDE/kdebase
# Usage: cb
# will simply go to the build folder if you are currently in a src folder
# Example:
# $ pwd
# /home/user/src/KDE/kdebase
# $ cb && pwd
# /home/user/build/KDE/kdebase
#
function cb {
local dest
# Make sure build directory exists.
mkdir -p "$KDE_BUILD"
# command line argument
if test -n "$1"; then
cd "$KDE_BUILD/$1"
return
fi
# substitute src dir with build dir
dest=`pwd | sed -e s,$KDE_SRC,$KDE_BUILD,`
if test ! -d "$dest"; then
# build directory does not exist, create
mkdir -p "$dest"
fi
cd "$dest"
}
##
# Change to the source directory. Same as cb, except this
# switches to $KDE_SRC instead of $KDE_BUILD.
# Usage: cs KDE/kdebase
# will change to $KDE_SRC/KDE/kdebase
# Usage: cs
# will simply go to the source folder if you are currently in a build folder
# Example:
# $ pwd
# /home/myuser/kde/build/master/KDE/kdebase
# $ cs && pwd
# /home/myuser/kde/src/master/KDE/kdebase
#
function cs {
local dest current
# Make sure source directory exists.
mkdir -p "$KDE_SRC"
# command line argument
if test -n "$1"; then
cd "$KDE_SRC/$1"
else
# substitute build dir with src dir
dest=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
current=`pwd`
if [ "$dest" = "$current" ]; then
cd "$KDE_SRC"
else
cd "$dest"
fi
fi
}
##
# Add autocompletion to cs function
#
function _cs_scandir
{
local base ext
base=$1
ext=$2
if [ -d $base ]; then
for d in `ls $base`; do
if [ -d $base/$d ]; then
dirs="$dirs $ext$d/"
fi
done
fi
}
function _cs()
{
local cur dirs
_cs_scandir "$KDE_SRC"
_cs_scandir "$KDE_SRC/KDE" "KDE/"
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${dirs}" -- ${cur}) )
}
svndiff ()
{
svn diff "$*" | colordiff | less;
}
# Setup shell
if [ "$CURRENT_SHELL" = "bash" ]; then
complete -F _cs cs
fi
# trigger function
cd $PWD