mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-27 03:46:23 +08:00
made the first powershell headers compile with stubs and modified coreclr headers
This commit is contained in:
parent
05dbe09c15
commit
a86b598f1f
@ -1 +1 @@
|
||||
Subproject commit 0a5065eff8ed00c77fcfdcaeb576f97013f7a91a
|
||||
Subproject commit 8172f4c13b7dc212d0f175f55496e1d93ecf8219
|
@ -6,20 +6,32 @@ set(CMAKE_CXX_COMPILER /usr/bin/clang++)
|
||||
# generic settings
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||
|
||||
# include folders from PS for Linux
|
||||
include_directories(${PROJECT_SOURCE_DIR}/stubs)
|
||||
|
||||
# add coreclr
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPLATFORM_UNIX -DPAL_IMPLEMENTATION -D__LINUX__")
|
||||
include_directories(${root_SOURCE_DIR}../coreclr/src/pal/inc)
|
||||
# - PLATFORM_UNIX is for pal headers
|
||||
# - PAL_IMPLEMENTATION is for pal headers to define required function implementations (required for coreclr)
|
||||
# - __LINUX__ defines the pal headers correctly define stuff for linux
|
||||
# - COM_NO_WINDOWS_H defines that coreclr headers are not used on windows
|
||||
# - CORECRL required for PowerShell code to enable CoreCRL support
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPLATFORM_UNIX -DPAL_IMPLEMENTATION -D__LINUX__ -DCOM_NO_WINDOWS_H -DCORECLR")
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../coreclr/src/pal/inc)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/../coreclr/src/pal/prebuilt/inc)
|
||||
|
||||
# include folders from PS
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../monad/monad/nttargets/assemblies/nativemsh/pwrshcommon)
|
||||
|
||||
set(SOURCE_FILES main.cpp
|
||||
test/test_pal.cpp
|
||||
# ../monad/monad/nttargets/assemblies/nativemsh/pwrshexe/CssMainEntry.cpp
|
||||
#../monad/monad/nttargets/assemblies/nativemsh/pwrshexe/CssMainEntry.cpp
|
||||
)
|
||||
|
||||
add_executable(linux ${SOURCE_FILES})
|
||||
|
||||
# add cppunit
|
||||
include_directories(${root_SOURCE_DIR}../../externals/cppunit/include)
|
||||
find_library(LIB_CPPUNIT cppunit ${root_SOURCE_DIR}../../externals/cppunit/lib)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../../externals/cppunit/include)
|
||||
find_library(LIB_CPPUNIT cppunit ${PROJECT_SOURCE_DIR}/../../externals/cppunit/lib)
|
||||
target_link_libraries(linux ${LIB_CPPUNIT})
|
||||
message(STATUS "cppunit lib: ${LIB_CPPUNIT}")
|
||||
|
||||
|
17
src/linux/stubs/Windows.h
Normal file
17
src/linux/stubs/Windows.h
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
// pal.h will provide everything windows.h otherwise would
|
||||
#include "pal.h"
|
||||
#include "rt/palrt.h"
|
||||
|
||||
|
||||
// SAL annotations
|
||||
#define _In_
|
||||
#define _Reserved_
|
||||
#define _Out_
|
||||
#define _In_opt_
|
||||
#define __deref_out_opt
|
||||
#define __deref_out_ecount(COUNT)
|
||||
#define __inout_ecount(COUNT)
|
||||
#define __out_ecount(COUNT)
|
||||
#define _Success_(VALUE)
|
||||
#define _In_z_
|
175
src/linux/stubs/mscoree.h
Normal file
175
src/linux/stubs/mscoree.h
Normal file
@ -0,0 +1,175 @@
|
||||
#pragma once
|
||||
|
||||
#include "pal.h"
|
||||
#include "rt/palrt.h"
|
||||
|
||||
//!
|
||||
//! This header pulls in actual items from the original mscoree.h and also
|
||||
//! defines stub classes and functions.
|
||||
//!
|
||||
|
||||
typedef /* [public][public] */
|
||||
enum __MIDL___MIDL_itf_mscoree_0000_0000_0002
|
||||
{
|
||||
STARTUP_CONCURRENT_GC = 0x1,
|
||||
STARTUP_LOADER_OPTIMIZATION_MASK = ( 0x3 << 1 ) ,
|
||||
STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN = ( 0x1 << 1 ) ,
|
||||
STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN = ( 0x2 << 1 ) ,
|
||||
STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST = ( 0x3 << 1 ) ,
|
||||
STARTUP_LOADER_SAFEMODE = 0x10,
|
||||
STARTUP_LOADER_SETPREFERENCE = 0x100,
|
||||
STARTUP_SERVER_GC = 0x1000,
|
||||
STARTUP_HOARD_GC_VM = 0x2000,
|
||||
STARTUP_SINGLE_VERSION_HOSTING_INTERFACE = 0x4000,
|
||||
STARTUP_LEGACY_IMPERSONATION = 0x10000,
|
||||
STARTUP_DISABLE_COMMITTHREADSTACK = 0x20000,
|
||||
STARTUP_ALWAYSFLOW_IMPERSONATION = 0x40000,
|
||||
STARTUP_TRIM_GC_COMMIT = 0x80000,
|
||||
STARTUP_ETW = 0x100000,
|
||||
STARTUP_ARM = 0x400000,
|
||||
STARTUP_SINGLE_APPDOMAIN = 0x800000,
|
||||
STARTUP_APPX_APP_MODEL = 0x1000000,
|
||||
STARTUP_DISABLE_RANDOMIZED_STRING_HASHING = 0x2000000
|
||||
} STARTUP_FLAGS;
|
||||
|
||||
|
||||
// other datatypes
|
||||
|
||||
typedef HRESULT ( __stdcall *FExecuteInAppDomainCallback )(
|
||||
void *cookie);
|
||||
|
||||
|
||||
// interfaces
|
||||
|
||||
class IUnknown
|
||||
{
|
||||
public:
|
||||
ULONG AddRef()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
ULONG Release()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
HRESULT QueryInterface(
|
||||
REFIID riid,
|
||||
void **ppvObject
|
||||
)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
};
|
||||
|
||||
struct IActivationFactory
|
||||
{};
|
||||
|
||||
class IHostControl : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetHostManager(
|
||||
/* [in] */ REFIID riid,
|
||||
/* [out] */ void **ppObject) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetAppDomainManager(
|
||||
/* [in] */ DWORD dwAppDomainID,
|
||||
/* [in] */ IUnknown *pUnkAppDomainManager) = 0;
|
||||
|
||||
};
|
||||
|
||||
class ICLRControl : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCLRManager(
|
||||
/* [in] */ REFIID riid,
|
||||
/* [out] */ void **ppObject) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetAppDomainManagerType(
|
||||
/* [in] */ LPCWSTR pwzAppDomainManagerAssembly,
|
||||
/* [in] */ LPCWSTR pwzAppDomainManagerType) = 0;
|
||||
|
||||
};
|
||||
|
||||
class ICLRRuntimeHost : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE Start( void) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE Stop( void) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetHostControl(
|
||||
/* [in] */ IHostControl *pHostControl) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCLRControl(
|
||||
/* [out] */ ICLRControl **pCLRControl) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE UnloadAppDomain(
|
||||
/* [in] */ DWORD dwAppDomainId,
|
||||
/* [in] */ BOOL fWaitUntilDone) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ExecuteInAppDomain(
|
||||
/* [in] */ DWORD dwAppDomainId,
|
||||
/* [in] */ FExecuteInAppDomainCallback pCallback,
|
||||
/* [in] */ void *cookie) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentAppDomainId(
|
||||
/* [out] */ DWORD *pdwAppDomainId) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ExecuteApplication(
|
||||
/* [in] */ LPCWSTR pwzAppFullName,
|
||||
/* [in] */ DWORD dwManifestPaths,
|
||||
/* [in] */ LPCWSTR *ppwzManifestPaths,
|
||||
/* [in] */ DWORD dwActivationData,
|
||||
/* [in] */ LPCWSTR *ppwzActivationData,
|
||||
/* [out] */ int *pReturnValue) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ExecuteInDefaultAppDomain(
|
||||
/* [in] */ LPCWSTR pwzAssemblyPath,
|
||||
/* [in] */ LPCWSTR pwzTypeName,
|
||||
/* [in] */ LPCWSTR pwzMethodName,
|
||||
/* [in] */ LPCWSTR pwzArgument,
|
||||
/* [out] */ DWORD *pReturnValue) = 0;
|
||||
|
||||
};
|
||||
|
||||
class ICLRRuntimeHost2 : public ICLRRuntimeHost
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateAppDomainWithManager(
|
||||
/* [in] */ LPCWSTR wszFriendlyName,
|
||||
/* [in] */ DWORD dwFlags,
|
||||
/* [in] */ LPCWSTR wszAppDomainManagerAssemblyName,
|
||||
/* [in] */ LPCWSTR wszAppDomainManagerTypeName,
|
||||
/* [in] */ int nProperties,
|
||||
/* [in] */ LPCWSTR *pPropertyNames,
|
||||
/* [in] */ LPCWSTR *pPropertyValues,
|
||||
/* [out] */ DWORD *pAppDomainID) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CreateDelegate(
|
||||
/* [in] */ DWORD appDomainID,
|
||||
/* [in] */ LPCWSTR wszAssemblyName,
|
||||
/* [in] */ LPCWSTR wszClassName,
|
||||
/* [in] */ LPCWSTR wszMethodName,
|
||||
/* [out] */ INT_PTR *fnPtr) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE Authenticate(
|
||||
/* [in] */ ULONGLONG authKey) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterMacEHPort( void) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetStartupFlags(
|
||||
/* [in] */ STARTUP_FLAGS dwFlags) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE DllGetActivationFactory(
|
||||
/* [in] */ DWORD appDomainID,
|
||||
/* [in] */ LPCWSTR wszTypeName,
|
||||
/* [out] */ IActivationFactory **factory) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ExecuteAssembly(
|
||||
/* [in] */ DWORD dwAppDomainId,
|
||||
/* [in] */ LPCWSTR pwzAssemblyPath,
|
||||
/* [in] */ int argc,
|
||||
/* [in] */ LPCWSTR *argv,
|
||||
/* [out] */ DWORD *pReturnValue) = 0;
|
||||
|
||||
};
|
0
src/linux/stubs/rpc.h
Normal file
0
src/linux/stubs/rpc.h
Normal file
0
src/linux/stubs/rpcndr.h
Normal file
0
src/linux/stubs/rpcndr.h
Normal file
10
src/linux/stubs/stubs_coreclr.h
Normal file
10
src/linux/stubs/stubs_coreclr.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "pal.h"
|
||||
|
||||
DWORD WINAPI ExpandEnvironmentStringsW(
|
||||
PCWSTR lpSrc,
|
||||
PWSTR lpDst,
|
||||
DWORD nSize
|
||||
);
|
||||
|
@ -1,10 +1,31 @@
|
||||
#include "pal.h"
|
||||
#include "test_pal.h"
|
||||
|
||||
// pull in some more headers
|
||||
#include "NativeMshConstants.h"
|
||||
#include "ClrHostWrapper.h"
|
||||
#include "IPwrshCommonOutput.h"
|
||||
#include "ConfigFileReader.h"
|
||||
#include "NativeMsh.h"
|
||||
#include "SystemCallFacade.h"
|
||||
#include "WinSystemCallFacade.h"
|
||||
|
||||
namespace Microsoft {
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(PalTestSuite);
|
||||
|
||||
// this unit test is used to test if stuff from different headers was pulled in correctly
|
||||
// this is for porting compatbility tests, not really functional tests
|
||||
void PalTestSuite::testHeaders() {
|
||||
|
||||
// check NativeMshConstants.h
|
||||
CPPUNIT_ASSERT_EQUAL(NativeMsh::g_MISSING_COMMAND_LINE_ARGUMENT,1);
|
||||
|
||||
// check ClrHostWrapper.h
|
||||
NativeMsh::ICLRRuntimeHost2Wrapper clrHostWrapper;
|
||||
|
||||
}
|
||||
|
||||
void PalTestSuite::testDatatypes() {
|
||||
|
||||
// check basic pointer lengths
|
||||
|
@ -4,10 +4,12 @@ namespace Microsoft {
|
||||
|
||||
class PalTestSuite : public CPPUNIT_NS::TestFixture {
|
||||
CPPUNIT_TEST_SUITE(PalTestSuite);
|
||||
CPPUNIT_TEST(testHeaders);
|
||||
CPPUNIT_TEST(testDatatypes);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testHeaders();
|
||||
void testDatatypes();
|
||||
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 64c6fd48b16c891a1c60598805756cb799aac1f5
|
||||
Subproject commit 2cb0227314bb6ea8d1456a564293156ce983cff3
|
Loading…
Reference in New Issue
Block a user