mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Backing up changes where the CoreCLR version runs on Nano Server. It still has the pwrshplugin!WSManPluginStartup call issue.
This commit is contained in:
1 parent
77a26b6b77
commit
c3bf2547e6
12 files changed
+495
-371
No files matched your search
+5
-1
@@ -223,6 +223,7 @@ function Start-PSBuild {
|
|||||||
throw "Could not find Visual Studio vcvarsall.bat at" + $vcPath
|
throw "Could not find Visual Studio vcvarsall.bat at" + $vcPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
# Compile native resources
|
# Compile native resources
|
||||||
@("nativemsh/pwrshplugin") | % {
|
@("nativemsh/pwrshplugin") | % {
|
||||||
$nativeResourcesFolder = $_
|
$nativeResourcesFolder = $_
|
||||||
@@ -230,8 +231,11 @@ function Start-PSBuild {
|
|||||||
& $mcexe -o -d -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder
|
& $mcexe -o -d -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#>
|
||||||
|
|
||||||
$overrideFlags = "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$PSScriptRoot\src\powershell-native\windows-compiler-override.txt"
|
# Disabling until I figure out if it is necessary
|
||||||
|
# $overrideFlags = "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$PSScriptRoot\src\powershell-native\windows-compiler-override.txt"
|
||||||
|
$overrideFlags = ""
|
||||||
$vcArch = "Win64"
|
$vcArch = "Win64"
|
||||||
$cmakeGenerator = "Visual Studio 14 2015 $vcArch"
|
$cmakeGenerator = "Visual Studio 14 2015 $vcArch"
|
||||||
# $CMakeArguments = "-G $cmakeGenerator ."
|
# $CMakeArguments = "-G $cmakeGenerator ."
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.4)
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
|
||||||
project(PowerShellNative)
|
project(PowerShellNative)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -51,7 +52,8 @@ SET (WIN_VERSION_WINTHRESHOLD 0x0A00)
|
|||||||
SET (WIN_VERSION_WINBLUE 0x0603)
|
SET (WIN_VERSION_WINBLUE 0x0603)
|
||||||
SET (WIN_VERSION_WIN8 0x0602)
|
SET (WIN_VERSION_WIN8 0x0602)
|
||||||
SET (WIN_VERSION_WIN7 0x0601)
|
SET (WIN_VERSION_WIN7 0x0601)
|
||||||
SET (NTDDI_VERSION_WIN7 0x06010000)
|
SET (NTDDI_VERSION_WIN7 0x06010000)
|
||||||
|
SET (NTDDI_VERSION_WIN10 0x0A000002)
|
||||||
SET (WIN_VERSION_VISTA 0x0600)
|
SET (WIN_VERSION_VISTA 0x0600)
|
||||||
SET (WIN_VERSION_LONGHORN 0x0600)
|
SET (WIN_VERSION_LONGHORN 0x0600)
|
||||||
SET (WIN_VERSION_WS03 0x0502)
|
SET (WIN_VERSION_WS03 0x0502)
|
||||||
@@ -73,313 +75,16 @@ SET (WIN_VERSION_WINXP 0x0501)
|
|||||||
# UNICODE
|
# UNICODE
|
||||||
# _UNICODE)
|
# _UNICODE)
|
||||||
|
|
||||||
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /VERBOSE")
|
|
||||||
|
|
||||||
# ***
|
# ***
|
||||||
# *** Original flags: END
|
# *** Original flags: END
|
||||||
# ***
|
# ***
|
||||||
|
|
||||||
# ***
|
#include(dsc_defs.cmake)
|
||||||
# *** CoreCLR flags: BEGIN
|
if (BUILD_ONECORE)
|
||||||
# ***
|
include(nano_defs.cmake)
|
||||||
|
else ()
|
||||||
set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
|
include(coreclr_defs.cmake)
|
||||||
|
endif (BUILD_ONECORE)
|
||||||
#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)
|
||||||
@@ -392,7 +97,7 @@ add_subdirectory(nativemsh/pwrshcommon)
|
|||||||
add_subdirectory(nativemsh/pwrshplugin)
|
add_subdirectory(nativemsh/pwrshplugin)
|
||||||
|
|
||||||
# Build powershell.exe
|
# Build powershell.exe
|
||||||
if (NOT BUILD_ONECORE)
|
#if (NOT BUILD_ONECORE)
|
||||||
# Conditionally build powershell.exe until CssMainEntry.cpp appears.
|
# Conditionally build powershell.exe until CssMainEntry.cpp appears.
|
||||||
add_subdirectory(nativemsh/pwrshexe)
|
add_subdirectory(nativemsh/pwrshexe)
|
||||||
endif ()
|
#endif ()
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
|
||||||
|
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_WIN8})# 0x0601 for Win7, was 0x0602
|
||||||
|
add_definitions(-D_WIN32_WINNT=${WIN_VERSION_WIN8}) # 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)
|
||||||
|
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
|
||||||
|
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 (OneCoreLibBase "$ENV{VCInstallDir}lib/onecore/amd64")
|
||||||
|
|
||||||
|
SET (LibraryPath)
|
||||||
|
if (BUILD_ONECORE)
|
||||||
|
list (APPEND LibraryPath "${OneCoreLibBase}")
|
||||||
|
endif (BUILD_ONECORE)
|
||||||
|
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
|
||||||
|
-DMD
|
||||||
|
-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}
|
||||||
|
-DNTDDI_VERSION=${NTDDI_VERSION_WIN10}
|
||||||
|
-DWINBLUE_KBSPRING14
|
||||||
|
#-D_APISET_WINDOWS_VERSION=${WIN_VERSION_WIN7}
|
||||||
|
-D_APISET_WINDOWS_VERSION=${WIN_VERSION_WIN10}
|
||||||
|
#-D_APISET_MINWIN_VERSION=0x0100
|
||||||
|
-D_APISET_MINWIN_VERSION=0x0106
|
||||||
|
#-D_APISET_MINCORE_VERSION=0x0100
|
||||||
|
-D_APISET_MINCORE_VERSION=0x0105
|
||||||
|
-D_WIN32_IE=0x0800
|
||||||
|
#-D_WIN32_WINNT=${WIN_VERSION_WIN7}
|
||||||
|
-D_WIN32_WINNT=${WIN_VERSION_WIN10}
|
||||||
|
#-DWINVER=${WIN_VERSION_WIN7}
|
||||||
|
-DWINVER=${WIN_VERSION_WIN10}
|
||||||
|
)
|
||||||
|
|
||||||
|
# if not DEBUG for DSC
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF /NODEFAULTLIB")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF /NODEFAULTLIB")
|
||||||
|
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
|
||||||
|
SET (WindowsSdkDir $ENV{WindowsSdkDir})
|
||||||
|
SET (WindowsSDKVersion $ENV{WindowsSDKVersion})
|
||||||
|
SET (NETFXSdkDir $ENV{NETFXSDKDir})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure include directories
|
||||||
|
#
|
||||||
|
SET (WindowsSDKIncludeBase "${WindowsSdkDir}/Include/${WindowsSDKVersion}")
|
||||||
|
|
||||||
|
SET (IncludePath)
|
||||||
|
list (APPEND IncludePath "${WindowsSDKIncludeBase}winrt")
|
||||||
|
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 (OneCoreLibBase "$ENV{VCInstallDir}lib/onecore/amd64")
|
||||||
|
|
||||||
|
SET (LibraryPath)
|
||||||
|
list (APPEND LibraryPath "${OneCoreLibBase}")
|
||||||
|
list (APPEND LibraryPath "${WindowsSDKLibBase}ucrt/${WindowsSDKPlatform}")
|
||||||
|
list (APPEND LibraryPath "${WindowsSDKLibBase}um/${WindowsSDKPlatform}" )
|
||||||
|
#list (APPEND LibraryPath "${NETFXSdkDir}lib/um/${WindowsSDKPlatform}")
|
||||||
|
link_directories(${LibraryPath})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Tell CMake to set the platform toolset.
|
||||||
|
#
|
||||||
|
set(CMAKE_VS_PLATFORM_TOOLSET "v140") # Use VS 2015 with Win 10 SDK
|
||||||
|
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "10.0.10586.0") # Targets Windows 10. Alt is ${WindowsSDKVersion}
|
||||||
|
|
||||||
|
if (BUILD_ONECORE)
|
||||||
|
set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc.
|
||||||
|
endif (BUILD_ONECORE)
|
||||||
|
|
||||||
|
add_compile_options(/Zl) # omit default library name in .OBJ
|
||||||
|
add_compile_options(/Zi) # enable debugging information
|
||||||
|
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(/wd4996) # Ignore deprecation warnings
|
||||||
|
add_compile_options(/Od) # enable intrinsics
|
||||||
|
add_compile_options(/sdl)
|
||||||
|
|
||||||
|
add_compile_options(/Gm) # minimal rebuild
|
||||||
|
add_compile_options(/EHsc) # enable C++ EH (w/ SEH exceptions)
|
||||||
|
add_compile_options(/RTC1)
|
||||||
|
#add_compile_options(/MDd)
|
||||||
|
add_compile_options(/MD)
|
||||||
|
add_compile_options(/GS) # Buffer Security Check
|
||||||
|
add_compile_options(/fp:precise)
|
||||||
|
add_compile_options(/Zp8) # pack structs on 8-byte boundary
|
||||||
|
add_compile_options(/Zc:wchar_t) # C++ language conformance: wchar_t is NOT the native type, but a typedef
|
||||||
|
#add_compile_options(/U_WINDOWS)
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
-DWIN32
|
||||||
|
-DNDEBUG
|
||||||
|
# -D_DEBUG
|
||||||
|
-D_UNICODE
|
||||||
|
-DUNICODE
|
||||||
|
-DWIN32_LEAN_AND_MEAN=1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#set(MY_COMMON_LINK_FLAGS "/INCREMENTAL /NOLOGO /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /TLBID:1 /MACHINE:x64 /NODEFAULTLIB")
|
||||||
|
set(MY_COMMON_LINK_FLAGS "/INCREMENTAL:NO /NOLOGO /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /TLBID:1 /MACHINE:x64 /guard:cf /OPT:REF /OPT:ICF")
|
||||||
|
set(MY_COMMON_LINK_FLAGS "${MY_COMMON_LINK_FLAGS} /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:advapi32.lib") # Explicitly exclude kernel32 and advapi32 since CMake is including them and they block execution on Nano Server
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MY_COMMON_LINK_FLAGS}")
|
||||||
|
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /OPT:REF") #windows subsystem
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") #windows subsystem
|
||||||
|
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MY_COMMON_LINK_FLAGS}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") #windows subsystem
|
||||||
|
|
||||||
@@ -12,17 +12,20 @@ if (BUILD_ONECORE)
|
|||||||
message("Building OneCore version of pwrshcommon.lib")
|
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)
|
||||||
|
set(pwrshcommon_definitions CORECLR)
|
||||||
|
set_target_properties(pwrshcommon PROPERTIES COMPILE_DEFINITIONS "${pwrshcommon_definitions}")
|
||||||
else () # NOT BUILD_ONECORE
|
else () # NOT BUILD_ONECORE
|
||||||
message("Building Full version of pwrshcommon.lib")
|
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
|
# CoreCLR libs
|
||||||
${STATIC_MT_CRT_LIB}
|
### ${STATIC_MT_CRT_LIB}
|
||||||
${STATIC_MT_VCRT_LIB}
|
### ${STATIC_MT_VCRT_LIB}
|
||||||
${STATIC_UCRT_LIB}
|
### ${STATIC_UCRT_LIB}
|
||||||
#
|
#
|
||||||
# ole32.lib
|
# ole32.lib
|
||||||
# oleaut32.lib
|
# oleaut32.lib
|
||||||
@@ -32,12 +35,12 @@ else () # NOT BUILD_ONECORE
|
|||||||
# msxml6.lib
|
# msxml6.lib
|
||||||
# mscoree.lib)
|
# mscoree.lib)
|
||||||
)
|
)
|
||||||
set(pwrshcommon_definitions ${common_pwrsh_definitions})
|
#set(pwrshcommon_definitions ${common_pwrsh_definitions})
|
||||||
# target_include_directories(pwrshcommon PUBLIC
|
# target_include_directories(pwrshcommon PUBLIC
|
||||||
# "%ProgramFiles(x86)%/Windows Kits/NETFXSDK/4.6/Include/um")
|
# "%ProgramFiles(x86)%/Windows Kits/NETFXSDK/4.6/Include/um")
|
||||||
endif (BUILD_ONECORE)
|
endif (BUILD_ONECORE)
|
||||||
|
|
||||||
set_target_properties(pwrshcommon PROPERTIES COMPILE_DEFINITIONS "${pwrshcommon_definitions}")
|
#set_target_properties(pwrshcommon PROPERTIES COMPILE_DEFINITIONS "${pwrshcommon_definitions}")
|
||||||
|
|
||||||
target_link_libraries(pwrshcommon
|
target_link_libraries(pwrshcommon
|
||||||
${PWRSHCOMMON_WINDOWS_LIBS})
|
${PWRSHCOMMON_WINDOWS_LIBS})
|
||||||
|
|||||||
@@ -148,6 +148,17 @@ namespace NativeMsh
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initPtr = (coreclr_initialize_ptr)GetProcAddress(result, "coreclr_initialize");
|
||||||
|
shutdownPtr = (coreclr_shutdown_ptr)GetProcAddress(result, "coreclr_shutdown");
|
||||||
|
createDelegatePtr = (coreclr_create_delegate_ptr)GetProcAddress(result, "coreclr_create_delegate");
|
||||||
|
|
||||||
|
if (NULL == initPtr ||
|
||||||
|
NULL == shutdownPtr ||
|
||||||
|
NULL == createDelegatePtr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialization succeeded. Save the handle and return success;
|
// Initialization succeeded. Save the handle and return success;
|
||||||
coreClrHandle = result;
|
coreClrHandle = result;
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1349,12 +1349,12 @@ namespace NativeMsh
|
|||||||
vals[nProps] = tempStr.c_str();
|
vals[nProps] = tempStr.c_str();
|
||||||
nProps++;
|
nProps++;
|
||||||
|
|
||||||
props[nProps] = L"APP_PATHS";
|
props[nProps] = "APP_PATHS";
|
||||||
vals[nProps] = L""; // Used to be hostEnvironment.GetHostDirectoryPath()
|
vals[nProps] = ""; // Used to be hostEnvironment.GetHostDirectoryPath()
|
||||||
nProps++;
|
nProps++;
|
||||||
|
|
||||||
props[nProps] = L"APP_NI_PATHS";
|
props[nProps] = "APP_NI_PATHS";
|
||||||
vals[nProps] = L""; // Used to be hostEnvironment.GetHostDirectoryPath()
|
vals[nProps] = ""; // Used to be hostEnvironment.GetHostDirectoryPath()
|
||||||
nProps++;
|
nProps++;
|
||||||
|
|
||||||
int hr = hostWrapper->InitializeClr(
|
int hr = hostWrapper->InitializeClr(
|
||||||
|
|||||||
@@ -4,25 +4,34 @@
|
|||||||
|
|
||||||
# Only build powershell.exe for "full" windows. Open PowerShell uses the managed executable.
|
# 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)
|
#set(BUILD_ONECORE OFF)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#if (BUILD_ONECORE)
|
if (BUILD_ONECORE)
|
||||||
|
message("*")
|
||||||
|
message("*********** Building PowerShell.exe for CoreCLR. Add CssMainEntry.cpp")
|
||||||
|
message("*")
|
||||||
# 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
|
CssMainEntry.cpp)
|
||||||
# CssMainEntry.cpp)
|
set(PWRSHEXE_WINDOWS_LIBS
|
||||||
# MainEntry.cpp)
|
### ${STATIC_MT_CRT_LIB}
|
||||||
# set(PWRSHEXE_WINDOWS_LIBS
|
### ${STATIC_MT_VCRT_LIB}
|
||||||
# onecore.lib)
|
### ${STATIC_UCRT_LIB}
|
||||||
# set(powershell_definitions
|
onecore.lib
|
||||||
# _CONSOLE
|
vcruntime.lib
|
||||||
# CORECLR
|
ucrtd.lib
|
||||||
# ${common_pwrsh_definitions})
|
msvcrt.lib
|
||||||
#else (BUILD_ONECORE)
|
)
|
||||||
|
set(powershell_definitions
|
||||||
|
_CONSOLE
|
||||||
|
CORECLR
|
||||||
|
)
|
||||||
|
# ${common_pwrsh_definitions})
|
||||||
|
else ()
|
||||||
|
message("*")
|
||||||
|
message("*********** Building PowerShell.exe for 'Full' CLR.")
|
||||||
|
message("*")
|
||||||
# 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)
|
||||||
@@ -33,10 +42,10 @@ endif ()
|
|||||||
${STATIC_MT_VCRT_LIB}
|
${STATIC_MT_VCRT_LIB}
|
||||||
${STATIC_UCRT_LIB}
|
${STATIC_UCRT_LIB}
|
||||||
#
|
#
|
||||||
# ole32.lib
|
# ole32.lib
|
||||||
# oleaut32.lib
|
# oleaut32.lib
|
||||||
# uuid.lib
|
# uuid.lib
|
||||||
# user32.lib
|
# user32.lib
|
||||||
MUILoad.lib
|
MUILoad.lib
|
||||||
msxml6.lib
|
msxml6.lib
|
||||||
mscoree.lib
|
mscoree.lib
|
||||||
@@ -44,17 +53,21 @@ endif ()
|
|||||||
)
|
)
|
||||||
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})
|
||||||
|
|
||||||
set_target_properties(powershell PROPERTIES COMPILE_DEFINITIONS "${powershell_definitions}")
|
set_target_properties(powershell PROPERTIES COMPILE_DEFINITIONS "${powershell_definitions}")
|
||||||
set_target_properties(powershell PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
# Set in nano_defs.cmake. Uncomment for other flavors
|
||||||
set_target_properties(powershell PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
#set_target_properties(powershell PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(powershell PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
#set_target_properties(powershell PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(powershell PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
#set_target_properties(powershell PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
||||||
|
#set_target_properties(powershell PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
||||||
|
|
||||||
|
message("==== Setting libs = ${PWRSHEXE_WINDOWS_LIBS}")
|
||||||
|
|
||||||
target_link_libraries(powershell
|
target_link_libraries(powershell
|
||||||
${PWRSHEXE_WINDOWS_LIBS})
|
${PWRSHEXE_WINDOWS_LIBS})
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mscoree.h"
|
#if !CORECLR
|
||||||
|
#include "mscoree.h"
|
||||||
|
#endif
|
||||||
#include "NativeMsh.h"
|
#include "NativeMsh.h"
|
||||||
#include "ClrHostWrapper.h"
|
#include "ClrHostWrapper.h"
|
||||||
#include "OutputWriter.h"
|
#include "OutputWriter.h"
|
||||||
@@ -34,9 +36,9 @@ namespace NativeMsh
|
|||||||
// All these objects will be destroyed when commonFuncs goes out of scope.
|
// All these objects will be destroyed when commonFuncs goes out of scope.
|
||||||
PwrshExeOutput* output = new PwrshExeOutput();
|
PwrshExeOutput* output = new PwrshExeOutput();
|
||||||
PwrshCommon commonFuncs(output, new WinSystemCallFacade());
|
PwrshCommon commonFuncs(output, new WinSystemCallFacade());
|
||||||
ICLRRuntimeHost2Wrapper hostWrapper;
|
CoreClrHostingApiWrapper hostWrapper;
|
||||||
|
|
||||||
exitCode = commonFuncs.LaunchCoreCLR(&hostWrapper, hostEnvironment);
|
exitCode = commonFuncs.LaunchCoreCLR(&hostWrapper, hostEnvironment, "powershell");
|
||||||
if (EXIT_CODE_SUCCESS != exitCode)
|
if (EXIT_CODE_SUCCESS != exitCode)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@@ -51,23 +53,14 @@ namespace NativeMsh
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCode = commonFuncs.CreateAppDomain(&hostWrapper, hostEnvironment.GetHostBinaryName(), hostEnvironment);
|
|
||||||
if (EXIT_CODE_SUCCESS != exitCode)
|
|
||||||
{
|
|
||||||
if (verbose)
|
|
||||||
::wprintf(L"Unable to create app domain\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
// Set the powershell custom assembly loader to be the default
|
// Set the powershell custom assembly loader to be the default
|
||||||
LoaderRunHelperFp initDelegate = NULL;
|
LoaderRunHelperFp initDelegate = NULL;
|
||||||
HRESULT hr = hostWrapper.CreateDelegate(
|
HRESULT hr = hostWrapper.CreateDelegate(
|
||||||
hostWrapper.GetAppDomainId(),
|
"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
||||||
L"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
"System.Management.Automation.PowerShellAssemblyLoadContextInitializer",
|
||||||
L"System.Management.Automation.PowerShellAssemblyLoadContextInitializer",
|
"SetPowerShellAssemblyLoadContext",
|
||||||
L"SetPowerShellAssemblyLoadContext",
|
(void**)&initDelegate);
|
||||||
(INT_PTR*)&initDelegate);
|
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
@@ -75,18 +68,17 @@ namespace NativeMsh
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initDelegate(hostEnvironment.GetHostDirectoryPath());
|
initDelegate(hostEnvironment.GetHostDirectoryPathW());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
// Start the assembly
|
// Start the assembly
|
||||||
MonadRunHelperFp pfnDelegate = NULL;
|
MonadRunHelperFp pfnDelegate = NULL;
|
||||||
hr = hostWrapper.CreateDelegate(
|
hr = hostWrapper.CreateDelegate(
|
||||||
hostWrapper.GetAppDomainId(),
|
"Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
||||||
L"Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
"Microsoft.PowerShell.UnmanagedPSEntry",
|
||||||
L"Microsoft.PowerShell.UnmanagedPSEntry",
|
"Start",
|
||||||
L"Start",
|
(void**)&pfnDelegate);
|
||||||
(INT_PTR*)&pfnDelegate);
|
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,11 +14,17 @@ if (BUILD_ONECORE)
|
|||||||
message("*")
|
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
|
||||||
${STATIC_MT_CRT_LIB}
|
### ${STATIC_MT_CRT_LIB}
|
||||||
${STATIC_MT_VCRT_LIB}
|
### ${STATIC_MT_VCRT_LIB}
|
||||||
${STATIC_UCRT_LIB}
|
### ${STATIC_UCRT_LIB}
|
||||||
|
onecore.lib
|
||||||
|
vcruntime.lib
|
||||||
|
ucrtd.lib
|
||||||
|
msvcrt.lib
|
||||||
wsmsvc.lib)
|
wsmsvc.lib)
|
||||||
set(pwrshplugin_definitions ${common_pwrsh_definitions} CORECLR)
|
#set(pwrshplugin_definitions ${common_pwrsh_definitions} CORECLR)
|
||||||
|
set(pwrshplugin_definitions CORECLR)
|
||||||
|
set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "${pwrshplugin_definitions}")
|
||||||
else ()
|
else ()
|
||||||
message("*")
|
message("*")
|
||||||
message("* Setting up NOT BUILD_ONECORE version of pwrshplugin.dll")
|
message("* Setting up NOT BUILD_ONECORE version of pwrshplugin.dll")
|
||||||
@@ -34,7 +40,7 @@ else ()
|
|||||||
# oleaut32.lib
|
# oleaut32.lib
|
||||||
# uuid.lib
|
# uuid.lib
|
||||||
wsmsvc.lib
|
wsmsvc.lib
|
||||||
# CoreCLR libs
|
# CoreCLR lib
|
||||||
${STATIC_MT_CRT_LIB}
|
${STATIC_MT_CRT_LIB}
|
||||||
${STATIC_MT_VCRT_LIB}
|
${STATIC_MT_VCRT_LIB}
|
||||||
${STATIC_UCRT_LIB}
|
${STATIC_UCRT_LIB}
|
||||||
@@ -43,7 +49,7 @@ else ()
|
|||||||
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")
|
#set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "_DLL")
|
||||||
|
|
||||||
target_link_libraries(pwrshplugin
|
target_link_libraries(pwrshplugin
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "pwrshplugindefs.h" // PwrshPluginWkr_Ptrs and PlugInException
|
#include "pwrshplugindefs.h" // PwrshPluginWkr_Ptrs and PlugInException
|
||||||
|
#if !CORECLR
|
||||||
#include <mscoree.h>
|
#include <mscoree.h>
|
||||||
|
#endif
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "SystemCallFacade.h"
|
#include "SystemCallFacade.h"
|
||||||
|
|||||||
Reference in new issue
Block a user