forked from cloudhan/jax-windows-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbazel-build-cpu.ps1
71 lines (55 loc) · 1.93 KB
/
bazel-build-cpu.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
param(
[Parameter(Mandatory = $true)]
[String]$bazel_path
)
. (Join-Path (Split-Path $MyInvocation.MyCommand.Path) functions.ps1)
$ErrorActionPreference = "Stop"
# path for patch.exe and realpath.exe
$msys2_path = "C:\msys64\usr\bin"
[System.Collections.ArrayList]$new_path = `
'C:\Windows\System32', `
'C:\Windows', `
'C:\Windows\System32\Wbem', `
'C:\Windows\System32\WindowsPowerShell\v1.0'
Push-Environment
Push-Location
try {
# insert your path here
$new_path.Insert(0, 'C:\Program Files\Git\cmd')
$new_path.Insert(0, 'C:\tools\bazelisk')
$new_path.Insert(0, "$msys2_path")
if ($env:pythonLocation) {
# bring github actions python into path
$new_path.Insert(0, "$env:pythonLocation")
$new_path.Insert(0, "$env:pythonLocation/Scripts")
}
$env:PATH = $new_path -join ";"
Set-VSEnv
# bring conda python into environment, this supersede MSYS2's python and
# maybe VS's python
# conda activate $conda_env
# auto-detection is causing M$ banner/header/logo being included in the the
# vcpath, workaround it.
$env:BAZEL_VC = $env:VCINSTALLDIR
git checkout .bazelrc
echo 'try-import %workspace%/../windows_configure.bazelrc' >> .bazelrc
mkdir ~/bzl_out -ErrorAction Continue
New-Item -Type Junction -Target (Resolve-Path ~/bzl_out) -Path D:/bzl_out -ErrorAction Continue
python .\build\build.py `
--noenable_cuda `
--bazel_path="$bazel_path" `
--bazel_startup_options="--output_user_root=D:/bzl_out"
if ($LASTEXITCODE -ne 0) {
throw "last command exit with $LASTEXITCODE"
}
if ((ls dist).Count -ne 1) {
throw "number of whl files != 1"
}
$name = (ls dist)[0].Name
mkdir "bazel-dist/cpu" -ErrorAction 0
mv -Force "dist/$name" "bazel-dist/cpu/$name"
}
finally {
Pop-Location
Pop-Environment
}