-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_c_project.sh
executable file
·132 lines (121 loc) · 4.69 KB
/
create_c_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
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
#!/bin/bash
#declare name project
BINARY_NAME=""
LIB_BOOL=0
CLONED=0
#Function to clone github project
github_window() {
option=$(yad --geometry=500x400+0+0 --image dialog-question --center --width=500 --height=200 --title "C Project GitClone" --button=gtk-no:1 --button=gtk-yes:0 --text "Do you want to clone a repo github?")
if [ $? == 0 ]; then
repo_name=$(yad --entry --geometry=500x400+0+0 --entry-label "Enter SSH key" --button=gtk-cancel:1 --button=gtk-ok:0 --entry-text="SSH key")
name=$(yad --entry --geometry=500x400+0+0 --text "Enter new directory name\n (You may left this empty it will get is default name)" --button=gtk-cancel:1 --button=gtk-ok:0)
if [ -z $repo_name ]; then
github_window
else
CLONED=1
if [ -z $name ]; then
git clone $repo_name
else
git clone $repo_name $name
fi
fi
else
CLONED=0
fi
}
#Function to create src directory with wanted a main.c
create_src() {
if [ $? == 0 ]; then
mkdir src
yad --image dialog-question --center --fixed --width=500 --height=200 --text "Do you want to create a file <b>main.c</b>?" --button=gtk-no:1 --button=gtk-yes:0
if [ $? == 0 ] ; then
cp c_structure/main.c src/
sed -i 's/${PROJECT_NAME}/'$BINARY_NAME'/' ./src/main.c
fi
fi
}
#Function to create include directory with wanted a lib.h and PROJECT.h
create_include() {
if [ $? == 0 ]; then
mkdir include
yad --image dialog-question --center --fixed --width=500 --height=200 --text "Do you want to create a file <b>"$BINARY_NAME".h</b>?" --button=gtk-no:1 --button=gtk-yes:0
if [ $? == 0 ] ; then
cp c_structure/lib.h include/$BINARY_NAME.h
sed -i 's/${PROJECT_NAME_UP}/'${BINARY_NAME^^}'/' ./include/$BINARY_NAME.h
sed -i 's/${PROJECT_NAME}/'$BINARY_NAME'/' ./include/$BINARY_NAME.h
fi
fi
}
#Function to create makefile file
create_makefile() {
if [ $? == 0 ]; then
echo $LIB_BOOL
if [ $LIB_BOOL = 1 ]; then
cp c_structure/Makefile_lib ./Makefile
else
cp c_structure/Makefile_nlib ./Makefile
fi
sed -i 's/${PROJECT_NAME}/'$BINARY_NAME'/' ./Makefile
yad --image dialog-question --geometry=500x400+0+0 --text "<b>CSFML</b> project?" --button=gtk-no:1 --button=gtk-yes:0
if [ $? == 0 ] ; then
sed -i 's/${CSFML_FLAG}/-lcsfml-graphics -lcsfml-audio -lcsfml-window -lcsfml-system -lcsfml-network/' ./Makefile
else
sed -i 's/${CSFML_FLAG}//' ./Makefile
fi
fi
}
#Function to insert a lib already in the pc
include_lib() {
if [ $? == 0 ]; then
select=$(yad --geometry=500x400+0+0 --title "Select your lib" --file-selection)
cp -rf $select .
LIB_BOOL=1
fi
}
#Function to set project directory (lib src include)
set_project() {
BINARY_NAME=$(yad --entry --geometry=500x400+0+0 --text "Enter binary name" --button=gtk-cancel:1 --button=gtk-ok:0)
if [[ $BINARY_NAME == "" ]]; then
main_loop
fi
if [ ! -d "src" ]; then
yad --image dialog-question --geometry=500x400+0+0 --title "Init C Project" --button=gtk-no:1 --button=gtk-yes:0 --text "Do you want to create a <b>src</b> directory ?"
create_src
else
notify-send "Directory SRC already created"
fi
if [ ! -d "include" ]; then
yad --image dialog-question --geometry=500x400+0+0 --title "Init C Project" --button=gtk-no:1 --button=gtk-yes:0 --text "Do you want to create a <b>include</b> directory ?"
create_include
else
notify-send "Directory INCLUDE already created"
fi
if [ ! -d "lib" ]; then
yad --image dialog-question --geometry=500x400+0+0 --title "Init C Project" --button=gtk-no:1 --button=gtk-yes:0 --text "Do you want to insert your lib ?"
include_lib
else
notify-send "Directory LIB already here"
fi
if [ ! -f "Makefile" ]; then
yad --image dialog-question --geometry=500x400+0+0 --title "Init C Project" --text "Do you want to create a file <b>Makefile</b>?" --button=gtk-no:1 --button=gtk-yes:0
create_makefile
else
notify-send "MAKEFILE already exist"
fi
}
#Function display succesful message
done_project() {
yad --info\
--geometry=500x400+0+0 \
--wrap \
--text="Project Created <span foreground='green'>Correctly</span> \nredirecting to YPA Panel"
main_loop
}
#Function to create a c project
create_c_project() {
github_window
if [ $CLONED = 0 ]; then
set_project
fi
done_project
}