-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvoke-Make.ps1
103 lines (78 loc) · 2.28 KB
/
Invoke-Make.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
<#PSScriptInfo
.VERSION 1.0
.GUID 32f9efa8-be81-4ac5-8f07-e1f57d528147
.AUTHOR Dan Backes
.COMPANYNAME
.COPYRIGHT
.TAGS
.LICENSEURI
.PROJECTURI https://github.com/dpbackes/Invoke-Make
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.SYNOPSIS
A PowerShell wrapper around Gnu Make
.DESCRIPTION
Invoke-Make as a Powershell wrapper around Gnu Make for Windows. On first use, the script will automatically download the necessary binaries. Once the binaries are downloaded, can be use just like make on a *nix system.
.INPUTS
None
.OUTPUTS
None
.NOTES
Version: 1.0
Author: Dan Backes
Creation Date: 8-May-2017
.EXAMPLE
Invoke-Make build
Runs the "build" target in your makefile
.EXAMPLE
Invoke-Make tests
Runs the "tests" target inyour makefile
.Link
https://github.com/dpbackes/Invoke-Make
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]] $ScriptArgs
)
$folder = Join-Path $PSScriptRoot "Make"
$unzipPath = $(Join-Path $folder "files")
$pathToBin = $(Join-Path $unzipPath "bin\make.exe")
$makeZip = "https://downloads.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-bin.zip"
$depsZip = "https://downloads.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-dep.zip"
$makeZipDest = Join-Path $folder "make.zip"
$depZipDest = Join-Path $folder "deps.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip([string]$zipfile, [string]$outpath)
{
Write-Output "Unzipping $zipFile to $outpath"
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
function DownloadIfMissing([string]$source, [string]$dest)
{
if ($(Test-Path $dest))
{
Write-Output "$dest already exists, skipping download"
return
}
Write-Output "Downloading $source to $dest"
Start-BitsTransfer -Source $source -Destination $dest
}
if (!$(Test-Path $pathToBin))
{
Write-Output "Make executable not detected. Downloading..."
if(!$(Test-Path $folder ))
{
New-Item $folder -Type Directory | Out-Null
}
DownloadIfMissing $makeZip $makeZipDest
DownloadIfMissing $depsZip $depZipDest
Unzip $makeZipDest $unzipPath
Unzip $depZipDest $unzipPath
}
& $pathToBin @ScriptArgs