-
Notifications
You must be signed in to change notification settings - Fork 3
/
create-qnx-project.sh
83 lines (73 loc) · 2.16 KB
/
create-qnx-project.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
#!/bin/sh
HELLOWORLD_ROOT=`pwd`/HelloWorld
# make directory qnx and copy all files and directories into it
copy_qnx_folder(){
if [ -d $PROJECT_DIR/qnx ]; then
echo "The '$PROJECT_NAME' project exists, can't override! Please input again!"
create_qnx_project
exit
fi
mkdir $PROJECT_DIR/qnx
echo $HELLOWORLD_ROOT
for file in `ls -a $HELLOWORLD_ROOT/qnx | grep -E '\.(project|cproject|xml|png|cpp)' `
do
file=$HELLOWORLD_ROOT/qnx/$file
if [ -f $file ];then
#echo $file
cp $file $PROJECT_DIR/qnx
fi
done
}
copy_cpp_h_from_helloworld(){
if [ -d $PROJECT_DIR/Classes ]; then
echo "Classes folder exists, skip copying Classes folder!"
else
mkdir $PROJECT_DIR/Classes
for file in `ls $HELLOWORLD_ROOT/Classes/* | grep -E '.(cpp|h|mk)' `
do
if [ -f $file ];then
#echo $file
cp $file $PROJECT_DIR/Classes
fi
done
fi
}
# copy resources
copy_resouces(){
if [ -d $PROJECT_DIR/Resource ]; then
echo "Resource folder exists, skip copying Resource folder!"
else
mkdir $PROJECT_DIR/Resource
for file in $HELLOWORLD_ROOT/Resource/*
do
#echo $file
cp $file $PROJECT_DIR/Resource
done
fi
}
# replace string
modify_file_content(){
# here should use # instead of /, why??
sed "s#HelloWorld#$PROJECT_NAME#" $PROJECT_DIR/qnx/$1 > $PROJECT_DIR/qnx/tmp.txt
rm $PROJECT_DIR/qnx/$1
mv $PROJECT_DIR/qnx/tmp.txt $PROJECT_DIR/qnx/$1
}
create_qnx_project(){
echo "Please input your project name:"
read PROJECT_NAME
PROJECT_DIR=`pwd`/$PROJECT_NAME
# check if PROJECT_DIR is exist
if [ -d $PROJECT_DIR ]; then
echo ""
else
mkdir $PROJECT_DIR
fi
copy_qnx_folder
modify_file_content .project
modify_file_content .cproject
modify_file_content bar-descriptor.xml
copy_cpp_h_from_helloworld
copy_resouces
echo "Congratulations, the '$PROJECT_NAME' project have been created successfully, please use QNX IDE to import the project!"
}
create_qnx_project