Skip to content
Closed
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
224 changes: 0 additions & 224 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1877,198 +1877,6 @@ function Start-DevPowerShell {
}
}


<#
.EXAMPLE
PS C:> Copy-MappedFiles -PslMonadRoot .\src\monad

copy files FROM .\src\monad (old location of submodule) TO src/<project> folders
#>
function Copy-MappedFiles {

[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
[string[]]$Path = "$PSScriptRoot",
[Parameter(Mandatory=$true)]
[string]$PslMonadRoot,
[switch]$Force,
[switch]$WhatIf
)

begin {
function MaybeTerminatingWarning {
param([string]$Message)

if ($Force) {
Write-Warning "$Message : ignoring (-Force)"
} elseif ($WhatIf) {
Write-Warning "$Message : ignoring (-WhatIf)"
} else {
throw "$Message : use -Force to ignore"
}
}

if (-not (Test-Path -PathType Container $PslMonadRoot)) {
throw "$pslMonadRoot is not a valid folder"
}

# Do some intelligence to prevent shooting us in the foot with CL management

# finding base-line CL
$cl = git --git-dir="$PSScriptRoot/.git" tag | % {if ($_ -match 'SD.(\d+)$') {[int]$Matches[1]} } | Sort-Object -Descending | Select-Object -First 1
if ($cl) {
log "Current base-line CL is SD:$cl (based on tags)"
} else {
MaybeTerminatingWarning "Could not determine base-line CL based on tags"
}

try {
Push-Location $PslMonadRoot
if (git status --porcelain -uno) {
MaybeTerminatingWarning "$pslMonadRoot has changes"
}

if (git log --grep="SD:$cl" HEAD^..HEAD) {
log "$pslMonadRoot HEAD matches [SD:$cl]"
} else {
Write-Warning "Try to checkout this commit in $pslMonadRoot :"
git log --grep="SD:$cl" | Write-Warning
MaybeTerminatingWarning "$pslMonadRoot HEAD doesn't match [SD:$cl]"
}
} finally {
Pop-Location
}

$map = @{}
}

process {
$map += Get-Mappings $Path -Root $PslMonadRoot
}

end {
$map.GetEnumerator() | % {
New-Item -ItemType Directory (Split-Path $_.Value) -ErrorAction SilentlyContinue > $null
Copy-Item $_.Key $_.Value -Verbose:([bool]$PSBoundParameters['Verbose']) -WhatIf:$WhatIf
}
}
}

function Get-Mappings
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
[string[]]$Path = "$PSScriptRoot",
[string]$Root,
[switch]$KeepRelativePaths
)

begin {
$mapFiles = @()
}

process {
Write-Verbose "Discovering map files in $Path"
$count = $mapFiles.Count

if (-not (Test-Path $Path)) {
throw "Mapping file not found in $mappingFilePath"
}

if (Test-Path -PathType Container $Path) {
$mapFiles += Get-ChildItem -Recurse $Path -Filter 'map.json' -File
} else {
# it exists and it's a file, don't check the name pattern
$mapFiles += Get-ChildItem $Path
}

Write-Verbose "Found $($mapFiles.Count - $count) map files in $Path"
}

end {
$map = @{}
$mapFiles | % {
$file = $_
try {
$rawHashtable = $_ | Get-Content -Raw | ConvertFrom-Json | Convert-PSObjectToHashtable
} catch {
Write-Error "Exception, when processing $($file.FullName): $_"
}

$mapRoot = Split-Path $_.FullName
if ($KeepRelativePaths) {
# not very elegant way to find relative for the current directory path
$mapRoot = $mapRoot.Substring($PSScriptRoot.Length + 1)
# keep original unix-style paths for git
$mapRoot = $mapRoot.Replace('\', '/')
}

$rawHashtable.GetEnumerator() | % {
$newKey = if ($Root) { Join-Path $Root $_.Key } else { $_.Key }
$newValue = if ($KeepRelativePaths) { ($mapRoot + '/' + $_.Value) } else { Join-Path $mapRoot $_.Value }
$map[$newKey] = $newValue
}
}

return $map
}
}


<#
.EXAMPLE Send-GitDiffToSd -diffArg1 32b90c048aa0c5bc8e67f96a98ea01c728c4a5be~1 -diffArg2 32b90c048aa0c5bc8e67f96a98ea01c728c4a5be -AdminRoot d:\e\ps_dev\admin
Apply a single commit to admin folder
#>
function Send-GitDiffToSd {
param(
[Parameter(Mandatory)]
[string]$diffArg1,
[Parameter(Mandatory)]
[string]$diffArg2,
[Parameter(Mandatory)]
[string]$AdminRoot,
[switch]$WhatIf
)

# this is only for windows, because you cannot have SD enlistment on Linux
$patchPath = (ls (Join-Path (get-command git).Source '..\..') -Recurse -Filter 'patch.exe').FullName
$m = Get-Mappings -KeepRelativePaths -Root $AdminRoot
$affectedFiles = git diff --name-only $diffArg1 $diffArg2
$affectedFiles | % {
log "Changes in file $_"
}

$rev = Get-InvertedOrderedMap $m
foreach ($file in $affectedFiles) {
if ($rev.Contains) {
$sdFilePath = $rev[$file]
if (-not $sdFilePath)
{
Write-Warning "Cannot find mapped file for $file, skipping"
continue
}

$diff = git diff $diffArg1 $diffArg2 -- $file
if ($diff) {
log "Apply patch to $sdFilePath"
Set-Content -Value $diff -Path $env:TEMP\diff -Encoding Ascii
if ($WhatIf) {
log "Patch content"
Get-Content $env:TEMP\diff
} else {
& $patchPath --binary -p1 $sdFilePath $env:TEMP\diff
}
} else {
log "No changes in $file"
}
} else {
log "Ignore changes in $file, because there is no mapping for it"
}
}
}

function Start-TypeGen
{
[CmdletBinding()]
Expand Down Expand Up @@ -2346,38 +2154,6 @@ function script:Get-InvertedOrderedMap {
return $res
}


## this function is from Dave Wyatt's answer on
## http://stackoverflow.com/questions/22002748/hashtables-from-convertfrom-json-have-different-type-from-powershells-built-in-h
function script:Convert-PSObjectToHashtable {
param (
[Parameter(ValueFromPipeline)]
$InputObject
)

process {
if ($null -eq $InputObject) { return $null }

if ($InputObject -is [System.Collections.IEnumerable] -and $InputObject -isnot [string]) {
$collection = @(
foreach ($object in $InputObject) { Convert-PSObjectToHashtable $object }
)

Write-Output -NoEnumerate $collection
} elseif ($InputObject -is [psobject]) {
$hash = @{}

foreach ($property in $InputObject.PSObject.Properties) {
$hash[$property.Name] = Convert-PSObjectToHashtable $property.Value
}

$hash
} else {
$InputObject
}
}
}

# this function wraps native command Execution
# for more information, read https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
function script:Start-NativeExecution([scriptblock]$sb, [switch]$IgnoreExitcode)
Expand Down
2 changes: 0 additions & 2 deletions docs/building/windows-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Build PowerShell on Windows for .NET Core
This guide will walk you through building PowerShell on Windows, targeting .NET Core.
We'll start by showing how to set up your environment from scratch.

You can also [build PowerShell for Full .NET framework](windows-full.md) on Windows.

Environment
===========

Expand Down
104 changes: 0 additions & 104 deletions docs/building/windows-full.md

This file was deleted.

Loading