diff --git a/Common/3dParty/v8/v8_xp/build.bat b/Common/3dParty/v8/v8_xp/build.bat new file mode 100644 index 0000000000..29916865ec --- /dev/null +++ b/Common/3dParty/v8/v8_xp/build.bat @@ -0,0 +1,64 @@ +SET SCRIPTPATH=%~dp0 +CD /D %~dp0 + +SET PATH=%SCRIPTPATH%depot_tools;%SCRIPTPATH%depot_tools\win_tools-2_7_6_bin\python\bin;%PATH% +SET DEPOT_TOOLS_WIN_TOOLCHAIN=0 +SET GYP_MSVS_VERSION=2015 + +SET VC64_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE +SET VC32_PATH=%ProgramFiles%\Microsoft Visual Studio 14.0\Common7\IDE + +setlocal enabledelayedexpansion +if defined ProgramFiles(x86) ( + SET PATH=!VC64_PATH!;!PATH! +) else ( + SET PATH=!VC32_PATH!;!PATH! +) + +if not exist "win_32" ( + echo "building x86... -------------------------------------------" + + md win_32 + md win_32\debug + md win_32\release + + call python v8\build\gyp_v8 + call .\change_projects.bat + + cd "%SCRIPTPATH%v8\tools\gyp" + + call devenv v8.sln /Rebuild "Release" + call devenv v8.sln /Rebuild "Debug" + + cd "%SCRIPTPATH%" + + XCOPY /Y "v8\build\Release\lib\*" "win_32\release\" + XCOPY /Y "v8\build\Release\icudt.dll" "win_32\release\" + + XCOPY /Y "v8\build\Debug\lib\*" "win_32\debug\" + XCOPY /Y "v8\build\Debug\icudt.dll" "win_32\debug\" +) + +if not exist "win_64" ( + echo "building x64... -------------------------------------------" + + md win_64 + md win_64\debug + md win_64\release + + call python v8\build\gyp_v8 -Dtarget_arch=x64 + call .\change_projects.bat + + cd "%SCRIPTPATH%v8\tools\gyp" + + call devenv v8.sln /Rebuild "Release" + call devenv v8.sln /Rebuild "Debug" + + cd "%SCRIPTPATH%" + + XCOPY /Y "v8\build\Release\lib\*" "win_64\release\" + XCOPY /Y "v8\build\Release\icudt.dll" "win_64\release\" + + XCOPY /Y "v8\build\Debug\lib\*" "win_64\debug\" + XCOPY /Y "v8\build\Debug\icudt.dll" "win_64\debug\" +) diff --git a/Common/3dParty/v8/v8_xp/change_projects.bat b/Common/3dParty/v8/v8_xp/change_projects.bat new file mode 100644 index 0000000000..63b38ab2b5 --- /dev/null +++ b/Common/3dParty/v8/v8_xp/change_projects.bat @@ -0,0 +1,34 @@ +SET SCRIPTPATH=%~dp0 +CD /D %~dp0 + +cd "%SCRIPTPATH%v8\tools\gyp" +call powershell -Command "(gc v8_base_0.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_base_0.vcxproj" +call powershell -Command "(gc v8_base_0.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_base_0.vcxproj" + +call powershell -Command "(gc v8_base_1.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_base_1.vcxproj" +call powershell -Command "(gc v8_base_1.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_base_1.vcxproj" + +call powershell -Command "(gc v8_base_2.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_base_2.vcxproj" +call powershell -Command "(gc v8_base_2.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_base_2.vcxproj" + +call powershell -Command "(gc v8_base_3.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_base_3.vcxproj" +call powershell -Command "(gc v8_base_3.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_base_3.vcxproj" + +call powershell -Command "(gc v8_libbase.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_libbase.vcxproj" +call powershell -Command "(gc v8_libbase.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_libbase.vcxproj" + +call powershell -Command "(gc v8_libplatform.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_libplatform.vcxproj" +call powershell -Command "(gc v8_libplatform.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_libplatform.vcxproj" + +call powershell -Command "(gc v8_nosnapshot.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' v8_nosnapshot.vcxproj" +call powershell -Command "(gc v8_nosnapshot.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' v8_nosnapshot.vcxproj" + +call powershell -Command "(gc mksnapshot.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' mksnapshot.vcxproj" +call powershell -Command "(gc mksnapshot.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' mksnapshot.vcxproj" + +cd "%SCRIPTPATH%v8\third_party\icu" +call powershell -Command "(gc icui18n.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' icui18n.vcxproj" +call powershell -Command "(gc icui18n.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' icui18n.vcxproj" + +call powershell -Command "(gc icuuc.vcxproj) -replace 'MultiThreadedDebug', 'MultiThreadedDebugDLL' | Out-File -Encoding 'UTF8' icuuc.vcxproj" +call powershell -Command "(gc icuuc.vcxproj) -replace 'MultiThreaded', 'MultiThreadedDLL' | Out-File -Encoding 'UTF8' icuuc.vcxproj" diff --git a/Common/3dParty/v8/v8_xp/fetch.bat b/Common/3dParty/v8/v8_xp/fetch.bat new file mode 100644 index 0000000000..140a7f80ad --- /dev/null +++ b/Common/3dParty/v8/v8_xp/fetch.bat @@ -0,0 +1,19 @@ +SET SCRIPTPATH=%~dp0 +CD /D %~dp0 + +if exist "depot_tools" ( + echo "depot_tools already fetched" +) else ( + call git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git + call powershell -File .\fix-depot_tools.ps1 +) + +SET PATH=%SCRIPTPATH%depot_tools;%SCRIPTPATH%depot_tools\python276_bin;%PATH% +SET DEPOT_TOOLS_WIN_TOOLCHAIN=0 +SET GYP_MSVS_VERSION=2015 + +if not exist "%SCRIPTPATH%v8" ( +call .\depot_tools\fetch v8 +) + +call depot_tools\gclient sync -r 4.10.253 diff --git a/Common/3dParty/v8/v8_xp/fix-depot_tools.ps1 b/Common/3dParty/v8/v8_xp/fix-depot_tools.ps1 new file mode 100644 index 0000000000..936bf7c7f8 --- /dev/null +++ b/Common/3dParty/v8/v8_xp/fix-depot_tools.ps1 @@ -0,0 +1,4 @@ +$gclient_path = "depot_tools\gclient.bat" +$fetch_path = "depot_tools\fetch.bat" +(Get-Content $gclient_path) | ForEach-Object { $_ -replace "^(`"%~dp0python`")", "call $&" } | Set-Content $gclient_path +(Get-Content $fetch_path) | ForEach-Object { $_ -replace "^(%~dp0python)", "call $&" } | Set-Content $fetch_path diff --git a/Common/3dParty/v8/v8_xp/v8.pri b/Common/3dParty/v8/v8_xp/v8.pri new file mode 100644 index 0000000000..dc4536a4a0 --- /dev/null +++ b/Common/3dParty/v8/v8_xp/v8.pri @@ -0,0 +1,30 @@ +CORE_V8_PATH_INCLUDE = $$PWD/v8 +CORE_V8_PATH_LIBS = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX + +INCLUDEPATH += \ + $$CORE_V8_PATH_INCLUDE \ + $$CORE_V8_PATH_INCLUDE/include + +core_windows { + CORE_V8_PATH_LIBS = $$CORE_V8_PATH_LIBS/$$CORE_BUILDS_CONFIGURATION_PREFIX + + LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base_0 -lv8_base_1 -lv8_base_2 -lv8_base_3 -lv8_libbase -lv8_libplatform -lv8_nosnapshot -lv8_external_snapshot + LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc + + LIBS += -lwinmm + LIBS += -ladvapi32 + LIBS += -lShell32 +} + +core_linux { + LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_nosnapshot -lv8_external_snapshot + LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc -licudata +} + +core_mac { + LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libbase -lv8_libplatform -lv8_nosnapshot -lv8_external_snapshot + LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc -lv8_libsampler + + QMAKE_CXXFLAGS += -Wall -Wno-inconsistent-missing-override + QMAKE_CFLAGS += -Wall -Wno-inconsistent-missing-override +} diff --git a/DesktopEditor/doctrenderer/doctrenderer.pro b/DesktopEditor/doctrenderer/doctrenderer.pro index f08560a34b..05b171ed22 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.pro +++ b/DesktopEditor/doctrenderer/doctrenderer.pro @@ -18,7 +18,15 @@ include(../../Common/base.pri) LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics -include(../../Common/3dParty/v8/v8.pri) +#CONFIG += build_xp + +!build_xp { + include(../../Common/3dParty/v8/v8.pri) +} else { + DEFINES += V8_OS_XP + DESTDIR=$$DESTDIR/xp + include(../../Common/3dParty/v8/v8_xp/v8.pri) +} SOURCES += \ memorystream.cpp \ diff --git a/DesktopEditor/doctrenderer/nativecontrol.h b/DesktopEditor/doctrenderer/nativecontrol.h index 97173c4b7e..de5e475d1a 100644 --- a/DesktopEditor/doctrenderer/nativecontrol.h +++ b/DesktopEditor/doctrenderer/nativecontrol.h @@ -1158,6 +1158,29 @@ public: }; #endif +#ifdef V8_OS_XP + +class ExternalMallocArrayBufferAllocator : public v8::ArrayBuffer::Allocator +{ +public: + virtual void* Allocate(size_t length) + { + void* ret = malloc(length); + memset(ret, 0, length); + return ret; + } + virtual void* AllocateUninitialized(size_t length) + { + return malloc(length); + } + virtual void Free(void* data, size_t length) + { + free(data); + } +}; + +#endif + ////////////////////////////////////////////////////////////////////////////// class CV8Initializer { @@ -1171,11 +1194,19 @@ public: std::wstring sPrW = NSFile::GetProcessPath(); std::string sPrA = U_TO_UTF8(sPrW); +#ifndef V8_OS_XP v8::V8::InitializeICUDefaultLocation(sPrA.c_str()); v8::V8::InitializeExternalStartupData(sPrA.c_str()); m_platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(m_platform); v8::V8::Initialize(); +#else + m_platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(m_platform); + + v8::V8::Initialize(); + v8::V8::InitializeICU(); +#endif } ~CV8Initializer() { @@ -1193,7 +1224,11 @@ public: v8::Isolate* CreateNew() { v8::Isolate::CreateParams create_params; +#ifndef V8_OS_XP m_pAllocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); +#else + m_pAllocator = new ExternalMallocArrayBufferAllocator(); +#endif create_params.array_buffer_allocator = m_pAllocator; return v8::Isolate::New(create_params); }