-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathace_functions
More file actions
357 lines (301 loc) · 10.2 KB
/
ace_functions
File metadata and controls
357 lines (301 loc) · 10.2 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#. ace_functions
#
# note: aliases have been sourced (in ace_profile file)
#
#
[[ -f ~/.color_functions ]] && source ~/.color_functions
# source /etc/environment file
[[ -f /etc/enrivonment ]] && source /etc/environment
########################################################################################
# ACE Helper functions to manage different versions and compilations.
########################################################################################
#
#########################################################################################
agrpexa()
{
[[ -z $1 ]] && return 1
find $ace/../examples -type f -exec grep -nH "$1" {} 2>/dev/null \;
}
#########################################################################################
_ace_proj_gen() # generate a default mpc file to make project.
{
if [[ ! -z $1 ]]
then
dt=$(date +%Y%m%d)
cp $ace_dflt_proj_template .
mv project.mpc proj_${1}.mpc
sed -i "s@projectName@${1}@g" proj_${1}.mpc
sed -i "s@ = exename@ = ${1}@g" proj_${1}.mpc
sed -i "s@Main@${1}@g" proj_${1}.mpc
sed -i "s@(project)@ (proj_${1})@g" proj_${1}.mpc
sed -i "s@main@main_${dt}_${1}.cpp@g" proj_${1}.mpc
$ACE_ROOT/bin/mpc.pl $(pwd)/proj_${1}.mpc -type gnuace
sed -i '14iCPPFLAGS = -frecord-gcc-switches -std=c++17' GNU*
touch main_${dt}_${1}.cpp ; vim main_${dt}_${1}.cpp
else
cp $ace_dflt_proj_template .
echo ; $ACE_ROOT/bin/mpc.pl $(pwd)/project.mpc -type gnuace ; echo
sed -i '14iCPPFLAGS = -frecord-gcc-switches -std=c++17' GNUmakefile.project
touch main.cpp ; vim main.cpp
fi
}
# 20190808
_ace_proj_gen_2()
{
time_stamp="$(echo $(date +"%Y%m%d%T")|tr -d ':')"
# default main cpp content
echo '// -*- C++ -*-
#define ACE_NTRACE 1
#include "ace/Log_Msg.h"
#if defined (LOG_FORMAT)
#undef (LOG_FORMAT)
#endif /* if defined (LOG_FORMAT) */
#define LOG_FORMAT ACE_TEXT ("(%I%T %M %P %t): ")
#if defined (Log)
#undef (Log)
#endif /* if defined (Log) */
#define Log(FMT, ...) ACE_DEBUG ((LM_DEBUG, \
LOG_FORMAT FMT, ##__VA_ARGS__));
int
ACE_TMAIN (int argc, const ACE_TCHAR* argv[])
{
Log ("Main starts\n");
ACE_UNUSED_ARG (argc);
ACE_UNUSED_ARG (argv);
Log ("Main ends\n");
ACE_RETURN (0);
}
' > __temp_main_.cpp
#1. if empty project name
#
# create a default main file
default_main_file=main_0_${time_stamp}.cpp
touch $default_main_file
mv __temp_main_.cpp $default_main_file
# create a default mpc project file
echo "// -*- MPC -*-
project ($time_stamp Default Project) : aceexe {
exename = bin
Header_Files {
}
Source_Files {
$default_main_file
}
}
" >> default_project.mpc
mpc.pl -type gnuace default_project.mpc
gmake -f GNU*${time_stamp}*
ls -lrth
}
#
#########################################################################################
custom_path_3up() # Show path till only 3 levels back.
{
echo $(pwd)|rev|cut -f1,2,3 -d'/'|rev ;
}
#
#########################################################################################
#
get_ace_lib_version() # Get the ACE version of a particular binary and display it.
{
#ace_lib_ver=$($(which ldd) $1|grep 'ACE.so.6.4.'|sed 's@^.*ACE.so.6.4.\(.\).*$@\1@g')
echo "$(ldd $1|grep 'ACE.so.6.4.'|sed 's@^.*ACE.so.6.4.\(.\).*$@\1@g')"
}
#
########################################################################################
#
get_gcc_version() # Get current gcc version in effect and display it.
{
echo $(g++ -v 2>&1|tail -1|sed 's/^gcc version \(.\).*$/\1/g')
}
#
########################################################################################
get_ace_root() # Check ACE version in effect and display it.
{
echo $ACE_ROOT
}
########################################################################################
achk() # Check ACE version in effect and display it.
{
echo "PATH: [$PATH]"
echo "ACE_ROOT: [$ACE_ROOT]"
echo "LD_LIBRARY_PATH: [$LD_LIBRARY_PATH]"
}
########################################################################################
get_ace_version() # Get current gcc version in effect and display it.
{
if [[ "$(achk)" =~ .*6.5.* ]]
then
echo 6.5
else
echo $(achk|grep LD_LIB|sed 's@^.*6.4.\(.\).*$@\1@g')
fi
}
########################################################################################
set_ace_default_env() # set default ace env variables.
{
export LD_LIBRARY_PATH="/home/compuser/gcc-8.2.0/lib64:$cplus/my-libs"
[[ $(get_gcc_version) -eq 7 ]] && \
export LD_LIBRARY_PATH='/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:'
export LD_LIBRARY_PATH="/home/compuser/mystuff/ace-stuff/ace_root/6.5.6/ACE_wrappers/lib:$LD_LIBRARY_PATH"
export ACE_ROOT=/home/compuser/mystuff/ace-stuff/ace_root/6.5/ACE_wrappers
export ace=$ACE_ROOT/ace
export PATH=$ACE_ROOT/bin:$PATH
}
########################################################################################
function ace_root_export() # export 'ace' as the current $ACE_ROOT
{
export ace=$ACE_ROOT/ace
}
########################################################################################
get_current_ace_version()
{
current_version=$(echo $ace|sed 's@^.*6.4.\(.\).*$@\1@g')
[[ -z $current_version ]] && echo "ACE_ROOT is NULL! Exiting" && return 1
echo $current_version
}
########################################################################################
acev() # Set the ACE version to either 6.4.6, 6.4.7 or 6.4.8(c++11)
{
[[ -z $1 ]] && echo "Need an argument. Exiting!" && return 1
base="$gahome/ace-stuff/ace_root/6.4"
base65="$gahome/ace-stuff/ace_root/6.5"
# adjusting current path for reset
# to avoid duplicates.
#
if [[ $PATH =~ .*$ACE_ROOT.* ]]
then
#export PATH=$(echo $PATH|sed "s@$ACE_ROOT/bin@@g;s@::*@:@g;s@::@:@g")
:
fi
set_ace_root()
{
[[ -z $1 ]] && return 1
export ACE_ROOT=''
val=$1
if [[ $1 != 65 ]]
then
export ACE_ROOT="${base}.${val}/ACE_wrappers"
ace_root_export
else
export ACE_ROOT="${base65}/ACE_wrappers"
ace_root_export
fi
}
set_ace_env_vals()
{
val=$1
export ACE_ROOT=''
export LD_LIBRARY_PATH='/home/compuser/gcc-8.2.0/lib64'
# if gcc is 7, then include its libs in LD_LIB path.
[[ $(get_gcc_version) -eq 7 ]] && \
export LD_LIBRARY_PATH='/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:'
case $val in
7) export ACE_ROOT="${base}.${val}/ACE_wrappers"
export LD_LIBRARY_PATH="$ACE_ROOT/lib:$LD_LIBRARY_PATH"
ace_root_export
;;
8) export ACE_ROOT="${base}.${val}/ACE_wrappers"
export LD_LIBRARY_PATH="$ACE_ROOT/lib:$LD_LIBRARY_PATH"
ace_root_export
;;
65) export ACE_ROOT="${base65}/ACE_wrappers"
export LD_LIBRARY_PATH="$ACE_ROOT/lib:$LD_LIBRARY_PATH"
export PATH="$ACE_ROOT/bin:$PATH"
ace_root_export
;;
esac
# if [[ ! $val -eq 8 ]]
# then
# export ACE_ROOT="${base}.${val}/ACE_wrappers"
# export LD_LIBRARY_PATH="$ACE_ROOT/lib:$LD_LIBRARY_PATH"
# ace_root_export
#
# fi
# if [[ $val -eq 8 ]]
# then
# export ACE_ROOT="${base}.${val}/ACE_wrappers"
# export LD_LIBRARY_PATH="$ACE_ROOT/lib:$LD_LIBRARY_PATH"
# ace_root_export
# fi
# setting global path as now
# ace root is set.
#
# 20181221 - not working so commented
#export PATH="$ACE_ROOT/bin:$PATH"
}
case $1 in
7) set_ace_env_vals 7
;;
8) set_ace_env_vals 8
;;
65) set_ace_env_vals 65
;;
*) echo "Invalid value. Only digits 7, 8 & 65 allowed!"
;;
esac
echo "ACE Version is: $(get_ace_version)"
return 1
}
########################################################################################
run () # Run the ace binary irrespective of its version.
{
[[ ! -z $1 ]] && latest_binary="$1"
[[ ! -z $1 ]] && [[ ! -f $1 ]] && return 1
# get the latest binary file which was compiled
# in the current directory
#
[[ -z $1 ]] && latest_binary="$(file *|grep ELF|cut -f1 -d:|tail -1)"
[[ -z $latest_binary ]] && return 1
if [[ ! -z $* ]]
then
my_args="$(echo $*|sed "s@$1@@g")"
fi
ace_lib_ver=$(get_ace_lib_version $latest_binary)
current_ace_version=$(get_current_ace_version)
# set ace version to the bin's version temporarily.
acev $ace_lib_ver 1>/dev/null 2>&1
# output header
echo "RUNNING @[$latest_binary] with ACE 6.4.$ace_lib_ver"
# line by line output is slow. so writing it to file
# and catting it.
tmp_file='.ace_func__run__tmp_file'
rm $tmp_file 2>/dev/null
{
# unset the IFS to not lose the spaces.
./${latest_binary} $my_args 2>&1 | while IFS= read line
do
((count++))
newline="$(echo "$line"|perl -pe 's@^(.+? calling .+?file ).+?\/([^\/]+?\.(?:h|cpp|inl)).( on line \d+)$@$1$2$3@g')"
echo "[$count] $newline"
done
} >> $tmp_file
cat $tmp_file
rm $tmp_file 2>/dev/null
# reset the version to what it was before
acev $current_ace_version 1>/dev/null 2>&1
# output footer: display the ace version of the bin
echo "@[$latest_binary] ACE 6.4.$ace_lib_ver" ;
}
runn () # Run the ace binary irrespective of its version.
{
latest_binary="$(file *|grep ELF|cut -f1 -d:|tail -1)"
[[ -z $latest_binary ]] && return 1
./${latest_binary} $* 2>&1 | while IFS= read line
do
((count++))
newline="$(echo "$line"|perl -pe 's@^(.+? calling .+?file ).+?\/([^\/]+?\.(?:h|cpp|inl)).( on line \d+)$@$1$2$3@g')"
echo "[$count] $newline"
done
}
#
########################################################################################
mkk() # Make the all GNUfiles in the directory.
{
ls GNU*${1}* 2>/dev/null|while read g
do
#[[ -e $g ]] && acmk $g
[[ -e $g ]] && acemakeit $g
done
}
########################################################################################