Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
0-powershell-crossplatform
0xfeeddeadbeef
100ms
2.x
2ae5d07
32-bit
64-bit
Expand Down Expand Up @@ -379,6 +380,7 @@ lynda.com
lzybkr
mababio
macos
macports
maertendmsft
mahawar
markekraus
Expand Down
17 changes: 15 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ function Get-EnvironmentInformation
$environment += @{'nugetPackagesRoot' = "${env:HOME}/.nuget/packages"}
}

if ($Environment.IsMacOS) {
$environment += @{'UsingHomebrew' = [bool](Get-Command brew -ErrorAction ignore)}
$environment += @{'UsingMacports' = [bool](Get-Command port -ErrorAction ignore)}

if (-not($environment.UsingHomebrew -or $environment.UsingMacports)) {
throw "Neither Homebrew nor MacPorts is installed on this system, visit https://brew.sh/ or https://www.macports.org/ to continue"
}
}

if ($Environment.IsLinux) {
$LinuxInfo = Get-Content /etc/os-release -Raw | ConvertFrom-StringData

Expand Down Expand Up @@ -1710,7 +1719,11 @@ function Start-PSBootstrap {
Invoke-Expression "$baseCommand $Deps"
}
} elseif ($Environment.IsMacOS) {
precheck 'brew' "Bootstrap dependency 'brew' not found, must install Homebrew! See https://brew.sh/"
if ($Environment.UsingHomebrew) {
$PackageManager = "brew"
} elseif ($Environment.UsingMacports) {
$PackageManager = "$sudo port"
}

# Build tools
$Deps += "cmake"
Expand All @@ -1720,7 +1733,7 @@ function Start-PSBootstrap {

# Install dependencies
# ignore exitcode, because they may be already installed
Start-NativeExecution { brew install $Deps } -IgnoreExitcode
Start-NativeExecution ([ScriptBlock]::Create("$PackageManager install $Deps")) -IgnoreExitcode
} elseif ($Environment.IsAlpine) {
$Deps += 'libunwind', 'libcurl', 'bash', 'cmake', 'clang', 'build-base', 'git', 'curl'

Expand Down
4 changes: 2 additions & 2 deletions docs/building/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ building on macOS is almost identical.

## Environment

You will want [Homebrew](https://brew.sh/), the missing package manager for macOS.
You will want [Homebrew](https://brew.sh/) or [MacPorts](https://www.macports.org/), the missing package manager for macOS.
Once installed, follow the same instructions to download and
install a self-hosted copy of PowerShell on your macOS machine.
From `pwsh.exe`, run `Import-Module ./build.psm1` and use `Start-PSBootstrap` to install the dependencies.

The `Start-PSBootstrap` function does the following:

- Uses `brew` to install CMake, OpenSSL, and GNU WGet
- Uses `brew` or `port` to install CMake, OpenSSL, and GNU WGet
- Uninstalls any prior versions of .NET CLI
- Downloads and installs .NET Core SDK to `~/.dotnet`

Expand Down