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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function Start-PSBuild {
}

$precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')

#mc.exe is Message Compiler for native resources
$mcexe = Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\" -Recurse -Filter 'mc.exe' | ? {$_.FullName -match 'x64'} | select -First 1 | % {$_.FullName}
if (-not $mcexe) {
throw 'mc.exe not found. Install Microsoft Windows SDK.'
}

} elseif ($IsLinux -or $IsOSX) {
$InstallCommand = if ($IsLinux) {
'apt-get'
Expand Down Expand Up @@ -182,13 +189,21 @@ function Start-PSBuild {
try {
Push-Location "$PSScriptRoot\src\powershell-native"

# Compile native resources
@("nativemsh/pwrshplugin") | % {
$nativeResourcesFolder = $_
Get-ChildItem $nativeResourcesFolder -Filter "*.mc" | % {
& $mcexe -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder
}
}

if ($cmakeGenerator) {
cmake -G $cmakeGenerator .
} else {
cmake .
}

Start-NativeExecution { msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration }
Start-NativeExecution { msbuild ALL_BUILD.vcxproj /p:Configuration=$msbuildConfiguration }

} finally {
Pop-Location
Expand Down
12 changes: 9 additions & 3 deletions src/powershell-native/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ x64/
ZERO_CHECK.vcxproj
ZERO_CHECK.vcxproj.filters
cmake_install.cmake
powershell.dir/
powershell.vcxproj
powershell.vcxproj.filters
*.dir/
*.vcxproj
*.vcxproj.filters
Release/

# Resources
MSG*.bin
pwrshpluginerrorcodes.h
pwrshpluginerrorcodes.rc
31 changes: 24 additions & 7 deletions src/powershell-native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,48 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

include_directories(
nativemsh/pwrshcommon)
nativemsh/pwrshcommon
nativemsh/pwrshplugin)

link_directories(
nativemsh/pwrshcommon)

add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)

add_executable(powershell WIN32
nativemsh/pwrshcommon/pwrshcommon.cpp
nativemsh/pwrshcommon/WinSystemCallFacade.cpp

nativemsh/pwrshexe/MainEntry.cpp)

# This subsystem definition is using old policy. TODO: figure out for release and the rest
set_target_properties(powershell PROPERTIES COMPILE_DEFINITIONS "_CONSOLE")
add_library(pwrshplugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to compile this DLL twice. For FullCLR and CoreCLR.
The CoreCLR version should
1 - Take the CDEFINE CORECLR
2 - Must build for CoreSystem (aka OneCore) by linking against onecore.lib

Both versions must link against wsmsvc.lib as well. I don't see it listed here

nativemsh/pwrshplugin/entrypoints.cpp
nativemsh/pwrshplugin/pwrshclrhost.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need pwrshplugin.def here as well

nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc
nativemsh/pwrshplugin/pwrshpluginerrorcodes.rc
nativemsh/pwrshplugin/pwrshplugin.def)


SET(powershell_definitions
_CONSOLE
UNICODE
_UNICODE)

set_target_properties(powershell PROPERTIES COMPILE_DEFINITIONS "${powershell_definitions}")
set_target_properties(powershell PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(powershell PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(powershell PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
set_target_properties(powershell PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")

SET(pwrshplugin_definitions
UNICODE
_UNICODE)

set_target_properties(pwrshplugin PROPERTIES COMPILE_DEFINITIONS "${pwrshplugin_definitions}")

target_link_libraries(powershell
mscoree.lib
MUILoad.lib
kernel32.lib
msxml6.lib
legacy_stdio_definitions.lib)

target_link_libraries(pwrshplugin)

14 changes: 13 additions & 1 deletion src/powershell-native/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@
"monad/nttargets/assemblies/nativemsh/pwrshcommon/WinSystemCallFacade.h": "nativemsh/pwrshcommon/WinSystemCallFacade.h",
"monad/nttargets/assemblies/nativemsh/pwrshcommon/IPwrshCommonOutput.h": "nativemsh/pwrshcommon/IPwrshCommonOutput.h",
"monad/nttargets/assemblies/nativemsh/pwrshexe/MainEntry.cpp": "nativemsh/pwrshexe/MainEntry.cpp",
"monad/nttargets/assemblies/nativemsh/pwrshcommon/ClrHostWrapper.h": "nativemsh/pwrshcommon/ClrHostWrapper.h"
"monad/nttargets/assemblies/nativemsh/pwrshcommon/ClrHostWrapper.h": "nativemsh/pwrshcommon/ClrHostWrapper.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/entrypoints.cpp": "nativemsh/pwrshplugin/entrypoints.cpp",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshclrhost.cpp": "nativemsh/pwrshplugin/pwrshclrhost.cpp",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc": "nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshpluginResources.rc": "nativemsh/pwrshplugin/pwrshpluginResources.rc",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugin.dll.manifest": "nativemsh/pwrshplugin/pwrshplugin.dll.manifest",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/version.rc": "nativemsh/pwrshplugin/version.rc",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/entrypoints.h": "nativemsh/pwrshplugin/entrypoints.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshclrhost.h": "nativemsh/pwrshplugin/pwrshclrhost.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshheaders.h": "nativemsh/pwrshplugin/pwrshheaders.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugin.h": "nativemsh/pwrshplugin/pwrshplugin.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugindefs.h": "nativemsh/pwrshplugin/pwrshplugindefs.h",
"monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugin.def": "nativemsh/pwrshplugin/pwrshplugin.def"
}
Loading