From dfea8da32791bfd81781ae883025cace198a4e7e Mon Sep 17 00:00:00 2001 From: namark Date: Thu, 14 Mar 2024 18:30:40 +0400 Subject: [PATCH 01/19] Added environment variable to override WebRTC ICE servers. Enabled verbose WebRTC logging. --- .../src/webrtc/WebRTCDataChannels.cpp | 68 +++++++++++++++++-- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 86feed65ac..578ede75bf 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -11,8 +11,10 @@ #if defined(WEBRTC_DATA_CHANNELS) +#include #include #include +#include #include "../NetworkLogging.h" @@ -29,7 +31,7 @@ const std::list DEFAULT_ICE_SERVER_URLS = { }; const int MAX_WEBRTC_BUFFER_SIZE = 16777216; // 16MB -// #define WEBRTC_DEBUG +#define WEBRTC_DEBUG using namespace webrtc; @@ -667,15 +669,67 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec #endif PeerConnectionInterface::RTCConfiguration configuration; - configuration.servers = _iceServers; - if (configuration.servers.empty()) { - for (const auto& url : DEFAULT_ICE_SERVER_URLS) { - PeerConnectionInterface::IceServer iceServer; - iceServer.urls = std::vector{url}; - configuration.servers.push_back(iceServer); + + const QString WEBRTC_ICE_SERVERS_OVERRIDE_ENV = "VRCA_OVERRIDE_WEBRTC_ICE_SERVERS"; + if (QProcessEnvironment::systemEnvironment().contains(WEBRTC_ICE_SERVERS_OVERRIDE_ENV)) { + auto envString = QProcessEnvironment::systemEnvironment().value(WEBRTC_ICE_SERVERS_OVERRIDE_ENV).toUtf8(); + auto json = QJsonDocument::fromJson(envString); + if (json.isArray()) { + auto array = json.array(); + for (auto&& server : array) { + PeerConnectionInterface::IceServer iceServer; + if (server.isObject() && server.toObject().contains("urls")) { + auto urls = server.toObject()["urls"]; + if (urls.isArray()) { + for (auto&& url : urls.toArray()) { + iceServer.urls.push_back(url.toString().toStdString()); + } + } else { + iceServer.urls.push_back(urls.toString().toStdString()); + } + auto password = server.toObject()["credential"].toString().toStdString(); + auto username = server.toObject()["username"].toString().toStdString(); + if (password != "") { + iceServer.password = password; + } + if (username != "") { + iceServer.username = username; + } + configuration.servers.push_back(iceServer); + } else { + qCDebug(networking_webrtc) << "WebRTCDataChannels::createPeerConnection() : " << WEBRTC_ICE_SERVERS_OVERRIDE_ENV << " environment variable invalid"; + qCDebug(networking_webrtc) << envString; + break; + } + } + } else { + qCDebug(networking_webrtc) << "WebRTCDataChannels::createPeerConnection() : " << WEBRTC_ICE_SERVERS_OVERRIDE_ENV << " environment variable is not a JSON array"; + qCDebug(networking_webrtc) << envString; + } + } else { + configuration.servers = _iceServers; + if (configuration.servers.empty()) { + for (const auto& url : DEFAULT_ICE_SERVER_URLS) { + PeerConnectionInterface::IceServer iceServer; + iceServer.urls = std::vector{url}; + configuration.servers.push_back(iceServer); + } } } +#ifdef WEBRTC_DEBUG + qCDebug(networking_webrtc) << "WebRTCDataChannels::createPeerConnection() : Configuration ICE server list:"; + for (const auto& server : configuration.servers) { + qCDebug(networking_webrtc) << "URL: " << (server.urls.size() > 0 ? server.urls.front().c_str() : ""); + if (server.username != "") { + qCDebug(networking_webrtc) << "USERNAME: " << server.username.c_str(); + } + if (server.password != "") { + qCDebug(networking_webrtc) << "PASSWORD: " << server.password.c_str(); + } + } +#endif + #ifdef WEBRTC_DEBUG qCDebug(networking_webrtc) << "2. Create a new peer connection"; #endif From 876c90c4de82dc315479a1296c2e1924467918a7 Mon Sep 17 00:00:00 2001 From: namark Date: Thu, 21 Mar 2024 13:48:06 +0400 Subject: [PATCH 02/19] Disabled verbose WebRTC logging. --- libraries/networking/src/webrtc/WebRTCDataChannels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 578ede75bf..8a79a6bfec 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -31,7 +31,7 @@ const std::list DEFAULT_ICE_SERVER_URLS = { }; const int MAX_WEBRTC_BUFFER_SIZE = 16777216; // 16MB -#define WEBRTC_DEBUG +// #define WEBRTC_DEBUG using namespace webrtc; From bb74c7387608a1bf90102aef91a73856cc2ceb76 Mon Sep 17 00:00:00 2001 From: namark Date: Wed, 27 Mar 2024 10:58:31 +0400 Subject: [PATCH 03/19] Rudimentary debug logging levels for WebRTC data channels. --- .../src/webrtc/WebRTCDataChannels.cpp | 116 +++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 8a79a6bfec..51e4216b5e 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -31,19 +31,23 @@ const std::list DEFAULT_ICE_SERVER_URLS = { }; const int MAX_WEBRTC_BUFFER_SIZE = 16777216; // 16MB -// #define WEBRTC_DEBUG +#define WEBRTC_DEBUG_LEVEL_NONE 0 // default value if left undefined +#define WEBRTC_DEBUG_LEVEL_NORMAL 1 // basic peer connection logs +#define WEBRTC_DEBUG_LEVEL_VERBOSE 2 // full data channel logs + +#define WEBRTC_DEBUG WEBRTC_DEBUG_LEVEL_NORMAL using namespace webrtc; void WDCSetSessionDescriptionObserver::OnSuccess() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCSetSessionDescriptionObserver::OnSuccess()"; #endif } void WDCSetSessionDescriptionObserver::OnFailure(RTCError error) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCSetSessionDescriptionObserver::OnFailure() :" << error.message(); #endif } @@ -54,7 +58,7 @@ void WDCSetSessionDescriptionObserver::OnFailure(RTCError error) { #ifdef API_SET_LOCAL_DESCRIPTION_OBSERVER_INTERFACE_H_ void WDCSetLocalDescriptionObserver::OnSetLocalDescriptionComplete(webrtc::RTCError error) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE if(error.ok()) { qCDebug(networking_webrtc) << "SetLocalDescription call succeeded"; } else { @@ -64,7 +68,7 @@ void WDCSetLocalDescriptionObserver::OnSetLocalDescriptionComplete(webrtc::RTCEr } void WDCSetRemoteDescriptionObserver::OnSetRemoteDescriptionComplete(webrtc::RTCError error) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE if(error.ok()) { qCDebug(networking_webrtc) << "SetRemoteDescription call succeeded"; } else { @@ -80,7 +84,7 @@ WDCCreateSessionDescriptionObserver::WDCCreateSessionDescriptionObserver(WDCConn { } void WDCCreateSessionDescriptionObserver::OnSuccess(SessionDescriptionInterface* descriptionRaw) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCCreateSessionDescriptionObserver::OnSuccess()"; #endif // NOTE: according to documentation in the relevant webrtc header, @@ -95,7 +99,7 @@ void WDCCreateSessionDescriptionObserver::OnSuccess(SessionDescriptionInterface* } void WDCCreateSessionDescriptionObserver::OnFailure(RTCError error) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCCreateSessionDescriptionObserver::OnFailure() :" << error.message(); #endif } @@ -106,7 +110,7 @@ WDCPeerConnectionObserver::WDCPeerConnectionObserver(WDCConnection* parent) : { } void WDCPeerConnectionObserver::OnSignalingChange(PeerConnectionInterface::SignalingState newState) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "Stable", "HaveLocalOffer", @@ -120,13 +124,13 @@ void WDCPeerConnectionObserver::OnSignalingChange(PeerConnectionInterface::Signa } void WDCPeerConnectionObserver::OnRenegotiationNeeded() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnRenegotiationNeeded()"; #endif } void WDCPeerConnectionObserver::OnIceGatheringChange(PeerConnectionInterface::IceGatheringState newState) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "New", "Gathering", @@ -137,14 +141,14 @@ void WDCPeerConnectionObserver::OnIceGatheringChange(PeerConnectionInterface::Ic } void WDCPeerConnectionObserver::OnIceCandidate(const IceCandidateInterface* candidate) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnIceCandidate()"; #endif _parent->sendIceCandidate(candidate); } void WDCPeerConnectionObserver::OnIceConnectionChange(PeerConnectionInterface::IceConnectionState newState) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "New", "Checking", @@ -160,7 +164,7 @@ void WDCPeerConnectionObserver::OnIceConnectionChange(PeerConnectionInterface::I } void WDCPeerConnectionObserver::OnStandardizedIceConnectionChange(PeerConnectionInterface::IceConnectionState newState) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "New", "Checking", @@ -177,14 +181,14 @@ void WDCPeerConnectionObserver::OnStandardizedIceConnectionChange(PeerConnection } void WDCPeerConnectionObserver::OnDataChannel(rtc::scoped_refptr dataChannel) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnDataChannel()"; #endif _parent->onDataChannelOpened(dataChannel); } void WDCPeerConnectionObserver::OnConnectionChange(PeerConnectionInterface::PeerConnectionState newState) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "New", "Connecting", @@ -205,14 +209,14 @@ WDCDataChannelObserver::WDCDataChannelObserver(WDCConnection* parent) : { } void WDCDataChannelObserver::OnStateChange() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCDataChannelObserver::OnStateChange()"; #endif _parent->onDataChannelStateChanged(); } void WDCDataChannelObserver::OnMessage(const DataBuffer& buffer) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCDataChannelObserver::OnMessage()"; #endif _parent->onDataChannelMessageReceived(buffer); @@ -224,7 +228,7 @@ WDCConnection::WDCConnection(WebRTCDataChannels* parent, const QString& dataChan _dataChannelID(dataChannelID), _peerConnection() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCConnection::WDCConnection() :" << dataChannelID; #endif @@ -240,7 +244,7 @@ WDCConnection::WDCConnection(WebRTCDataChannels* parent, const QString& dataChan }; void WDCConnection::setRemoteDescription(QJsonObject& description) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::setRemoteDescription() :" << description; #endif @@ -261,7 +265,7 @@ void WDCConnection::setRemoteDescription(QJsonObject& description) { return; } -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "3. Set remote description:" << sessionDescription.get(); #endif if (_peerConnection) { @@ -276,7 +280,7 @@ void WDCConnection::setRemoteDescription(QJsonObject& description) { } void WDCConnection::createAnswer() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::createAnswer()"; qCDebug(networking_webrtc) << "4.a Create answer"; #endif @@ -286,7 +290,7 @@ void WDCConnection::createAnswer() { } void WDCConnection::sendAnswer(std::string descriptionString) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::sendAnswer()"; qCDebug(networking_webrtc) << "4.b Send answer to the remote peer"; #endif @@ -307,7 +311,7 @@ void WDCConnection::sendAnswer(std::string descriptionString) { } void WDCConnection::setLocalDescription(std::unique_ptr description) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::setLocalDescription()"; qCDebug(networking_webrtc) << "5. Set local description"; #endif @@ -323,7 +327,7 @@ void WDCConnection::setLocalDescription(std::unique_ptr= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::addIceCandidate()"; #endif @@ -339,7 +343,7 @@ void WDCConnection::addIceCandidate(QJsonObject& data) { return; } -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "6. Add ICE candidate"; #endif if (_peerConnection) { @@ -348,7 +352,7 @@ void WDCConnection::addIceCandidate(QJsonObject& data) { } void WDCConnection::sendIceCandidate(const IceCandidateInterface* candidate) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::sendIceCandidate()"; #endif @@ -368,14 +372,14 @@ void WDCConnection::sendIceCandidate(const IceCandidateInterface* candidate) { jsonObject.insert("data", jsonWebRTCData); QJsonDocument jsonDocument = QJsonDocument(jsonObject); -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "7. Send ICE candidate to the remote peer"; #endif _parent->sendSignalingMessage(jsonObject); } void WDCConnection::onPeerConnectionStateChanged(PeerConnectionInterface::PeerConnectionState state) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL QStringList states { "New", "Connecting", @@ -389,7 +393,7 @@ void WDCConnection::onPeerConnectionStateChanged(PeerConnectionInterface::PeerCo } void WDCConnection::onDataChannelOpened(rtc::scoped_refptr dataChannel) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCConnection::onDataChannelOpened() :" << dataChannel->id() << QString::fromStdString(dataChannel->label()) @@ -404,7 +408,7 @@ void WDCConnection::onDataChannelOpened(rtc::scoped_refptr _dataChannel = dataChannel; _dataChannel->RegisterObserver(_dataChannelObserver.get()); -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCConnection::onDataChannelOpened() : channel ID:" << _dataChannelID; #endif _parent->onDataChannelOpened(this, _dataChannelID); @@ -412,7 +416,7 @@ void WDCConnection::onDataChannelOpened(rtc::scoped_refptr void WDCConnection::onDataChannelStateChanged() { auto state = _dataChannel->state(); -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WDCConnection::onDataChannelStateChanged() :" << (int)state << DataChannelInterface::DataStateString(state); #endif @@ -428,7 +432,7 @@ void WDCConnection::onDataChannelStateChanged() { } void WDCConnection::onDataChannelMessageReceived(const DataBuffer& buffer) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::onDataChannelMessageReceived()"; #endif @@ -436,7 +440,7 @@ void WDCConnection::onDataChannelMessageReceived(const DataBuffer& buffer) { // Echo message back to sender. if (byteArray.startsWith("echo:")) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "Echo message back"; #endif auto addressParts = _dataChannelID.split(":"); @@ -453,7 +457,7 @@ void WDCConnection::onDataChannelMessageReceived(const DataBuffer& buffer) { } qint64 WDCConnection::getBufferedAmount() const { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::getBufferedAmount()"; #endif return _dataChannel && _dataChannel->state() != DataChannelInterface::kClosing @@ -462,7 +466,7 @@ qint64 WDCConnection::getBufferedAmount() const { } bool WDCConnection::sendDataMessage(const DataBuffer& buffer) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::sendDataMessage()"; if (!_dataChannel || _dataChannel->state() == DataChannelInterface::kClosing || _dataChannel->state() == DataChannelInterface::kClosed) { @@ -482,7 +486,7 @@ bool WDCConnection::sendDataMessage(const DataBuffer& buffer) { } void WDCConnection::closePeerConnection() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL if (_peerConnection) { qCDebug(networking_webrtc) << "WDCConnection::closePeerConnection() :" << (int)_peerConnection->peer_connection_state(); } @@ -492,7 +496,7 @@ void WDCConnection::closePeerConnection() { } // Don't set _peerConnection = nullptr because it is a scoped_refptr. _peerConnectionObserver = nullptr; -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "Disposed of peer connection"; #endif } @@ -502,12 +506,12 @@ WebRTCDataChannels::WebRTCDataChannels(QObject* parent) : QObject(parent), _parent(parent) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::WebRTCDataChannels()"; #endif // Create a peer connection factory. -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL // Numbers are per WebRTC's peer_connection_interface.h. qCDebug(networking_webrtc) << "1. Create a new PeerConnectionFactoryInterface"; #endif @@ -531,7 +535,7 @@ WebRTCDataChannels::WebRTCDataChannels(QObject* parent) : } WebRTCDataChannels::~WebRTCDataChannels() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::~WebRTCDataChannels()"; #endif reset(); @@ -545,7 +549,7 @@ WebRTCDataChannels::~WebRTCDataChannels() { } void WebRTCDataChannels::reset() { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::reset() :" << _connectionsByID.count(); #endif QHashIterator i(_connectionsByID); @@ -557,14 +561,14 @@ void WebRTCDataChannels::reset() { } void WebRTCDataChannels::onDataChannelOpened(WDCConnection* connection, const QString& dataChannelID) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::onDataChannelOpened() :" << dataChannelID; #endif _connectionsByID.insert(dataChannelID, connection); } void WebRTCDataChannels::onSignalingMessage(const QJsonObject& message) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannel::onSignalingMessage()" << message; #endif @@ -614,14 +618,14 @@ void WebRTCDataChannels::onSignalingMessage(const QJsonObject& message) { } void WebRTCDataChannels::sendSignalingMessage(const QJsonObject& message) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::sendSignalingMessage() :" << QJsonDocument(message).toJson(QJsonDocument::Compact); #endif emit signalingMessage(message); } void WebRTCDataChannels::emitDataMessage(const QString& dataChannelID, const QByteArray& byteArray) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WebRTCDataChannels::emitDataMessage() :" << dataChannelID << byteArray.toHex() << byteArray.length(); #endif @@ -636,7 +640,7 @@ void WebRTCDataChannels::emitDataMessage(const QString& dataChannelID, const QBy bool WebRTCDataChannels::sendDataMessage(const SockAddr& destination, const QByteArray& byteArray) { auto dataChannelID = destination.toShortString(); -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WebRTCDataChannels::sendDataMessage() :" << dataChannelID; #endif @@ -653,7 +657,7 @@ bool WebRTCDataChannels::sendDataMessage(const SockAddr& destination, const QByt qint64 WebRTCDataChannels::getBufferedAmount(const SockAddr& address) const { auto dataChannelID = address.toShortString(); if (!_connectionsByID.contains(dataChannelID)) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WebRTCDataChannels::getBufferedAmount() : Channel doesn't exist:" << dataChannelID; #endif return 0; @@ -664,7 +668,7 @@ qint64 WebRTCDataChannels::getBufferedAmount(const SockAddr& address) const { rtc::scoped_refptr WebRTCDataChannels::createPeerConnection( const std::shared_ptr peerConnectionObserver) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::createPeerConnection()"; #endif @@ -717,7 +721,7 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec } } -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::createPeerConnection() : Configuration ICE server list:"; for (const auto& server : configuration.servers) { qCDebug(networking_webrtc) << "URL: " << (server.urls.size() > 0 ? server.urls.front().c_str() : ""); @@ -730,7 +734,7 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec } #endif -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "2. Create a new peer connection"; #endif PeerConnectionDependencies dependencies(peerConnectionObserver.get()); @@ -740,7 +744,7 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec #ifdef API_SET_LOCAL_DESCRIPTION_OBSERVER_INTERFACE_H_ auto result = _peerConnectionFactory->CreatePeerConnectionOrError(configuration, std::move(dependencies)); if (result.ok()) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "Created peer connection"; #endif return result.MoveValue(); @@ -750,7 +754,7 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec } #else auto result = _peerConnectionFactory->CreatePeerConnection(configuration, std::move(dependencies)); -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "Created peer connection"; #endif return result; @@ -760,7 +764,7 @@ rtc::scoped_refptr WebRTCDataChannels::createPeerConnec void WebRTCDataChannels::closePeerConnection(WDCConnection* connection) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::closePeerConnection()"; #endif // Use Qt's signals/slots mechanism to close the peer connection on its own call stack, separate from the DataChannel @@ -771,19 +775,19 @@ void WebRTCDataChannels::closePeerConnection(WDCConnection* connection) { void WebRTCDataChannels::closePeerConnectionNow(WDCConnection* connection) { -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "WebRTCDataChannels::closePeerConnectionNow()"; #endif // Close the peer connection. connection->closePeerConnection(); // Delete the WDCConnection. -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "Dispose of connection for channel:" << connection->getDataChannelID(); #endif _connectionsByID.remove(connection->getDataChannelID()); delete connection; -#ifdef WEBRTC_DEBUG +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "Disposed of connection"; #endif } From 8c198d1ac1ead177adf86eaa1afe93c0cb67bd7f Mon Sep 17 00:00:00 2001 From: namark Date: Sat, 25 May 2024 22:14:01 +0400 Subject: [PATCH 04/19] Removed nsis override in GHA windows PR build. --- .github/workflows/pr_build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 14148cf31f..06bf6ded09 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -209,11 +209,6 @@ jobs: echo " done" fi - - name: Override NSIS - shell: pwsh - if: startsWith(matrix.os, 'windows') - run: choco install nsis --version=3.06.1 - - name: Create Build Environment shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" From c6da2800129f835dbcec07c57cd3dca3794142cd Mon Sep 17 00:00:00 2001 From: namark Date: Sat, 25 May 2024 23:09:25 +0400 Subject: [PATCH 05/19] Updated bootstrapped vcpkg to latest release. --- hifi_vcpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hifi_vcpkg.py b/hifi_vcpkg.py index 835d65664d..d3882333a8 100644 --- a/hifi_vcpkg.py +++ b/hifi_vcpkg.py @@ -208,7 +208,7 @@ def bootstrap(self): hifi_utils.downloadAndExtract(self.vcpkgUrl, self.path, self.vcpkgSha512) else: print("Cloning vcpkg from github to {}".format(self.path)) - hifi_utils.executeSubprocess(['git', 'clone', '--depth', '1', '--branch', '2022.06.16.1', 'https://github.com/microsoft/vcpkg', self.path]) + hifi_utils.executeSubprocess(['git', 'clone', '--depth', '1', '--branch', '2024.04.26', 'https://github.com/microsoft/vcpkg', self.path]) print("Bootstrapping vcpkg") hifi_utils.executeSubprocess(self.bootstrapCmds, folder=self.path, env=self.bootstrapEnv) From 34cfcaa9cb2c4409a3dc09c9f680417712499fb3 Mon Sep 17 00:00:00 2001 From: namark Date: Sat, 25 May 2024 23:21:23 +0400 Subject: [PATCH 06/19] Temporarily disabled installer logs in GHA windows PR build. --- .github/workflows/pr_build.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 06bf6ded09..8be34ca132 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -343,11 +343,12 @@ jobs: echo "Disk usage:" df -h - - name: Output Installer Logs - if: failure() && matrix.os == 'windows-2019' - shell: bash - working-directory: ${{runner.workspace}}/build - run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log + # TODO: uncomment + # - name: Output Installer Logs + # if: failure() && matrix.os == 'windows-2019' + # shell: bash + # working-directory: ${{runner.workspace}}/build + # run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log - name: Upload full build if: matrix.build_type == 'full' && matrix.os != 'ubuntu-18.04' && matrix.os != 'ubuntu-20.04' From 6d9e8de325541c7f5b2f87b8e19d6068bde69009 Mon Sep 17 00:00:00 2001 From: namark Date: Sat, 25 May 2024 23:40:20 +0400 Subject: [PATCH 07/19] Updated spirv-tools vcpkg port to latest release. --- cmake/ports/spirv-tools/portfile.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/ports/spirv-tools/portfile.cmake b/cmake/ports/spirv-tools/portfile.cmake index b52a3b96c2..24c96583e6 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -5,8 +5,8 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Tools - REF v2018.5 - SHA512 068a39e15111f24ad2a6b27e7ada786b3124b239aa8b13e187a4d512044db57a8e6a0fccadd0451155e1f57c96c8dec91a2338996c59fc883007cf7be07f2cad + REF v2024.1 + SHA512 2c265a9f4b6c40501a8f1925080c0b176f5d3be50afddbbf16bcd2230ce09ca47d2393404d3717dabb7ebe25cce7decaede16223f79edfbcbf77ed9a35d74a6c HEAD_REF master ) From 9d520eaf71f38a60892a32b3a4b43b933462363d Mon Sep 17 00:00:00 2001 From: namark Date: Sun, 26 May 2024 00:20:37 +0400 Subject: [PATCH 08/19] Downgraded spirv-tools vcpkg port. --- cmake/ports/spirv-tools/CONTROL | 2 +- cmake/ports/spirv-tools/portfile.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/ports/spirv-tools/CONTROL b/cmake/ports/spirv-tools/CONTROL index 057fe5db0a..2072c42beb 100644 --- a/cmake/ports/spirv-tools/CONTROL +++ b/cmake/ports/spirv-tools/CONTROL @@ -1,3 +1,3 @@ Source: spirv-tools -Version: 2018.5-1 +Version: 2023.2 Description: API and commands for processing SPIR-V modules diff --git a/cmake/ports/spirv-tools/portfile.cmake b/cmake/ports/spirv-tools/portfile.cmake index 24c96583e6..9e9009961e 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -5,8 +5,8 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Tools - REF v2024.1 - SHA512 2c265a9f4b6c40501a8f1925080c0b176f5d3be50afddbbf16bcd2230ce09ca47d2393404d3717dabb7ebe25cce7decaede16223f79edfbcbf77ed9a35d74a6c + REF v2023.2 + SHA512 988f5e31508e3f19c1dd9d9a013c8e9ff89eba86207a769d7d804f9ee0201c794f412a874c860167b2c040b2c5e1fb1c835ae3684c70feaac86e47f90c1a5010 HEAD_REF master ) From e31804ed3106ddbf3f0051505c26eb7833ace6c9 Mon Sep 17 00:00:00 2001 From: namark Date: Sun, 26 May 2024 18:35:43 +0400 Subject: [PATCH 09/19] spirv-tools port form latest vcpkg release. --- cmake/ports/spirv-headers/portfile.cmake | 20 +++++ cmake/ports/spirv-headers/vcpkg.json | 16 ++++ cmake/ports/spirv-tools/CONTROL | 3 - cmake/ports/spirv-tools/cmake-config-dir.diff | 13 ++++ cmake/ports/spirv-tools/fix-tool-deps.diff | 18 +++++ cmake/ports/spirv-tools/portfile.cmake | 74 +++++++++++-------- .../ports/spirv-tools/spirv-tools-shared.diff | 35 +++++++++ cmake/ports/spirv-tools/usage | 22 ++++++ cmake/ports/spirv-tools/vcpkg.json | 23 ++++++ 9 files changed, 192 insertions(+), 32 deletions(-) create mode 100644 cmake/ports/spirv-headers/portfile.cmake create mode 100644 cmake/ports/spirv-headers/vcpkg.json delete mode 100644 cmake/ports/spirv-tools/CONTROL create mode 100644 cmake/ports/spirv-tools/cmake-config-dir.diff create mode 100644 cmake/ports/spirv-tools/fix-tool-deps.diff create mode 100644 cmake/ports/spirv-tools/spirv-tools-shared.diff create mode 100644 cmake/ports/spirv-tools/usage create mode 100644 cmake/ports/spirv-tools/vcpkg.json diff --git a/cmake/ports/spirv-headers/portfile.cmake b/cmake/ports/spirv-headers/portfile.cmake new file mode 100644 index 0000000000..1642b1e7c6 --- /dev/null +++ b/cmake/ports/spirv-headers/portfile.cmake @@ -0,0 +1,20 @@ + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO KhronosGroup/SPIRV-Headers + REF "vulkan-sdk-${VERSION}" + SHA512 6c20022df343e900793370cb30ccea6f4e64f42f4f7c495a0fbb9d3c5fcf3c15a173b93fe883e407d40f8c6dd9d0a6853d8a6907e3df5aa61ad48ae8485019e8 + HEAD_REF master +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug") + +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/spirv-headers/vcpkg.json b/cmake/ports/spirv-headers/vcpkg.json new file mode 100644 index 0000000000..81075a0536 --- /dev/null +++ b/cmake/ports/spirv-headers/vcpkg.json @@ -0,0 +1,16 @@ +{ + "name": "spirv-headers", + "version": "1.3.280.0", + "description": "Machine-readable files for the SPIR-V Registry", + "homepage": "https://github.com/KhronosGroup/SPIRV-Headers", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/cmake/ports/spirv-tools/CONTROL b/cmake/ports/spirv-tools/CONTROL deleted file mode 100644 index 2072c42beb..0000000000 --- a/cmake/ports/spirv-tools/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: spirv-tools -Version: 2023.2 -Description: API and commands for processing SPIR-V modules diff --git a/cmake/ports/spirv-tools/cmake-config-dir.diff b/cmake/ports/spirv-tools/cmake-config-dir.diff new file mode 100644 index 0000000000..65a9e399b4 --- /dev/null +++ b/cmake/ports/spirv-tools/cmake-config-dir.diff @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 75830b44..367fe889 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -270,7 +270,7 @@ else() + endif() + + if(ENABLE_SPIRV_TOOLS_INSTALL) +- if(WIN32 AND NOT MINGW) ++ if(0) + macro(spvtools_config_package_dir TARGET PATH) + set(${PATH} ${TARGET}/cmake) + endmacro() diff --git a/cmake/ports/spirv-tools/fix-tool-deps.diff b/cmake/ports/spirv-tools/fix-tool-deps.diff new file mode 100644 index 0000000000..e842277a4a --- /dev/null +++ b/cmake/ports/spirv-tools/fix-tool-deps.diff @@ -0,0 +1,18 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 75830b44..9c9e7ba8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -281,8 +281,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) + endif() + + macro(spvtools_generate_config_file TARGET) ++ set(sgcf_find_extra "") ++ if(NOT "${TARGET}" STREQUAL "SPIRV-Tools-opt") ++ set(sgcf_find_extra "find_dependency(SPIRV-Tools-opt)\n") ++ endif() + file(WRITE ${CMAKE_BINARY_DIR}/${TARGET}Config.cmake + "include(CMakeFindDependencyMacro)\n" ++ ${sgcf_find_extra} + "find_dependency(${SPIRV_TOOLS})\n" + "include(\${CMAKE_CURRENT_LIST_DIR}/${TARGET}Targets.cmake)\n" + "set(${TARGET}_LIBRARIES ${TARGET})\n" diff --git a/cmake/ports/spirv-tools/portfile.cmake b/cmake/ports/spirv-tools/portfile.cmake index 9e9009961e..b85d776226 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -1,43 +1,59 @@ -include(vcpkg_common_functions) - -vcpkg_check_linkage(ONLY_STATIC_LIBRARY) - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Tools - REF v2023.2 - SHA512 988f5e31508e3f19c1dd9d9a013c8e9ff89eba86207a769d7d804f9ee0201c794f412a874c860167b2c040b2c5e1fb1c835ae3684c70feaac86e47f90c1a5010 - HEAD_REF master -) - -vcpkg_from_github( - OUT_SOURCE_PATH SPIRV_HEADERS_PATH - REPO KhronosGroup/SPIRV-Headers - REF 801cca8104245c07e8cc53292da87ee1b76946fe - SHA512 2bfc37beec1f6afb565fa7dad08eb838c8fe4bacda7f80a3a6c75d80c7eb1caea7e7716dc1da11b337b723a0870700d524c6617c5b7cab8b28048fa8c0785ba9 - HEAD_REF master + REF "vulkan-sdk-${VERSION}" + SHA512 3ccab3118e0a1d6f20d031cd1f90f2546b618370b90aacc468fc598d523463452f65ed2c89c1de4e2bb8933b9757eb8123363483bcd853e92d41c95ea419e79f + PATCHES + cmake-config-dir.diff + spirv-tools-shared.diff + fix-tool-deps.diff ) vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) vcpkg_add_to_path("${PYTHON3_DIR}") -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA +vcpkg_check_features( + OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + tools SPIRV_SKIP_EXECUTABLES +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" OPTIONS - -DSPIRV-Headers_SOURCE_DIR=${SPIRV_HEADERS_PATH} + ${FEATURE_OPTIONS} + "-DSPIRV-Headers_SOURCE_DIR=${CURRENT_INSTALLED_DIR}" + -DSPIRV_SKIP_TESTS=ON + -DSPIRV_TOOLS_BUILD_STATIC=ON -DSPIRV_WERROR=OFF + OPTIONS_DEBUG + -DSPIRV_SKIP_EXECUTABLES=ON ) -vcpkg_install_cmake() - -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(GLOB EXES "${CURRENT_PACKAGES_DIR}/bin/*") -file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) -file(REMOVE ${EXES}) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools PACKAGE_NAME spirv-tools DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-link PACKAGE_NAME spirv-tools-link DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-lint PACKAGE_NAME spirv-tools-lint DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-opt PACKAGE_NAME spirv-tools-opt DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-reduce PACKAGE_NAME spirv-tools-reduce) # now delete +vcpkg_fixup_pkgconfig() + +if("tools" IN_LIST FEATURES) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + file(RENAME "${CURRENT_PACKAGES_DIR}/bin/spirv-lesspipe.sh" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/spirv-lesspipe.sh") + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/spirv-lesspipe.sh") + set(tools spirv-as spirv-cfg spirv-dis spirv-link spirv-lint spirv-opt spirv-val) + if(NOT VCPKG_TARGET_IS_IOS) + list(APPEND tools spirv-reduce) + endif() + vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN) +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) -# Handle copyright -file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/spirv-tools) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/spirv-tools/LICENSE ${CURRENT_PACKAGES_DIR}/share/spirv-tools/copyright) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cmake/ports/spirv-tools/spirv-tools-shared.diff b/cmake/ports/spirv-tools/spirv-tools-shared.diff new file mode 100644 index 0000000000..e2bf13cae9 --- /dev/null +++ b/cmake/ports/spirv-tools/spirv-tools-shared.diff @@ -0,0 +1,35 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 75830b44..39cc039e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -390,10 +390,14 @@ add_custom_target(spirv-tools-shared-pkg-config ALL + + # Install pkg-config file + if (ENABLE_SPIRV_TOOLS_INSTALL) ++ set(shared_pc "") ++ if(BUILD_SHARED_LIBS) ++ set(shared_pc "${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc") ++ endif() + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools.pc +- ${CMAKE_CURRENT_BINARY_DIR}/SPIRV-Tools-shared.pc ++ ${shared_pc} + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + endif() +diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt +index acfa0c12..b3286db3 100644 +--- a/source/CMakeLists.txt ++++ b/source/CMakeLists.txt +@@ -425,6 +425,10 @@ if (ANDROID) + endif() + + if(ENABLE_SPIRV_TOOLS_INSTALL) ++ if(NOT BUILD_SHARED_LIBS) ++ set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES EXCLUDE_FROM_ALL 1) ++ list(REMOVE_ITEM SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-shared) ++ endif() + install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets) + export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake) + diff --git a/cmake/ports/spirv-tools/usage b/cmake/ports/spirv-tools/usage new file mode 100644 index 0000000000..1890e6de9a --- /dev/null +++ b/cmake/ports/spirv-tools/usage @@ -0,0 +1,22 @@ +spirv-tools provides CMake targets: + + find_package(SPIRV-Tools CONFIG REQUIRED) + # The static libary is always available. + # It offers full public symbol visibility. + target_link_libraries(main PRIVATE SPIRV-Tools-static) + # In triplets with dynamic library linkage, there is also a shared libary. + target_link_libraries(main PRIVATE SPIRV-Tools-shared) + + # The following libraries are static and depend on SPIRV-Tools-static. + + find_package(SPIRV-Tools-link CONFIG REQUIRED) + target_link_libraries(main PRIVATE SPIRV-Tools-link) + + find_package(SPIRV-Tools-lint CONFIG REQUIRED) + target_link_libraries(main PRIVATE SPIRV-Tools-lint) + + find_package(SPIRV-Tools-opt CONFIG REQUIRED) + target_link_libraries(main PRIVATE SPIRV-Tools-opt) + + find_package(SPIRV-Tools-reduce CONFIG REQUIRED) + target_link_libraries(main PRIVATE SPIRV-Tools-reduce) diff --git a/cmake/ports/spirv-tools/vcpkg.json b/cmake/ports/spirv-tools/vcpkg.json new file mode 100644 index 0000000000..e62e4f0d71 --- /dev/null +++ b/cmake/ports/spirv-tools/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "spirv-tools", + "version": "1.3.280.0", + "description": "API and commands for processing SPIR-V modules", + "homepage": "https://github.com/KhronosGroup/SPIRV-Tools", + "license": "Apache-2.0", + "dependencies": [ + "spirv-headers", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "tools": { + "description": "Build tools." + } + } +} From c52f25d645ff8a4db97e8b55ba7b2523db5b08da Mon Sep 17 00:00:00 2001 From: namark Date: Sun, 26 May 2024 19:05:58 +0400 Subject: [PATCH 10/19] Fixed new spirv-tools vcpkg port skipping executables. --- cmake/ports/spirv-tools/portfile.cmake | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmake/ports/spirv-tools/portfile.cmake b/cmake/ports/spirv-tools/portfile.cmake index b85d776226..ae4d736fde 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -13,12 +13,6 @@ vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) vcpkg_add_to_path("${PYTHON3_DIR}") -vcpkg_check_features( - OUT_FEATURE_OPTIONS FEATURE_OPTIONS - INVERTED_FEATURES - tools SPIRV_SKIP_EXECUTABLES -) - vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS @@ -28,7 +22,6 @@ vcpkg_cmake_configure( -DSPIRV_TOOLS_BUILD_STATIC=ON -DSPIRV_WERROR=OFF OPTIONS_DEBUG - -DSPIRV_SKIP_EXECUTABLES=ON ) vcpkg_cmake_install() @@ -50,7 +43,7 @@ if("tools" IN_LIST FEATURES) vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN) endif() -file(REMOVE_RECURSE +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share" ) From 70fc1883d932b3cfc6b00e26b93a70c4e127709f Mon Sep 17 00:00:00 2001 From: namark Date: Sun, 26 May 2024 21:37:56 +0400 Subject: [PATCH 11/19] These were important. --- cmake/ports/spirv-tools/portfile.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/ports/spirv-tools/portfile.cmake b/cmake/ports/spirv-tools/portfile.cmake index ae4d736fde..89a25432fe 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -50,3 +50,6 @@ file(REMOVE_RECURSE file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + +file(GLOB EXES "${CURRENT_PACKAGES_DIR}/bin/*") +file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) From 2077b19ba6023cbc6620dae5837cadce98abe386 Mon Sep 17 00:00:00 2001 From: namark Date: Mon, 27 May 2024 01:53:43 +0400 Subject: [PATCH 12/19] Restored installer log output step in GHA windows PR build. --- .github/workflows/pr_build.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 8be34ca132..06bf6ded09 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -343,12 +343,11 @@ jobs: echo "Disk usage:" df -h - # TODO: uncomment - # - name: Output Installer Logs - # if: failure() && matrix.os == 'windows-2019' - # shell: bash - # working-directory: ${{runner.workspace}}/build - # run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log + - name: Output Installer Logs + if: failure() && matrix.os == 'windows-2019' + shell: bash + working-directory: ${{runner.workspace}}/build + run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log - name: Upload full build if: matrix.build_type == 'full' && matrix.os != 'ubuntu-18.04' && matrix.os != 'ubuntu-20.04' From 35b419aeba91fca17e842b66b69b319e25264956 Mon Sep 17 00:00:00 2001 From: namark Date: Mon, 27 May 2024 12:08:53 +0400 Subject: [PATCH 13/19] Downgrade NSIS in GHA windows PR build. --- .github/workflows/pr_build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 06bf6ded09..e64f06f097 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -209,6 +209,11 @@ jobs: echo " done" fi + - name: Override NSIS + shell: pwsh + if: startsWith(matrix.os, 'windows') + run: choco install nsis --version=3.06.1 --allow-downgrade + - name: Create Build Environment shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" From 7121ef084654abb622cee5969f9c9564c5c3e24c Mon Sep 17 00:00:00 2001 From: namark Date: Mon, 27 May 2024 13:38:45 +0400 Subject: [PATCH 14/19] Downgrade NSIS in GHA windows master build. --- .github/workflows/master_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index 25d78833c2..2012beb855 100644 --- a/.github/workflows/master_build.yml +++ b/.github/workflows/master_build.yml @@ -189,7 +189,7 @@ jobs: - name: Override NSIS shell: pwsh if: startsWith(matrix.os, 'windows') - run: choco install nsis --version=3.06.1 + run: choco install nsis --version=3.06.1 --allow-downgrade - name: Install Python modules if: startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macOS') From c9703609be7322802e138cc57f4da4c0873029bf Mon Sep 17 00:00:00 2001 From: namark Date: Mon, 27 May 2024 18:15:09 +0400 Subject: [PATCH 15/19] Disabled WebRTC debug logs. --- libraries/networking/src/webrtc/WebRTCDataChannels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 51e4216b5e..de04533606 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -35,7 +35,7 @@ const int MAX_WEBRTC_BUFFER_SIZE = 16777216; // 16MB #define WEBRTC_DEBUG_LEVEL_NORMAL 1 // basic peer connection logs #define WEBRTC_DEBUG_LEVEL_VERBOSE 2 // full data channel logs -#define WEBRTC_DEBUG WEBRTC_DEBUG_LEVEL_NORMAL +// #define WEBRTC_DEBUG WEBRTC_DEBUG_LEVEL_NORMAL using namespace webrtc; From 7a703204faa55c51d57c96f5094e3aea8ac2d410 Mon Sep 17 00:00:00 2001 From: namark Date: Wed, 29 May 2024 00:45:05 +0400 Subject: [PATCH 16/19] Updated glslang and spirv-corss vcpkg ports. --- cmake/ports/glslang/CONTROL | 3 -- cmake/ports/glslang/copyright | 35 -------------- cmake/ports/glslang/portfile.cmake | 63 +++++++++++++++++++------- cmake/ports/glslang/usage | 4 ++ cmake/ports/glslang/vcpkg.json | 32 +++++++++++++ cmake/ports/hifi-host-tools/CONTROL | 2 +- cmake/ports/spirv-cross/CONTROL | 3 -- cmake/ports/spirv-cross/portfile.cmake | 49 ++++++++++++-------- cmake/ports/spirv-cross/vcpkg.json | 17 +++++++ tools/shadergen.py | 16 +++---- 10 files changed, 139 insertions(+), 85 deletions(-) delete mode 100644 cmake/ports/glslang/CONTROL delete mode 100644 cmake/ports/glslang/copyright create mode 100644 cmake/ports/glslang/usage create mode 100644 cmake/ports/glslang/vcpkg.json delete mode 100644 cmake/ports/spirv-cross/CONTROL create mode 100644 cmake/ports/spirv-cross/vcpkg.json diff --git a/cmake/ports/glslang/CONTROL b/cmake/ports/glslang/CONTROL deleted file mode 100644 index 74a2530e4c..0000000000 --- a/cmake/ports/glslang/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: glslang -Version: untagged-048c4dbc7f021224a933-1 -Description: Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator diff --git a/cmake/ports/glslang/copyright b/cmake/ports/glslang/copyright deleted file mode 100644 index dfffea6a8c..0000000000 --- a/cmake/ports/glslang/copyright +++ /dev/null @@ -1,35 +0,0 @@ -// -//Copyright (C) 2002-2005 3Dlabs Inc. Ltd. -//Copyright (C) 2012-2013 LunarG, Inc. -// -//All rights reserved. -// -//Redistribution and use in source and binary forms, with or without -//modification, are permitted provided that the following conditions -//are met: -// -// Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// -// Neither the name of 3Dlabs Inc. Ltd. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -//POSSIBILITY OF SUCH DAMAGE. -// diff --git a/cmake/ports/glslang/portfile.cmake b/cmake/ports/glslang/portfile.cmake index 72d62d26f3..37034ce167 100644 --- a/cmake/ports/glslang/portfile.cmake +++ b/cmake/ports/glslang/portfile.cmake @@ -1,26 +1,55 @@ -include(vcpkg_common_functions) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO KhronosGroup/glslang - REF untagged-048c4dbc7f021224a933 - SHA512 e3097dd2db88320982d7da1ddce138839daf3251935909c3998a114aeadd408760b26b2d7c7ee547fb0519895ac1853a45c23df2eecf61135849b080252e9dec - HEAD_REF master + OUT_SOURCE_PATH SOURCE_PATH + REPO KhronosGroup/glslang + REF "${VERSION}" + SHA512 45ec1a23a390319b9270761cf8befb832ac8b4bc215b211c41a543553a97e5ccf17c134c34d8fdbed6efe887a9a7c2f0a955d1bfe1add9e04cc3e95b12e1973a + HEAD_REF master +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + opt ENABLE_OPT + opt ALLOW_EXTERNAL_SPIRV_TOOLS + tools ENABLE_GLSLANG_BINARIES + rtti ENABLE_RTTI +) + +if (ENABLE_GLSLANG_BINARIES) + vcpkg_find_acquire_program(PYTHON3) + get_filename_component(PYTHON_PATH ${PYTHON3} DIRECTORY) + vcpkg_add_to_path("${PYTHON_PATH}") +endif () + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_EXTERNAL=OFF + -DGLSLANG_TESTS=OFF + ${FEATURE_OPTIONS} ) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS -DCMAKE_DEBUG_POSTFIX=d +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/glslang DO_NOT_DELETE_PARENT_CONFIG_PATH) +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/glslang-config.cmake" + [[${PACKAGE_PREFIX_DIR}/lib/cmake/glslang/glslang-targets.cmake]] + [[${CMAKE_CURRENT_LIST_DIR}/glslang-targets.cmake]] ) +file(REMOVE_RECURSE CONFIG_PATH "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/glslang/Public/ShaderLang.h" "ifdef GLSLANG_IS_SHARED_LIBRARY" "if 1") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/glslang/Include/glslang_c_interface.h" "ifdef GLSLANG_IS_SHARED_LIBRARY" "if 1") +endif() + +vcpkg_copy_pdbs() -vcpkg_install_cmake() +if (ENABLE_GLSLANG_BINARIES) + vcpkg_copy_tools(TOOL_NAMES glslang glslangValidator spirv-remap AUTO_CLEAN) +endif () -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(RENAME "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/tools") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -# Handle copyright -file(COPY ${CMAKE_CURRENT_LIST_DIR}/copyright DESTINATION ${CURRENT_PACKAGES_DIR}/share/glslang) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/cmake/ports/glslang/usage b/cmake/ports/glslang/usage new file mode 100644 index 0000000000..ee64499ddd --- /dev/null +++ b/cmake/ports/glslang/usage @@ -0,0 +1,4 @@ +glslang provides CMake targets: + + find_package(glslang CONFIG REQUIRED) + target_link_libraries(main PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV glslang::SPVRemapper) diff --git a/cmake/ports/glslang/vcpkg.json b/cmake/ports/glslang/vcpkg.json new file mode 100644 index 0000000000..139ddcc38a --- /dev/null +++ b/cmake/ports/glslang/vcpkg.json @@ -0,0 +1,32 @@ +{ + "name": "glslang", + "version": "14.0.0", + "description": "Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.", + "homepage": "https://github.com/KhronosGroup/glslang", + "license": "Apache-2.0 AND BSD-3-Clause AND MIT AND GPL-3.0-or-later", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "opt": { + "description": "Build with spirv-opt capability", + "dependencies": [ + "spirv-tools" + ] + }, + "rtti": { + "description": "Build with dynamic typeinfo" + }, + "tools": { + "description": "Build the glslangValidator and spirv-remap binaries", + "supports": "!ios" + } + } +} diff --git a/cmake/ports/hifi-host-tools/CONTROL b/cmake/ports/hifi-host-tools/CONTROL index ec8eda965e..e59635a604 100644 --- a/cmake/ports/hifi-host-tools/CONTROL +++ b/cmake/ports/hifi-host-tools/CONTROL @@ -1,4 +1,4 @@ Source: hifi-host-tools Version: 0 Description: Host build system compatible tools for building High Fidelity applications -Build-Depends: hifi-scribe, glslang, spirv-cross, spirv-tools +Build-Depends: hifi-scribe, glslang[opt,tools], spirv-cross, spirv-tools diff --git a/cmake/ports/spirv-cross/CONTROL b/cmake/ports/spirv-cross/CONTROL deleted file mode 100644 index 9068608da6..0000000000 --- a/cmake/ports/spirv-cross/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: spirv-cross -Version: 2018-08-07-1 -Description: SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages. diff --git a/cmake/ports/spirv-cross/portfile.cmake b/cmake/ports/spirv-cross/portfile.cmake index 6495e82bc3..60d4364916 100644 --- a/cmake/ports/spirv-cross/portfile.cmake +++ b/cmake/ports/spirv-cross/portfile.cmake @@ -1,33 +1,46 @@ -include(vcpkg_common_functions) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Cross - REF 2018-08-07 - SHA512 1ac6ee6b2864d950199d4e856ae1576f9435827501baa5d53821a973cd68aaa03ec428094bf74c570784997baac5b2e3802ddc7f02844e2ee546741fa726bf91 + REF vulkan-sdk-${VERSION} + SHA512 56172ce2a766ea83a04701a3253a17fb611c66e25303448d7ca34d507b0476f4d14420021066b382ae6f35a1b1ee4b35443e2e0475b468552f3bd1ad3413e3af HEAD_REF master ) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA - OPTIONS -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=OFF -) +if(VCPKG_TARGET_IS_IOS) + message(STATUS "Using iOS triplet. Executables won't be created...") + set(BUILD_CLI OFF) +else() + set(BUILD_CLI ON) +endif() -vcpkg_install_cmake() +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=OFF + -DSPIRV_CROSS_CLI=${BUILD_CLI} + -DSPIRV_CROSS_SKIP_INSTALL=OFF + -DSPIRV_CROSS_ENABLE_C_API=ON +) +vcpkg_cmake_install() vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() -foreach(COMPONENT core cpp glsl hlsl msl reflect util) - vcpkg_fixup_cmake_targets(CONFIG_PATH share/spirv_cross_${COMPONENT}/cmake TARGET_PATH share/spirv_cross_${COMPONENT}) +foreach(COMPONENT core c cpp glsl hlsl msl reflect util) + vcpkg_cmake_config_fixup(CONFIG_PATH share/spirv_cross_${COMPONENT}/cmake PACKAGE_NAME spirv_cross_${COMPONENT}) endforeach() +if(BUILD_CLI) + vcpkg_copy_tools(TOOL_NAMES spirv-cross AUTO_CLEAN) +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + file(GLOB EXES "${CURRENT_PACKAGES_DIR}/bin/*") file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) - -# cleanup -configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/spirv-cross/copyright COPYONLY) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) diff --git a/cmake/ports/spirv-cross/vcpkg.json b/cmake/ports/spirv-cross/vcpkg.json new file mode 100644 index 0000000000..2d9603c729 --- /dev/null +++ b/cmake/ports/spirv-cross/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "spirv-cross", + "version": "1.3.280.0", + "description": "SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.", + "homepage": "https://github.com/KhronosGroup/SPIRV-Cross", + "dependencies": [ + "spirv-headers", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/tools/shadergen.py b/tools/shadergen.py index 1f4acae915..49581eefdf 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -15,7 +15,7 @@ # # Target dependant Custom rule on the SHADER_FILE # if (ANDROID) # set(GLPROFILE LINUX_GL) - # else() + # else() # if (APPLE) # set(GLPROFILE MAC_GL) # elseif(UNIX) @@ -157,7 +157,7 @@ def executeSubprocess(processArgs): if (0 != processResult.returncode): raise RuntimeError('Call to "{}" failed.\n\narguments:\n{}\n\nstdout:\n{}\n\nstderr:\n{}'.format( processArgs[0], - ' '.join(processArgs[1:]), + ' '.join(processArgs[1:]), processResult.stdout.decode('utf-8'), processResult.stderr.decode('utf-8'))) @@ -166,8 +166,8 @@ def executeSubprocess(processArgs): def processCommand(line): global args global scribeDepCache - glslangExec = args.tools_dir + '/glslangValidator' - spirvCrossExec = args.tools_dir + '/spirv-cross' + glslangExec = args.tools_dir + '/glslang/glslangValidator' + spirvCrossExec = args.tools_dir + '/spirv-cross/spirv-cross' spirvOptExec = args.tools_dir + '/spirv-opt' params = line.split(';') dialect = params.pop(0) @@ -188,12 +188,12 @@ def processCommand(line): scribeOutputDir = os.path.abspath(os.path.join(unoptGlslFile, os.pardir)) - # Serialize checking and creation of the output directory to avoid occasional + # Serialize checking and creation of the output directory to avoid occasional # crashes global folderMutex folderMutex.acquire() if not os.path.exists(scribeOutputDir): - os.makedirs(scribeOutputDir) + os.makedirs(scribeOutputDir) folderMutex.release() scribeDeps = scribeDepCache.getOrGen(scribeFile, libs, dialect, variant, defines) @@ -217,7 +217,7 @@ def processCommand(line): executeSubprocess(scribeArgs) # Generate the un-optimized output - executeSubprocess([glslangExec, '-V110', '-o', upoptSpirvFile, unoptGlslFile]) + executeSubprocess([glslangExec, '-V100', '-o', upoptSpirvFile, unoptGlslFile]) # Optimize the SPIRV executeSubprocess([spirvOptExec, '-O', '-o', spirvFile, upoptSpirvFile]) @@ -233,7 +233,7 @@ def processCommand(line): if (dialect == '410'): spirvCrossArgs.append('--no-420pack-extension') executeSubprocess(spirvCrossArgs) else: - # This logic is necessary because cmake will agressively keep re-executing the shadergen + # This logic is necessary because cmake will agressively keep re-executing the shadergen # code otherwise Path(unoptGlslFile).touch() Path(upoptSpirvFile).touch() From 2ea74e9687c0d152f380f4267244f7e17cd8a3e0 Mon Sep 17 00:00:00 2001 From: namark Date: Wed, 29 May 2024 11:04:59 +0400 Subject: [PATCH 17/19] Fixed shadergen script on Windows. --- tools/shadergen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shadergen.py b/tools/shadergen.py index 49581eefdf..768da60ba4 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -166,7 +166,7 @@ def executeSubprocess(processArgs): def processCommand(line): global args global scribeDepCache - glslangExec = args.tools_dir + '/glslang/glslangValidator' + glslangExec = args.tools_dir + '/glslang/glslang' spirvCrossExec = args.tools_dir + '/spirv-cross/spirv-cross' spirvOptExec = args.tools_dir + '/spirv-opt' params = line.split(';') From 68d7ed5de110d7e0299110e9afdbf3705f6bea15 Mon Sep 17 00:00:00 2001 From: namark Date: Wed, 29 May 2024 11:04:59 +0400 Subject: [PATCH 18/19] Fixed shadergen script on Windows. --- tools/shadergen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shadergen.py b/tools/shadergen.py index 49581eefdf..768da60ba4 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -166,7 +166,7 @@ def executeSubprocess(processArgs): def processCommand(line): global args global scribeDepCache - glslangExec = args.tools_dir + '/glslang/glslangValidator' + glslangExec = args.tools_dir + '/glslang/glslang' spirvCrossExec = args.tools_dir + '/spirv-cross/spirv-cross' spirvOptExec = args.tools_dir + '/spirv-opt' params = line.split(';') From 13267b38586c7dbf605edc8465357477ffdfbb26 Mon Sep 17 00:00:00 2001 From: namark Date: Wed, 29 May 2024 11:19:00 +0400 Subject: [PATCH 19/19] Fixed glslang vcpkg port on Windows. --- cmake/ports/glslang/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ports/glslang/portfile.cmake b/cmake/ports/glslang/portfile.cmake index 37034ce167..051fd57f8d 100644 --- a/cmake/ports/glslang/portfile.cmake +++ b/cmake/ports/glslang/portfile.cmake @@ -46,7 +46,7 @@ endif() vcpkg_copy_pdbs() if (ENABLE_GLSLANG_BINARIES) - vcpkg_copy_tools(TOOL_NAMES glslang glslangValidator spirv-remap AUTO_CLEAN) + vcpkg_copy_tools(TOOL_NAMES glslang spirv-remap AUTO_CLEAN) endif () file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")