From 979610035af7edb4e7123245e1a5135e56bb0ccb Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 18:59:06 -0700 Subject: [PATCH 1/8] Update .gitignore --- .gitignore | 2 ++ src/powershell-native/.gitignore | 1 + 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ea82ac5cd..5ed5c1628 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ dotnet-install.ps1 # VS auto-generated solution files for project.json solutions *.xproj *.xproj.user +*.suo + # Ignore executables *.exe diff --git a/src/powershell-native/.gitignore b/src/powershell-native/.gitignore index 62f5f82d5..4f159ef0a 100644 --- a/src/powershell-native/.gitignore +++ b/src/powershell-native/.gitignore @@ -4,6 +4,7 @@ CMakeCache.txt CMakeFiles/ PowerShell.sln Win32/ +x64/ ZERO_CHECK.vcxproj ZERO_CHECK.vcxproj.filters cmake_install.cmake From 1ece589975907d7cb02e0f61c227d0229235c435 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 18:59:46 -0700 Subject: [PATCH 2/8] Add first version of docs/building/internals.md --- docs/building/internals.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/building/internals.md diff --git a/docs/building/internals.md b/docs/building/internals.md new file mode 100644 index 000000000..8313fee31 --- /dev/null +++ b/docs/building/internals.md @@ -0,0 +1,27 @@ +Internals of build process +========================================= + +The purpose of this document is to explain build process **internals** with subtle nuances. +This document is not by any means complete. +The ultimate source of truth is the code in `.\build.psm1` that's getting executed on the corresponding CI system. + +This document assumes, that you can successfully build PowerShell from sources for your platform. + + +Top directory +----------- + +We are calling `dotnet` tool build for `$Top` directory + +- `src\powershell` for CoreCLR builds (all platforms) +- `src\Microsoft.PowerShell.ConsoleHost` for FullCLR builds (Windows only) + +Modules +---------- + +There are 3 modules directories with the same purpose: they have **content** files (i.e. `*.psm1`, `*.psd1`) +which would be binplaced by `dotnet` + +- `src\Modules` shared between all flavours +- `src\Microsoft.PowerShell.ConsoleHost\Modules` FullCLR (Windows) +- `src\powershell\Modules` CoreCLR (all platforms) From d5060bc7e36163d53811645386226369cf5cbf05 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 19:07:49 -0700 Subject: [PATCH 3/8] build.psm1: Add Copy-MappedFiles -WhatIf switch --- build.psm1 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build.psm1 b/build.psm1 index f830a5d71..3aa158a05 100644 --- a/build.psm1 +++ b/build.psm1 @@ -670,7 +670,8 @@ function Copy-MappedFiles { [string[]]$Path = "$PSScriptRoot", [Parameter(Mandatory=$true)] [string]$PslMonadRoot, - [switch]$Force + [switch]$Force, + [switch]$WhatIf ) begin @@ -683,6 +684,10 @@ function Copy-MappedFiles { { Write-Warning "$Message : ignoring (-Force)" } + elseif ($WhatIf) + { + Write-Warning "$Message : ignoring (-WhatIf)" + } else { throw "$Message : use -Force to ignore" @@ -745,14 +750,7 @@ function Copy-MappedFiles { $map.GetEnumerator() | % { New-Item -ItemType Directory (Split-Path $_.Value) -ErrorAction SilentlyContinue > $null - if ($PSBoundParameters['Verbose']) - { - Copy-Item $_.Key $_.Value -Verbose - } - else - { - Copy-Item $_.Key $_.Value - } + Copy-Item $_.Key $_.Value -Verbose:([bool]$PSBoundParameters['Verbose']) -WhatIf:$WhatIf } } } From f9b11ed9662b1fad567f918c6defa1d760a7a9e5 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 19:17:45 -0700 Subject: [PATCH 4/8] Add info about dummy dependencies --- docs/building/internals.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/building/internals.md b/docs/building/internals.md index 8313fee31..ca22828a8 100644 --- a/docs/building/internals.md +++ b/docs/building/internals.md @@ -16,6 +16,24 @@ We are calling `dotnet` tool build for `$Top` directory - `src\powershell` for CoreCLR builds (all platforms) - `src\Microsoft.PowerShell.ConsoleHost` for FullCLR builds (Windows only) + +### Dummy dependencies + +We use dummy dependencies between project.json files to leverage `dotnet` build functionality. +For example, `src\Microsoft.PowerShell.ConsoleHost\project.json` has dependency on `Microsoft.PowerShell.PSReadLine`, +but in reality, there is no build dependency. + +Dummy dependencies allows us to build just `$Top` folder, instead of building several folders. + +### Dummy dependencies rules + +* If assembly is part of FullCLR build, +it should be listed as a dependency for FullCLR $Top folder (src\Microsoft.PowerShell.ConsoleHost) + +* If assembly is part of CoreCLR build, +it should be listed as a dependency for CoreCLR $Top folder (src\powershell) + + Modules ---------- From 05ecfd33d32e080406fdd295d600232ab9024693 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 19:18:08 -0700 Subject: [PATCH 5/8] Fix indentation in project.json --- src/Microsoft.PowerShell.ConsoleHost/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/project.json b/src/Microsoft.PowerShell.ConsoleHost/project.json index e2b59dc7d..a64e63859 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/project.json +++ b/src/Microsoft.PowerShell.ConsoleHost/project.json @@ -28,7 +28,7 @@ "dependencies": { "Microsoft.PowerShell.PSReadLine": "1.0.0-*", - "Microsoft.PowerShell.Commands.Diagnostics": "1.0.0-*", + "Microsoft.PowerShell.Commands.Diagnostics": "1.0.0-*", "Microsoft.PowerShell.Commands.Management": "1.0.0-*", "Microsoft.PowerShell.Commands.Utility": "1.0.0-*", "Microsoft.PowerShell.LocalAccounts": "1.0.0-*" From 2cb0461b3d94e0330d4f77ccdb33983c6629ad5b Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 19:19:23 -0700 Subject: [PATCH 6/8] Move LocalAccounts ps1xml, psd1 files from powershell/map.json to Modules/map.json --- src/Modules/map.json | 4 +++- src/powershell/map.json | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Modules/map.json b/src/Modules/map.json index f6a5fae62..20161971a 100644 --- a/src/Modules/map.json +++ b/src/Modules/map.json @@ -15,5 +15,7 @@ "monad/miscfiles/modules/Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1": "Microsoft.PowerShell.Host/Microsoft.PowerShell.Host.psd1", "monad/miscfiles/modules/AppxProvider/AppxProvider.Resource.psd1": "AppxProvider/AppxProvider.Resource.psd1", "monad/miscfiles/modules/AppxProvider/AppxProvider.psd1": "AppxProvider/AppxProvider.psd1", - "monad/miscfiles/modules/PSGet/PSGet.Resource.psd1": "PSGet/PSGet.Resource.psd1" + "monad/miscfiles/modules/PSGet/PSGet.Resource.psd1": "PSGet/PSGet.Resource.psd1", + "monad/src/LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1": "Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1", + "monad/src/LocalAccounts/LocalAccounts.format.ps1xml": "Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml" } diff --git a/src/powershell/map.json b/src/powershell/map.json index 244c3606d..bde38359e 100644 --- a/src/powershell/map.json +++ b/src/powershell/map.json @@ -1,6 +1,4 @@ { "monad/miscfiles/modules/Microsoft.PowerShell.Diagnostics/CoreClr/Microsoft.PowerShell.Diagnostics.psd1": "Modules/Microsoft.PowerShell.Diagnostics/Microsoft.PowerShell.Diagnostics.psd1", - "monad/miscfiles/modules/Microsoft.PowerShell.Utility/CoreClr/Microsoft.PowerShell.Utility.psd1": "Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1", - "monad/src/LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1": "Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1", - "monad/src/LocalAccounts/LocalAccounts.format.ps1xml": "Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml" + "monad/miscfiles/modules/Microsoft.PowerShell.Utility/CoreClr/Microsoft.PowerShell.Utility.psd1": "Modules/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1" } From ee4d6ab8b324fcb67bb41dbf6061b4e48246436f Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 19:25:28 -0700 Subject: [PATCH 7/8] Move LocalAccounts ps1xml, psd1 files on the filesystem --- .../LocalAccounts.format.ps1xml | 0 .../Microsoft.PowerShell.LocalAccounts.psd1 | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{powershell => }/Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml (100%) rename src/{powershell => }/Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1 (100%) diff --git a/src/powershell/Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml b/src/Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml similarity index 100% rename from src/powershell/Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml rename to src/Modules/Microsoft.PowerShell.LocalAccounts/LocalAccounts.format.ps1xml diff --git a/src/powershell/Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1 b/src/Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1 similarity index 100% rename from src/powershell/Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1 rename to src/Modules/Microsoft.PowerShell.LocalAccounts/Microsoft.PowerShell.LocalAccounts.psd1 From 60b6f7287d65edb05253e11de621d022af3c6052 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Wed, 15 Jun 2016 20:16:38 -0700 Subject: [PATCH 8/8] Fix our ResGen to make LocalAccounts work --- build.psm1 | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/build.psm1 b/build.psm1 index 3aa158a05..a514fa6b8 100644 --- a/build.psm1 +++ b/build.psm1 @@ -884,21 +884,12 @@ function Start-ResGen "Microsoft.PowerShell.Security", "System.Management.Automation") | % { $module = $_ - Get-ChildItem "$PSScriptRoot/src/$module/resources" | % { + Get-ChildItem "$PSScriptRoot/src/$module/resources" -Filter '*.resx' | % { $className = $_.Name.Replace('.resx', '') $xml = [xml](Get-Content -raw $_.FullName) $fileName = $className - $namespace = '' - - $lastIndexOfDot = $className.LastIndexOf(".") - if ($lastIndexOfDot -ne -1) - { - $namespace = $className.Substring(0, $lastIndexOfDot) - $className = $className.Substring($lastIndexOfDot + 1) - } - - $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className -NamespaceName $namespace + $genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className $outPath = "$PSScriptRoot/src/$module/gen/$fileName.cs" Write-Verbose "ResGen for $outPath" New-Item -Type Directory -ErrorAction SilentlyContinue (Split-Path $outPath) > $null @@ -996,7 +987,23 @@ function script:Start-NativeExecution([scriptblock]$sb) function script:Get-StronglyTypeCsFileForResx { - param($xml, $ModuleName, $ClassName, $NamespaceName = '') + param($xml, $ModuleName, $ClassName) + + # Example + # + # $ClassName = Full.Name.Of.The.ClassFoo + # $shortClassName = ClassFoo + # $namespaceName = Full.Name.Of.The + + $shortClassName = $ClassName + $namespaceName = $null + + $lastIndexOfDot = $className.LastIndexOf(".") + if ($lastIndexOfDot -ne -1) + { + $namespaceName = $className.Substring(0, $lastIndexOfDot) + $shortClassName = $className.Substring($lastIndexOfDot + 1) + } $banner = @' //------------------------------------------------------------------------------ @@ -1046,7 +1053,7 @@ internal class {0} {{ internal static global::System.Resources.ResourceManager ResourceManager {{ get {{ if (object.ReferenceEquals(resourceMan, null)) {{ - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{1}.resources.{0}", typeof({0}).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{1}.resources.{3}", typeof({0}).GetTypeInfo().Assembly); resourceMan = temp; }} return resourceMan; @@ -1089,9 +1096,9 @@ internal class {0} {{ } } | Out-String - $bodyCode = $body -f $ClassName,$ModuleName,$entries + $bodyCode = $body -f $shortClassName,$ModuleName,$entries,$ClassName - if ($NamespaceName -ne '') + if ($NamespaceName) { $bodyCode = $namespace -f $NamespaceName, $bodyCode }