-
Notifications
You must be signed in to change notification settings - Fork 3
/
with-mlb-dependencies.ps1
91 lines (64 loc) · 1.78 KB
/
with-mlb-dependencies.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
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
if ($args.Count -lt 1) {
"Usage: with-mlb-dependencies <buildcommand> <buildargs>"
exit 1
}
$mydir = Split-Path -Parent $PSCommandPath
. $mydir/smlbuild-include.ps1
$mlb = ""
$sml = ""
$output = ""
$expecting_output = $false
$args = $args -Replace "_DASH_","-"
foreach ($arg in $args) {
if ($expecting_output) {
$output = $arg
$expecting_output = $false
} else {
if ($arg -match "[.]mlb$") {
$mlb = $arg
} elseif ($arg -match "[.]sml") {
$sml = $arg
} elseif ($arg -match "-o") {
$expecting_output = $true
} elseif ($arg -match "-output") {
$expecting_output = $true
}
if ($mlb) {
break
}
}
}
"mlb = $mlb" | Out-Host
"sml = $sml" | Out-Host
"output = $output" | Out-Host
$compiler=$args[0]
$compiler_args=$args[1..$args.length]
"$compiler $compiler_args" | Out-File ".mlb-dependencies-command"
&$compiler $compiler_args | Tee-Object -FilePath ".mlb-dependencies-output" | Out-Host
"Completed" | Out-Host
if ($mlb) {
if (!$output) {
$output = $mlb -replace "[.]mlb$",".exe"
}
$base = $output -replace "[.]exe$",""
$deps = "$base.deps"
"Writing dependencies to $deps"
$lines = @(listMLB $mlb)
if ($lines -match "^Error: ") {
$lines -match "^Error: "
exit 1
}
$lines = $lines -replace "^","${output}: "
$lines | Out-File -Encoding "ASCII" $deps
} elseif ($sml) {
if (!$output) {
$output = $sml -replace "[.]mlb$",".exe"
}
$base = $output -replace "[.]exe$",""
$deps = "$base.deps"
"Writing dependencies to $deps"
"${target}: $sml" | Out-File -Encoding "ASCII" $deps
}
Get-Content ".mlb-dependencies-output" | Out-Host