From 615163dcbce0be34c3a2613ce6936e3ed76854f4 Mon Sep 17 00:00:00 2001 From: Stephen Crain Date: Mon, 17 Jun 2019 15:11:55 -0700 Subject: [PATCH 1/4] Add flag to use chakra core in uwp --- vnext/Chakra/ChakraHelpers.cpp | 3 ++- vnext/Chakra/ChakraJsiRuntime_core.cpp | 2 ++ vnext/ReactUWP/ReactUWP.vcxproj | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vnext/Chakra/ChakraHelpers.cpp b/vnext/Chakra/ChakraHelpers.cpp index 85913a95744..0c3cded07fb 100644 --- a/vnext/Chakra/ChakraHelpers.cpp +++ b/vnext/Chakra/ChakraHelpers.cpp @@ -73,6 +73,7 @@ class ChakraVersionInfo bool initialize() noexcept { +#if !defined(CHAKRACOREUWP) // This code is win32 only at the moment. We will need to change this // line if we want to support UWP. constexpr wchar_t chakraDllName[] = L"ChakraCore.dll"; @@ -107,7 +108,7 @@ class ChakraVersionInfo m_fileVersionLS = chakraVersionInfo->fixedFileInfo.dwFileVersionLS; m_productVersionMS = chakraVersionInfo->fixedFileInfo.dwProductVersionMS; m_productVersionLS = chakraVersionInfo->fixedFileInfo.dwProductVersionLS; - +#endif return true; } diff --git a/vnext/Chakra/ChakraJsiRuntime_core.cpp b/vnext/Chakra/ChakraJsiRuntime_core.cpp index 0d0ddca8456..ab9ba7683fc 100644 --- a/vnext/Chakra/ChakraJsiRuntime_core.cpp +++ b/vnext/Chakra/ChakraJsiRuntime_core.cpp @@ -197,6 +197,7 @@ struct FileVersionInfoResource { /*static*/ void ChakraJsiRuntime::initRuntimeVersion() noexcept { // This code is win32 only at the moment. We will need to change this // line if we want to support UWP. +#if !defined(CHAKRACOREUWP) constexpr wchar_t chakraDllName[] = L"ChakraCore.dll"; auto freeLibraryWrapper = [](void* p) { FreeLibrary((HMODULE)p); }; @@ -222,6 +223,7 @@ struct FileVersionInfoResource { s_runtimeVersion = chakraVersionInfo->fixedFileInfo.dwFileVersionMS; s_runtimeVersion <<= 32; s_runtimeVersion |= chakraVersionInfo->fixedFileInfo.dwFileVersionLS; +#endif } JsErrorCode ChakraJsiRuntime::enableDebugging(JsRuntimeHandle runtime, std::string const& runtimeName, bool breakOnNextLine, uint16_t port, diff --git a/vnext/ReactUWP/ReactUWP.vcxproj b/vnext/ReactUWP/ReactUWP.vcxproj index 26e87c8a4f5..dd62f0f81b2 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -79,7 +79,9 @@ REACTWINDOWS_BUILD - building with REACTWINDOWS_API as dll exports OLD_CPPWINRT is a workaround to make target version to 19H1 --> - OLD_CPPWINRT;REACTWINDOWS_BUILD;RN_PLATFORM=uwp;USE_EDGEMODE_JSRT;NOMINMAX;FOLLY_NO_CONFIG;RN_EXPORT=;JSI_EXPORT=;WIN32=0;WINRT=1;NOJSC;_HAS_AUTO_PTR_ETC;%(PreprocessorDefinitions) + CHAKRACORE;CHAKRACOREUWP;%(PreprocessorDefinitions) + USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) + OLD_CPPWINRT;REACTWINDOWS_BUILD;RN_PLATFORM=uwp;NOMINMAX;FOLLY_NO_CONFIG;RN_EXPORT=;JSI_EXPORT=;WIN32=0;WINRT=1;NOJSC;_HAS_AUTO_PTR_ETC;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Pch;$(ReactNativeWindowsDir)ReactUWP\GeneratedWinmdHeader;$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactUWP;$(YogaDir);$(ReactNativeDir)\ReactCommon;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)Shared;$(FollyDir);%(AdditionalIncludeDirectories) stdcpp17 /await %(AdditionalOptions) From 9f683ed0cd30ae0b22294f55ce9386da658d80cd Mon Sep 17 00:00:00 2001 From: Stephen Crain Date: Mon, 17 Jun 2019 15:30:55 -0700 Subject: [PATCH 2/4] fix whitespace --- vnext/ReactUWP/ReactUWP.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vnext/ReactUWP/ReactUWP.vcxproj b/vnext/ReactUWP/ReactUWP.vcxproj index dd62f0f81b2..66d6ff466b3 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -79,8 +79,8 @@ REACTWINDOWS_BUILD - building with REACTWINDOWS_API as dll exports OLD_CPPWINRT is a workaround to make target version to 19H1 --> - CHAKRACORE;CHAKRACOREUWP;%(PreprocessorDefinitions) - USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) + CHAKRACORE;CHAKRACOREUWP;%(PreprocessorDefinitions) + USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) OLD_CPPWINRT;REACTWINDOWS_BUILD;RN_PLATFORM=uwp;NOMINMAX;FOLLY_NO_CONFIG;RN_EXPORT=;JSI_EXPORT=;WIN32=0;WINRT=1;NOJSC;_HAS_AUTO_PTR_ETC;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Pch;$(ReactNativeWindowsDir)ReactUWP\GeneratedWinmdHeader;$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactUWP;$(YogaDir);$(ReactNativeDir)\ReactCommon;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)Shared;$(FollyDir);%(AdditionalIncludeDirectories) stdcpp17 From 158813e60a13399a94f5e95effa09f06dfbf9241 Mon Sep 17 00:00:00 2001 From: Stephen Crain Date: Mon, 17 Jun 2019 15:46:13 -0700 Subject: [PATCH 3/4] add libs too --- vnext/ReactUWP/ReactUWP.vcxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vnext/ReactUWP/ReactUWP.vcxproj b/vnext/ReactUWP/ReactUWP.vcxproj index 66d6ff466b3..76d54b850eb 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -83,6 +83,7 @@ USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) OLD_CPPWINRT;REACTWINDOWS_BUILD;RN_PLATFORM=uwp;NOMINMAX;FOLLY_NO_CONFIG;RN_EXPORT=;JSI_EXPORT=;WIN32=0;WINRT=1;NOJSC;_HAS_AUTO_PTR_ETC;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Pch;$(ReactNativeWindowsDir)ReactUWP\GeneratedWinmdHeader;$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactUWP;$(YogaDir);$(ReactNativeDir)\ReactCommon;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)Shared;$(FollyDir);%(AdditionalIncludeDirectories) + $(ChakraCoreInclude);$(ChakraCoreDebugInclude);%(AdditionalIncludeDirectories) stdcpp17 /await %(AdditionalOptions) false @@ -92,6 +93,8 @@ true DebugFull -minpdbpathlen:256 + ChakraCore.Debugger.Protocol.lib;ChakraCore.Debugger.ProtocolHandler.lib;ChakraCore.Debugger.Service.lib;ChakraCore.lib;WindowsApp.lib;%(AdditionalDependencies) + $(ChakraCoreLibDir);$(ChakraCoreDebugLibDir) $(ProjectDir)ABI\idl From dd677c1fa4a259bcf04b961852bacd0f3bf3c303 Mon Sep 17 00:00:00 2001 From: Stephen Crain Date: Tue, 18 Jun 2019 09:08:35 -0700 Subject: [PATCH 4/4] one more ifdef --- vnext/Chakra/ChakraHelpers.cpp | 3 ++- vnext/Chakra/ChakraJsiRuntime_core.cpp | 2 ++ vnext/package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vnext/Chakra/ChakraHelpers.cpp b/vnext/Chakra/ChakraHelpers.cpp index 0c3cded07fb..98bd91fc6c7 100644 --- a/vnext/Chakra/ChakraHelpers.cpp +++ b/vnext/Chakra/ChakraHelpers.cpp @@ -49,6 +49,7 @@ bool fwrite(const T& val, FILE* file) noexcept return fwrite(&val, 1, file) == 1; } +#if !defined(CHAKRACOREUWP) struct FileVersionInfoResource { uint16_t len; @@ -59,7 +60,7 @@ struct FileVersionInfoResource VS_FIXEDFILEINFO fixedFileInfo; uint32_t padding2; }; - +#endif class ChakraVersionInfo { public: diff --git a/vnext/Chakra/ChakraJsiRuntime_core.cpp b/vnext/Chakra/ChakraJsiRuntime_core.cpp index ab9ba7683fc..4eaba820d7d 100644 --- a/vnext/Chakra/ChakraJsiRuntime_core.cpp +++ b/vnext/Chakra/ChakraJsiRuntime_core.cpp @@ -179,6 +179,7 @@ void ChakraJsiRuntime::setupNativePromiseContinuation() noexcept{ } } +#if !defined(CHAKRACOREUWP) // This is very wierd. This should match with the definition of VS_VERSIONINFO as defined in https://docs.microsoft.com/en-us/windows/desktop/menurc/vs-versioninfo // I can't find a way to include the actual definition of VS_VERSIONINFO // TODO :: Re-evaluate this strategy. @@ -191,6 +192,7 @@ struct FileVersionInfoResource { VS_FIXEDFILEINFO fixedFileInfo; uint32_t padding2; }; +#endif // TODO :: This code is mostly copied from the old ChakraExecutor flow, and not verified for reliability yet. // TODO :: Re-evaluate this strategy of finding the dll version for versioning the runtime. diff --git a/vnext/package.json b/vnext/package.json index bc3033bd373..4df767bfd08 100644 --- a/vnext/package.json +++ b/vnext/package.json @@ -72,4 +72,4 @@ "react": "16.8.3", "react-native": "^0.59.0 || 0.59.0-microsoft.4 || https://github.com/microsoft/react-native/archive/v0.59.0-microsoft.4.tar.gz" } -} \ No newline at end of file +}