| |
1 # ------------------------- |
| |
2 # Utility functions |
| |
3 # ------------------------- |
| |
4 |
| |
5 function Is-Platform { |
| |
6 param([string]$Name) |
| |
7 return $PLATFORM -contains $Name |
| |
8 } |
| |
9 |
| |
10 function Not-IsPlatform { |
| |
11 param([string]$Name) |
| |
12 return -not ($PLATFORM -contains $Name) |
| |
13 } |
| |
14 |
| |
15 # ------------------------- |
| |
16 # Platform (fixed) |
| |
17 # ------------------------- |
| |
18 |
| |
19 Write-Host "detect platform... windows" |
| |
20 |
| |
21 $PLATFORM = @('windows') |
| |
22 $PLATFORM_NAME = 'windows' |
| |
23 |
| |
24 # ------------------------- |
| |
25 # Result directories |
| |
26 # ------------------------- |
| |
27 |
| |
28 New-Item -ItemType Directory -Force -Path result | Out-Null |
| |
29 $result_dir = (Resolve-Path result).Path |
| |
30 |
| |
31 $configure_log = "configure.log" |
| |
32 $compile_log = "compile.log" |
| |
33 $check_log = "check.log" |
| |
34 |
| |
35 $result_file = Join-Path $result_dir "result.json" |
| |
36 |
| |
37 "[" | Out-File -FilePath $result_file -Encoding utf8 |
| |
38 |
| |
39 # ------------------------- |
| |
40 # Source directory |
| |
41 # ------------------------- |
| |
42 |
| |
43 Set-Location src |
| |
44 |
| |
45 {{ $nbuild := len .Build }} |
| |
46 {{ range $i, $build := .Build}} |
| |
47 |
| |
48 # Build isplatform="{{ .IsPlatform }}" not="{{ .NotPlatform }}" |
| |
49 while ($true) { |
| |
50 |
| |
51 $log_dir = Join-Path $result_dir "build{{$i}}" |
| |
52 New-Item -ItemType Directory -Force -Path $log_dir | Out-Null |
| |
53 if (-not $?) { |
| |
54 Write-Error "failed to create log dir $log_dir" |
| |
55 exit 1 |
| |
56 } |
| |
57 |
| |
58 {{- if .IsPlatform}} |
| |
59 if (Not-IsPlatform "{{ $build.IsPlatform }}") { |
| |
60 break |
| |
61 } |
| |
62 {{- end}} |
| |
63 |
| |
64 {{- range $build.NotList}} |
| |
65 if (Is-Platform "{{.}}") { |
| |
66 break |
| |
67 } |
| |
68 {{- end}} |
| |
69 |
| |
70 # ------------------------- |
| |
71 # configure |
| |
72 # ------------------------- |
| |
73 |
| |
74 $configure = $null |
| |
75 {{- if $build.Configure}} |
| |
76 @" |
| |
77 {{ $build.Configure }} |
| |
78 "@ | Out-File uwbuild-configure.ps1 -Encoding utf8 |
| |
79 |
| |
80 .\uwbuild-configure.ps1 *> (Join-Path $log_dir $configure_log) |
| |
81 |
| |
82 $configure = $LASTEXITCODE |
| |
83 {{- end}} |
| |
84 |
| |
85 # ------------------------- |
| |
86 # compile |
| |
87 # ------------------------- |
| |
88 |
| |
89 $compile = $null |
| |
90 {{- if $build.Compile}} |
| |
91 @" |
| |
92 {{ $build.Compile }} |
| |
93 "@ | Out-File uwbuild-compile.ps1 -Encoding utf8 |
| |
94 |
| |
95 .\uwbuild-compile.ps1 *> (Join-Path $log_dir $compile_log) |
| |
96 |
| |
97 $compile = $LASTEXITCODE |
| |
98 {{- end}} |
| |
99 |
| |
100 # ------------------------- |
| |
101 # check |
| |
102 # ------------------------- |
| |
103 |
| |
104 $check = $null |
| |
105 {{- if $build.Check}} |
| |
106 @" |
| |
107 {{ $build.Check }} |
| |
108 "@ | Out-File uwbuild-check.ps1 -Encoding utf8 |
| |
109 |
| |
110 .\uwbuild-check.ps1 *> (Join-Path $log_dir $check_log) |
| |
111 |
| |
112 $check = $LASTEXITCODE |
| |
113 {{- end}} |
| |
114 |
| |
115 # ------------------------- |
| |
116 # write result |
| |
117 # ------------------------- |
| |
118 |
| |
119 Add-Content $result_file "{ `"build`": `"{{$i}}`"," |
| |
120 |
| |
121 {{- if $build.Name}} |
| |
122 Add-Content $result_file " `"name`": `"{{$build.Name}}`"," |
| |
123 {{- end}} |
| |
124 |
| |
125 if ($null -ne $configure) { |
| |
126 Add-Content $result_file " `"configure`": `"$configure`"," |
| |
127 } |
| |
128 if ($null -ne $compile) { |
| |
129 Add-Content $result_file " `"compile`": `"$compile`"," |
| |
130 } |
| |
131 if ($null -ne $check) { |
| |
132 Add-Content $result_file " `"check`": `"$check`"" |
| |
133 } |
| |
134 |
| |
135 {{- if eq $i (sub $nbuild 1)}} |
| |
136 Add-Content $result_file "}" |
| |
137 {{ else }} |
| |
138 Add-Content $result_file "}," |
| |
139 {{- end}} |
| |
140 |
| |
141 break |
| |
142 } |
| |
143 |
| |
144 # End Build |
| |
145 {{ end}} |
| |
146 |
| |
147 "]" | Add-Content $result_file |