-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.au3
117 lines (117 loc) · 4.51 KB
/
compiler.au3
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
; program compiler:
#include <Array.au3>
#include <File.au3>
Local $aPaths = [ _
"Documentation", _
"images", _
"lng", _
"sounds" _
]
Local $sCopy = ""
ConsoleWrite("Compilation util: starting..." &@crlf)
if @compiled then
ConsoleWriteError("Error: script compiled" &@crlf)
Exit
EndIf
ConsoleWrite("Compilation util: Starting paths..." & @CRLF)
_start_paths(@ScriptDir & "\..\compiled", $aPaths)
ConsoleWrite("Copying files..." & @CRLF)
_CopiFiles(@ScriptDir & "\..\compiled")
If @error Then
ConsoleWrite("Error: ")
Switch @error
Case 1
ConsoleWriteError("Base dir doesn't exists." & @CRLF)
Case 2
ConsoleWriteError("Required files not found." & @CRLF)
Case 3
ConsoleWriteError("Can't compy file." & @CRLF)
EndSwitch
Exit
EndIf
ConsoleWrite("Final steps: copying final folders..." & @CRLF)
$sCopy = _copyFolders(@ScriptDir & "\..\compiled", $aPaths)
If @error Then
ConsoleWrite("Error: ")
Switch @error
Case 1
ConsoleWriteError("Base dir doesn't exists." & @CRLF)
Case 2
ConsoleWriteError("Folder " & $sCopy & " not found." & @CRLF)
EndSwitch
Exit
EndIf
ConsoleWrite("Ready to compile" & @CRLF)
; #FUNCTION# ====================================================================================================================
; Name ..........: _start_paths
; Description ...: Starts creating folder structure.
; Syntax ........: _start_paths($sBaseDir, $aPaths)
; Parameters ....: $sBaseDir - The destination folder in which to create the subfolders.
; $aPaths - an array containing the folders to create.
; Return values .: None
; Author ........: Mateo Cedillo
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _start_paths($sBaseDir, $aPaths)
Local $sPath = ""
If Not FileExists($sBaseDir) Then DirCreate($sBaseDir)
For $sPath In $aPaths
If Not FileExists($sBaseDir & "\" & $sPath) Then DirCreate($sBaseDir & "\" & $sPath)
Next
Return 1
EndFunc ;==>_start_paths
; #FUNCTION# ====================================================================================================================
; Name ..........: _CopiFiles
; Description ...: Function that is responsible for copying the files necessary for the project.
; Syntax ........: _CopiFiles($sBaseDir)
; Parameters ....: $sBaseDir - The destination folder where the files will be copied.
; Return values .: None
; Author ........: Mateo Cedillo
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _CopiFiles($sBaseDir)
Local $aFiles
If Not FileExists($sBaseDir) Then Return SetError(1, 0, "") ; please call to _start_paths first
$aFiles = _FileListToArrayRec(@ScriptDir, "nvdaControllerClient32.dll", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT)
If @error Then Return SetError(2, 0, "")
For $I = 1 To $aFiles[0]
If Not FileExists($aFiles) Then FileCopy($aFiles[$I], $sBaseDir)
If @error Then
ExitLoop
Return SetError(3, 0, "")
EndIf
Next
Return 1
EndFunc ;==>_CopiFiles
; #FUNCTION# ====================================================================================================================
; Name ..........: _copyFolders
; Description ...: Copies the folders and their content required for the project.
; Syntax ........: _copyFolders($sBaseDir, $aPaths)
; Parameters ....: $sBaseDir - the destination folder.
; $aPaths - An array containing the folders to be copied.
; Return values .: None
; Author ........: Mateo Cedillo
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _copyFolders($sBaseDir, $aPaths)
Local $sPath
If Not FileExists($sBaseDir) Then Return SetError(1, 0, "") ; please call to _start_paths first
For $sPath In $aPaths
If Not FileExists(@ScriptDir & "\" & $sPath) Then Return SetError(2, 0, $sPath)
consoleWrite("Copying folder " & @ScriptDir & "\" & $sPath & " to " & $sBaseDir &@crlf)
DirCopy(@ScriptDir & "\" & $sPath, $sBaseDir & "\" & $sPath, 1)
Next
Return 1
EndFunc ;==>_copyFolders