diff --git a/.github/workflows/master_build.yml b/.github/workflows/master_build.yml index 25d78833c2d..2012beb855e 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') diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 14148cf31ff..e64f06f097c 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -212,7 +212,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: Create Build Environment shell: bash diff --git a/cmake/ports/glslang/CONTROL b/cmake/ports/glslang/CONTROL deleted file mode 100644 index 74a2530e4c1..00000000000 --- 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 dfffea6a8c1..00000000000 --- 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 72d62d26f37..051fd57f8d6 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 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 00000000000..ee64499dddb --- /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 00000000000..139ddcc38a9 --- /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 ec8eda965e6..e59635a6042 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 9068608da6a..00000000000 --- 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 6495e82bc35..60d4364916b 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 00000000000..2d9603c7298 --- /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/cmake/ports/spirv-headers/portfile.cmake b/cmake/ports/spirv-headers/portfile.cmake new file mode 100644 index 00000000000..1642b1e7c66 --- /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 00000000000..81075a0536b --- /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 057fe5db0a0..00000000000 --- a/cmake/ports/spirv-tools/CONTROL +++ /dev/null @@ -1,3 +0,0 @@ -Source: spirv-tools -Version: 2018.5-1 -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 00000000000..65a9e399b4d --- /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 00000000000..e842277a4a1 --- /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 b52a3b96c20..89a25432fe7 100644 --- a/cmake/ports/spirv-tools/portfile.cmake +++ b/cmake/ports/spirv-tools/portfile.cmake @@ -1,43 +1,55 @@ -include(vcpkg_common_functions) - -vcpkg_check_linkage(ONLY_STATIC_LIBRARY) - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/SPIRV-Tools - REF v2018.5 - SHA512 068a39e15111f24ad2a6b27e7ada786b3124b239aa8b13e187a4d512044db57a8e6a0fccadd0451155e1f57c96c8dec91a2338996c59fc883007cf7be07f2cad - 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_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 +) + +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" ) -vcpkg_install_cmake() +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") -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) - -# 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) 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 00000000000..e2bf13cae97 --- /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 00000000000..1890e6de9ab --- /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 00000000000..e62e4f0d714 --- /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." + } + } +} diff --git a/hifi_vcpkg.py b/hifi_vcpkg.py index 835d65664da..d3882333a8a 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) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 86feed65ac8..de045336062 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,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 } @@ -52,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 { @@ -62,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 { @@ -78,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, @@ -93,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 } @@ -104,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", @@ -118,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", @@ -135,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", @@ -158,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", @@ -175,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", @@ -203,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); @@ -222,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 @@ -238,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 @@ -259,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) { @@ -274,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 @@ -284,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 @@ -305,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 @@ -321,7 +327,7 @@ void WDCConnection::setLocalDescription(std::unique_ptr= WEBRTC_DEBUG_LEVEL_VERBOSE qCDebug(networking_webrtc) << "WDCConnection::addIceCandidate()"; #endif @@ -337,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) { @@ -346,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 @@ -366,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", @@ -387,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()) @@ -402,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); @@ -410,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 @@ -426,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 @@ -434,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(":"); @@ -451,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 @@ -460,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) { @@ -480,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(); } @@ -490,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 } @@ -500,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 @@ -529,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(); @@ -543,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); @@ -555,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 @@ -612,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 @@ -634,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 @@ -651,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; @@ -662,21 +668,73 @@ 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 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 +#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() : ""); + if (server.username != "") { + qCDebug(networking_webrtc) << "USERNAME: " << server.username.c_str(); + } + if (server.password != "") { + qCDebug(networking_webrtc) << "PASSWORD: " << server.password.c_str(); + } + } +#endif + +#if WEBRTC_DEBUG >= WEBRTC_DEBUG_LEVEL_NORMAL qCDebug(networking_webrtc) << "2. Create a new peer connection"; #endif PeerConnectionDependencies dependencies(peerConnectionObserver.get()); @@ -686,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(); @@ -696,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; @@ -706,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 @@ -717,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 } diff --git a/tools/shadergen.py b/tools/shadergen.py index 1f4acae9153..768da60ba4e 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/glslang' + 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()