forked from kotatogram/kotatogram-desktop
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate.bat
134 lines (121 loc) · 3.08 KB
/
create.bat
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
@echo off
setlocal enabledelayedexpansion
set "FullScriptPath=%~dp0"
set "FullExecPath=%cd%"
set "Command=%1"
if "%Command%" == "test" (
call :write_test %2
exit /b %errorlevel%
) else if "%Command%" == "header" (
call :write_header %2
exit /b %errorlevel%
) else if "%Command%" == "source" (
call :write_source %2
exit /b %errorlevel%
) else if "%Command%" == "" (
echo This is an utility for fast blank module creation.
echo Please provide module path.
exit /b
)
call :write_module %Command%
exit /b %errorlevel%
:write_module
(
set "CommandPath=%1"
set "CommandPathUnix=!CommandPath:\=/!"
if "!CommandPathUnix!" == "" (
echo Provide module path.
exit /b 1
)
echo Generating module !CommandPathUnix!..
call create.bat header !CommandPathUnix!
call create.bat source !CommandPathUnix!
exit /b
)
:write_header
(
set "CommandPath=%1"
set "CommandPathUnix=!CommandPath:\=/!"
set "CommandPathWin=!CommandPath:/=\!"
if "!CommandPathUnix!" == "" (
echo Provide header path.
exit /b 1
) else if exist "SourceFiles\!CommandPathWin!.h" (
echo This header already exists.
exit /b 1
)
echo Generating header !CommandPathUnix!.h..
mkdir "SourceFiles\!CommandPathWin!.h"
rmdir "SourceFiles\!CommandPathWin!.h"
call :write_comment !CommandPathWin!.h
set "header1=#pragma once"
(
echo !header1!
echo.
)>> "SourceFiles\!CommandPathWin!.h"
exit /b
)
:write_source
(
set "CommandPath=%1"
set "CommandPathUnix=!CommandPath:\=/!"
set "CommandPathWin=!CommandPath:/=\!"
if "!CommandPathUnix!" == "" (
echo Provide source path.
exit /b 1
) else if exist "SourceFiles\!CommandPathWin!.cpp" (
echo This source already exists.
exit /b 1
)
echo Generating source !CommandPathUnix!.cpp..
mkdir "SourceFiles\!CommandPathWin!.cpp"
rmdir "SourceFiles\!CommandPathWin!.cpp"
call :write_comment !CommandPathWin!.cpp
set "quote="""
set "quote=!quote:~0,1!"
set "source1=#include !quote!!CommandPathUnix!.h!quote!"
(
echo !source1!
echo.
)>> "SourceFiles\!CommandPathWin!.cpp"
exit /b
)
:write_test
(
set "CommandPath=%1"
set "CommandPathUnix=!CommandPath:\=/!"
set "CommandPathWin=!CommandPath:/=\!"
if "!CommandPathUnix!" == "" (
echo Provide source path.
exit /b 1
) else if exist "SourceFiles\!CommandPathWin!.cpp" (
echo This source already exists.
exit /b 1
)
echo Generating test !CommandPathUnix!.cpp..
mkdir "SourceFiles\!CommandPathWin!.cpp"
rmdir "SourceFiles\!CommandPathWin!.cpp"
call :write_comment !CommandPathWin!.cpp
set "quote="""
set "quote=!quote:~0,1!"
set "source1=#include !quote!catch.hpp!quote!"
(
echo !source1!
echo.
)>> "SourceFiles\!CommandPathWin!.cpp"
exit /b
)
:write_comment
(
set "Path=%1"
(
echo /*
echo This file is part of Telegram Desktop,
echo the official desktop application for the Telegram messaging service.
echo.
echo For license and copyright information please follow this link:
echo https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
echo */
)> "SourceFiles\!Path!"
exit /b
)