aboutsummaryrefslogtreecommitdiff
path: root/scripts/all-dependencies.ps1
blob: 945f301da0b51ab121ec027b788f60eb8449f513 (plain) (blame)
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
param(
  [Alias("f")][switch]$Force = $false
)

$ErrorActionPreference = 'Stop'

$DidAnything = $false;

$BUN_BASE_DIR = if ($env:BUN_BASE_DIR) { $env:BUN_BASE_DIR } else { Join-Path $PSScriptRoot '..' }
$BUN_DEPS_DIR = if ($env:BUN_DEPS_DIR) { $env:BUN_DEPS_DIR } else { Join-Path $BUN_BASE_DIR 'src\deps' }
$BUN_DEPS_OUT_DIR = if ($env:BUN_DEPS_OUT_DIR) { $env:BUN_DEPS_OUT_DIR } else { $BUN_DEPS_DIR }

function Build-Dependency {
  param(
    $Script,
    [string[]]$Outputs
  )

  $ScriptPath = Join-Path $PSScriptRoot "build-$Script.ps1"
  
  if (!$Force) {
    foreach ($Output in $Outputs) {
      $OutputPath = Join-Path $BUN_DEPS_OUT_DIR $Output
      if (Test-Path $OutputPath) {
        Write-Host "$Script - already built"
        return
      }
    }
  }
  else {
    Remove-Item $Outputs -ErrorAction SilentlyContinue
  }

  Write-Host "$Script - Building"
  Push-Location $PSScriptRoot
  try {
    & $ScriptPath
  }
  catch {
    Write-Host "Failed to build $Script"
    throw $_
  }
  finally {
    Pop-Location
  }

  $Script:DidAnything = $true
}

Build-Dependency `
  -Script "base64" `
  -Outputs @("base64.lib")
Build-Dependency `
  -Script "boringssl" `
  -Outputs @("crypto.lib", "ssl.lib", "decrepit.lib")
Build-Dependency `
  -Script "cares" `
  -Outputs @("cares.lib")
Build-Dependency `
  -Script "libarchive" `
  -Outputs @("archive.lib")
Build-Dependency `
  -Script "lolhtml" `
  -Outputs @("lolhtml.lib")
Build-Dependency `
  -Script "mimalloc" `
  -Outputs @("mimalloc.lib")
# Build-Dependency `
#   -Script "tinycc" `
#   -Outputs @("tcc.lib")
Build-Dependency `
  -Script "zlib" `
  -Outputs @("zlib.lib")
Build-Dependency `
  -Script "zstd" `
  -Outputs @("zstd.lib")
Build-Dependency `
  -Script "libuv" `
  -Outputs @("libuv.lib")

if (!($Script:DidAnything)) {
  Write-Host "(run with -Force to rebuild all)"
}