-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathease.sh
177 lines (147 loc) · 3.93 KB
/
ease.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
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
#!/bin/bash
HELPER_PROMPT="
Usage: ./ease [options]
Initialize a C project for both windows and unix
Types of options
-------------
--init <project_name> := creates a project with the given name
--help := prints the helper prompt
--target <platform> := win64(default) and unix
--kill <project_name> := deletes the given project safely
Examples
--------
* For windows
ease --init foo
* For unix
ease --init foo --target unix
"
function setup_symlink_for_win {
if [ "$USER" == "simploo" ]
then
echo "[!] OWNER RECOGNIZED!"
cmd.exe /c mklink /j lib E:\\dev\\lib
fi
}
function print_helper_prompt {
printf %s "$HELPER_PROMPT"
}
function download_forge {
if [ "$1" == "unix" ]
then
wget https://raw.githubusercontent.com/gimploo/forge/main/build.sh 2> /dev/null
chmod +x build.sh
return 0
elif [ "$1" == "win64" ]
then
wget https://raw.githubusercontent.com/gimploo/forge/main/build.bat 2> /dev/null
return 0
fi
}
function main {
if [ "$1" == "--init" ]
then
if [ ! -d "$2" ]
then
mkdir $2
mkdir $2/src && cd $2
create_main_c_file $2
if [ "$3" == "--target" ]
then
download_forge $4
else
download_forge "win64"
setup_symlink_for_win
fi
cd - > /dev/null
else
echo "[EASE] Folder \`$2\` exist"
return 0
fi
elif [ "$1" == "--kill" ]
then
if [ -d "$2" ]
then
cd $2 &&
if [ -f "build.sh" ]
then
./build.sh deepclean || { echo [EASE] something went wrong; return 1; }
elif [ -f "build.bat" ]
then
if [ -L "lib" ]
then
rm lib && echo [EASE] SYMLINK FOUND, SAFELY REMOVED!
fi
cmd.exe /c build.bat deepclean || { echo [EASE] something went wrong; return 1; }
else
echo "[EASE] Build script not found"
return 0
fi
cd - > /dev/null
rm -rf $2
echo "[EASE] Project \`$2\` successfully deleted"
return 0
else
echo "[EASE] Project \`$2\` doesnot exist"
return 0
fi
else
print_helper_prompt
return 00
fi
echo "[EASE] Project \`$2\` successfully created"
return 0
}
function create_main_c_file {
echo -e "#define WINDOW_SDL
#include <poglib/application.h>
typedef struct content_t {
const char *text;
} content_t ;
void $1_init(application_t *app)
{
content_t c = {
.text = \"Hello world\\\n\"
};
application_pass_content(app, &c);
}
void $1_update(application_t *app)
{
window_t *win = application_get_window(app);
content_t *c = application_get_content(app);
window_update_user_input(win);
}
void $1_render(application_t *app)
{
window_t *win = application_get_window(app);
content_t *c = application_get_content(app);
}
void $1_destroy(application_t *app)
{
window_t *win = application_get_window(app);
content_t *c = application_get_content(app);
}
int main(void)
{
application_t app = {
.window = {
.title = \"$1\",
.width = 1080,
.height = 920,
.aspect_ratio = 1080.f / 920.f,
.fps_limit = 60,
.background_color = COLOR_GREEN
},
.content = {
.size = sizeof(content_t )
},
.init = $1_init,
.update = $1_update,
.render = $1_render,
.destroy = $1_destroy
};
application_run(&app);
return 0;
}
" > src/main.c
}
main $1 $2 $3 $4