-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_win.ps1
132 lines (104 loc) · 2.97 KB
/
Makefile_win.ps1
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
## Makefile_win.ps1
## Manual compile on Win10:
## This will compile and build the cli terminal app on Win10.
## This script must be run within Visual Studio's Developer Powershell.
## External argument inputs
param( $inputArgs )
## Store the file name of this script
$scriptName = $MyInvocation.MyCommand.Name
function makeClean {
Write-Host "Cleaning ...
"
## array of file extensions
$fileExt = @("*.obj", "*.exe", "*.pdb", "*.ilk")
foreach ($element in $fileExt) {
## clean previous builds
if ( Test-Path $element ) {
Write-Host "Removing the following:"
Get-ChildItem $element
Remove-Item $element
}
}
Write-Host "Done Cleaning.
"
}
function makeBuild {
Write-Host "Building ...
"
## Compile and build object modules
cl /c sources\my_calendar.c
cl /c sources\my_csv_structs.c
cl /c sources\my_tty_ui_win.c
cl /c sources\my_tty_ui.c
## Build the executable file
#cl mainTTY.c my_calendar.obj my_csv_structs.obj my_tty_ui.obj my_tty_ui_win.obj /o "ttyRosary.exe"
cl mainTTY.c my_calendar.obj my_csv_structs.obj my_tty_ui.obj my_tty_ui_win.obj /Fe"ttyRosary.exe"
Write-Host "Done Building.
"
}
function makeRun {
Write-Host "Running ...
"
## Run
if ( Test-Path .\ttyRosary.exe ) {
.\ttyRosary.exe
}
Write-Host "Done Running.
"
}
function menu {
Write-Host ""
Write-Host "$scriptName
Compile and build a CLI scripture Rosary on Win10."
Write-Host "
About:
This script is a DIY Makefile. Select from the following option.
clean, build, run
Important:
This script must run within: Developer Powershell for VS 2019+
The executable will be mainTTY.exe
Run from terminal:
.\$scriptName clean
.\$scriptName build
.\$scriptName run
Options:
clean:
clear previous builds
build:
clear previous builds
compile and build
run:
clear previous builds
compile and build
run the compile executable 'mainTTY.exe'
"
$userinput = Read-Host -Prompt " Type selection option [ clean, build, run ]: "
if ( $userinput -eq "clean" ) {
Write-Host "You entered: $userinput"
makeClean
} elseif ( $userinput -eq "build" ) {
Write-Host "You entered $userinput"
makeClean
makeBuild
} elseif ( $userinput -eq "run" ) {
Write-Host "You entered: $userinput"
makeClean
makeBuild
makeRun
} else {
Write-Host "You entered: $userinput"
Write-Host " !!! bad input !!!
Input only one of the following: 'clean', 'build', or 'run'.
Try Again.
"
Write-Host "Done.
"
}
}
## main
switch ( $inputArgs ) {
"clean" { makeClean }
"build" { makeClean; makeBuild }
"run" { makeClean; makeBuild; makeRun }
default { menu }
}