forked from zed-industries/zed
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsetup-windows-dev.ps1
More file actions
112 lines (91 loc) · 3.57 KB
/
setup-windows-dev.ps1
File metadata and controls
112 lines (91 loc) · 3.57 KB
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
104
105
106
107
108
109
110
111
112
param(
[switch]$Run
)
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
function Require-Command {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[string]$Message
)
if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
if ($Message) {
throw $Message
}
throw "Required command not found: $Name"
}
}
function Add-ToPathIfPresent {
param(
[Parameter(Mandatory = $true)]
[string]$PathEntry
)
if ((Test-Path $PathEntry) -and -not (($env:PATH -split ";") -contains $PathEntry)) {
$env:PATH = "$PathEntry;$env:PATH"
}
}
function Ensure-Ninja {
if (Get-Command ninja -ErrorAction SilentlyContinue) {
return
}
Require-Command -Name winget -Message "Ninja is required and winget is not available. Install Ninja manually and re-run this script."
Write-Host "Installing Ninja with winget..."
& winget install --id Ninja-build.Ninja --scope user --accept-package-agreements --accept-source-agreements --silent
Add-ToPathIfPresent -PathEntry (Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Links")
if (-not (Get-Command ninja -ErrorAction SilentlyContinue)) {
throw "Ninja installation completed, but ninja.exe is not visible in PATH yet. Open a new shell and re-run this script."
}
}
function Invoke-BuildCommand {
param(
[Parameter(Mandatory = $true)]
[string[]]$Arguments
)
if ($script:UseLocalGpuiResolved) {
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "cargo-gpui-local.ps1") @Arguments
} else {
& cargo @Arguments
}
}
$repoRoot = Split-Path -Parent $PSScriptRoot
Set-Location $repoRoot
Add-ToPathIfPresent -PathEntry (Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Links")
Require-Command -Name cargo -Message "Cargo is required. Install rustup and the Rust toolchain first."
Require-Command -Name cmake -Message "CMake is required. Install CMake and ensure it is on PATH."
Ensure-Ninja
$script:UseLocalGpuiResolved = $false
$defaultGpuiPath = Join-Path (Split-Path $repoRoot -Parent) "gpui"
if (Test-Path (Join-Path $defaultGpuiPath "crates\gpui\Cargo.toml")) {
$script:UseLocalGpuiResolved = $true
Write-Host "Using sibling GPUI checkout at '$defaultGpuiPath'."
}
Write-Host "Building companion CLI..."
Invoke-BuildCommand -Arguments @("build", "--package", "cli", "--bin", "cli")
if ($Run) {
Write-Host "Building Glass..."
Invoke-BuildCommand -Arguments @("build", "-p", "zed")
$zedBinary = Join-Path $repoRoot "target\debug\zed.exe"
if (-not (Test-Path $zedBinary)) {
throw "Expected Glass binary not found at '$zedBinary'."
}
$cefRuntimeDirectory = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "stage-windows-cef-runtime.ps1")
if (-not $cefRuntimeDirectory) {
throw "Failed to stage the Windows CEF runtime."
}
$cefRuntimeDirectory = $cefRuntimeDirectory.Trim()
$env:CEF_PATH = $cefRuntimeDirectory
Add-ToPathIfPresent -PathEntry $cefRuntimeDirectory
Write-Host "Launching Glass..."
Start-Process -FilePath $zedBinary -WorkingDirectory $repoRoot | Out-Null
} else {
Write-Host "Building Glass..."
Invoke-BuildCommand -Arguments @("build", "-p", "zed")
Write-Host ""
Write-Host "Environment is ready."
if ($script:UseLocalGpuiResolved) {
Write-Host "Run '.\script\cargo-gpui-local.ps1 run -p zed' or re-run this script with -Run."
} else {
Write-Host "Run 'cargo run -p zed' or re-run this script with -Run."
}
}