зеркало из https://github.com/microsoft/v8-jsi.git
Switch to V8 8.0; improve CI build time (#5)
* Switch back to V8 8.0 (with disabled FH4 support for 141 toolset compatibility); * Reduce unnecessary dependencies on Boost libraries; * Use NuGet for bringing in Boost ASIO headers (much faster than downloading the whole zip from boostorg); * Misc fixes (include v8 version / ref number in NuGet, etc.);
This commit is contained in:
Родитель
496803ff04
Коммит
c77944d194
|
@ -1,2 +1,3 @@
|
|||
build
|
||||
out
|
||||
out
|
||||
.vscode
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<metadata>
|
||||
<id>ReactNative.V8Jsi.Windows</id>
|
||||
<version>$Version$</version>
|
||||
<description>Contains a Windows implementation of the V8 JSI wrapper for ReactNative</description>
|
||||
<description>Contains a Windows implementation of the V8 JSI wrapper for ReactNative (VERSION_DETAILS)</description>
|
||||
<authors>Facebook, Google, Microsoft</authors>
|
||||
<projectUrl>https://github.com/microsoft/v8-jsi</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
|
|
|
@ -30,12 +30,12 @@ jobs:
|
|||
X86Release:
|
||||
BuildConfiguration: Release
|
||||
BuildPlatform: x86
|
||||
X64Release-Clang:
|
||||
BuildConfiguration: Release-Clang
|
||||
BuildPlatform: x64
|
||||
X86Release-Clang:
|
||||
BuildConfiguration: Release-Clang
|
||||
BuildPlatform: x86
|
||||
#X64Release-Clang:
|
||||
# BuildConfiguration: Release-Clang
|
||||
# BuildPlatform: x64
|
||||
#X86Release-Clang:
|
||||
# BuildConfiguration: Release-Clang
|
||||
# BuildPlatform: x86
|
||||
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"version": "0.2.2",
|
||||
"v8ref": "refs/branch-heads/7.9"
|
||||
"v8ref": "refs/branch-heads/8.0"
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
$OutputPath = "$PSScriptRoot\out"
|
||||
$SourcesPath = $PSScriptRoot
|
||||
$Platforms = "x64", "x86"
|
||||
$Configurations = "Debug", "Release", "Release-Clang"
|
||||
$Configurations = "Release", "Debug", "Release-Clang", "EXPERIMENTAL-libcpp-Clang"
|
||||
|
||||
Write-Host "Downloading environment..."
|
||||
& ".\scripts\download_depottools.ps1" -SourcesPath $SourcesPath
|
||||
|
@ -14,7 +14,7 @@ if (!$?) {
|
|||
}
|
||||
|
||||
Write-Host "Fetching code..."
|
||||
& ".\scripts\fetch_code.ps1" -SourcesPath $SourcesPath -Configuration $Configurations[0]
|
||||
& ".\scripts\fetch_code.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Configuration $Configurations[0]
|
||||
|
||||
if (!$?) {
|
||||
Write-Host "Failed to retrieve the v8 code"
|
||||
|
|
|
@ -28,6 +28,19 @@ if (!(Select-String -Path (Join-Path $workpath "v8build\v8\BUILD.gn") -Pattern '
|
|||
$FixNeededPath = Join-Path $workpath "v8build\v8\build\config\win\BUILD.gn"
|
||||
(Get-Content $FixNeededPath) -replace (":static_crt", ":dynamic_crt") | Set-Content $FixNeededPath
|
||||
|
||||
#TODO: This is temporary until Office moves to the new toolset with FH4 support (ETA: May 2020)
|
||||
(Get-Content $FixNeededPath) -replace ('/Zc:sizedDealloc-', @'
|
||||
/Zc:sizedDealloc-","-d2FH4-
|
||||
'@) | Set-Content $FixNeededPath
|
||||
|
||||
(Get-Content $FixNeededPath) -replace ('ldflags = \[\]', @'
|
||||
if (is_clang) {
|
||||
ldflags = []
|
||||
} else {
|
||||
ldflags = ["-d2:-FH4-"]
|
||||
}
|
||||
'@) | Set-Content $FixNeededPath
|
||||
|
||||
Remove-Item (Join-Path $workpath "v8build\v8\jsi") -Recurse -ErrorAction Ignore
|
||||
Copy-Item $jsigitpath -Destination (Join-Path $workpath "v8build\v8\jsi") -Recurse -Force
|
||||
|
||||
|
@ -40,7 +53,11 @@ if ($Configuration -like "*android") {
|
|||
$gnargs += ' use_goma=false target_os=\"android\" target_cpu=\"' + $Platform + '\"'
|
||||
}
|
||||
else {
|
||||
$gnargs += ' use_custom_libcxx=false target_cpu=\"' + $Platform + '\"'
|
||||
if (-not ($Configuration -like "*libcpp*")) {
|
||||
$gnargs += ' use_custom_libcxx=false'
|
||||
}
|
||||
|
||||
$gnargs += ' target_cpu=\"' + $Platform + '\"'
|
||||
|
||||
if ($Configuration -like "*clang") {
|
||||
#TODO (#2): we need to figure out how to actually build DEBUG with clang-cl (won't work today due to STL iterator issues)
|
||||
|
@ -118,7 +135,7 @@ Copy-Item "$jsigitpath\jsi\jsi.cpp" -Destination "$OutputPath\build\native\inclu
|
|||
Copy-Item "$jsigitpath\jsi\instrumentation.h" -Destination "$OutputPath\build\native\include\jsi\"
|
||||
|
||||
# Miscellaneous
|
||||
Copy-Item "$SourcesPath\ReactNative.V8Jsi.Windows.nuspec" -Destination "$OutputPath\"
|
||||
#Copy-Item "$SourcesPath\ReactNative.V8Jsi.Windows.nuspec" -Destination "$OutputPath\"
|
||||
Copy-Item "$SourcesPath\ReactNative.V8Jsi.Windows.targets" -Destination "$OutputPath\build\native\"
|
||||
Copy-Item "$SourcesPath\config.json" -Destination "$OutputPath\"
|
||||
Copy-Item "$SourcesPath\LICENSE" -Destination "$OutputPath\license\"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT license.
|
||||
param(
|
||||
[string]$SourcesPath = $PSScriptRoot,
|
||||
[string]$OutputPath = "$PSScriptRoot\out",
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
|
@ -27,7 +28,7 @@ $env:GIT_REDIRECT_STDERR = '2>&1'
|
|||
$config = Get-Content (Join-Path $SourcesPath "config.json") | Out-String | ConvertFrom-Json
|
||||
|
||||
& git fetch origin $config.v8ref
|
||||
& git checkout FETCH_HEAD
|
||||
$CheckOutVersion = (git checkout FETCH_HEAD) | Out-String
|
||||
& gclient sync
|
||||
|
||||
#TODO (#2): Submit PR upstream to Google for this fix
|
||||
|
@ -42,7 +43,26 @@ if (!$PSVersionTable.Platform -or $IsWindows) {
|
|||
Pop-Location
|
||||
Pop-Location
|
||||
|
||||
Write-Host "##vso[task.setvariable variable=V8JSI_VERSION;]$config.version"
|
||||
$verString = $config.version
|
||||
|
||||
$gitRevision = ""
|
||||
$v8Version = ""
|
||||
|
||||
$Matches = $CheckOutVersion | Select-String -Pattern 'HEAD is now at (.+) Version (.+)'
|
||||
if ($Matches.Matches.Success) {
|
||||
$gitRevision = $Matches.Matches.Groups[1].Value
|
||||
$v8Version = $Matches.Matches.Groups[2].Value.Trim()
|
||||
$verString = $verString + "-v8_" + $v8Version.Replace('.', '_')
|
||||
}
|
||||
|
||||
# Save the revision information in the NuGet description
|
||||
if (!(Test-Path -Path $OutputPath)) {
|
||||
New-Item -ItemType "directory" -Path $OutputPath | Out-Null
|
||||
}
|
||||
|
||||
(Get-Content "$SourcesPath\ReactNative.V8Jsi.Windows.nuspec") -replace ('VERSION_DETAILS', "V8 version: $v8Version; Git revision: $gitRevision") | Set-Content "$OutputPath\ReactNative.V8Jsi.Windows.nuspec"
|
||||
|
||||
Write-Host "##vso[task.setvariable variable=V8JSI_VERSION;]$verString"
|
||||
|
||||
# Install build depndencies for Android
|
||||
if ($PSVersionTable.Platform -and !$IsWindows) {
|
||||
|
@ -54,28 +74,15 @@ if ($PSVersionTable.Platform -and !$IsWindows) {
|
|||
#TODO (#2): Use the .gzip for Android / Linux builds
|
||||
# Verify the Boost installation
|
||||
if (-not (Test-Path "$env:BOOST_ROOT\boost\asio.hpp")) {
|
||||
|
||||
if (-not (Test-Path (Join-Path $workpath "v8build\boost\boost_1_72_0\boost\asio.hpp"))) {
|
||||
if (-not (Test-Path (Join-Path $workpath "v8build/boost.1.71.0.0/lib/native/include/boost/asio.hpp"))) {
|
||||
Write-Host "Boost ASIO not found, downloading..."
|
||||
|
||||
# This operation will take a long time, but it's required on the Azure Agents because they don't have ASIO headers
|
||||
$output = [System.IO.Path]::GetTempFileName()
|
||||
$targetNugetExe = Join-Path $workpath "nuget.exe"
|
||||
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $targetNugetExe
|
||||
|
||||
# If 7-zip is available on path, use it as it's much faster and lets us unpack just the folder we need
|
||||
if (Get-Command "7z.exe" -ErrorAction SilentlyContinue) {
|
||||
Invoke-WebRequest -Uri "https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.7z" -OutFile "$output.7z"
|
||||
Write-Host "Unzipping archive..."
|
||||
7z x "$output.7z" -o"$workpath\v8build\boost" -i!boost_1_72_0\boost
|
||||
Remove-Item "$output.7z"
|
||||
}
|
||||
else {
|
||||
Invoke-WebRequest -Uri "https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.zip" -OutFile "$output.zip"
|
||||
Write-Host "Unzipping archive..."
|
||||
Expand-Archive -path "$output.zip" -DestinationPath "$workpath\v8build\boost"
|
||||
Remove-Item "$output.zip"
|
||||
}
|
||||
& $targetNugetExe install -OutputDirectory (Join-Path $workpath "v8build") boost -Version 1.71.0
|
||||
}
|
||||
|
||||
$env:BOOST_ROOT = Join-Path $workpath "v8build\boost\boost_1_72_0"
|
||||
Write-Host "##vso[task.setvariable variable=BOOST_ROOT;]$workpath\v8build\boost\boost_1_72_0"
|
||||
$env:BOOST_ROOT = Join-Path $workpath "v8build/boost.1.71.0.0/lib/native/include"
|
||||
Write-Host "##vso[task.setvariable variable=BOOST_ROOT;]$env:BOOST_ROOT"
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ target("shared_library", "v8jsi") {
|
|||
"V8Platform.h",
|
||||
]
|
||||
|
||||
cflags = [ "-DBOOST_ASIO_STANDALONE", "-DBOOST_ASIO_HEADER_ONLY" ]
|
||||
|
||||
if (is_win) {
|
||||
sources += [
|
||||
"etw/tracing.h",
|
||||
|
|
|
@ -15,12 +15,10 @@
|
|||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <condition_variable>
|
||||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
#include <array>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
|
||||
namespace inspector {
|
||||
|
||||
|
@ -42,9 +40,21 @@ std::string GetProcessTitle() {
|
|||
}
|
||||
|
||||
std::string GenerateID() {
|
||||
boost::uuids::uuid uuid = boost::uuids::random_generator()();
|
||||
return boost::uuids::to_string(uuid);
|
||||
//return "RANDON_UUID";
|
||||
static std::random_device rd;
|
||||
static std::mt19937 mte(rd());
|
||||
|
||||
std::uniform_int_distribution<uint16_t> dist;
|
||||
|
||||
std::array<uint16_t, 8> buffer;
|
||||
std::generate(buffer.begin(), buffer.end(), [&] () { return dist(mte); });
|
||||
|
||||
char uuid[256];
|
||||
snprintf(uuid, sizeof(uuid), "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
buffer[0], buffer[1], buffer[2],
|
||||
(buffer[3] & 0x0fff) | 0x4000,
|
||||
(buffer[4] & 0x3fff) | 0x8000,
|
||||
buffer[5], buffer[6], buffer[7]);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
std::string StringViewToUtf8(const v8_inspector::StringView &view) {
|
||||
|
|
|
@ -73,7 +73,7 @@ class TcpHolder {
|
|||
|
||||
void read_loop();
|
||||
|
||||
boost::shared_ptr<tcp_connection> connection() { return connection_; };
|
||||
std::shared_ptr<tcp_connection> connection() { return connection_; };
|
||||
InspectorSocket::Delegate* delegate();
|
||||
|
||||
static void OnClosedCallback(void*data);
|
||||
|
@ -84,7 +84,7 @@ class TcpHolder {
|
|||
|
||||
tcp_connection::pointer connection_;
|
||||
|
||||
explicit TcpHolder(boost::shared_ptr<tcp_connection> connection, InspectorSocket::DelegatePointer delegate);
|
||||
explicit TcpHolder(std::shared_ptr<tcp_connection> connection, InspectorSocket::DelegatePointer delegate);
|
||||
~TcpHolder() = default;
|
||||
|
||||
const InspectorSocket::DelegatePointer delegate_;
|
||||
|
@ -638,7 +638,7 @@ std::string ProtocolHandler::GetHost() const {
|
|||
}
|
||||
|
||||
// RAII uv_tcp_t wrapper
|
||||
TcpHolder::TcpHolder(boost::shared_ptr<tcp_connection> connection, InspectorSocket::DelegatePointer delegate)
|
||||
TcpHolder::TcpHolder(std::shared_ptr<tcp_connection> connection, InspectorSocket::DelegatePointer delegate)
|
||||
: delegate_(std::move(delegate)),
|
||||
connection_(connection), handler_(nullptr) { }
|
||||
|
||||
|
@ -712,7 +712,7 @@ void InspectorSocket::Shutdown(ProtocolHandler* handler) {
|
|||
}
|
||||
|
||||
// static
|
||||
InspectorSocket::Pointer InspectorSocket::Accept(boost::shared_ptr<tcp_connection> connection, DelegatePointer delegate) {
|
||||
InspectorSocket::Pointer InspectorSocket::Accept(std::shared_ptr<tcp_connection> connection, DelegatePointer delegate) {
|
||||
auto tcp = TcpHolder::Accept(connection, std::move(delegate));
|
||||
if (tcp) {
|
||||
InspectorSocket* inspector = new InspectorSocket();
|
||||
|
|
|
@ -38,7 +38,7 @@ class InspectorSocket {
|
|||
using DelegatePointer = std::unique_ptr<Delegate>;
|
||||
using Pointer = std::unique_ptr<InspectorSocket>;
|
||||
|
||||
static Pointer Accept(boost::shared_ptr<tcp_connection> connection, DelegatePointer delegate);
|
||||
static Pointer Accept(std::shared_ptr<tcp_connection> connection, DelegatePointer delegate);
|
||||
|
||||
~InspectorSocket();
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ std::string InspectorSocketServer::GetFrontendURL(bool is_compat,
|
|||
return frontend_url.str();
|
||||
}
|
||||
|
||||
/*static */void InspectorSocketServer::SocketConnectedCallback(boost::shared_ptr<tcp_connection> connection, void* callbackData_) {
|
||||
/*static */void InspectorSocketServer::SocketConnectedCallback(std::shared_ptr<tcp_connection> connection, void* callbackData_) {
|
||||
InspectorSocketServer* server = reinterpret_cast<InspectorSocketServer*>(callbackData_);
|
||||
server->Accept(connection, server->port_);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ int InspectorSocketServer::Port() const {
|
|||
return port_;
|
||||
}
|
||||
|
||||
void InspectorSocketServer::Accept(boost::shared_ptr<tcp_connection> connection, int server_port) {
|
||||
void InspectorSocketServer::Accept(std::shared_ptr<tcp_connection> connection, int server_port) {
|
||||
std::unique_ptr<SocketSession> session(
|
||||
new SocketSession(this, next_session_id_++, server_port));
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
int Port() const;
|
||||
|
||||
// Session connection lifecycle
|
||||
void Accept(boost::shared_ptr<tcp_connection> connection, int server_port/*, uv_stream_t* server_socket*/);
|
||||
void Accept(std::shared_ptr<tcp_connection> connection, int server_port/*, uv_stream_t* server_socket*/);
|
||||
bool HandleGetRequest(int session_id, const std::string& host, const std::string& path);
|
||||
void SessionStarted(int session_id, const std::string& target_id, const std::string& ws_id);
|
||||
void SessionTerminated(int session_id);
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
// return server_sockets_.empty() && connected_sessions_.empty();
|
||||
//}
|
||||
|
||||
static void InspectorSocketServer::SocketConnectedCallback(boost::shared_ptr<tcp_connection> connection, void* callbackData_);
|
||||
static void InspectorSocketServer::SocketConnectedCallback(std::shared_ptr<tcp_connection> connection, void* callbackData_);
|
||||
static void InspectorSocketServer::SocketClosedCallback(void* callbackData_);
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
// This code is based on the old node inspector implementation. See LICENSE_NODE for Node.js' project license details
|
||||
#include "inspector_tcp.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace inspector {
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
// This code is based on the old node inspector implementation. See LICENSE_NODE for Node.js' project license details
|
||||
#pragma once
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
|
||||
namespace inspector {
|
||||
|
||||
class tcp_connection : public boost::enable_shared_from_this<tcp_connection>
|
||||
class tcp_connection : public std::enable_shared_from_this<tcp_connection>
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<tcp_connection> pointer;
|
||||
typedef std::shared_ptr<tcp_connection> pointer;
|
||||
|
||||
static pointer create(boost::asio::ip::tcp::socket socket);
|
||||
boost::asio::ip::tcp::socket& socket();
|
||||
|
@ -56,10 +54,10 @@ private:
|
|||
bool writing_{ false };
|
||||
};
|
||||
|
||||
class tcp_server : public boost::enable_shared_from_this<tcp_server> {
|
||||
class tcp_server : public std::enable_shared_from_this<tcp_server> {
|
||||
public:
|
||||
typedef std::shared_ptr<tcp_server> pointer;
|
||||
typedef void(*ConnectionCallback)(boost::shared_ptr<tcp_connection> connection, void* callbackData_);
|
||||
typedef void(*ConnectionCallback)(std::shared_ptr<tcp_connection> connection, void* callbackData_);
|
||||
|
||||
void run();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче