aboutsummaryrefslogtreecommitdiff
path: root/scripts/build-libuv.ps1
blob: 9a10121d83cdc243c306f2737cf8d2eacc460f7b (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
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
. (Join-Path $PSScriptRoot "env.ps1")
$CWD = Get-Location

$Source = (Join-Path $PSScriptRoot "../src/deps/libuv")
$Commit = "da527d8d2a908b824def74382761566371439003"

if (!(Test-Path -PathType Container $Source)) {
  Write-Host "Cloning libuv: $Commit"
  New-Item -ItemType Directory -Force -Path $Source
  Push-Location $Source
  try {
    Run git init
    Run git remote add origin "https://github.com/libuv/libuv"
    Run git fetch --depth 1 origin $Commit
    Run git checkout FETCH_HEAD
  } finally { Pop-Location }
} else {
  Push-Location $Source
  try {
    $CurrentCommit = git rev-parse HEAD
    if ($CurrentCommit -ne $Commit) {
      Write-Host "Updating libuv: $Commit"
      Run git fetch --depth 1 origin $Commit
      Run git checkout FETCH_HEAD
    }
  } finally { Pop-Location }
}

Push-Location $Source
try {
  $null = mkdir build -ErrorAction SilentlyContinue
  Set-Location build
  
  Run cmake .. @CMAKE_FLAGS "-DCMAKE_C_FLAGS=/DWIN32 /D_WINDOWS -Wno-int-conversion"
  Run cmake --build . --clean-first --config Release

  Copy-Item libuv.lib $BUN_DEPS_OUT_DIR
  Write-Host "-> libuv.lib"
} finally { Pop-Location }