mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Additional code changes and link fixes
This commit is contained in:
1 parent
8948aa7efb
commit
77a26b6b77
14 files changed
+563
-83
No files matched your search
+67
-34
@@ -62,7 +62,7 @@ function Start-PSBuild {
|
|||||||
[ValidateSet('x86', 'x64')]
|
[ValidateSet('x86', 'x64')]
|
||||||
[string]$NativeHostArch = "x64",
|
[string]$NativeHostArch = "x64",
|
||||||
|
|
||||||
[ValidateSet('Linux', 'Debug', 'Release', '')]
|
[ValidateSet('Linux', 'Debug', 'Release', '')] # We might need "Checked" as well
|
||||||
[string]$Configuration
|
[string]$Configuration
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -156,36 +156,36 @@ function Start-PSBuild {
|
|||||||
$Arguments += "--runtime", $Options.Runtime
|
$Arguments += "--runtime", $Options.Runtime
|
||||||
|
|
||||||
# handle Restore
|
# handle Restore
|
||||||
if ($Restore -or -not (Test-Path "$($Options.Top)/project.lock.json")) {
|
# if ($Restore -or -not (Test-Path "$($Options.Top)/project.lock.json")) {
|
||||||
log "Run dotnet restore"
|
# log "Run dotnet restore"
|
||||||
|
|
||||||
$RestoreArguments = @("--verbosity")
|
# $RestoreArguments = @("--verbosity")
|
||||||
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
|
# if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
|
||||||
$RestoreArguments += "Info"
|
# $RestoreArguments += "Info"
|
||||||
} else {
|
# } else {
|
||||||
$RestoreArguments += "Warning"
|
# $RestoreArguments += "Warning"
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
$RestoreArguments += "$PSScriptRoot"
|
# $RestoreArguments += "$PSScriptRoot"
|
||||||
|
#
|
||||||
Start-NativeExecution { dotnet restore $RestoreArguments }
|
# Start-NativeExecution { dotnet restore $RestoreArguments }
|
||||||
}
|
# }
|
||||||
|
|
||||||
# handle ResGen
|
# handle ResGen
|
||||||
# Heuristic to run ResGen on the fresh machine
|
# Heuristic to run ResGen on the fresh machine
|
||||||
if ($ResGen -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.ConsoleHost/gen"))
|
# if ($ResGen -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.ConsoleHost/gen"))
|
||||||
{
|
# {
|
||||||
log "Run ResGen (generating C# bindings for resx files)"
|
# log "Run ResGen (generating C# bindings for resx files)"
|
||||||
Start-ResGen
|
# Start-ResGen
|
||||||
}
|
# }
|
||||||
|
|
||||||
# handle xaml files
|
# handle xaml files
|
||||||
# Heuristic to resolve xaml on the fresh machine
|
# Heuristic to resolve xaml on the fresh machine
|
||||||
if ($FullCLR -and ($XamlGen -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.Activities/gen/*.g.cs")))
|
# if ($FullCLR -and ($XamlGen -or -not (Test-Path "$PSScriptRoot/src/Microsoft.PowerShell.Activities/gen/*.g.cs")))
|
||||||
{
|
# {
|
||||||
log "Run XamlGen (generating .g.cs and .resources for .xaml files)"
|
# log "Run XamlGen (generating .g.cs and .resources for .xaml files)"
|
||||||
Start-XamlGen -MSBuildConfiguration $msbuildConfiguration
|
# Start-XamlGen -MSBuildConfiguration $msbuildConfiguration
|
||||||
}
|
# }
|
||||||
|
|
||||||
# Build native components
|
# Build native components
|
||||||
if ($IsLinux -or $IsOSX) {
|
if ($IsLinux -or $IsOSX) {
|
||||||
@@ -217,6 +217,12 @@ function Start-PSBuild {
|
|||||||
try {
|
try {
|
||||||
Push-Location "$PSScriptRoot\src\powershell-native"
|
Push-Location "$PSScriptRoot\src\powershell-native"
|
||||||
|
|
||||||
|
$vcPath = (Get-Item(Join-Path -Path "$env:VS140COMNTOOLS" -ChildPath '../../vc')).FullName
|
||||||
|
if ((Test-Path -Path $vcPath\vcvarsall.bat) -eq $false)
|
||||||
|
{
|
||||||
|
throw "Could not find Visual Studio vcvarsall.bat at" + $vcPath
|
||||||
|
}
|
||||||
|
|
||||||
# Compile native resources
|
# Compile native resources
|
||||||
@("nativemsh/pwrshplugin") | % {
|
@("nativemsh/pwrshplugin") | % {
|
||||||
$nativeResourcesFolder = $_
|
$nativeResourcesFolder = $_
|
||||||
@@ -224,18 +230,46 @@ function Start-PSBuild {
|
|||||||
& $mcexe -o -d -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder
|
& $mcexe -o -d -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmakeGenerator) {
|
$overrideFlags = "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$PSScriptRoot\src\powershell-native\windows-compiler-override.txt"
|
||||||
Start-NativeExecution { cmake -G $cmakeGenerator . }
|
$vcArch = "Win64"
|
||||||
} else {
|
$cmakeGenerator = "Visual Studio 14 2015 $vcArch"
|
||||||
Start-NativeExecution { cmake . }
|
# $CMakeArguments = "-G $cmakeGenerator ."
|
||||||
}
|
$vcPlatform = "x64"
|
||||||
|
$location = Get-Location
|
||||||
Start-NativeExecution { msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration }
|
# $MSBuildArguments = "ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration"
|
||||||
|
# if ($cmakeGenerator) {
|
||||||
|
# Start-NativeExecution { cmake $overrideFlags -G $cmakeGenerator . }
|
||||||
|
# } else {
|
||||||
|
# Start-NativeExecution { cmake $overrideFlags . }
|
||||||
|
# }
|
||||||
|
# #
|
||||||
|
# # BUILD_ONECORE
|
||||||
|
# #
|
||||||
|
$command = @"
|
||||||
|
cmd.exe /C cd /d "$location" "&" "$($vcPath)\vcvarsall.bat" "$vcPlatform" "&" cmake "$overrideFlags" -DBUILD_ONECORE=ON -G "$cmakeGenerator" . "&" msbuild ALL_BUILD.vcxproj "/p:Configuration=$msbuildConfiguration"
|
||||||
|
"@
|
||||||
|
#cmd.exe /C cd /d "$location" "&" "$($vcPath)\vcvarsall.bat" "$vcPlatform" "&" "$cmakeCmd" "&" "msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration"
|
||||||
|
# "&" exit
|
||||||
|
log " Executing command: $command"
|
||||||
|
#Start-NativeExecution { msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration }
|
||||||
|
Start-NativeExecution { Invoke-Expression -Command:$command }
|
||||||
|
|
||||||
|
#
|
||||||
|
# NOT BUILD_ONECORE
|
||||||
|
#
|
||||||
|
$command = @"
|
||||||
|
cmd.exe /C cd /d "$location" "&" "$($vcPath)\vcvarsall.bat" "$vcPlatform" "&" cmake "$overrideFlags" -DBUILD_ONECORE=OFF -G "$cmakeGenerator" . "&" msbuild ALL_BUILD.vcxproj "/p:Configuration=$msbuildConfiguration"
|
||||||
|
"@
|
||||||
|
#cmd.exe /C cd /d "$location" "&" "$($vcPath)\vcvarsall.bat" "$vcPlatform" "&" "$cmakeCmd" "&" "msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration"
|
||||||
|
# "&" exit
|
||||||
|
log " Executing command: $command"
|
||||||
|
#Start-NativeExecution { msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration }
|
||||||
|
Start-NativeExecution { Invoke-Expression -Command:$command }
|
||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
throw "All done"
|
||||||
}
|
}
|
||||||
|
|
||||||
# handle TypeGen
|
# handle TypeGen
|
||||||
@@ -254,7 +288,6 @@ function Start-PSBuild {
|
|||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1312,7 +1345,7 @@ function script:Start-NativeExecution([scriptblock]$sb)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
& $sb
|
& $sb
|
||||||
# note, if $sb doens't have a native invokation, $LASTEXITCODE will
|
# note, if $sb doens't have a native invocation, $LASTEXITCODE will
|
||||||
# point to the obsolete value
|
# point to the obsolete value
|
||||||
if ($LASTEXITCODE -ne 0)
|
if ($LASTEXITCODE -ne 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,27 +1,385 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.4)
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
project(PowerShell)
|
project(PowerShellNative)
|
||||||
|
|
||||||
add_compile_options()
|
#
|
||||||
|
# Verify prerequisites
|
||||||
|
#
|
||||||
|
if (NOT $ENV{${WindowsSDKVersion}})
|
||||||
|
message (FATAL_ERROR "WindowsSDKVersion environment variable not found")
|
||||||
|
endif ()
|
||||||
|
|
||||||
# set the output path for `powershell.exe`
|
if (NOT $ENV{${Platform}})
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/../Microsoft.PowerShell.ConsoleHost")
|
message(FATAL_ERROR "Platform environment variable not found")
|
||||||
|
else ()
|
||||||
|
SET(WindowsSDKPlatform "$ENV{Platform}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the path to the Windows SDK build tools.
|
||||||
|
#
|
||||||
|
if (WindowsSDKPlatform STREQUAL "x64" OR WindowsSDKPlatform STREQUAL "X64" OR WindowsSDKPlatform STREQUAL "amd64" OR WindowsSDKPlatform STREQUAL "AMD64")
|
||||||
|
# Normalize the platform name
|
||||||
|
SET(WindowsSDKPlatform "x64")
|
||||||
|
elseif (WindowsSDKPlatform STREQUAL "x86" OR WindowsSDKPlatform STREQUAL "X86")
|
||||||
|
# Normalize the platform name
|
||||||
|
SET(WindowsSDKPlatform "x86")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unsupported WindowsSDKPlatform ${WindowsSDKPlatform}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#
|
||||||
|
# set the output path for all binaries
|
||||||
|
#
|
||||||
|
if (BUILD_ONECORE)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/Bin/CoreClr")
|
||||||
|
else ()
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/Bin/FullClr")
|
||||||
|
endif (BUILD_ONECORE)
|
||||||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||||
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||||
|
message(" Setting output directory for ${OUTPUTCONFIG} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||||
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
|
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Definitions for ease of reading
|
||||||
|
#
|
||||||
|
SET (WIN_VERSION_WIN10_RS1 0x0A000002)
|
||||||
|
SET (WIN_VERSION_WIN10_TH2 0x0A000001)
|
||||||
|
SET (WIN_VERSION_WIN10 0x0A00)
|
||||||
|
SET (WIN_VERSION_WINTHRESHOLD 0x0A00)
|
||||||
|
SET (WIN_VERSION_WINBLUE 0x0603)
|
||||||
|
SET (WIN_VERSION_WIN8 0x0602)
|
||||||
|
SET (WIN_VERSION_WIN7 0x0601)
|
||||||
|
SET (NTDDI_VERSION_WIN7 0x06010000)
|
||||||
|
SET (WIN_VERSION_VISTA 0x0600)
|
||||||
|
SET (WIN_VERSION_LONGHORN 0x0600)
|
||||||
|
SET (WIN_VERSION_WS03 0x0502)
|
||||||
|
SET (WIN_VERSION_WINXP 0x0501)
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** Original flags: BEGIN
|
||||||
|
# ***
|
||||||
#
|
#
|
||||||
# TODO: Will this interfere with OneCore compilations?
|
# TODO: Will this interfere with OneCore compilations?
|
||||||
#
|
#
|
||||||
# set these flags, so build does static linking for msvcr120.dll
|
# set these flags, so build does static linking for msvcr120.dll
|
||||||
# otherwise this dll need to be present on the system
|
# otherwise this dll need to be present on the system
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||||
|
|
||||||
# Compiler flags that are universal to all powershell native binaries
|
# Compiler flags that are universal to all powershell native binaries
|
||||||
SET(common_pwrsh_definitions
|
#SET(common_pwrsh_definitions
|
||||||
UNICODE
|
# UNICODE
|
||||||
_UNICODE)
|
# _UNICODE)
|
||||||
|
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /VERBOSE")
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** Original flags: END
|
||||||
|
# ***
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** CoreCLR flags: BEGIN
|
||||||
|
# ***
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
|
||||||
|
|
||||||
|
#if(NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
|
||||||
|
#endif (NOT CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||||
|
|
||||||
|
# Incremental linking with CFG is broken until next VS release.
|
||||||
|
# This needs to be appended to the last for each build type to override the default flag.
|
||||||
|
set(NO_INCREMENTAL_LINKER_FLAGS "/INCREMENTAL:NO")
|
||||||
|
|
||||||
|
# Linker flags
|
||||||
|
#
|
||||||
|
# Disable the following line for UNIX altjit on Windows
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") #Do not create Side-by-Side Assembly Manifest
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,6.00") #windows subsystem
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") # can handle addresses larger than 2 gigabytes
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /RELEASE") #sets the checksum in the header
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") #Compatible with Data Execution Prevention
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") #Use address space layout randomization
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUGTYPE:cv,fixup") #debugging format
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") #shrink pdb size
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
|
||||||
|
|
||||||
|
#
|
||||||
|
# TODO: Should these be ignored????
|
||||||
|
#
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221")
|
||||||
|
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
|
||||||
|
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /PDBCOMPRESS")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
|
||||||
|
|
||||||
|
# Debug build specific flags
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
|
||||||
|
# Checked build specific flags
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF /NOVCFEATURE ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
#set(CMAKE_STATIC_LINKER_FLAGS_CHECKED "${CMAKE_STATIC_LINKER_FLAGS_CHECKED}")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS_CHECKED "${CMAKE_EXE_LINKER_FLAGS_CHECKED} /OPT:REF /OPT:NOICF ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
|
||||||
|
# Release build specific flags
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
#set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
|
||||||
|
# ReleaseWithDebugInfo build specific flags
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
#set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}")
|
||||||
|
|
||||||
|
# Temporary until cmake has VS generators for arm64
|
||||||
|
#if(CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||||
|
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:arm64")
|
||||||
|
# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /machine:arm64")
|
||||||
|
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:arm64")
|
||||||
|
#endif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||||
|
|
||||||
|
# Force uCRT to be dynamically linked for Release build
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
|
||||||
|
#set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
|
||||||
|
|
||||||
|
#------------------------------------
|
||||||
|
# Definitions (for platform)
|
||||||
|
#-----------------------------------
|
||||||
|
#if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||||
|
add_definitions(-D_AMD64_)
|
||||||
|
add_definitions(-D_WIN64)
|
||||||
|
add_definitions(-DAMD64)
|
||||||
|
add_definitions(-DBIT64=1)
|
||||||
|
#elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
|
||||||
|
# add_definitions(-D_X86_)
|
||||||
|
#elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
|
||||||
|
# add_definitions(-D_ARM_)
|
||||||
|
# add_definitions(-DARM)
|
||||||
|
#elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||||
|
# add_definitions(-D_ARM64_)
|
||||||
|
# add_definitions(-DARM64)
|
||||||
|
# add_definitions(-D_WIN64)
|
||||||
|
# add_definitions(-DBIT64=1)
|
||||||
|
#else ()
|
||||||
|
# clr_unknown_arch()
|
||||||
|
#endif ()
|
||||||
|
|
||||||
|
# Define the CRT lib references that link into Desktop imports
|
||||||
|
set(STATIC_MT_CRT_LIB "libcmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
|
||||||
|
set(STATIC_MT_VCRT_LIB "libvcruntime$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
|
||||||
|
set(STATIC_MT_CPP_LIB "libcpmt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
|
||||||
|
|
||||||
|
# Define the uCRT lib reference
|
||||||
|
set(STATIC_UCRT_LIB "libucrt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
|
||||||
|
set(DYNAMIC_UCRT_LIB "ucrt$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>.lib")
|
||||||
|
|
||||||
|
#------------------------------------
|
||||||
|
# Definitions for compile
|
||||||
|
#-----------------------------------
|
||||||
|
|
||||||
|
add_compile_options(/Zl) # omit default library name in .OBJ
|
||||||
|
|
||||||
|
# The following options are set by the razzle build
|
||||||
|
add_compile_options(/TP) # compile all files as C++
|
||||||
|
add_compile_options(/d2Zi+) # make optimized builds debugging easier
|
||||||
|
add_compile_options(/nologo) # Suppress Startup Banner
|
||||||
|
add_compile_options(/W3) # set warning level to 3
|
||||||
|
#add_compile_options(/WX) # treat warnings as errors
|
||||||
|
add_compile_options(/Oi) # enable intrinsics
|
||||||
|
add_compile_options(/Oy-) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls
|
||||||
|
#add_compile_options(/U_MT) # undefine the predefined _MT macro
|
||||||
|
add_compile_options(/GF) # enable read-only string pooling
|
||||||
|
add_compile_options(/Gm-) # disable minimal rebuild
|
||||||
|
add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions)
|
||||||
|
add_compile_options(/Zp8) # pack structs on 8-byte boundary
|
||||||
|
add_compile_options(/Gy) # separate functions for linker
|
||||||
|
add_compile_options(/Zc:wchar_t-) # C++ language conformance: wchar_t is NOT the native type, but a typedef
|
||||||
|
add_compile_options(/Zc:forScope) # C++ language conformance: enforce Standard C++ for scoping rules
|
||||||
|
add_compile_options(/GR-) # disable C++ RTTI
|
||||||
|
add_compile_options(/FC) # use full pathnames in diagnostics
|
||||||
|
#add_compile_options(/MP) # Build with Multiple Processes (number of processes equal to the number of processors)
|
||||||
|
add_compile_options(/GS) # Buffer Security Check
|
||||||
|
add_compile_options(/Zm200) # Specify Precompiled Header Memory Allocation Limit of 150MB
|
||||||
|
add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
|
||||||
|
add_compile_options(/Zi) # enable debugging information
|
||||||
|
add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files.
|
||||||
|
|
||||||
|
#if (CLR_CMAKE_PLATFORM_ARCH_I386)
|
||||||
|
# add_compile_options(/Gz)
|
||||||
|
#endif (CLR_CMAKE_PLATFORM_ARCH_I386)
|
||||||
|
|
||||||
|
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/GL>)
|
||||||
|
add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<CONFIG:Checked>>:/O1>)
|
||||||
|
|
||||||
|
#if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||||
|
# The generator expression in the following command means that the /homeparams option is added only for debug builds
|
||||||
|
add_compile_options($<$<CONFIG:Debug>:/homeparams>) # Force parameters passed in registers to be written to the stack
|
||||||
|
#endif (CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||||
|
|
||||||
|
# enable control-flow-guard support for native components for non-Arm64 builds
|
||||||
|
add_compile_options(/guard:cf)
|
||||||
|
|
||||||
|
# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
|
||||||
|
# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
|
||||||
|
#
|
||||||
|
# For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
|
||||||
|
# wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
|
||||||
|
# production-time scenarios.
|
||||||
|
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
|
||||||
|
add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
|
||||||
|
|
||||||
|
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")
|
||||||
|
|
||||||
|
#if (CLR_CMAKE_TARGET_ARCH_AMD64)
|
||||||
|
add_definitions(-D_TARGET_AMD64_=1)
|
||||||
|
add_definitions(-DDBG_TARGET_64BIT=1)
|
||||||
|
add_definitions(-DDBG_TARGET_AMD64=1)
|
||||||
|
add_definitions(-DDBG_TARGET_WIN64=1)
|
||||||
|
#elseif (CLR_CMAKE_TARGET_ARCH_ARM)
|
||||||
|
# add_definitions(-D_TARGET_ARM_=1)
|
||||||
|
# add_definitions(-DDBG_TARGET_32BIT=1)
|
||||||
|
# add_definitions(-DDBG_TARGET_ARM=1)
|
||||||
|
#elseif (CLR_CMAKE_TARGET_ARCH_I386)
|
||||||
|
# add_definitions(-D_TARGET_X86_=1)
|
||||||
|
# add_definitions(-DDBG_TARGET_32BIT=1)
|
||||||
|
# add_definitions(-DDBG_TARGET_X86=1)
|
||||||
|
#else ()
|
||||||
|
# clr_unknown_arch()
|
||||||
|
#endif (CLR_CMAKE_TARGET_ARCH_AMD64)
|
||||||
|
|
||||||
|
#
|
||||||
|
# TODO: Are these needed???????????
|
||||||
|
#
|
||||||
|
#add_definitions(-D_BLD_CLR)
|
||||||
|
#add_definitions(-DDEBUGGING_SUPPORTED)
|
||||||
|
#add_definitions(-DPROFILING_SUPPORTED)
|
||||||
|
|
||||||
|
add_definitions(-DWIN32)
|
||||||
|
add_definitions(-D_WIN32)
|
||||||
|
add_definitions(-DWINVER=${WIN_VERSION_WIN7})# 0x0601 for Win7, was 0x0602
|
||||||
|
add_definitions(-D_WIN32_WINNT=${WIN_VERSION_WIN7}) # 0x0601 for Win7
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN=1)
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
#if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
|
||||||
|
# Only enable edit and continue on windows x86 and x64
|
||||||
|
# exclude Linux, arm & arm64
|
||||||
|
add_definitions(-DEnC_SUPPORTED)
|
||||||
|
#endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
|
||||||
|
|
||||||
|
add_definitions(-DUNICODE)
|
||||||
|
add_definitions(-D_UNICODE)
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** CoreCLR flags: END
|
||||||
|
# ***
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** DSC flags: BEGIN
|
||||||
|
# ***
|
||||||
|
|
||||||
|
|
||||||
|
SET (WindowsSdkDir $ENV{WindowsSdkDir})
|
||||||
|
SET (WindowsSDKVersion $ENV{WindowsSDKVersion})
|
||||||
|
SET (NETFXSdkDir $ENV{NETFXSDKDir})
|
||||||
|
#SET (FrameWorkLibPath $ENV{FrameworkDir}/$ENV{FrameworkVersion})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure include directories
|
||||||
|
#
|
||||||
|
SET (WindowsSDKIncludeBase "${WindowsSdkDir}/Include/${WindowsSDKVersion}")
|
||||||
|
|
||||||
|
SET (IncludePath)
|
||||||
|
#list (APPEND IncludePath "${INTERNAL_HEADER_DIR}")
|
||||||
|
#list (APPEND IncludePath "${PUBLIC_HEADER_DIR}")
|
||||||
|
list (APPEND IncludePath "${WindowsSDKIncludeBase}winrt")
|
||||||
|
# Don't include due to incompatible instance.h
|
||||||
|
# list (APPEND IncludePath "${WindowsSDKIncludeBase}um")
|
||||||
|
list (APPEND IncludePath "${WindowsSDKIncludeBase}shared")
|
||||||
|
list (APPEND IncludePath "${NETFXSdkDir}/Include/um")
|
||||||
|
list (APPEND IncludePath "${WindowsSDKIncludeBase}ucrt")
|
||||||
|
include_directories(BEFORE ${IncludePath})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure lib directories
|
||||||
|
#
|
||||||
|
SET (WindowsSDKLibBase "${WindowsSdkDir}/Lib/${WindowsSDKVersion}")
|
||||||
|
|
||||||
|
SET (LibraryPath)
|
||||||
|
list (APPEND LibraryPath "${WindowsSDKLibBase}ucrt/${WindowsSDKPlatform}")
|
||||||
|
list (APPEND LibraryPath "${NETFXSdkDir}lib/um/${WindowsSDKPlatform}")
|
||||||
|
list (APPEND LibraryPath "${WindowsSDKLibBase}um/${WindowsSDKPlatform}" )
|
||||||
|
list (APPEND LibraryPath "${INTERNAL_LIBRARY_DIR}")
|
||||||
|
list (APPEND LibraryPath "${PUBLIC_LIBRARY_DIR}")
|
||||||
|
#list (APPEND LibraryPath ${FrameWorkLibPath})
|
||||||
|
SET (WindowsSDKLibBase "${WindowsSdkDir}/Lib/${WindowsSDKVersion}")
|
||||||
|
link_directories(${LibraryPath})
|
||||||
|
|
||||||
|
#if (${WindowsSDKPlatform} STREQUAL "x64")
|
||||||
|
# add_definitions (
|
||||||
|
# -D_WIN64
|
||||||
|
# -D_AMD64_
|
||||||
|
# -DAMD64
|
||||||
|
# -DBUILD_WOW64_ENABLED=1
|
||||||
|
# -DBUILD_UMS_ENABLED=1
|
||||||
|
# )
|
||||||
|
#else()
|
||||||
|
# add_definitions (
|
||||||
|
# -DBUILD_WOW64_ENABLED=1
|
||||||
|
# -DBUILD_UMS_ENABLED=0
|
||||||
|
# )
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common defines.
|
||||||
|
#
|
||||||
|
#add_definitions (
|
||||||
|
# -D_CRT_SECURE_NO_WARNINGS
|
||||||
|
# -DCONDITION_HANDLING=1
|
||||||
|
# -DNT_UP=1
|
||||||
|
# -DNT_INST=0
|
||||||
|
# -D_NT1X_=100
|
||||||
|
# -DWINNT=1
|
||||||
|
# -DWIN32_LEAN_AND_MEAN=1
|
||||||
|
# -DDEVL=1
|
||||||
|
# -D_MT=1
|
||||||
|
# -D_STL70_
|
||||||
|
# -DMI_INTERNAL
|
||||||
|
# -DWINBUILD
|
||||||
|
# -DHOOK_BUILD # TODO: should be target specific
|
||||||
|
# -DCONFIG_ENABLE_WCHAR
|
||||||
|
# -D_INTLSTR_NOTAPPEND_NULL
|
||||||
|
# -DMSC_NOOPT
|
||||||
|
# -DBUILD_WINDOWS
|
||||||
|
# -D_USE_DECLSPECS_FOR_SAL=1
|
||||||
|
# -DUNICODE
|
||||||
|
# -D_UNICODE
|
||||||
|
# -D_USE_DEV11_CRT
|
||||||
|
#)
|
||||||
|
|
||||||
|
#
|
||||||
|
# platform specific defines
|
||||||
|
#
|
||||||
|
#add_definitions(
|
||||||
|
# -DNTDDI_VERSION=${NTDDI_VERSION_WIN7}
|
||||||
|
# -DWINBLUE_KBSPRING14
|
||||||
|
# -D_APISET_WINDOWS_VERSION=${WIN_VERSION_WIN7}
|
||||||
|
# -D_APISET_MINWIN_VERSION=0x0100
|
||||||
|
# -D_APISET_MINCORE_VERSION=0x0100
|
||||||
|
# -D_WIN32_IE=0x0800
|
||||||
|
# -D_WIN32_WINNT=${WIN_VERSION_WIN7}
|
||||||
|
# -DWINVER=${WIN_VERSION_WIN7}
|
||||||
|
# )
|
||||||
|
|
||||||
|
# ***
|
||||||
|
# *** DSC flags: END
|
||||||
|
# ***
|
||||||
|
|
||||||
# Default of BUILD_ONECORE should be ON once it is supported
|
# Default of BUILD_ONECORE should be ON once it is supported
|
||||||
option(BUILD_ONECORE "Compile the OneCore version of the binaries" OFF)
|
option(BUILD_ONECORE "Compile the OneCore version of the binaries" OFF)
|
||||||
@@ -34,5 +392,7 @@ add_subdirectory(nativemsh/pwrshcommon)
|
|||||||
add_subdirectory(nativemsh/pwrshplugin)
|
add_subdirectory(nativemsh/pwrshplugin)
|
||||||
|
|
||||||
# Build powershell.exe
|
# Build powershell.exe
|
||||||
add_subdirectory(nativemsh/pwrshexe)
|
if (NOT BUILD_ONECORE)
|
||||||
|
# Conditionally build powershell.exe until CssMainEntry.cpp appears.
|
||||||
|
add_subdirectory(nativemsh/pwrshexe)
|
||||||
|
endif ()
|
||||||
@@ -9,14 +9,21 @@ add_library(pwrshcommon
|
|||||||
target_include_directories(pwrshcommon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(pwrshcommon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if (BUILD_ONECORE)
|
if (BUILD_ONECORE)
|
||||||
|
message("Building OneCore version of pwrshcommon.lib")
|
||||||
# Libraries to use when creating this binary for Windows on OneCore-based SKUs
|
# Libraries to use when creating this binary for Windows on OneCore-based SKUs
|
||||||
set(PWRSHCOMMON_WINDOWS_LIBS
|
set(PWRSHCOMMON_WINDOWS_LIBS
|
||||||
onecore.lib)
|
onecore.lib)
|
||||||
set(pwrshcommon_definitions ${common_pwrsh_definitions} CORECLR)
|
set(pwrshcommon_definitions ${common_pwrsh_definitions} CORECLR)
|
||||||
else () # !BUILD_ONECORE
|
else () # NOT BUILD_ONECORE
|
||||||
|
message("Building Full version of pwrshcommon.lib")
|
||||||
# Libraries to use when creating this binary for Windows on full SKUs
|
# Libraries to use when creating this binary for Windows on full SKUs
|
||||||
# Note: The appropriate libs get added automatically by VS
|
# Note: The appropriate libs get added automatically by VS
|
||||||
set(PWRSHCOMMON_WINDOWS_LIBS
|
set(PWRSHCOMMON_WINDOWS_LIBS
|
||||||
|
# CoreCLR libs
|
||||||
|
${STATIC_MT_CRT_LIB}
|
||||||
|
${STATIC_MT_VCRT_LIB}
|
||||||
|
${STATIC_UCRT_LIB}
|
||||||
|
#
|
||||||
# ole32.lib
|
# ole32.lib
|
||||||
# oleaut32.lib
|
# oleaut32.lib
|
||||||
# uuid.lib
|
# uuid.lib
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ namespace NativeMsh
|
|||||||
|
|
||||||
// The path to the directory that CoreCLR is in
|
// The path to the directory that CoreCLR is in
|
||||||
char m_coreCLRDirectoryPath[MAX_PATH];
|
char m_coreCLRDirectoryPath[MAX_PATH];
|
||||||
|
wchar_t m_coreCLRDirectoryPathW[MAX_PATH];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -333,6 +334,25 @@ namespace NativeMsh
|
|||||||
if (hostClrPath)
|
if (hostClrPath)
|
||||||
{
|
{
|
||||||
::ExpandEnvironmentStringsA(hostClrPath, m_coreCLRDirectoryPath, MAX_PATH);
|
::ExpandEnvironmentStringsA(hostClrPath, m_coreCLRDirectoryPath, MAX_PATH);
|
||||||
|
|
||||||
|
// Generate the wide version of the string and save its value;
|
||||||
|
//
|
||||||
|
// This is a two call function. The first call is to get the necessary length.
|
||||||
|
// The second call is to perform the actual operation.
|
||||||
|
int length = MultiByteToWideChar(CP_UTF8, 0, m_coreCLRDirectoryPath, -1, NULL, 0);
|
||||||
|
if (0 < length)
|
||||||
|
{
|
||||||
|
LPWSTR result = new wchar_t[length];
|
||||||
|
if (NULL != result)
|
||||||
|
{
|
||||||
|
length = ::MultiByteToWideChar(CP_UTF8, 0, m_coreCLRDirectoryPath, -1, result, length);
|
||||||
|
if (0 < length)
|
||||||
|
{
|
||||||
|
wcscpy_s(m_coreCLRDirectoryPathW, MAX_PATH, result);
|
||||||
|
}
|
||||||
|
delete[] result; // Free the allocated string to avoid a memory leak
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,5 +361,11 @@ namespace NativeMsh
|
|||||||
{
|
{
|
||||||
return m_coreCLRDirectoryPath;
|
return m_coreCLRDirectoryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the directory path of the host module
|
||||||
|
PCWSTR GetCoreCLRDirectoryPathW()
|
||||||
|
{
|
||||||
|
return m_coreCLRDirectoryPathW;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace NativeMsh
|
} // namespace NativeMsh
|
||||||
@@ -48,7 +48,8 @@ namespace NativeMsh
|
|||||||
_In_ HMODULE hModule) = 0;
|
_In_ HMODULE hModule) = 0;
|
||||||
|
|
||||||
// File Manipulation Wrappers
|
// File Manipulation Wrappers
|
||||||
virtual FILE* fopen(
|
virtual errno_t fopen_s(
|
||||||
|
FILE** file,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const char *mode) = 0;
|
const char *mode) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,12 @@ namespace NativeMsh
|
|||||||
return ::FreeLibrary(hModule);
|
return ::FreeLibrary(hModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* WinSystemCallFacade::fopen(
|
errno_t WinSystemCallFacade::fopen_s(
|
||||||
|
FILE** file,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const char *mode)
|
const char *mode)
|
||||||
{
|
{
|
||||||
return ::fopen(filename, mode);
|
return ::fopen_s(file, filename, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WinSystemCallFacade::fclose(
|
int WinSystemCallFacade::fclose(
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ namespace NativeMsh
|
|||||||
_In_ HMODULE hModule);
|
_In_ HMODULE hModule);
|
||||||
|
|
||||||
// File Manipulation Wrappers
|
// File Manipulation Wrappers
|
||||||
virtual FILE* fopen(
|
virtual errno_t fopen_s(
|
||||||
|
FILE** file,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const char *mode);
|
const char *mode);
|
||||||
|
|
||||||
|
|||||||
@@ -868,11 +868,13 @@ namespace NativeMsh
|
|||||||
bool PwrshCommon::DoesAssemblyExist(
|
bool PwrshCommon::DoesAssemblyExist(
|
||||||
std::string& fileToTest)
|
std::string& fileToTest)
|
||||||
{
|
{
|
||||||
FILE *file = sysCalls->fopen(fileToTest.c_str(), "r"); // TODO: Use fopen_s?
|
//FILE *file = sysCalls->fopen(fileToTest.c_str(), "r"); // TODO: Use fopen_s?
|
||||||
|
FILE *file = NULL;
|
||||||
|
errno_t status = sysCalls->fopen_s(&file, fileToTest.c_str(), "r");
|
||||||
|
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
sysCalls->fclose(file);
|
sysCalls->fclose(file);
|
||||||
return true;
|
return (status == 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,38 @@
|
|||||||
#
|
#
|
||||||
# Builds PowerShell.exe, the native host for PowerShell.
|
# Builds PowerShell.exe, the native host for PowerShell.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Only build powershell.exe for "full" windows. Open PowerShell uses the managed executable.
|
||||||
if (BUILD_ONECORE)
|
if (BUILD_ONECORE)
|
||||||
|
message("*")
|
||||||
|
message("*********** Building PowerShell.exe for 'full' CLR instead of OneCore. Add CssMainEntry.cpp")
|
||||||
|
message("*")
|
||||||
|
#set(BUILD_ONECORE OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#if (BUILD_ONECORE)
|
||||||
# Settings to use when creating PowerShell.exe for Windows on OneCore-based SKUs
|
# Settings to use when creating PowerShell.exe for Windows on OneCore-based SKUs
|
||||||
set(PWRSHEXE_WINDOWS_SOURCES
|
# set(PWRSHEXE_WINDOWS_SOURCES
|
||||||
# TODO: Fix this once the file is migrated from SD
|
# TODO: Fix this once the file is migrated from SD
|
||||||
# CssMainEntry.cpp)
|
# CssMainEntry.cpp)
|
||||||
MainEntry.cpp)
|
# MainEntry.cpp)
|
||||||
set(PWRSHEXE_WINDOWS_LIBS
|
# set(PWRSHEXE_WINDOWS_LIBS
|
||||||
onecore.lib)
|
# onecore.lib)
|
||||||
set(powershell_definitions
|
# set(powershell_definitions
|
||||||
_CONSOLE
|
# _CONSOLE
|
||||||
CORECLR
|
# CORECLR
|
||||||
${common_pwrsh_definitions})
|
# ${common_pwrsh_definitions})
|
||||||
else (BUILD_ONECORE)
|
#else (BUILD_ONECORE)
|
||||||
# Settings to use when creating PowerShell.exe for Windows on full SKUs or downlevel platforms
|
# Settings to use when creating PowerShell.exe for Windows on full SKUs or downlevel platforms
|
||||||
set(PWRSHEXE_WINDOWS_SOURCES
|
set(PWRSHEXE_WINDOWS_SOURCES
|
||||||
MainEntry.cpp)
|
MainEntry.cpp)
|
||||||
# Most libs are automatically added by VS
|
# Most libs are automatically added by VS
|
||||||
set(PWRSHEXE_WINDOWS_LIBS
|
set(PWRSHEXE_WINDOWS_LIBS
|
||||||
|
# CoreCLR libs
|
||||||
|
${STATIC_MT_CRT_LIB}
|
||||||
|
${STATIC_MT_VCRT_LIB}
|
||||||
|
${STATIC_UCRT_LIB}
|
||||||
|
#
|
||||||
# ole32.lib
|
# ole32.lib
|
||||||
# oleaut32.lib
|
# oleaut32.lib
|
||||||
# uuid.lib
|
# uuid.lib
|
||||||
@@ -26,11 +40,12 @@ else (BUILD_ONECORE)
|
|||||||
MUILoad.lib
|
MUILoad.lib
|
||||||
msxml6.lib
|
msxml6.lib
|
||||||
mscoree.lib
|
mscoree.lib
|
||||||
|
legacy_stdio_definitions.lib # Resolves: LNK2019: unresolved external symbol _vsnwprintf
|
||||||
)
|
)
|
||||||
set(powershell_definitions
|
set(powershell_definitions
|
||||||
_CONSOLE
|
_CONSOLE
|
||||||
${common_pwrsh_definitions})
|
${common_pwrsh_definitions})
|
||||||
endif (BUILD_ONECORE)
|
#endif (BUILD_ONECORE)
|
||||||
|
|
||||||
add_executable(powershell
|
add_executable(powershell
|
||||||
${PWRSHEXE_WINDOWS_SOURCES})
|
${PWRSHEXE_WINDOWS_SOURCES})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Builds pwrshplugin.dll, the WinRM plugin for PowerShell remote hosting.
|
# Builds pwrshplugin.dll, the WinRM plugin for PowerShell remote hosting.
|
||||||
#
|
#
|
||||||
add_library(pwrshplugin
|
add_library(pwrshplugin SHARED
|
||||||
entrypoints.cpp
|
entrypoints.cpp
|
||||||
pwrshclrhost.cpp
|
pwrshclrhost.cpp
|
||||||
pwrshpluginerrorcodes.mc
|
pwrshpluginerrorcodes.mc
|
||||||
@@ -9,26 +9,42 @@ add_library(pwrshplugin
|
|||||||
pwrshplugin.def)
|
pwrshplugin.def)
|
||||||
|
|
||||||
if (BUILD_ONECORE)
|
if (BUILD_ONECORE)
|
||||||
|
message("*")
|
||||||
|
message("* Setting up BUILD_ONECORE version of pwrshplugin.dll")
|
||||||
|
message("*")
|
||||||
# Libraries to use when creating this binary for Windows on OneCore-based SKUs
|
# Libraries to use when creating this binary for Windows on OneCore-based SKUs
|
||||||
set(PWRSHPLUGIN_WINDOWS_LIBS
|
set(PWRSHPLUGIN_WINDOWS_LIBS
|
||||||
onecore.lib)
|
${STATIC_MT_CRT_LIB}
|
||||||
|
${STATIC_MT_VCRT_LIB}
|
||||||
|
${STATIC_UCRT_LIB}
|
||||||
|
wsmsvc.lib)
|
||||||
set(pwrshplugin_definitions ${common_pwrsh_definitions} CORECLR)
|
set(pwrshplugin_definitions ${common_pwrsh_definitions} CORECLR)
|
||||||
else (BUILD_ONECORE)
|
else ()
|
||||||
|
message("*")
|
||||||
|
message("* Setting up NOT BUILD_ONECORE version of pwrshplugin.dll")
|
||||||
|
message("*")
|
||||||
# Libraries to use when creating this binary for Windows on full SKUs
|
# Libraries to use when creating this binary for Windows on full SKUs
|
||||||
set(PWRSHPLUGIN_WINDOWS_LIBS
|
set(PWRSHPLUGIN_WINDOWS_LIBS
|
||||||
ntdll.lib
|
# ntdll.lib
|
||||||
kernel32.lib
|
# kernel32.lib
|
||||||
advapi32.lib
|
# advapi32.lib
|
||||||
ole32.lib
|
# ole32.lib
|
||||||
MUILoad.lib
|
MUILoad.lib
|
||||||
mscoree.lib
|
mscoree.lib
|
||||||
oleaut32.lib
|
# oleaut32.lib
|
||||||
uuid.lib
|
# uuid.lib
|
||||||
wsmsvc.lib)
|
wsmsvc.lib
|
||||||
|
# CoreCLR libs
|
||||||
|
${STATIC_MT_CRT_LIB}
|
||||||
|
${STATIC_MT_VCRT_LIB}
|
||||||
|
${STATIC_UCRT_LIB}
|
||||||
|
legacy_stdio_definitions.lib # Resolves: LNK2019: unresolved external symbol _vsnwprintf
|
||||||
|
)
|
||||||
set(pwrshplugin_definitions ${common_pwrsh_definitions})
|
set(pwrshplugin_definitions ${common_pwrsh_definitions})
|
||||||
endif (BUILD_ONECORE)
|
endif (BUILD_ONECORE)
|
||||||
|
|
||||||
set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "${pwrshplugin_definitions}")
|
set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "${pwrshplugin_definitions}")
|
||||||
|
#set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "_DLL")
|
||||||
|
|
||||||
target_link_libraries(pwrshplugin
|
target_link_libraries(pwrshplugin
|
||||||
${PWRSHPLUGIN_WINDOWS_LIBS})
|
${PWRSHPLUGIN_WINDOWS_LIBS})
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ unsigned int PowerShellCoreClrWorker::LoadWorkerCallbackPtrs(
|
|||||||
"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
||||||
"System.Management.Automation.PowerShellAssemblyLoadContextInitializer",
|
"System.Management.Automation.PowerShellAssemblyLoadContextInitializer",
|
||||||
"SetPowerShellAssemblyLoadContext",
|
"SetPowerShellAssemblyLoadContext",
|
||||||
(INT_PTR*)&initDelegate);
|
//(INT_PTR*)&initDelegate);
|
||||||
|
(void**)&initDelegate);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
@@ -80,7 +81,7 @@ unsigned int PowerShellCoreClrWorker::LoadWorkerCallbackPtrs(
|
|||||||
"System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
"System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
||||||
"System.Management.Automation.Remoting.WSManPluginManagedEntryWrapper",
|
"System.Management.Automation.Remoting.WSManPluginManagedEntryWrapper",
|
||||||
"InitPlugin",
|
"InitPlugin",
|
||||||
(INT_PTR*)&entryPointDelegate);
|
(void**)&entryPointDelegate);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
output->DisplayMessage(false, g_CREATING_MSH_ENTRANCE_FAILED, hr);
|
output->DisplayMessage(false, g_CREATING_MSH_ENTRANCE_FAILED, hr);
|
||||||
@@ -232,7 +233,7 @@ PowerShellClrWorker::~PowerShellClrWorker()
|
|||||||
unsigned int PowerShellClrWorker::LaunchClr(
|
unsigned int PowerShellClrWorker::LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion,
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
_In_ LPCWSTR friendlyName)
|
_In_ LPCSTR friendlyName)
|
||||||
{
|
{
|
||||||
return commonLib.LaunchCLR(wszMonadVersion, wszRuntimeVersion, &pHost);
|
return commonLib.LaunchCLR(wszMonadVersion, wszRuntimeVersion, &pHost);
|
||||||
}
|
}
|
||||||
@@ -303,7 +304,7 @@ unsigned int PowerShellClrWorker::LoadWorkerCallbackPtrs(
|
|||||||
unsigned int PowerShellClrManagedWorker::LaunchClr(
|
unsigned int PowerShellClrManagedWorker::LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion,
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
_In_ LPCWSTR friendlyName)
|
_In_ LPCSTR friendlyName)
|
||||||
{
|
{
|
||||||
return commonLib.LaunchCLR(wszMonadVersion, wszRuntimeVersion, &pHost);
|
return commonLib.LaunchCLR(wszMonadVersion, wszRuntimeVersion, &pHost);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
virtual unsigned int LaunchClr(
|
virtual unsigned int LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion,
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
_In_ LPCWSTR friendlyName) = 0;
|
_In_ LPCSTR friendlyName) = 0;
|
||||||
|
|
||||||
virtual unsigned int LoadWorkerCallbackPtrs(
|
virtual unsigned int LoadWorkerCallbackPtrs(
|
||||||
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
virtual unsigned int LaunchClr(
|
virtual unsigned int LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion,
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
_In_ LPCWSTR friendlyName);
|
_In_ LPCSTR friendlyName);
|
||||||
|
|
||||||
virtual unsigned int LoadWorkerCallbackPtrs(
|
virtual unsigned int LoadWorkerCallbackPtrs(
|
||||||
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
virtual unsigned int LaunchClr(
|
virtual unsigned int LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion,
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
_In_ LPCWSTR friendlyName);
|
_In_ LPCSTR friendlyName);
|
||||||
|
|
||||||
virtual unsigned int LoadWorkerCallbackPtrs(
|
virtual unsigned int LoadWorkerCallbackPtrs(
|
||||||
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
||||||
@@ -146,15 +146,16 @@ public:
|
|||||||
|
|
||||||
virtual ~PowerShellCoreClrWorker();
|
virtual ~PowerShellCoreClrWorker();
|
||||||
|
|
||||||
std::wstring GetHostDirectory() { return std::wstring(hostEnvironment.GetHostDirectoryPath()); }
|
std::wstring GetHostDirectory() { return std::wstring(hostEnvironment.GetHostDirectoryPathW()); }
|
||||||
std::wstring GetClrDirectory() { return std::wstring(hostEnvironment.GetCoreCLRDirectoryPath()); }
|
std::wstring GetClrDirectory() { return std::wstring(hostEnvironment.GetCoreCLRDirectoryPathW()); }
|
||||||
|
|
||||||
//
|
//
|
||||||
// IPowerShellClrHost Methods
|
// IPowerShellClrHost Methods
|
||||||
//
|
//
|
||||||
virtual unsigned int LaunchClr(
|
virtual unsigned int LaunchClr(
|
||||||
_In_ LPCWSTR wszMonadVersion,
|
_In_ LPCWSTR wszMonadVersion,
|
||||||
_In_ LPCWSTR wszRuntimeVersion);
|
_In_ LPCWSTR wszRuntimeVersion,
|
||||||
|
_In_ LPCSTR friendlyName);
|
||||||
|
|
||||||
virtual unsigned int LoadWorkerCallbackPtrs(
|
virtual unsigned int LoadWorkerCallbackPtrs(
|
||||||
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
_In_ PwrshPluginWkr_Ptrs* workerCallbackPtrs,
|
||||||
|
|||||||
@@ -714,7 +714,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCode = powerShellClrHost->LaunchClr(wszMonadVersion, wszTempCLRVersion, L"PwrshPlugin");
|
exitCode = powerShellClrHost->LaunchClr(wszMonadVersion, wszTempCLRVersion, "PwrshPlugin");
|
||||||
if (EXIT_CODE_SUCCESS != exitCode)
|
if (EXIT_CODE_SUCCESS != exitCode)
|
||||||
{
|
{
|
||||||
PWSTR msg = NULL;
|
PWSTR msg = NULL;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
SET (CMAKE_C_FLAGS_INIT "/Wall /FC")
|
||||||
|
SET (CMAKE_C_FLAGS_DEBUG_INIT "/Od /Zi")
|
||||||
|
SET (CLR_C_FLAGS_CHECKED_INIT "/O1 /Zi")
|
||||||
|
SET (CMAKE_C_FLAGS_RELEASE_INIT "/Ox /Zi")
|
||||||
|
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/O2 /Zi")
|
||||||
|
|
||||||
|
SET (CMAKE_CXX_FLAGS_INIT "/Wall /FC")
|
||||||
|
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/Od /Zi")
|
||||||
|
SET (CLR_CXX_FLAGS_CHECKED_INIT "/O1 /Zi")
|
||||||
|
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/Ox /Zi")
|
||||||
|
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/O2 /Zi")
|
||||||
|
|
||||||
|
SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
|
||||||
|
SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)
|
||||||
|
SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
|
||||||
|
SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail)
|
||||||
Reference in new issue
Block a user