From fc343e5da6cc0a771107a644cea277ea1513990b Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 25 Jul 2024 11:03:40 -0400 Subject: [PATCH 01/67] Fix the Windows build after vcpkg. --- native~/CMakeLists.txt | 16 ++++++++++++++++ .../Runtime/src/CesiumFeaturesMetadataUtility.h | 11 +++++++++++ native~/Runtime/src/CesiumGlobeAnchorImpl.cpp | 2 +- native~/extern/cesium-native | 2 +- native~/vcpkg/triplets/x64-windows-unity.cmake | 3 +++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 native~/vcpkg/triplets/x64-windows-unity.cmake diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index f1e2b10c..2072e770 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -57,6 +57,22 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(ANDROID_NDK ${CMAKE_ANDROID_NDK}) endif() +# vcpkg setup +#set(ENV{VCPKG_OVERLAY_PORTS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/ports") +set(ENV{VCPKG_OVERLAY_TRIPLETS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/triplets") + +include(${CMAKE_CURRENT_SOURCE_DIR}/extern/cesium-native/cmake/detect-vcpkg-triplet.cmake) + +if (NOT VCPKG_TRIPLET) + if (DEFINED ENV{VCPKG_TRIPLET}) + set(VCPKG_TRIPLET "$ENV{VCPKG_TRIPLET}") + elseif(DETECTED_VCPKG_TRIPLET_ERROR) + message(FATAL_ERROR "${DETECTED_VCPKG_TRIPLET_ERROR}") + else() + set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}-unity") + endif() +endif() + add_subdirectory(extern/cesium-native EXCLUDE_FROM_ALL) # Enum flags is a header-only library without a CMakeLists.txt diff --git a/native~/Runtime/src/CesiumFeaturesMetadataUtility.h b/native~/Runtime/src/CesiumFeaturesMetadataUtility.h index 8dd836dc..a13738cf 100644 --- a/native~/Runtime/src/CesiumFeaturesMetadataUtility.h +++ b/native~/Runtime/src/CesiumFeaturesMetadataUtility.h @@ -59,6 +59,10 @@ class CesiumFeaturesMetadataUtility { static DotNet::CesiumForUnity::CesiumPropertyArray makePropertyArray(const CesiumGltf::PropertyArrayView& arrayView); + template + static DotNet::CesiumForUnity::CesiumPropertyArray + makePropertyArray(const CesiumGltf::PropertyArrayCopy& arrayCopy); + template static DotNet::CesiumForUnity::CesiumPropertyTableProperty makePropertyTableProperty( @@ -320,6 +324,13 @@ CesiumFeaturesMetadataUtility::makePropertyArray( return array; } +template +DotNet::CesiumForUnity::CesiumPropertyArray +CesiumFeaturesMetadataUtility::makePropertyArray( + const CesiumGltf::PropertyArrayCopy& arrayCopy) { + return makePropertyArray(arrayCopy.view()); +} + template DotNet::CesiumForUnity::CesiumPropertyTableProperty CesiumFeaturesMetadataUtility::makePropertyTableProperty( diff --git a/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp b/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp index 360eb25d..24ffb94e 100644 --- a/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp +++ b/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index c668061d..23eaa7f3 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit c668061dafc1fedb22882679d99c8b944c29a8f8 +Subproject commit 23eaa7f37028826b9c3d141ca7bf5f4228bbe330 diff --git a/native~/vcpkg/triplets/x64-windows-unity.cmake b/native~/vcpkg/triplets/x64-windows-unity.cmake new file mode 100644 index 00000000..75f9b953 --- /dev/null +++ b/native~/vcpkg/triplets/x64-windows-unity.cmake @@ -0,0 +1,3 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) From 17a3e31c5fe5da7a0cdf896bd798ad7ba8f7e508 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 2 Aug 2024 19:42:08 +1000 Subject: [PATCH 02/67] Link against Release (not Debug) in RelWithDebInfo. --- native~/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index 2072e770..f29685e9 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -6,6 +6,12 @@ project(CesiumForUnityNative LANGUAGES CXX C ) +# By default, vcpkg (or is it cmake?) will try to link against the Debug version +# of the vcpkg libraries when we build the RelWithDebInfo configuration. Tell it +# to prefer Release instead. vcpkg Release builds DO have debug symbols, just like +# RelWithDebInfo. +SET(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;") + # When building for the Editor, both Runtime and Editor assemblies are # written to the Editor directory so that Unity won't load them in # a standalone build. From e89587404f4082c689ae2d1abd5cc5509a53bebc Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 5 Aug 2024 16:01:30 +1000 Subject: [PATCH 03/67] Add asyncplusplus overlay port. So far it is just a copy of the official vcpkg 2024.02.14 version. --- .../vcpkg/ports/asyncplusplus/portfile.cmake | 21 +++++++++++++++++++ native~/vcpkg/ports/asyncplusplus/vcpkg.json | 18 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 native~/vcpkg/ports/asyncplusplus/portfile.cmake create mode 100644 native~/vcpkg/ports/asyncplusplus/vcpkg.json diff --git a/native~/vcpkg/ports/asyncplusplus/portfile.cmake b/native~/vcpkg/ports/asyncplusplus/portfile.cmake new file mode 100644 index 00000000..cd8bf8b6 --- /dev/null +++ b/native~/vcpkg/ports/asyncplusplus/portfile.cmake @@ -0,0 +1,21 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Amanieu/asyncplusplus + REF 172ca3f8e0df1b3f7f5ee8b8244e4ac67258b0d8 # v1.1 + SHA512 fd95b3349ceed4cab5cb0e146d2ccfe77c85318303015cf513037fc69c1ade7cfdb3dc81de8a90846c4387c5e31f5a70a64da770547c201dfe24d2c181be1933 + HEAD_REF master +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH cmake PACKAGE_NAME async++) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/native~/vcpkg/ports/asyncplusplus/vcpkg.json b/native~/vcpkg/ports/asyncplusplus/vcpkg.json new file mode 100644 index 00000000..6b597765 --- /dev/null +++ b/native~/vcpkg/ports/asyncplusplus/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "asyncplusplus", + "version": "1.1", + "port-version": 2, + "description": "Async++ is a lightweight concurrency framework for C++11", + "license": "MIT", + "supports": "!uwp", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} From e075776465f2a3be7a3aba59c0d348e94afe2ff7 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 5 Aug 2024 16:02:39 +1000 Subject: [PATCH 04/67] Use a version of Async++ with a required fix for C++20 support. Specifically this fix: Amanieu/asyncplusplus#47 Unfortunately, 2.5 years later, a new official version including that fix still hasn't been released. This is a copy of cesium-unreal commit: https://github.com/CesiumGS/cesium-unreal/commit/d5bb5752e1611d10a4114d862e8d627578eed0c8 --- native~/vcpkg/ports/asyncplusplus/portfile.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native~/vcpkg/ports/asyncplusplus/portfile.cmake b/native~/vcpkg/ports/asyncplusplus/portfile.cmake index cd8bf8b6..54b343b2 100644 --- a/native~/vcpkg/ports/asyncplusplus/portfile.cmake +++ b/native~/vcpkg/ports/asyncplusplus/portfile.cmake @@ -3,8 +3,8 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO Amanieu/asyncplusplus - REF 172ca3f8e0df1b3f7f5ee8b8244e4ac67258b0d8 # v1.1 - SHA512 fd95b3349ceed4cab5cb0e146d2ccfe77c85318303015cf513037fc69c1ade7cfdb3dc81de8a90846c4387c5e31f5a70a64da770547c201dfe24d2c181be1933 + REF 4159da79e20ad6d0eb1f13baa0f10e989edd9fba + SHA512 a7b099ce24184aa56e843d4858228196f8220374585a375a9c0d944832bd68c8aabd6b2efde5aacbb9c73f9dd8e942e97262be04550205b3fbea44d8b972d78e HEAD_REF master ) From abfee34383b46cc8b4d5643c9c709eade7b3b83a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 5 Aug 2024 16:03:40 +1000 Subject: [PATCH 05/67] Remove unnecessary exclusion of UWP from Async++. --- native~/vcpkg/ports/asyncplusplus/vcpkg.json | 1 - 1 file changed, 1 deletion(-) diff --git a/native~/vcpkg/ports/asyncplusplus/vcpkg.json b/native~/vcpkg/ports/asyncplusplus/vcpkg.json index 6b597765..f70a5993 100644 --- a/native~/vcpkg/ports/asyncplusplus/vcpkg.json +++ b/native~/vcpkg/ports/asyncplusplus/vcpkg.json @@ -4,7 +4,6 @@ "port-version": 2, "description": "Async++ is a lightweight concurrency framework for C++11", "license": "MIT", - "supports": "!uwp", "dependencies": [ { "name": "vcpkg-cmake", From 93648ba8fca1f317e5ef33a7113d674259da658e Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 5 Aug 2024 18:14:51 +1000 Subject: [PATCH 06/67] Fix UWP build, hopefully. --- native~/CMakeLists.txt | 2 +- native~/extern/cesium-native | 2 +- native~/vcpkg/triplets/arm64-uwp-unity.cmake | 6 ++++++ native~/vcpkg/triplets/x64-uwp-unity.cmake | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 native~/vcpkg/triplets/arm64-uwp-unity.cmake create mode 100644 native~/vcpkg/triplets/x64-uwp-unity.cmake diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index f29685e9..1c796905 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -64,7 +64,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") endif() # vcpkg setup -#set(ENV{VCPKG_OVERLAY_PORTS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/ports") +set(ENV{VCPKG_OVERLAY_PORTS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/ports") set(ENV{VCPKG_OVERLAY_TRIPLETS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/triplets") include(${CMAKE_CURRENT_SOURCE_DIR}/extern/cesium-native/cmake/detect-vcpkg-triplet.cmake) diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index 23eaa7f3..52c3f2c5 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit 23eaa7f37028826b9c3d141ca7bf5f4228bbe330 +Subproject commit 52c3f2c5b2eaa3990b51e5ecdd20d4de53f6bb6f diff --git a/native~/vcpkg/triplets/arm64-uwp-unity.cmake b/native~/vcpkg/triplets/arm64-uwp-unity.cmake new file mode 100644 index 00000000..e7322b75 --- /dev/null +++ b/native~/vcpkg/triplets/arm64-uwp-unity.cmake @@ -0,0 +1,6 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore) +set(VCPKG_CMAKE_SYSTEM_VERSION 10.0) diff --git a/native~/vcpkg/triplets/x64-uwp-unity.cmake b/native~/vcpkg/triplets/x64-uwp-unity.cmake new file mode 100644 index 00000000..dea649ef --- /dev/null +++ b/native~/vcpkg/triplets/x64-uwp-unity.cmake @@ -0,0 +1,6 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore) +set(VCPKG_CMAKE_SYSTEM_VERSION 10.0) From 538fbb833c0e2bb7b42fa1caeed9275a46fdc261 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 6 Aug 2024 19:21:17 +1000 Subject: [PATCH 07/67] Add zlib-ng port from 2024.07.12 tag in microsoft/vcpkg repo. --- native~/vcpkg/ports/zlib-ng/portfile.cmake | 53 ++++++++++++++++++++++ native~/vcpkg/ports/zlib-ng/vcpkg.json | 14 ++++++ 2 files changed, 67 insertions(+) create mode 100644 native~/vcpkg/ports/zlib-ng/portfile.cmake create mode 100644 native~/vcpkg/ports/zlib-ng/vcpkg.json diff --git a/native~/vcpkg/ports/zlib-ng/portfile.cmake b/native~/vcpkg/ports/zlib-ng/portfile.cmake new file mode 100644 index 00000000..17a0015a --- /dev/null +++ b/native~/vcpkg/ports/zlib-ng/portfile.cmake @@ -0,0 +1,53 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO zlib-ng/zlib-ng + REF "${VERSION}" + SHA512 9212d87c63a2da4e5355a7a1c75380aeba40fbd0ea3d71d3784cb3eac94237f9bea2a1b7993a08f39d4197725c4c133087d3a9d213d3944aa48a7559de2be920 + HEAD_REF develop +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DZLIB_FULL_VERSION=${ZLIB_FULL_VERSION}" + -DZLIB_ENABLE_TESTS=OFF + -DWITH_NEW_STRATEGIES=ON + OPTIONS_RELEASE + -DWITH_OPTIM=ON +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +# Condition in `WIN32`, from https://github.com/zlib-ng/zlib-ng/blob/2.1.5/CMakeLists.txt#L1081-L1100 +# (dynamic) for `zlib` or (static `MSVC) for `zlibstatic` or default `z` +# i.e. (windows) and not (static mingw) https://learn.microsoft.com/en-us/vcpkg/maintainers/variables#vcpkg_target_is_system +if(VCPKG_TARGET_IS_WINDOWS AND (NOT (VCPKG_LIBRARY_LINKAGE STREQUAL static AND VCPKG_TARGET_IS_MINGW))) + set(_port_suffix) + if(ZLIB_COMPAT) + set(_port_suffix "") + else() + set(_port_suffix "-ng") + endif() + + set(_port_output_name) + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(_port_output_name "zlib${_port_suffix}") + else() + set(_port_output_name "zlibstatic${_port_suffix}") + endif() + + # CMAKE_DEBUG_POSTFIX from https://github.com/zlib-ng/zlib-ng/blob/2.1.5/CMakeLists.txt#L494 + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib${_port_suffix}.pc" " -lz${_port_suffix}" " -l${_port_output_name}") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/zlib${_port_suffix}.pc" " -lz${_port_suffix}" " -l${_port_output_name}d") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/debug/include" +) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/native~/vcpkg/ports/zlib-ng/vcpkg.json b/native~/vcpkg/ports/zlib-ng/vcpkg.json new file mode 100644 index 00000000..c1cebd73 --- /dev/null +++ b/native~/vcpkg/ports/zlib-ng/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "zlib-ng", + "version": "2.1.5", + "port-version": 1, + "description": "zlib replacement with optimizations for 'next generation' systems", + "homepage": "https://github.com/zlib-ng/zlib-ng", + "license": "Zlib", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ] +} From 41ffcd455fd22a3eedc9ff09377974680d160f45 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 6 Aug 2024 19:23:11 +1000 Subject: [PATCH 08/67] Fix zlib-ng build on Android. --- native~/vcpkg/ports/zlib-ng/portfile.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/native~/vcpkg/ports/zlib-ng/portfile.cmake b/native~/vcpkg/ports/zlib-ng/portfile.cmake index 17a0015a..bb837527 100644 --- a/native~/vcpkg/ports/zlib-ng/portfile.cmake +++ b/native~/vcpkg/ports/zlib-ng/portfile.cmake @@ -2,7 +2,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO zlib-ng/zlib-ng REF "${VERSION}" - SHA512 9212d87c63a2da4e5355a7a1c75380aeba40fbd0ea3d71d3784cb3eac94237f9bea2a1b7993a08f39d4197725c4c133087d3a9d213d3944aa48a7559de2be920 + SHA512 59ef586c09b9a63788475abfd6dd59ed602316b38f543f801bea802ff8bec8b55a89bee90375b8bbffa3bdebc7d92a00903f4b7c94cdc1a53a36e2e1fd71d13a HEAD_REF develop ) @@ -12,6 +12,17 @@ vcpkg_cmake_configure( "-DZLIB_FULL_VERSION=${ZLIB_FULL_VERSION}" -DZLIB_ENABLE_TESTS=OFF -DWITH_NEW_STRATEGIES=ON + # Disable ARMv6 instructions. We don't need this because we only run on 64-bit ARM (v8), + # which has better instructions. zlib-ng has a bug that makes it try to use these v6 + # instructions even though they're not available. An attempt to fix it was made in this + # PR: https://github.com/zlib-ng/zlib-ng/pull/1617 + # But it doesn't work in our Android builds because the dependent option + # "NOT ARCH STREQUAL \"aarch64\"" that is meant to set `WITH_ARMV6` to FALSE is not + # triggered because our ARCH is `aarch64-none-linux-android21`. It's not clear if this + # is something quirky about our environment or if the fix is just not robust. + # Either way, forcing WITH_ARMV6=OFF here fixes the problem and should be reasonable + # on all platforms that Cesium for Unity supports. + -DWITH_ARMV6=OFF OPTIONS_RELEASE -DWITH_OPTIM=ON ) From 2d9e22b1efd8f8f8611c789b9f1de1c6150d4f81 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 6 Aug 2024 19:25:35 +1000 Subject: [PATCH 09/67] Bump version to match hash. --- native~/vcpkg/ports/zlib-ng/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/vcpkg/ports/zlib-ng/vcpkg.json b/native~/vcpkg/ports/zlib-ng/vcpkg.json index c1cebd73..a5ed45dd 100644 --- a/native~/vcpkg/ports/zlib-ng/vcpkg.json +++ b/native~/vcpkg/ports/zlib-ng/vcpkg.json @@ -1,6 +1,6 @@ { "name": "zlib-ng", - "version": "2.1.5", + "version": "2.1.6", "port-version": 1, "description": "zlib replacement with optimizations for 'next generation' systems", "homepage": "https://github.com/zlib-ng/zlib-ng", From 068438e9fd74b7407a3e048cd47659a954cc684a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 6 Aug 2024 19:48:58 +1000 Subject: [PATCH 10/67] Fix Android build. --- Editor/CompileCesiumForUnityNative.cs | 12 ++++++++++++ native~/extern/android-toolchain.cmake | 6 +++--- native~/extern/cesium-native | 2 +- native~/vcpkg/triplets/arm64-android-unity.cmake | 9 +++++++++ native~/vcpkg/triplets/x64-android-unity.cmake | 9 +++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 native~/vcpkg/triplets/arm64-android-unity.cmake create mode 100644 native~/vcpkg/triplets/x64-android-unity.cmake diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 52de6f9f..44913b54 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -527,6 +527,18 @@ private static void ConfigureEnvironmentVariables(IDictionary en } #endif + // If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process. + // So map a drive letter and rewrite the path. + if (ndkRoot.Contains(' ')) + { + if (!Directory.Exists("N:\\")) + { + Process.Start("subst", "N: \"" + ndkRoot + "\"").WaitForExit(); + } + + ndkRoot = "N:\\"; + } + // On Windows, use the make program included in the NDK. Because Visual Studio (which is usually // the default) won't work to build for Android. if (library.Platform == BuildTarget.Android && Environment.OSVersion.Platform == PlatformID.Win32NT) diff --git a/native~/extern/android-toolchain.cmake b/native~/extern/android-toolchain.cmake index e525187c..52be2c24 100644 --- a/native~/extern/android-toolchain.cmake +++ b/native~/extern/android-toolchain.cmake @@ -7,9 +7,9 @@ SET(CMAKE_ANDROID_STL_TYPE c++_static) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) SET(HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF) diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index 52c3f2c5..ffa2bbea 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit 52c3f2c5b2eaa3990b51e5ecdd20d4de53f6bb6f +Subproject commit ffa2bbea536590b07fcafcdac49e12ce63fb9be9 diff --git a/native~/vcpkg/triplets/arm64-android-unity.cmake b/native~/vcpkg/triplets/arm64-android-unity.cmake new file mode 100644 index 00000000..fa623131 --- /dev/null +++ b/native~/vcpkg/triplets/arm64-android-unity.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 21) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-linux-android") +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=arm64-v8a) +set(VCPKG_ENV_PASSTHROUGH "ANDROID_NDK_ROOT") +set(ENV{ANDROID_NDK_HOME} "$ENV{ANDROID_NDK_ROOT}") diff --git a/native~/vcpkg/triplets/x64-android-unity.cmake b/native~/vcpkg/triplets/x64-android-unity.cmake new file mode 100644 index 00000000..85dfaacb --- /dev/null +++ b/native~/vcpkg/triplets/x64-android-unity.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Android) +set(VCPKG_CMAKE_SYSTEM_VERSION 21) +set(VCPKG_MAKE_BUILD_TRIPLET "--host=x86_64-linux-android") +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=x86_64) +set(VCPKG_ENV_PASSTHROUGH "ANDROID_NDK_ROOT") +set(ENV{ANDROID_NDK_HOME} "$ENV{ANDROID_NDK_ROOT}") From 77c4563156ca8becc8ed1cc2944db85dbb5ada71 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 05:59:40 +1000 Subject: [PATCH 11/67] Print Android build log. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b65a9eb8..c5ca261c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,7 +104,7 @@ jobs: # Store temp files on the D drive, which is much faster than the EBS-backed C drive. $ENV:TEMP="d:\cesium\temp" dotnet run --project Build~ - cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log + cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log dir d:\cesium\CesiumForUnityBuildProject - name: Publish package artifact if: ${{ success() }} From 3238e59a3e0e41e3b32f9b61de3ba21aa5fcc6ba Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 14:22:18 +1000 Subject: [PATCH 12/67] vcpkg release builds only, use Unity's Android NDK. --- .github/workflows/build.yml | 5 +++++ native~/vcpkg/triplets/arm64-android-unity.cmake | 2 ++ native~/vcpkg/triplets/arm64-uwp-unity.cmake | 2 ++ native~/vcpkg/triplets/shared/common.cmake | 5 +++++ native~/vcpkg/triplets/x64-android-unity.cmake | 2 ++ native~/vcpkg/triplets/x64-uwp-unity.cmake | 2 ++ native~/vcpkg/triplets/x64-windows-unity.cmake | 2 ++ 7 files changed, 20 insertions(+) create mode 100644 native~/vcpkg/triplets/shared/common.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5ca261c..8f19c065 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,6 +103,11 @@ jobs: mkdir -p d:\cesium\temp # Store temp files on the D drive, which is much faster than the EBS-backed C drive. $ENV:TEMP="d:\cesium\temp" + # We only need a release build of vcpkg dependencies + $ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE" + # Clear ANDROID_NDK_ROOT so that we use Unity's version + Remove-Item Env:ANDROID_NDK_ROOT + # Run the build dotnet run --project Build~ cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log dir d:\cesium\CesiumForUnityBuildProject diff --git a/native~/vcpkg/triplets/arm64-android-unity.cmake b/native~/vcpkg/triplets/arm64-android-unity.cmake index fa623131..470d060d 100644 --- a/native~/vcpkg/triplets/arm64-android-unity.cmake +++ b/native~/vcpkg/triplets/arm64-android-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE static) set(VCPKG_LIBRARY_LINKAGE static) diff --git a/native~/vcpkg/triplets/arm64-uwp-unity.cmake b/native~/vcpkg/triplets/arm64-uwp-unity.cmake index e7322b75..c44215b1 100644 --- a/native~/vcpkg/triplets/arm64-uwp-unity.cmake +++ b/native~/vcpkg/triplets/arm64-uwp-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) diff --git a/native~/vcpkg/triplets/shared/common.cmake b/native~/vcpkg/triplets/shared/common.cmake new file mode 100644 index 00000000..18203f5b --- /dev/null +++ b/native~/vcpkg/triplets/shared/common.cmake @@ -0,0 +1,5 @@ +list(APPEND VCPKG_ENV_PASSTHROUGH "CESIUM_VCPKG_RELEASE_ONLY") + +if(DEFINED ENV{CESIUM_VCPKG_RELEASE_ONLY} AND "$ENV{CESIUM_VCPKG_RELEASE_ONLY}") + set(VCPKG_BUILD_TYPE "release") +endif() diff --git a/native~/vcpkg/triplets/x64-android-unity.cmake b/native~/vcpkg/triplets/x64-android-unity.cmake index 85dfaacb..bba63abd 100644 --- a/native~/vcpkg/triplets/x64-android-unity.cmake +++ b/native~/vcpkg/triplets/x64-android-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE static) set(VCPKG_LIBRARY_LINKAGE static) diff --git a/native~/vcpkg/triplets/x64-uwp-unity.cmake b/native~/vcpkg/triplets/x64-uwp-unity.cmake index dea649ef..0d16dec8 100644 --- a/native~/vcpkg/triplets/x64-uwp-unity.cmake +++ b/native~/vcpkg/triplets/x64-uwp-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) diff --git a/native~/vcpkg/triplets/x64-windows-unity.cmake b/native~/vcpkg/triplets/x64-windows-unity.cmake index 75f9b953..b16f3e88 100644 --- a/native~/vcpkg/triplets/x64-windows-unity.cmake +++ b/native~/vcpkg/triplets/x64-windows-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE static) set(VCPKG_LIBRARY_LINKAGE static) From e3fca3687551f357f2a3335824bfe8dc0ab68908 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 15:13:27 +1000 Subject: [PATCH 13/67] Don't crash when there's no Android NDK. This is normal for UWP builds. --- Editor/CompileCesiumForUnityNative.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 44913b54..5e143cd2 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -529,7 +529,7 @@ private static void ConfigureEnvironmentVariables(IDictionary en // If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process. // So map a drive letter and rewrite the path. - if (ndkRoot.Contains(' ')) + if (ndkRoot != null && ndkRoot.Contains(' ')) { if (!Directory.Exists("N:\\")) { From 40628a9a4231b8a246fad551cc1ccec3714d5647 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 16:13:54 +1000 Subject: [PATCH 14/67] Add triplet files for macOS. --- native~/vcpkg/triplets/arm64-osx-unity.cmake | 9 +++++++++ native~/vcpkg/triplets/x64-osx-unity.cmake | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 native~/vcpkg/triplets/arm64-osx-unity.cmake create mode 100644 native~/vcpkg/triplets/x64-osx-unity.cmake diff --git a/native~/vcpkg/triplets/arm64-osx-unity.cmake b/native~/vcpkg/triplets/arm64-osx-unity.cmake new file mode 100644 index 00000000..2a9a0741 --- /dev/null +++ b/native~/vcpkg/triplets/arm64-osx-unity.cmake @@ -0,0 +1,9 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES arm64) +set(VCPKG_OSX_DEPLOYMENT_TARGET "10.13") diff --git a/native~/vcpkg/triplets/x64-osx-unity.cmake b/native~/vcpkg/triplets/x64-osx-unity.cmake new file mode 100644 index 00000000..7eae373d --- /dev/null +++ b/native~/vcpkg/triplets/x64-osx-unity.cmake @@ -0,0 +1,9 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) +set(VCPKG_OSX_DEPLOYMENT_TARGET "10.13") From 53efd6f746e7ee920bc21e06aaaace34874fe2a8 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 16:22:36 +1000 Subject: [PATCH 15/67] Add iOS triplet. --- native~/vcpkg/triplets/arm64-ios-unity.cmake | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 native~/vcpkg/triplets/arm64-ios-unity.cmake diff --git a/native~/vcpkg/triplets/arm64-ios-unity.cmake b/native~/vcpkg/triplets/arm64-ios-unity.cmake new file mode 100644 index 00000000..a43f644f --- /dev/null +++ b/native~/vcpkg/triplets/arm64-ios-unity.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME iOS) +set(VCPKG_OSX_DEPLOYMENT_TARGET 15) From 4752cb2e0a5a6431ea618ee13d497d1e59a93f12 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 16:31:31 +1000 Subject: [PATCH 16/67] Only build release vcpkg dependencies on macOS too. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f19c065..abcb9b29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -207,6 +207,8 @@ jobs: dotnet publish Reinterop~ -o . - name: Build Package run: | + # We only need a release build of vcpkg dependencies + export CESIUM_VCPKG_RELEASE_ONLY="TRUE" cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity dotnet run --project Build~ ls -l ~/cesium/CesiumForUnityBuildProject From 00102c7ea37f10b05b945fce1e17674b06494d04 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 17:45:04 +1000 Subject: [PATCH 17/67] Print macOS log. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abcb9b29..ff2f1b9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -215,6 +215,8 @@ jobs: - name: Print log if: ${{ failure() }} run: | + cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-x86_64/build.log + cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-arm64/build.log cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log - name: Publish package artifact if: ${{ success() }} From b78b6a78b5cb97b845eda0812b1f8110ea18ead5 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 19:48:45 +1000 Subject: [PATCH 18/67] Target macOS 10.15. 10.13 doesn't support std::filesystem::path. --- native~/vcpkg/triplets/arm64-osx-unity.cmake | 2 +- native~/vcpkg/triplets/x64-osx-unity.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/native~/vcpkg/triplets/arm64-osx-unity.cmake b/native~/vcpkg/triplets/arm64-osx-unity.cmake index 2a9a0741..c6110068 100644 --- a/native~/vcpkg/triplets/arm64-osx-unity.cmake +++ b/native~/vcpkg/triplets/arm64-osx-unity.cmake @@ -6,4 +6,4 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Darwin) set(VCPKG_OSX_ARCHITECTURES arm64) -set(VCPKG_OSX_DEPLOYMENT_TARGET "10.13") +set(VCPKG_OSX_DEPLOYMENT_TARGET "10.15") diff --git a/native~/vcpkg/triplets/x64-osx-unity.cmake b/native~/vcpkg/triplets/x64-osx-unity.cmake index 7eae373d..cc04fd28 100644 --- a/native~/vcpkg/triplets/x64-osx-unity.cmake +++ b/native~/vcpkg/triplets/x64-osx-unity.cmake @@ -6,4 +6,4 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Darwin) set(VCPKG_OSX_ARCHITECTURES x86_64) -set(VCPKG_OSX_DEPLOYMENT_TARGET "10.13") +set(VCPKG_OSX_DEPLOYMENT_TARGET "10.15") From d8b12ed8f7854d18dc566a5a8314f5c05d62c593 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 7 Aug 2024 19:51:34 +1000 Subject: [PATCH 19/67] Target 10.15 in player builds, too. --- Editor/CompileCesiumForUnityNative.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 5e143cd2..a1b0dec5 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -345,7 +345,7 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, Library if (cpu != null) library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=" + cpu.ToString().ToLowerInvariant()); - library.ExtraConfigureArgs.Add("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13"); + library.ExtraConfigureArgs.Add("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"); } if (platform.platform == BuildTarget.WSAPlayer) From 45ac07b61af7eb04cd4c0022f70cd477e883bbec Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 06:17:48 +1000 Subject: [PATCH 20/67] Change iOS lib/include/package resolution. --- native~/extern/ios-toolchain.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/native~/extern/ios-toolchain.cmake b/native~/extern/ios-toolchain.cmake index 0929898b..20847533 100644 --- a/native~/extern/ios-toolchain.cmake +++ b/native~/extern/ios-toolchain.cmake @@ -1,3 +1,6 @@ set(CMAKE_SYSTEM_NAME iOS) set(CMAKE_OSX_ARCHITECTURES arm64) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) From df77ca685f3dfe4876ded243e919edf6e2b960bb Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 08:33:22 +1000 Subject: [PATCH 21/67] iOS improvements. --- native~/extern/ios-toolchain.cmake | 3 +++ native~/vcpkg/triplets/arm64-ios-unity.cmake | 2 ++ 2 files changed, 5 insertions(+) diff --git a/native~/extern/ios-toolchain.cmake b/native~/extern/ios-toolchain.cmake index 20847533..dc9120b7 100644 --- a/native~/extern/ios-toolchain.cmake +++ b/native~/extern/ios-toolchain.cmake @@ -1,5 +1,8 @@ +set(GENERATOR Xcode) set(CMAKE_SYSTEM_NAME iOS) set(CMAKE_OSX_ARCHITECTURES arm64) +set(CMAKE_SYSTEM_PROCESSOR arm64) +set(CMAKE_OSX_DEPLOYMENT_TARGET 15) set(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) diff --git a/native~/vcpkg/triplets/arm64-ios-unity.cmake b/native~/vcpkg/triplets/arm64-ios-unity.cmake index a43f644f..ef884ac1 100644 --- a/native~/vcpkg/triplets/arm64-ios-unity.cmake +++ b/native~/vcpkg/triplets/arm64-ios-unity.cmake @@ -1,3 +1,5 @@ +include("${CMAKE_CURRENT_LIST_DIR}/shared/common.cmake") + set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) From 1338bba1258083bb19071e98db17280247fc2a5e Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 09:12:16 +1000 Subject: [PATCH 22/67] Add original KTX from vcpkg 2024.07.12 tag. --- .../vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch | 122 ++++++++++++++++++ .../vcpkg/ports/ktx/0002-Fix-versioning.patch | 17 +++ native~/vcpkg/ports/ktx/0003-mkversion.patch | 13 ++ native~/vcpkg/ports/ktx/0004-quirks.patch | 21 +++ .../ports/ktx/0005-no-vendored-libs.patch | 17 +++ .../ports/ktx/0006-fix-ios-install.patch | 13 ++ native~/vcpkg/ports/ktx/portfile.cmake | 81 ++++++++++++ native~/vcpkg/ports/ktx/vcpkg.json | 37 ++++++ 8 files changed, 321 insertions(+) create mode 100644 native~/vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch create mode 100644 native~/vcpkg/ports/ktx/0002-Fix-versioning.patch create mode 100644 native~/vcpkg/ports/ktx/0003-mkversion.patch create mode 100644 native~/vcpkg/ports/ktx/0004-quirks.patch create mode 100644 native~/vcpkg/ports/ktx/0005-no-vendored-libs.patch create mode 100644 native~/vcpkg/ports/ktx/0006-fix-ios-install.patch create mode 100644 native~/vcpkg/ports/ktx/portfile.cmake create mode 100644 native~/vcpkg/ports/ktx/vcpkg.json diff --git a/native~/vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch b/native~/vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch new file mode 100644 index 00000000..71a587bd --- /dev/null +++ b/native~/vcpkg/ports/ktx/0001-Use-vcpkg-zstd.patch @@ -0,0 +1,122 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9a56491..d7ca937 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -345,7 +345,6 @@ set(KTX_MAIN_SRC + lib/basisu/transcoder/basisu_transcoder.cpp + lib/basisu/transcoder/basisu_transcoder.h + lib/basisu/transcoder/basisu.h +- lib/basisu/zstd/zstd.c + lib/checkheader.c + lib/dfdutils/createdfd.c + lib/dfdutils/colourspaces.c +@@ -532,7 +531,6 @@ macro(common_libktx_settings target enable_write library_type) + $ + + $ +- $ + + $ + $ +@@ -627,6 +625,11 @@ macro(common_libktx_settings target enable_write library_type) + target_compile_definitions(${target} PUBLIC KTX_FEATURE_KTX2) + endif() + ++ # Use vcpkg zstd ++ find_package(zstd CONFIG REQUIRED) ++ set(ZSTD_LIBRARIES "$,zstd::libzstd_shared,zstd::libzstd_static>") ++ target_link_libraries(${target} PRIVATE ${ZSTD_LIBRARIES}) ++ + if(WIN32) + if(MINGW) + # Check if the Threads package is provided; if using Mingw it MIGHT be +diff --git a/cmake/KtxConfig.cmake b/cmake/KtxConfig.cmake +index 6386ba2..537bf4f 100644 +--- a/cmake/KtxConfig.cmake ++++ b/cmake/KtxConfig.cmake +@@ -1,7 +1,8 @@ + # Copyright 2015-2020 The Khronos Group Inc. + # SPDX-License-Identifier: Apache-2.0 + +-# include(CMakeFindDependencyMacro) +-# find_dependency() ++include(CMakeFindDependencyMacro) ++find_dependency(Threads) ++find_dependency(zstd CONFIG) + + include("${CMAKE_CURRENT_LIST_DIR}/KtxTargets.cmake") +diff --git a/lib/basisu/CMakeLists.txt b/lib/basisu/CMakeLists.txt +index 492233a..152ceb5 100644 +--- a/lib/basisu/CMakeLists.txt ++++ b/lib/basisu/CMakeLists.txt +@@ -145,9 +145,6 @@ set(BASISU_SRC_LIST ${COMMON_SRC_LIST} + transcoder/basisu_transcoder.cpp + ) + +-if (ZSTD) +- set(BASISU_SRC_LIST ${BASISU_SRC_LIST} zstd/zstd.c) +-endif() + + if (APPLE) + set(BIN_DIRECTORY "bin_osx") +@@ -165,6 +162,10 @@ else() + target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) + endif() + ++if(ZSTD_LIBRARIES) ++ target_link_libraries(basisu ${ZSTD_LIBRARIES}) ++endif() ++ + if (NOT MSVC) + # For Non-Windows builds, let cmake try and find the system OpenCL headers/libs for us. + if (OPENCL_FOUND) +diff --git a/lib/basisu/webgl/encoder/CMakeLists.txt b/lib/basisu/webgl/encoder/CMakeLists.txt +index 588d91b..a337b13 100644 +--- a/lib/basisu/webgl/encoder/CMakeLists.txt ++++ b/lib/basisu/webgl/encoder/CMakeLists.txt +@@ -34,9 +34,6 @@ if (EMSCRIPTEN) + ) + + if (KTX2_ZSTANDARD) +- set(SRC_LIST ${SRC_LIST} +- ../../zstd/zstd.c +- ) + set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) + else() + set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) +@@ -55,6 +52,10 @@ if (EMSCRIPTEN) + target_compile_options(basis_encoder.js PRIVATE -fno-strict-aliasing -O3) + + target_include_directories(basis_encoder.js PRIVATE ../../transcoder) ++ ++ if(ZSTD_LIBRARIES) ++ target_link_libraries(basis_encoder.js ${ZSTD_LIBRARIES}) ++ endif() + + set_target_properties(basis_encoder.js PROPERTIES + OUTPUT_NAME "basis_encoder" +diff --git a/lib/basisu/webgl/transcoder/CMakeLists.txt b/lib/basisu/webgl/transcoder/CMakeLists.txt +index 372653d..5ebc3cf 100644 +--- a/lib/basisu/webgl/transcoder/CMakeLists.txt ++++ b/lib/basisu/webgl/transcoder/CMakeLists.txt +@@ -28,9 +28,6 @@ if (EMSCRIPTEN) + endif() + + if (KTX2_ZSTANDARD) +- set(SRC_LIST ${SRC_LIST} +- ../../zstd/zstddeclib.c +- ) + set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=1) + else() + set(ZSTD_DEFINITION BASISD_SUPPORT_KTX2_ZSTD=0) +@@ -44,6 +41,10 @@ if (EMSCRIPTEN) + target_compile_definitions(basis_transcoder.js PRIVATE NDEBUG BASISD_SUPPORT_UASTC=1 BASISD_SUPPORT_BC7=1 BASISD_SUPPORT_ATC=0 BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY=0 BASISD_SUPPORT_PVRTC2=0 BASISD_SUPPORT_FXT1=0 BASISD_SUPPORT_ETC2_EAC_RG11=0 BASISU_SUPPORT_ENCODING=0 ${KTX2_DEFINITION} ${ZSTD_DEFINITION} ) + target_compile_options(basis_transcoder.js PRIVATE -O3 -fno-strict-aliasing) + target_include_directories(basis_transcoder.js PRIVATE ../../transcoder) ++ ++ if(ZSTD_LIBRARIES) ++ target_link_libraries(basis_transcoder.js ${ZSTD_LIBRARIES}) ++ endif() + + set_target_properties(basis_transcoder.js PROPERTIES + OUTPUT_NAME "basis_transcoder" diff --git a/native~/vcpkg/ports/ktx/0002-Fix-versioning.patch b/native~/vcpkg/ports/ktx/0002-Fix-versioning.patch new file mode 100644 index 00000000..1e509880 --- /dev/null +++ b/native~/vcpkg/ports/ktx/0002-Fix-versioning.patch @@ -0,0 +1,17 @@ +diff --git a/cmake/version.cmake b/cmake/version.cmake +index 4094df1a..3b2af3bb 100644 +--- a/cmake/version.cmake ++++ b/cmake/version.cmake +@@ -108,8 +108,10 @@ function(generate_version _var ) + set(${_var} "${KTX_VERSION}" PARENT_SCOPE) + endfunction() + +-# Get latest tag +-git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*) ++if (!KTX_VERSION_FULL) ++ # Get latest tag ++ git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*) ++endif() + #message("KTX full version: ${KTX_VERSION_FULL}") + + # generate_version(TOKTX_VERSION tools/toktx) diff --git a/native~/vcpkg/ports/ktx/0003-mkversion.patch b/native~/vcpkg/ports/ktx/0003-mkversion.patch new file mode 100644 index 00000000..ee8b3c4a --- /dev/null +++ b/native~/vcpkg/ports/ktx/0003-mkversion.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/version.cmake b/cmake/version.cmake +index 9a90622..0fc3521 100644 +--- a/cmake/version.cmake ++++ b/cmake/version.cmake +@@ -176,7 +176,7 @@ function( create_version_header dest_path target ) + add_custom_command( + OUTPUT ${version_h_output} + # On Windows this command has to be invoked by a shell in order to work +- COMMAND ${BASH_EXECUTABLE} -c "\"./mkversion\" \"-o\" \"version.h\" \"${dest_path}\"" ++ COMMAND "${BASH_EXECUTABLE}" -- ./mkversion -o version.h "${dest_path}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Generate ${version_h_output}" + VERBATIM diff --git a/native~/vcpkg/ports/ktx/0004-quirks.patch b/native~/vcpkg/ports/ktx/0004-quirks.patch new file mode 100644 index 00000000..afc34236 --- /dev/null +++ b/native~/vcpkg/ports/ktx/0004-quirks.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1500844..810914e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -263,7 +263,7 @@ if(MSVC) + # ";" argument separator is problematic. Can't use a GenEx `$:/WX> ) +- add_compile_options( $,/Gz,/O2> ) ++ add_compile_options( $,,/O2> ) + # Enable UTF-8 support + add_compile_options( $<$:/utf-8> ) + add_compile_options( $<$:/utf-8> ) +@@ -946,6 +946,7 @@ if(EMSCRIPTEN) + endif() + + add_library( objUtil STATIC ++ EXCLUDE_FROM_ALL + utils/argparser.cpp + utils/argparser.h + utils/ktxapp.h diff --git a/native~/vcpkg/ports/ktx/0005-no-vendored-libs.patch b/native~/vcpkg/ports/ktx/0005-no-vendored-libs.patch new file mode 100644 index 00000000..77cdd851 --- /dev/null +++ b/native~/vcpkg/ports/ktx/0005-no-vendored-libs.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d7ca937..ffcbe95 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1059,10 +1059,10 @@ endif() + # except for building the ktx library. + if((KTX_FEATURE_TOOLS OR KTX_FEATURE_TESTS) AND NOT TARGET fmt::fmt) + set(FMT_SYSTEM_HEADERS ON) +- add_subdirectory(other_projects/fmt) ++ find_package(fmt CONFIG REQUIRED) + endif() + if(KTX_FEATURE_TOOLS AND NOT TARGET cxxopts::cxxopts) +- add_subdirectory(other_projects/cxxopts) ++ find_package(cxxopts CONFIG REQUIRED) + endif() + + # Tools diff --git a/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch b/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch new file mode 100644 index 00000000..f81cfb46 --- /dev/null +++ b/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ccf4af61..2f6e404f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -484,7 +484,7 @@ macro(common_libktx_settings target enable_write library_type) + CXX_STANDARD_REQUIRED YES + + ) +- if(IOS) ++ if(0) + set_target_properties(${target} PROPERTIES + FRAMEWORK TRUE + ) diff --git a/native~/vcpkg/ports/ktx/portfile.cmake b/native~/vcpkg/ports/ktx/portfile.cmake new file mode 100644 index 00000000..f3fd2690 --- /dev/null +++ b/native~/vcpkg/ports/ktx/portfile.cmake @@ -0,0 +1,81 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO KhronosGroup/KTX-Software + REF "v${VERSION}" + SHA512 8ecb10d188b42c2104ae1ad1df8ba01a86af8b9ff673d74a767f742d2b5aa7effdc4765c2c280df43d717af3a14765189421d6b162f39515972dc439bd624619 + HEAD_REF master + PATCHES + 0001-Use-vcpkg-zstd.patch + 0002-Fix-versioning.patch + 0003-mkversion.patch + 0004-quirks.patch + 0005-no-vendored-libs.patch + 0006-fix-ios-install.patch +) +file(REMOVE "${SOURCE_PATH}/other_include/zstd_errors.h") + +vcpkg_list(SET OPTIONS) +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_acquire_msys(MSYS_ROOT + PACKAGES + bash + DIRECT_PACKAGES + # Required for "getopt" + "https://repo.msys2.org/msys/x86_64/util-linux-2.35.2-3-x86_64.pkg.tar.zst" + da26540881cd5734072717133307e5d1a27a60468d3656885507833b80f24088c5382eaa0234b30bdd9e8484a6638b4514623f5327f10b19eed36f12158e8edb + # Required for "dos2unix" + "https://mirror.msys2.org/msys/x86_64/dos2unix-7.5.1-1-x86_64.pkg.tar.zst" + 83d85e6ccea746ef9e8153a0d605e774dbe7efc0ee952804acfee4ffd7e3b0386a353b45ff989dd99bc3ce75968209fea3d246ad2af88bbb5c4eca12fc5a8f92 + ) + vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") + vcpkg_list(APPEND OPTIONS "-DBASH_EXECUTABLE=${MSYS_ROOT}/usr/bin/bash.exe") +endif() + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + tools KTX_FEATURE_TOOLS + vulkan KTX_FEATURE_VK_UPLOAD +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DKTX_VERSION_FULL=v${VERSION} + -DKTX_FEATURE_TESTS=OFF + -DKTX_FEATURE_LOADTEST_APPS=OFF + -DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC} + ${FEATURE_OPTIONS} + ${OPTIONS} + DISABLE_PARALLEL_CONFIGURE +) + +vcpkg_cmake_install() + +if(tools IN_LIST FEATURES) + vcpkg_copy_tools( + TOOL_NAMES + ktx + toktx + ktxsc + ktxinfo + ktx2ktx2 + ktx2check + AUTO_CLEAN + ) +else() + vcpkg_copy_pdbs() +endif() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ktx) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +file(GLOB LICENSE_FILES "${SOURCE_PATH}/LICENSES/*") +file(COPY ${LICENSE_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSES") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/native~/vcpkg/ports/ktx/vcpkg.json b/native~/vcpkg/ports/ktx/vcpkg.json new file mode 100644 index 00000000..b4d4a015 --- /dev/null +++ b/native~/vcpkg/ports/ktx/vcpkg.json @@ -0,0 +1,37 @@ +{ + "name": "ktx", + "version-semver": "4.3.1", + "port-version": 1, + "description": [ + "The Khronos KTX library and tools.", + "Functions for writing and reading KTX files, and instantiating OpenGL®, OpenGL ES™️ and Vulkan® textures from them." + ], + "homepage": "https://github.com/KhronosGroup/KTX-Software", + "license": null, + "supports": "arm64 | x64 | !windows", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "zstd" + ], + "features": { + "tools": { + "description": "Build tools", + "supports": "!android & !uwp", + "dependencies": [ + "cxxopts", + "fmt" + ] + }, + "vulkan": { + "description": "Build Vulkan support", + "supports": "!emscripten" + } + } +} From 1c16f808a94062598d2f5cf7306d94b72e82adfb Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 09:19:09 +1000 Subject: [PATCH 23/67] Add our modifications to KTX. These were copied from cesium-unreal. --- .../CESIUM-0001-do-not-define-_DEBUG.patch | 13 ++ .../ktx/CESIUM-0002-not-a-framework.patch | 17 ++ .../CESIUM-0003-ios-normal-header-path.patch | 30 ++++ native~/vcpkg/ports/ktx/portfile.cmake | 165 +++++++++--------- 4 files changed, 144 insertions(+), 81 deletions(-) create mode 100644 native~/vcpkg/ports/ktx/CESIUM-0001-do-not-define-_DEBUG.patch create mode 100644 native~/vcpkg/ports/ktx/CESIUM-0002-not-a-framework.patch create mode 100644 native~/vcpkg/ports/ktx/CESIUM-0003-ios-normal-header-path.patch diff --git a/native~/vcpkg/ports/ktx/CESIUM-0001-do-not-define-_DEBUG.patch b/native~/vcpkg/ports/ktx/CESIUM-0001-do-not-define-_DEBUG.patch new file mode 100644 index 00000000..d3c38256 --- /dev/null +++ b/native~/vcpkg/ports/ktx/CESIUM-0001-do-not-define-_DEBUG.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ffcbe95..7b13753 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -490,7 +490,7 @@ macro(common_libktx_settings target enable_write library_type) + target_compile_definitions( + ${target} + PUBLIC +- "$<$:_DEBUG;DEBUG>" ++ #"$<$:_DEBUG;DEBUG>" + PRIVATE + LIBKTX + ) diff --git a/native~/vcpkg/ports/ktx/CESIUM-0002-not-a-framework.patch b/native~/vcpkg/ports/ktx/CESIUM-0002-not-a-framework.patch new file mode 100644 index 00000000..4458110f --- /dev/null +++ b/native~/vcpkg/ports/ktx/CESIUM-0002-not-a-framework.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7b13753..b62b849 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -474,9 +474,9 @@ macro(common_libktx_settings target enable_write library_type) + + ) + if(IOS) +- set_target_properties(${target} PROPERTIES +- FRAMEWORK TRUE +- ) ++# set_target_properties(${target} PROPERTIES ++# FRAMEWORK TRUE ++# ) + endif() + + if( NOT ${library_type} STREQUAL STATIC ) diff --git a/native~/vcpkg/ports/ktx/CESIUM-0003-ios-normal-header-path.patch b/native~/vcpkg/ports/ktx/CESIUM-0003-ios-normal-header-path.patch new file mode 100644 index 00000000..6ad9c977 --- /dev/null +++ b/native~/vcpkg/ports/ktx/CESIUM-0003-ios-normal-header-path.patch @@ -0,0 +1,30 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b62b849..d8c4745 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1133,18 +1133,18 @@ endif() + # Use of this to install KHR/khr_df.h is due to CMake's failure to + # preserve the include source folder hierarchy. + # See https://gitlab.kitware.com/cmake/cmake/-/issues/16739. +-if (IOS) +- set_source_files_properties( +- include/KHR/khr_df.h +- PROPERTIES MACOSX_PACKAGE_LOCATION Headers/KHR +- ) +-else() ++# if (IOS) ++# set_source_files_properties( ++# include/KHR/khr_df.h ++# PROPERTIES MACOSX_PACKAGE_LOCATION Headers/KHR ++# ) ++# else() + include(GNUInstallDirs) + install(FILES include/KHR/khr_df.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/KHR + COMPONENT dev + ) +-endif() ++# endif() + + install(EXPORT KTXTargets + FILE KtxTargets.cmake diff --git a/native~/vcpkg/ports/ktx/portfile.cmake b/native~/vcpkg/ports/ktx/portfile.cmake index f3fd2690..ec0933e1 100644 --- a/native~/vcpkg/ports/ktx/portfile.cmake +++ b/native~/vcpkg/ports/ktx/portfile.cmake @@ -1,81 +1,84 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO KhronosGroup/KTX-Software - REF "v${VERSION}" - SHA512 8ecb10d188b42c2104ae1ad1df8ba01a86af8b9ff673d74a767f742d2b5aa7effdc4765c2c280df43d717af3a14765189421d6b162f39515972dc439bd624619 - HEAD_REF master - PATCHES - 0001-Use-vcpkg-zstd.patch - 0002-Fix-versioning.patch - 0003-mkversion.patch - 0004-quirks.patch - 0005-no-vendored-libs.patch - 0006-fix-ios-install.patch -) -file(REMOVE "${SOURCE_PATH}/other_include/zstd_errors.h") - -vcpkg_list(SET OPTIONS) -if(VCPKG_TARGET_IS_WINDOWS) - vcpkg_acquire_msys(MSYS_ROOT - PACKAGES - bash - DIRECT_PACKAGES - # Required for "getopt" - "https://repo.msys2.org/msys/x86_64/util-linux-2.35.2-3-x86_64.pkg.tar.zst" - da26540881cd5734072717133307e5d1a27a60468d3656885507833b80f24088c5382eaa0234b30bdd9e8484a6638b4514623f5327f10b19eed36f12158e8edb - # Required for "dos2unix" - "https://mirror.msys2.org/msys/x86_64/dos2unix-7.5.1-1-x86_64.pkg.tar.zst" - 83d85e6ccea746ef9e8153a0d605e774dbe7efc0ee952804acfee4ffd7e3b0386a353b45ff989dd99bc3ce75968209fea3d246ad2af88bbb5c4eca12fc5a8f92 - ) - vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") - vcpkg_list(APPEND OPTIONS "-DBASH_EXECUTABLE=${MSYS_ROOT}/usr/bin/bash.exe") -endif() - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - tools KTX_FEATURE_TOOLS - vulkan KTX_FEATURE_VK_UPLOAD -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - -DKTX_VERSION_FULL=v${VERSION} - -DKTX_FEATURE_TESTS=OFF - -DKTX_FEATURE_LOADTEST_APPS=OFF - -DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC} - ${FEATURE_OPTIONS} - ${OPTIONS} - DISABLE_PARALLEL_CONFIGURE -) - -vcpkg_cmake_install() - -if(tools IN_LIST FEATURES) - vcpkg_copy_tools( - TOOL_NAMES - ktx - toktx - ktxsc - ktxinfo - ktx2ktx2 - ktx2check - AUTO_CLEAN - ) -else() - vcpkg_copy_pdbs() -endif() - -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ktx) - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") -endif() - -file(GLOB LICENSE_FILES "${SOURCE_PATH}/LICENSES/*") -file(COPY ${LICENSE_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSES") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO KhronosGroup/KTX-Software + REF "v${VERSION}" + SHA512 8ecb10d188b42c2104ae1ad1df8ba01a86af8b9ff673d74a767f742d2b5aa7effdc4765c2c280df43d717af3a14765189421d6b162f39515972dc439bd624619 + HEAD_REF master + PATCHES + 0001-Use-vcpkg-zstd.patch + 0002-Fix-versioning.patch + 0003-mkversion.patch + 0004-quirks.patch + 0005-no-vendored-libs.patch + 0006-fix-ios-install.patch + CESIUM-0001-do-not-define-_DEBUG.patch + CESIUM-0002-not-a-framework.patch + CESIUM-0003-ios-normal-header-path.patch +) +file(REMOVE "${SOURCE_PATH}/other_include/zstd_errors.h") + +vcpkg_list(SET OPTIONS) +# if(VCPKG_TARGET_IS_WINDOWS) +# vcpkg_acquire_msys(MSYS_ROOT +# PACKAGES +# bash +# DIRECT_PACKAGES +# # Required for "getopt" +# "https://repo.msys2.org/msys/x86_64/util-linux-2.35.2-3-x86_64.pkg.tar.zst" +# da26540881cd5734072717133307e5d1a27a60468d3656885507833b80f24088c5382eaa0234b30bdd9e8484a6638b4514623f5327f10b19eed36f12158e8edb +# # Required for "dos2unix" +# "https://mirror.msys2.org/msys/x86_64/dos2unix-7.5.1-1-x86_64.pkg.tar.zst" +# 83d85e6ccea746ef9e8153a0d605e774dbe7efc0ee952804acfee4ffd7e3b0386a353b45ff989dd99bc3ce75968209fea3d246ad2af88bbb5c4eca12fc5a8f92 +# ) +# vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") +# vcpkg_list(APPEND OPTIONS "-DBASH_EXECUTABLE=${MSYS_ROOT}/usr/bin/bash.exe") +# endif() + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + tools KTX_FEATURE_TOOLS + vulkan KTX_FEATURE_VK_UPLOAD +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DKTX_VERSION_FULL=v${VERSION} + -DKTX_FEATURE_TESTS=OFF + -DKTX_FEATURE_LOADTEST_APPS=OFF + -DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC} + ${FEATURE_OPTIONS} + ${OPTIONS} + DISABLE_PARALLEL_CONFIGURE +) + +vcpkg_cmake_install() + +if(tools IN_LIST FEATURES) + vcpkg_copy_tools( + TOOL_NAMES + ktx + toktx + ktxsc + ktxinfo + ktx2ktx2 + ktx2check + AUTO_CLEAN + ) +else() + vcpkg_copy_pdbs() +endif() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ktx) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +file(GLOB LICENSE_FILES "${SOURCE_PATH}/LICENSES/*") +file(COPY ${LICENSE_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/LICENSES") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") From cd005f4984925a862f1074fa88eee39edb3c8602 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 09:20:17 +1000 Subject: [PATCH 24/67] Don't modify nonexistent targets. --- native~/CMakeLists.txt | 118 ++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index 1c796905..28914209 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -95,70 +95,70 @@ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) # Specify all targets that need to compile bitcode if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - set (ALL_TARGETS - CesiumForUnityNative-Runtime - Async++ - Cesium3DTilesContent - Cesium3DTilesReader - Cesium3DTilesSelection - CesiumAsync - CesiumGeometry - CesiumGeospatial - CesiumGltf - CesiumGltfContent - CesiumGltfReader - CesiumJsonReader - CesiumRasterOverlays - CesiumQuantizedMeshTerrain - CesiumUtility - draco_attributes - draco_compression_attributes_dec - draco_compression_bit_coders - draco_compression_entropy - draco_compression_decode - draco_compression_mesh_dec - draco_compression_point_cloud_dec - draco_core - draco_mesh - draco_metadata - draco_metadata_dec - draco_point_cloud - draco_points_dec - draco_static - expected-lite - GSL - httplib - ktx - meshoptimizer - modp_b64 - spdlog - sqlite3 - s2geometry - tinyxml2 - tidy-static - uriparser - webpdecode - webpdecoder - webpdspdecode - webputils - webputilsdecode - zlibstatic - ) - set(MESHOPT_BUILD_SHARED_LIBS OFF BOOL FORCE) + # set (ALL_TARGETS + # CesiumForUnityNative-Runtime + # Async++ + # Cesium3DTilesContent + # Cesium3DTilesReader + # Cesium3DTilesSelection + # CesiumAsync + # CesiumGeometry + # CesiumGeospatial + # CesiumGltf + # CesiumGltfContent + # CesiumGltfReader + # CesiumJsonReader + # CesiumRasterOverlays + # CesiumQuantizedMeshTerrain + # CesiumUtility + # draco_attributes + # draco_compression_attributes_dec + # draco_compression_bit_coders + # draco_compression_entropy + # draco_compression_decode + # draco_compression_mesh_dec + # draco_compression_point_cloud_dec + # draco_core + # draco_mesh + # draco_metadata + # draco_metadata_dec + # draco_point_cloud + # draco_points_dec + # draco_static + # expected-lite + # GSL + # httplib + # ktx + # meshoptimizer + # modp_b64 + # spdlog + # sqlite3 + # s2geometry + # tinyxml2 + # tidy-static + # uriparser + # webpdecode + # webpdecoder + # webpdspdecode + # webputils + # webputilsdecode + # zlibstatic + # ) + #set(MESHOPT_BUILD_SHARED_LIBS OFF BOOL FORCE) install(TARGETS tidy-static) - install( - TARGETS ${ALL_TARGETS} - PUBLIC_HEADER - EXCLUDE_FROM_ALL - FRAMEWORK - DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) + # install( + # TARGETS ${ALL_TARGETS} + # PUBLIC_HEADER + # EXCLUDE_FROM_ALL + # FRAMEWORK + # DESTINATION ${CMAKE_INSTALL_LIBDIR} + # ) set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) set_target_properties(tidy-static PROPERTIES EXCLUDE_FROM_ALL 0 EXCLUDE_FROM_DEFAULT_BUILD 0) - set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") + #set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") # ktx tags itself as a FRAMEWORK on iOS, which causes linker errors. Undo that. - set_target_properties(ktx PROPERTIES FRAMEWORK FALSE) + #set_target_properties(ktx PROPERTIES FRAMEWORK FALSE) endif() From 67f21cf08f45b6486b42db03575fb057037624ab Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 09:43:40 +1000 Subject: [PATCH 25/67] Use ktx directly from cesium-unreal. At commit 00a26bd8823f3e9b69d86ec584eb4580e601ac1b. --- native~/vcpkg/ports/ktx/0006-fix-ios-install.patch | 13 ------------- native~/vcpkg/ports/ktx/portfile.cmake | 5 +++-- native~/vcpkg/ports/ktx/vcpkg.json | 4 ++-- 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 native~/vcpkg/ports/ktx/0006-fix-ios-install.patch diff --git a/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch b/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch deleted file mode 100644 index f81cfb46..00000000 --- a/native~/vcpkg/ports/ktx/0006-fix-ios-install.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ccf4af61..2f6e404f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -484,7 +484,7 @@ macro(common_libktx_settings target enable_write library_type) - CXX_STANDARD_REQUIRED YES - - ) -- if(IOS) -+ if(0) - set_target_properties(${target} PROPERTIES - FRAMEWORK TRUE - ) diff --git a/native~/vcpkg/ports/ktx/portfile.cmake b/native~/vcpkg/ports/ktx/portfile.cmake index ec0933e1..40c64bbf 100644 --- a/native~/vcpkg/ports/ktx/portfile.cmake +++ b/native~/vcpkg/ports/ktx/portfile.cmake @@ -2,7 +2,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO KhronosGroup/KTX-Software REF "v${VERSION}" - SHA512 8ecb10d188b42c2104ae1ad1df8ba01a86af8b9ff673d74a767f742d2b5aa7effdc4765c2c280df43d717af3a14765189421d6b162f39515972dc439bd624619 + SHA512 5a89f8986464705ec36ac1becaddd0ff335e4c3c235468aaef0e963fcfeda4c0d669a086b91e61c16a3ae9e1fa5bf456dccf12cc65720e1a22e7cc0f30552541 HEAD_REF master PATCHES 0001-Use-vcpkg-zstd.patch @@ -10,7 +10,6 @@ vcpkg_from_github( 0003-mkversion.patch 0004-quirks.patch 0005-no-vendored-libs.patch - 0006-fix-ios-install.patch CESIUM-0001-do-not-define-_DEBUG.patch CESIUM-0002-not-a-framework.patch CESIUM-0003-ios-normal-header-path.patch @@ -51,6 +50,8 @@ vcpkg_cmake_configure( -DKTX_FEATURE_STATIC_LIBRARY=${ENABLE_STATIC} ${FEATURE_OPTIONS} ${OPTIONS} + # Do not regenerate headers (needs more dependencies) + -DCMAKE_DISABLE_FIND_PACKAGE_Vulkan=1 DISABLE_PARALLEL_CONFIGURE ) diff --git a/native~/vcpkg/ports/ktx/vcpkg.json b/native~/vcpkg/ports/ktx/vcpkg.json index b4d4a015..102e2813 100644 --- a/native~/vcpkg/ports/ktx/vcpkg.json +++ b/native~/vcpkg/ports/ktx/vcpkg.json @@ -1,6 +1,6 @@ { "name": "ktx", - "version-semver": "4.3.1", + "version-semver": "4.3.0-beta1", "port-version": 1, "description": [ "The Khronos KTX library and tools.", @@ -23,7 +23,7 @@ "features": { "tools": { "description": "Build tools", - "supports": "!android & !uwp", + "supports": "!android", "dependencies": [ "cxxopts", "fmt" From bd234d1b80b6bf985c6ae9de5b9348c3677f673a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 13:53:38 +1000 Subject: [PATCH 26/67] Fix iOS build by installing the right stuff. --- native~/CMakeLists.txt | 14 ++++++++++++-- native~/extern/cesium-native | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index 28914209..e1425e07 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -79,7 +79,18 @@ if (NOT VCPKG_TRIPLET) endif() endif() -add_subdirectory(extern/cesium-native EXCLUDE_FROM_ALL) +# We never need any of cesium-native's header files to be installed. +set(CESIUM_INSTALL_HEADERS OFF) + +# We only need cesium-native's static lib files to be installed on iOS. +if (NOT IOS) + set(CESIUM_INSTALL_STATIC_LIBS OFF) +endif() + +add_subdirectory(extern/cesium-native) + +# Don't build the cesium-native tests by default. +set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) # Enum flags is a header-only library without a CMakeLists.txt file(GLOB ENUM_FLAGS_HEADERS ${CMAKE_CURRENT_LIST_DIR}/extern/enum-flags/include/*.hpp) @@ -153,7 +164,6 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") # FRAMEWORK # DESTINATION ${CMAKE_INSTALL_LIBDIR} # ) - set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) set_target_properties(tidy-static PROPERTIES EXCLUDE_FROM_ALL 0 EXCLUDE_FROM_DEFAULT_BUILD 0) #set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index ffa2bbea..616ce113 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit ffa2bbea536590b07fcafcdac49e12ce63fb9be9 +Subproject commit 616ce1130a8ff336d2f78b91325e656832edc344 From 21a67a9626611464917a465faf8c947052718735 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 15:56:48 +1000 Subject: [PATCH 27/67] Use macos-latest runner and don't force an xcode version. This will hopefully fix bitcode conflicts because newer versions of xcode don't do bitcode at all. --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff2f1b9c..db559c4c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,14 +130,14 @@ jobs: reporter: dotnet-nunit MacOS: needs: [QuickChecks] - runs-on: macos-12 + runs-on: macos-latest # Only allow a single macOS build at a time, for Unity licensing reasons concurrency: mac steps: - - name: Set XCode version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: "14.1" + # - name: Set XCode version + # uses: maxim-lobanov/setup-xcode@v1 + # with: + # xcode-version: "14.1" - name: Check out repository code uses: actions/checkout@v4 with: From 13fc626e3ede0fc26aa3b9085ab63069e089c81d Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 21:13:36 +1000 Subject: [PATCH 28/67] Reduce Unity build time by shutting down immediately after compile. --- Editor/BuildCesiumForUnity.cs | 10 ++++++++++ Editor/CompileCesiumForUnityNative.cs | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Editor/BuildCesiumForUnity.cs b/Editor/BuildCesiumForUnity.cs index 8d8ed5f5..5b75633a 100644 --- a/Editor/BuildCesiumForUnity.cs +++ b/Editor/BuildCesiumForUnity.cs @@ -29,6 +29,8 @@ private static void OnEditorCompilationFinished(object o) public static void CompileForAndroidAndExit() { + CompileCesiumForUnityNative.ExitAfterCompile = true; + string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(buildPath); try @@ -46,6 +48,8 @@ public static void CompileForAndroidAndExit() public static void CompileForUWPAndExit() { + CompileCesiumForUnityNative.ExitAfterCompile = true; + string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(buildPath); try @@ -62,6 +66,8 @@ public static void CompileForUWPAndExit() public static void CompileForIOSAndExit() { + CompileCesiumForUnityNative.ExitAfterCompile = true; + string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(buildPath); try @@ -85,6 +91,8 @@ public static void CompileForIOSAndExit() public static void CompileForWindowsAndExit() { + CompileCesiumForUnityNative.ExitAfterCompile = true; + string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(buildPath); try @@ -100,6 +108,8 @@ public static void CompileForWindowsAndExit() public static void CompileForMacAndExit() { + CompileCesiumForUnityNative.ExitAfterCompile = true; + string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(buildPath); try diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index a1b0dec5..c5951809 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -195,6 +195,8 @@ private static void OnPostprocessAllAssets( public int callbackOrder => 0; + public bool ExitAfterCompile = false; + /// /// Invoked after the managed script assemblies are compiled, including the CesiumForUnity /// managed code. Building the CesiumForUnity assembly will generate C++ code via Reinterop, @@ -232,6 +234,11 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report) Directory.Delete(library.InstallDirectory, true); } } + + if (this.ExitAfterCompile) + { + EditorApplication.Exit(0); + } } /// From 2b3898b7ba2aff5c3d38508e33d3884ae609656f Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 8 Aug 2024 21:16:13 +1000 Subject: [PATCH 29/67] Make property static. --- Editor/CompileCesiumForUnityNative.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index c5951809..25389726 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -195,7 +195,7 @@ private static void OnPostprocessAllAssets( public int callbackOrder => 0; - public bool ExitAfterCompile = false; + public static bool ExitAfterCompile = false; /// /// Invoked after the managed script assemblies are compiled, including the CesiumForUnity @@ -235,7 +235,7 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report) } } - if (this.ExitAfterCompile) + if (ExitAfterCompile) { EditorApplication.Exit(0); } From 672dbb1fa07f23fb2abcffe99dd77913d513d5b5 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 08:56:42 +1000 Subject: [PATCH 30/67] Failed the build if cmake invocation fails. --- Editor/CompileCesiumForUnityNative.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 25389726..83b50372 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -195,8 +195,16 @@ private static void OnPostprocessAllAssets( public int callbackOrder => 0; + /// + /// True if Unity should exit immediately after `OnPostBuildPlayerScriptDLLs` completes. + /// public static bool ExitAfterCompile = false; + /// + /// The exit code of the last step of the build process, such as cmake or lipo. + /// + private static int LastRunExitCode = 0; + /// /// Invoked after the managed script assemblies are compiled, including the CesiumForUnity /// managed code. Building the CesiumForUnity assembly will generate C++ code via Reinterop, @@ -227,7 +235,10 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report) Process p = Process.Start("lipo", string.Join(' ', args)); p.WaitForExit(); if (p.ExitCode != 0) - throw new Exception("lipo failed"); + { + UnityEngine.Debug.LogError($"Invocation of 'lipo' tool failed. The command-line was:{Environment.NewLine}lipo {string.Join(' ', args)}"); + LastRunExitCode = p.ExitCode; + } foreach (LibraryToBuild library in libraries) { @@ -237,7 +248,7 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report) if (ExitAfterCompile) { - EditorApplication.Exit(0); + EditorApplication.Exit(LastRunExitCode); } } @@ -517,6 +528,7 @@ private static void RunAndLog(ProcessStartInfo startInfo, StreamWriter log, stri if (configure.ExitCode != 0) { UnityEngine.Debug.LogError($"An error occurred while building CesiumForUnityNative. See {logFilename} for details. The command-line was:{Environment.NewLine}{startInfo.FileName} {startInfo.Arguments}"); + LastRunExitCode = configure.ExitCode; } } } From d48f3dead4045843f4ed376723c7267911b1bd5e Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 12:29:11 +1000 Subject: [PATCH 31/67] Desperate attempt to debug CI-only Android build failure. --- .github/workflows/build.yml | 3 +++ Editor/CompileCesiumForUnityNative.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db559c4c..f676d68c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,6 +111,9 @@ jobs: dotnet run --project Build~ cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log dir d:\cesium\CesiumForUnityBuildProject + dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity + dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include + dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include\spdlog - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 83b50372..c67f6e63 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -462,6 +462,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) List args = new List() { + "--verbose", "-B", library.BuildDirectory, "-S", @@ -482,6 +483,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) args = new List() { + "--verbose", "--build", $"\"{library.BuildDirectory}\"", "--config", From 8d9060a41a756577e4ff4d9094f9a57ca7ef5268 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 13:22:45 +1000 Subject: [PATCH 32/67] More and better logging. --- .github/workflows/build.yml | 2 ++ Editor/CompileCesiumForUnityNative.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f676d68c..2f2e75e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,6 +109,8 @@ jobs: Remove-Item Env:ANDROID_NDK_ROOT # Run the build dotnet run --project Build~ + cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log + cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log dir d:\cesium\CesiumForUnityBuildProject dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index c67f6e63..c8c98224 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -462,7 +462,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) List args = new List() { - "--verbose", + "--trace-expand", "-B", library.BuildDirectory, "-S", @@ -483,7 +483,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) args = new List() { - "--verbose", + "--trace-expand", "--build", $"\"{library.BuildDirectory}\"", "--config", From 9bda02499203afb4aac83b76c8d071ebbe4c5519 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 14:35:37 +1000 Subject: [PATCH 33/67] Account for pernicketyness. --- Editor/CompileCesiumForUnityNative.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index c8c98224..e26576d8 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -483,7 +483,6 @@ internal static void BuildNativeLibrary(LibraryToBuild library) args = new List() { - "--trace-expand", "--build", $"\"{library.BuildDirectory}\"", "--config", @@ -491,7 +490,8 @@ internal static void BuildNativeLibrary(LibraryToBuild library) "--parallel", (Environment.ProcessorCount + 1).ToString(), "--target", - "install" + "install", + "--verbose" }; args.AddRange(library.ExtraBuildArgs); startInfo.Arguments = string.Join(' ', args); From e7a01299b93dd20a20523d2e03f3ab784b9b8c74 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 18:23:41 +1000 Subject: [PATCH 34/67] More debugging. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f2e75e6..ccdd3ce4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,6 +109,8 @@ jobs: Remove-Item Env:ANDROID_NDK_ROOT # Run the build dotnet run --project Build~ + dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include + dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include/spdlog cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log From 4ffb869b57969538d64624fc5ddf23e8c18b223c Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 18:24:55 +1000 Subject: [PATCH 35/67] Temporarily skip Windows player and UWP build. --- Build~/Package.cs | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Build~/Package.cs b/Build~/Package.cs index f009ae36..5e6fcf6a 100644 --- a/Build~/Package.cs +++ b/Build~/Package.cs @@ -145,41 +145,41 @@ public void Run() if (OperatingSystem.IsWindows()) { // TODO: we're currently only building for UWP on Windows. This should be an option, or a separate build command. - Console.WriteLine("**** Compiling for Universal Windows Platform Player"); - unity.Run(new[] - { - "-batchmode", - "-nographics", - "-projectPath", - Utility.ProjectRoot, - "-buildTarget", - "WindowsStoreApps", - "-executeMethod", - "CesiumForUnity.BuildCesiumForUnity.CompileForUWPAndExit" - }); - - Console.WriteLine("**** Adding generated files (for the UWP Player) to the package"); - AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); - - Console.WriteLine("**** Compiling for Windows Player"); - unity.Run(new[] - { - "-batchmode", - "-nographics", - "-projectPath", - Utility.ProjectRoot, - "-buildTarget", - "Win64", - "-executeMethod", - "CesiumForUnity.BuildCesiumForUnity.CompileForWindowsAndExit" - }); - - Console.WriteLine("**** Adding generated files (for the Windows Player) to the package"); - AddGeneratedFiles("!UNITY_EDITOR && UNITY_STANDALONE_WIN", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); - - // Clean the generated code directory. - Directory.Delete(generatedRuntimePath, true); - Directory.CreateDirectory(generatedRuntimePath); + // Console.WriteLine("**** Compiling for Universal Windows Platform Player"); + // unity.Run(new[] + // { + // "-batchmode", + // "-nographics", + // "-projectPath", + // Utility.ProjectRoot, + // "-buildTarget", + // "WindowsStoreApps", + // "-executeMethod", + // "CesiumForUnity.BuildCesiumForUnity.CompileForUWPAndExit" + // }); + + // Console.WriteLine("**** Adding generated files (for the UWP Player) to the package"); + // AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); + + // Console.WriteLine("**** Compiling for Windows Player"); + // unity.Run(new[] + // { + // "-batchmode", + // "-nographics", + // "-projectPath", + // Utility.ProjectRoot, + // "-buildTarget", + // "Win64", + // "-executeMethod", + // "CesiumForUnity.BuildCesiumForUnity.CompileForWindowsAndExit" + // }); + + // Console.WriteLine("**** Adding generated files (for the Windows Player) to the package"); + // AddGeneratedFiles("!UNITY_EDITOR && UNITY_STANDALONE_WIN", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); + + // // Clean the generated code directory. + // Directory.Delete(generatedRuntimePath, true); + // Directory.CreateDirectory(generatedRuntimePath); // TODO: we're currently only building for Android on Windows. This should be an option, or a separate build command. Console.WriteLine("**** Compiling for Android Player"); From c17f561eccc307d5626447cf51c255eee50241b3 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 19:54:27 +1000 Subject: [PATCH 36/67] Don't try to print WSA log. --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccdd3ce4..444501cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,13 +111,13 @@ jobs: dotnet run --project Build~ dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include/spdlog - cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log - cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log + # cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log + # cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log - dir d:\cesium\CesiumForUnityBuildProject - dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity - dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include - dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include\spdlog + # dir d:\cesium\CesiumForUnityBuildProject + # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity + # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include + # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include\spdlog - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 From 65840914fe52f1172f8ee024465e477b081e6c1a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 9 Aug 2024 22:10:58 +1000 Subject: [PATCH 37/67] Explicitly specify ezvcpkg path. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 444501cf..8b013e8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,6 +107,7 @@ jobs: $ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE" # Clear ANDROID_NDK_ROOT so that we use Unity's version Remove-Item Env:ANDROID_NDK_ROOT + $ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg" # Run the build dotnet run --project Build~ dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include From b53487f6038d9f9ad2ca88a4a710fa9176534788 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Sat, 10 Aug 2024 11:12:46 +1000 Subject: [PATCH 38/67] Use Ninja to build Android. The potentially old and busted make included with the potentially old and busted Android NDK fails to build our project because it generates command lines that exceed the Windows limit. Ugh. Hopefully Ninja will work better. --- .github/workflows/build.yml | 3 +++ Editor/CompileCesiumForUnityNative.cs | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b013e8b..1bd21848 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,9 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + - name: Install Ninja + run: | + choco install -y ninja - name: Install nasm uses: ilammy/setup-nasm@v1.5.1 - name: Install wget diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index e26576d8..5542f1be 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -564,13 +564,13 @@ private static void ConfigureEnvironmentVariables(IDictionary en // the default) won't work to build for Android. if (library.Platform == BuildTarget.Android && Environment.OSVersion.Platform == PlatformID.Win32NT) { - library.ExtraConfigureArgs.Add("-G \"Unix Makefiles\""); + library.ExtraConfigureArgs.Add("-G Ninja"); - if (!string.IsNullOrEmpty(ndkRoot)) - { - string make = Path.Combine(ndkRoot, "prebuilt", "windows-x86_64", "bin", "make.exe").Replace('\\', '/'); - library.ExtraConfigureArgs.Add($"-DCMAKE_MAKE_PROGRAM=\"{make}\""); - } + // if (!string.IsNullOrEmpty(ndkRoot)) + // { + // string make = Path.Combine(ndkRoot, "prebuilt", "windows-x86_64", "bin", "make.exe").Replace('\\', '/'); + // library.ExtraConfigureArgs.Add($"-DCMAKE_MAKE_PROGRAM=\"{make}\""); + // } } if (!string.IsNullOrEmpty(ndkRoot)) From 2c2ec89a6b3a335cdefc93500c1ba1334d649f49 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Sat, 10 Aug 2024 13:11:19 +1000 Subject: [PATCH 39/67] Reactivate builds, other cleanup. --- .github/workflows/build.yml | 10 +--- Build~/Package.cs | 74 ++++++++++++++------------- Editor/CompileCesiumForUnityNative.cs | 4 +- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bd21848..497a916a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,18 +110,10 @@ jobs: $ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE" # Clear ANDROID_NDK_ROOT so that we use Unity's version Remove-Item Env:ANDROID_NDK_ROOT + # Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous. $ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg" # Run the build dotnet run --project Build~ - dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include - dir /.ezvcpkg/2024.07.12/installed/arm64-android-unity/include/spdlog - # cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log - # cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log - cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log - # dir d:\cesium\CesiumForUnityBuildProject - # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity - # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include - # dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include\spdlog - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 diff --git a/Build~/Package.cs b/Build~/Package.cs index 5e6fcf6a..12fc7218 100644 --- a/Build~/Package.cs +++ b/Build~/Package.cs @@ -145,41 +145,45 @@ public void Run() if (OperatingSystem.IsWindows()) { // TODO: we're currently only building for UWP on Windows. This should be an option, or a separate build command. - // Console.WriteLine("**** Compiling for Universal Windows Platform Player"); - // unity.Run(new[] - // { - // "-batchmode", - // "-nographics", - // "-projectPath", - // Utility.ProjectRoot, - // "-buildTarget", - // "WindowsStoreApps", - // "-executeMethod", - // "CesiumForUnity.BuildCesiumForUnity.CompileForUWPAndExit" - // }); - - // Console.WriteLine("**** Adding generated files (for the UWP Player) to the package"); - // AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); - - // Console.WriteLine("**** Compiling for Windows Player"); - // unity.Run(new[] - // { - // "-batchmode", - // "-nographics", - // "-projectPath", - // Utility.ProjectRoot, - // "-buildTarget", - // "Win64", - // "-executeMethod", - // "CesiumForUnity.BuildCesiumForUnity.CompileForWindowsAndExit" - // }); - - // Console.WriteLine("**** Adding generated files (for the Windows Player) to the package"); - // AddGeneratedFiles("!UNITY_EDITOR && UNITY_STANDALONE_WIN", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); - - // // Clean the generated code directory. - // Directory.Delete(generatedRuntimePath, true); - // Directory.CreateDirectory(generatedRuntimePath); + Console.WriteLine("**** Compiling for Universal Windows Platform Player"); + unity.Run(new[] + { + "-batchmode", + "-nographics", + "-projectPath", + Utility.ProjectRoot, + "-buildTarget", + "WindowsStoreApps", + "-executeMethod", + "CesiumForUnity.BuildCesiumForUnity.CompileForUWPAndExit" + }); + + Console.WriteLine("**** Adding generated files (for the UWP Player) to the package"); + AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); + + // Clean the generated code directory. + Directory.Delete(generatedRuntimePath, true); + Directory.CreateDirectory(generatedRuntimePath); + + Console.WriteLine("**** Compiling for Windows Player"); + unity.Run(new[] + { + "-batchmode", + "-nographics", + "-projectPath", + Utility.ProjectRoot, + "-buildTarget", + "Win64", + "-executeMethod", + "CesiumForUnity.BuildCesiumForUnity.CompileForWindowsAndExit" + }); + + Console.WriteLine("**** Adding generated files (for the Windows Player) to the package"); + AddGeneratedFiles("!UNITY_EDITOR && UNITY_STANDALONE_WIN", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated")); + + // Clean the generated code directory. + Directory.Delete(generatedRuntimePath, true); + Directory.CreateDirectory(generatedRuntimePath); // TODO: we're currently only building for Android on Windows. This should be an option, or a separate build command. Console.WriteLine("**** Compiling for Android Player"); diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 5542f1be..f0189fc5 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -462,7 +462,6 @@ internal static void BuildNativeLibrary(LibraryToBuild library) List args = new List() { - "--trace-expand", "-B", library.BuildDirectory, "-S", @@ -490,8 +489,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) "--parallel", (Environment.ProcessorCount + 1).ToString(), "--target", - "install", - "--verbose" + "install" }; args.AddRange(library.ExtraBuildArgs); startInfo.Arguments = string.Join(' ', args); From 270da43e796e9730b647911a651be11420f1b45d Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 08:06:24 +1000 Subject: [PATCH 40/67] Add vcpkg caching. --- .github/workflows/build.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 497a916a..a936229e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,13 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + - name: Cache vcpkg artifacts + uses: actions/cache@v4 + with: + path: "d:/.ezvcpkg" + key: vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }} + restore-keys: | + vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}- - name: Install Ninja run: | choco install -y ninja @@ -137,18 +144,19 @@ jobs: # Only allow a single macOS build at a time, for Unity licensing reasons concurrency: mac steps: - # - name: Set XCode version - # uses: maxim-lobanov/setup-xcode@v1 - # with: - # xcode-version: "14.1" - name: Check out repository code uses: actions/checkout@v4 with: submodules: recursive + - name: Cache vcpkg artifacts + uses: actions/cache@v4 + with: + path: "~/.ezvcpkg" + key: vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }} + restore-keys: | + vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}- - name: Install nasm uses: ilammy/setup-nasm@v1.5.1 - - name: Install jq - run: brew install jq - name: Install Unity Hub run: | wget --quiet https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg From e81981219f929d5131c063f58ef0d52586e93fc1 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 10:27:16 +1000 Subject: [PATCH 41/67] Print Android build log again. Because it randomly failed. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a936229e..da056c33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,6 +121,7 @@ jobs: $ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg" # Run the build dotnet run --project Build~ + cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 From d90ebbe9380b0192ca09291eebeddfaf506ca9e2 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 18:13:27 +1000 Subject: [PATCH 42/67] Use swl-variant to improve compile times. --- .gitmodules | 6 +- native~/CMakeLists.txt | 64 +- native~/Editor/CMakeLists.txt | 2 +- native~/Runtime/CMakeLists.txt | 4 +- native~/Runtime/src/CesiumFeatureImpl.h | 4 +- .../Runtime/src/CesiumMetadataValueImpl.cpp | 1249 +++++++++-------- native~/Runtime/src/CesiumMetadataValueImpl.h | 91 -- native~/extern/enum-flags | 2 +- native~/extern/swl-variant | 1 + 9 files changed, 656 insertions(+), 767 deletions(-) create mode 160000 native~/extern/swl-variant diff --git a/.gitmodules b/.gitmodules index 2fab52ba..0a9976d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,4 +6,8 @@ url = https://github.com/htacg/tidy-html5.git [submodule "native~/extern/enum-flags"] path = native~/extern/enum-flags - url = https://github.com/grisumbras/enum-flags.git + url = https://github.com/kring/enum-flags.git +[submodule "native~/extern/swl-variant"] + path = native~/extern/swl-variant + url = https://github.com/kring/swl-variant.git + branch = exception-public-inheritance diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt index e1425e07..77599343 100644 --- a/native~/CMakeLists.txt +++ b/native~/CMakeLists.txt @@ -87,6 +87,7 @@ if (NOT IOS) set(CESIUM_INSTALL_STATIC_LIBS OFF) endif() +add_subdirectory(extern/swl-variant) add_subdirectory(extern/cesium-native) # Don't build the cesium-native tests by default. @@ -106,69 +107,6 @@ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) # Specify all targets that need to compile bitcode if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - # set (ALL_TARGETS - # CesiumForUnityNative-Runtime - # Async++ - # Cesium3DTilesContent - # Cesium3DTilesReader - # Cesium3DTilesSelection - # CesiumAsync - # CesiumGeometry - # CesiumGeospatial - # CesiumGltf - # CesiumGltfContent - # CesiumGltfReader - # CesiumJsonReader - # CesiumRasterOverlays - # CesiumQuantizedMeshTerrain - # CesiumUtility - # draco_attributes - # draco_compression_attributes_dec - # draco_compression_bit_coders - # draco_compression_entropy - # draco_compression_decode - # draco_compression_mesh_dec - # draco_compression_point_cloud_dec - # draco_core - # draco_mesh - # draco_metadata - # draco_metadata_dec - # draco_point_cloud - # draco_points_dec - # draco_static - # expected-lite - # GSL - # httplib - # ktx - # meshoptimizer - # modp_b64 - # spdlog - # sqlite3 - # s2geometry - # tinyxml2 - # tidy-static - # uriparser - # webpdecode - # webpdecoder - # webpdspdecode - # webputils - # webputilsdecode - # zlibstatic - # ) - #set(MESHOPT_BUILD_SHARED_LIBS OFF BOOL FORCE) install(TARGETS tidy-static) - # install( - # TARGETS ${ALL_TARGETS} - # PUBLIC_HEADER - # EXCLUDE_FROM_ALL - # FRAMEWORK - # DESTINATION ${CMAKE_INSTALL_LIBDIR} - # ) set_target_properties(tidy-static PROPERTIES EXCLUDE_FROM_ALL 0 EXCLUDE_FROM_DEFAULT_BUILD 0) - #set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") - - # ktx tags itself as a FRAMEWORK on iOS, which causes linker errors. Undo that. - #set_target_properties(ktx PROPERTIES FRAMEWORK FALSE) endif() - - diff --git a/native~/Editor/CMakeLists.txt b/native~/Editor/CMakeLists.txt index ba8183ba..5bd262f0 100644 --- a/native~/Editor/CMakeLists.txt +++ b/native~/Editor/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries( set_target_properties( CesiumForUnityNative-Editor PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) diff --git a/native~/Runtime/CMakeLists.txt b/native~/Runtime/CMakeLists.txt index 02038c76..92515530 100644 --- a/native~/Runtime/CMakeLists.txt +++ b/native~/Runtime/CMakeLists.txt @@ -44,12 +44,13 @@ target_link_libraries( PRIVATE tidy-static enum-flags + swl-variant ) set_target_properties( CesiumForUnityNative-Runtime PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD 20 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) @@ -66,6 +67,7 @@ target_compile_definitions( CesiumForUnityNative-Runtime PUBLIC TIDY_STATIC + SWL_VARIANT_NO_CONSTEXPR_EMPLACE ) # If we're building for the Unity Editor, set a #define accordingly. diff --git a/native~/Runtime/src/CesiumFeatureImpl.h b/native~/Runtime/src/CesiumFeatureImpl.h index 7c7c3b7c..7898788e 100644 --- a/native~/Runtime/src/CesiumFeatureImpl.h +++ b/native~/Runtime/src/CesiumFeatureImpl.h @@ -4,9 +4,9 @@ #include #include +#include #include -#include namespace DotNet::CesiumForUnity { class CesiumFeature; @@ -18,7 +18,7 @@ class String; namespace CesiumForUnityNative { -using ValueType = std::variant< +using ValueType = swl::variant< int8_t, uint8_t, int16_t, diff --git a/native~/Runtime/src/CesiumMetadataValueImpl.cpp b/native~/Runtime/src/CesiumMetadataValueImpl.cpp index f0ba7adc..48571d94 100644 --- a/native~/Runtime/src/CesiumMetadataValueImpl.cpp +++ b/native~/Runtime/src/CesiumMetadataValueImpl.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -55,21 +56,22 @@ namespace CesiumForUnityNative { namespace { -CesiumMetadataValueImpl::ValueType getNativeBooleanValue( - const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeBooleanValue( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { std::optional maybeBoolean = CesiumForUnity::CesiumMetadataValue::GetObjectAsBoolean( value.objectValue()); if (maybeBoolean) { - return *maybeBoolean; + return callback(*maybeBoolean); } - return std::monostate(); + return callback(swl::monostate()); } -template -CesiumMetadataValueImpl::ValueType -getNativeScalarValue(const DotNet::System::Object& object) { +template +auto getNativeScalarValue(const DotNet::System::Object& object, F&& callback) { std::optional maybeValue; if constexpr (std::is_same_v) { maybeValue = CesiumMetadataValue::GetObjectAsSByte(object); @@ -94,45 +96,66 @@ getNativeScalarValue(const DotNet::System::Object& object) { } if (maybeValue) { - return *maybeValue; + return callback(std::move(*maybeValue)); } - return std::monostate(); + return callback(swl::monostate()); } -CesiumMetadataValueImpl::ValueType -getNativeScalarValue(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeScalarValue( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Scalar); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeScalarValue(value.objectValue()); + return getNativeScalarValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -template -CesiumMetadataValueImpl::ValueType -getNativeVecValue(const DotNet::System::Object& object) { +template +auto getNativeVecValue(const DotNet::System::Object& object, F&& callback) { std::optional maybeValue; if constexpr (std::is_same_v) { maybeValue = CesiumMetadataValue::GetObjectAsCesiumIntVec2(object); @@ -161,7 +184,7 @@ getNativeVecValue(const DotNet::System::Object& object) { } if (!maybeValue) { - return std::monostate(); + return callback(swl::monostate()); } TTo result = TTo(); @@ -170,102 +193,167 @@ getNativeVecValue(const DotNet::System::Object& object) { result[i] = value[i]; } - return result; + return callback(std::move(result)); } -CesiumMetadataValueImpl::ValueType -getNativeVec2Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeVec2Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Vec2); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -CesiumMetadataValueImpl::ValueType -getNativeVec3Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeVec3Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Vec3); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -CesiumMetadataValueImpl::ValueType -getNativeVec4Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeVec4Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Vec4); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeVecValue(value.objectValue()); + return getNativeVecValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -template -CesiumMetadataValueImpl::ValueType -getNativeMatValue(const DotNet::System::Object& object) { +template +auto getNativeMatValue(const DotNet::System::Object& object, F&& callback) { std::optional maybeValue; if constexpr (std::is_same_v) { maybeValue = CesiumMetadataValue::GetObjectAsCesiumIntMat2x2(object); @@ -294,7 +382,7 @@ getNativeMatValue(const DotNet::System::Object& object) { } if (!maybeValue) { - return std::monostate(); + return callback(swl::monostate()); } TTo result = TTo(); @@ -305,824 +393,771 @@ getNativeMatValue(const DotNet::System::Object& object) { } } - return result; + return callback(std::move(result)); } -CesiumMetadataValueImpl::ValueType -getNativeMat2Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeMat2Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Mat2); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -CesiumMetadataValueImpl::ValueType -getNativeMat3Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeMat3Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Mat3); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -CesiumMetadataValueImpl::ValueType -getNativeMat4Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeMat4Value( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumMetadataValueType valueType = value.valueType(); assert(valueType.type == CesiumMetadataType::Mat4); switch (valueType.componentType) { case CesiumMetadataComponentType::Int8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint8: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint16: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint32: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Int64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Uint64: return getNativeMatValue( - value.objectValue()); + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float32: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); case CesiumMetadataComponentType::Float64: - return getNativeMatValue(value.objectValue()); + return getNativeMatValue( + value.objectValue(), + std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } -CesiumMetadataValueImpl::ValueType -getNativeStringValue(const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeStringValue( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { DotNet::System::String string = CesiumForUnity::CesiumMetadataValue::GetObjectAsString( value.objectValue()); if (string == nullptr) { - return std::monostate(); + return callback(swl::monostate()); } - return string.ToStlString(); + return callback(string.ToStlString()); } -} // namespace - -/*static*/ CesiumMetadataValueImpl::ValueType -CesiumMetadataValueImpl::getNativeValue( - const DotNet::CesiumForUnity::CesiumMetadataValue& value) { +template +auto getNativeValue( + const DotNet::CesiumForUnity::CesiumMetadataValue& value, + F&& callback) { CesiumForUnity::CesiumMetadataValueType valueType = value.valueType(); switch (valueType.type) { case CesiumForUnity::CesiumMetadataType::Boolean: - return getNativeBooleanValue(value); + return getNativeBooleanValue(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Scalar: - return getNativeScalarValue(value); + return getNativeScalarValue(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Vec2: - return getNativeVec2Value(value); + return getNativeVec2Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Vec3: - return getNativeVec3Value(value); + return getNativeVec3Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Vec4: - return getNativeVec4Value(value); + return getNativeVec4Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Mat2: - return getNativeMat2Value(value); + return getNativeMat2Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Mat3: - return getNativeMat3Value(value); + return getNativeMat3Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::Mat4: - return getNativeMat4Value(value); + return getNativeMat4Value(value, std::forward(callback)); case CesiumForUnity::CesiumMetadataType::String: - return getNativeStringValue(value); + return getNativeStringValue(value, std::forward(callback)); default: - return std::monostate(); + return callback(swl::monostate()); } } +} // namespace + /*static*/ bool CesiumMetadataValueImpl::ConvertToBoolean( const DotNet::CesiumForUnity::CesiumMetadataValue& value, bool defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> bool { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ int8_t CesiumMetadataValueImpl::ConvertToSByte( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int8_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int8_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> int8_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ uint8_t CesiumMetadataValueImpl::ConvertToByte( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint8_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint8_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> uint8_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ int16_t CesiumMetadataValueImpl::ConvertToInt16( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int16_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int16_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> int16_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ uint16_t CesiumMetadataValueImpl::ConvertToUInt16( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint16_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint16_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> uint16_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ int32_t CesiumMetadataValueImpl::ConvertToInt32( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int32_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int32_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> int32_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ uint32_t CesiumMetadataValueImpl::ConvertToUInt32( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint32_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint32_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> uint32_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ int64_t CesiumMetadataValueImpl::ConvertToInt64( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int64_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int64_t { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> int64_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ uint64_t CesiumMetadataValueImpl::ConvertToUInt64( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint64_t defaultValue) { - ValueType nativeValue = getNativeValue(value); - std::optional test; - test = std::visit( - [&defaultValue, &test](auto trueValue) -> std::optional { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue); - } - }, - nativeValue); - return test.value_or(defaultValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> uint64_t { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ float CesiumMetadataValueImpl::ConvertToFloat( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> float { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ double CesiumMetadataValueImpl::ConvertToDouble( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - return MetadataConversions::convert( - trueValue) - .value_or(defaultValue); - } - }, - nativeValue); + return getNativeValue(value, [defaultValue](auto&& trueValue) -> double { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + return MetadataConversions::convert(trueValue).value_or( + defaultValue); + } + }); } /*static*/ int2 CesiumMetadataValueImpl::ConvertToInt2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec2 = - MetadataConversions::convert( - trueValue); - return maybeVec2 ? UnityMetadataConversions::toInt2(*maybeVec2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec2 = + MetadataConversions::convert(trueValue); + return maybeVec2 ? UnityMetadataConversions::toInt2(*maybeVec2) + : defaultValue; + } + }); } /*static*/ uint2 CesiumMetadataValueImpl::ConvertToUInt2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec2 = - MetadataConversions::convert( - trueValue); - return maybeVec2 ? UnityMetadataConversions::toUint2(*maybeVec2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec2 = + MetadataConversions::convert(trueValue); + return maybeVec2 ? UnityMetadataConversions::toUint2(*maybeVec2) + : defaultValue; + } + }); } /*static*/ float2 CesiumMetadataValueImpl::ConvertToFloat2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec2 = - MetadataConversions::convert( - trueValue); - return maybeVec2 ? UnityMetadataConversions::toFloat2(*maybeVec2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec2 = + MetadataConversions::convert(trueValue); + return maybeVec2 ? UnityMetadataConversions::toFloat2(*maybeVec2) + : defaultValue; + } + }); } /*static*/ double2 CesiumMetadataValueImpl::ConvertToDouble2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec2 = - MetadataConversions::convert( - trueValue); - return maybeVec2 ? UnityMetadataConversions::toDouble2(*maybeVec2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec2 = + MetadataConversions::convert(trueValue); + return maybeVec2 ? UnityMetadataConversions::toDouble2(*maybeVec2) + : defaultValue; + } + }); } /*static*/ int3 CesiumMetadataValueImpl::ConvertToInt3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec3 = - MetadataConversions::convert( - trueValue); - return maybeVec3 ? UnityMetadataConversions::toInt3(*maybeVec3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec3 = + MetadataConversions::convert(trueValue); + return maybeVec3 ? UnityMetadataConversions::toInt3(*maybeVec3) + : defaultValue; + } + }); } /*static*/ uint3 CesiumMetadataValueImpl::ConvertToUInt3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec3 = - MetadataConversions::convert( - trueValue); - return maybeVec3 ? UnityMetadataConversions::toUint3(*maybeVec3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec3 = + MetadataConversions::convert(trueValue); + return maybeVec3 ? UnityMetadataConversions::toUint3(*maybeVec3) + : defaultValue; + } + }); } /*static*/ float3 CesiumMetadataValueImpl::ConvertToFloat3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec3 = - MetadataConversions::convert( - trueValue); - return maybeVec3 ? UnityMetadataConversions::toFloat3(*maybeVec3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec3 = + MetadataConversions::convert(trueValue); + return maybeVec3 ? UnityMetadataConversions::toFloat3(*maybeVec3) + : defaultValue; + } + }); } /*static*/ double3 CesiumMetadataValueImpl::ConvertToDouble3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec3 = - MetadataConversions::convert( - trueValue); - return maybeVec3 ? UnityMetadataConversions::toDouble3(*maybeVec3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec3 = + MetadataConversions::convert(trueValue); + return maybeVec3 ? UnityMetadataConversions::toDouble3(*maybeVec3) + : defaultValue; + } + }); } /*static*/ int4 CesiumMetadataValueImpl::ConvertToInt4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec4 = - MetadataConversions::convert( - trueValue); - return maybeVec4 ? UnityMetadataConversions::toInt4(*maybeVec4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec4 = + MetadataConversions::convert(trueValue); + return maybeVec4 ? UnityMetadataConversions::toInt4(*maybeVec4) + : defaultValue; + } + }); } /*static*/ uint4 CesiumMetadataValueImpl::ConvertToUInt4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec4 = - MetadataConversions::convert( - trueValue); - return maybeVec4 ? UnityMetadataConversions::toUint4(*maybeVec4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec4 = + MetadataConversions::convert(trueValue); + return maybeVec4 ? UnityMetadataConversions::toUint4(*maybeVec4) + : defaultValue; + } + }); } /*static*/ float4 CesiumMetadataValueImpl::ConvertToFloat4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec4 = - MetadataConversions::convert( - trueValue); - return maybeVec4 ? UnityMetadataConversions::toFloat4(*maybeVec4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec4 = + MetadataConversions::convert(trueValue); + return maybeVec4 ? UnityMetadataConversions::toFloat4(*maybeVec4) + : defaultValue; + } + }); } /*static*/ double4 CesiumMetadataValueImpl::ConvertToDouble4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeVec4 = - MetadataConversions::convert( - trueValue); - return maybeVec4 ? UnityMetadataConversions::toDouble4(*maybeVec4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeVec4 = + MetadataConversions::convert(trueValue); + return maybeVec4 ? UnityMetadataConversions::toDouble4(*maybeVec4) + : defaultValue; + } + }); } /*static*/ int2x2 CesiumMetadataValueImpl::ConvertToInt2x2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int2x2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int2x2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat2 = - MetadataConversions::convert( - trueValue); - return maybeMat2 ? UnityMetadataConversions::toInt2x2(*maybeMat2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int2x2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat2 = + MetadataConversions::convert(trueValue); + return maybeMat2 ? UnityMetadataConversions::toInt2x2(*maybeMat2) + : defaultValue; + } + }); } /*static*/ uint2x2 CesiumMetadataValueImpl::ConvertToUInt2x2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint2x2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint2x2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat2 = - MetadataConversions::convert( - trueValue); - return maybeMat2 ? UnityMetadataConversions::toUint2x2(*maybeMat2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint2x2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat2 = + MetadataConversions::convert(trueValue); + return maybeMat2 ? UnityMetadataConversions::toUint2x2(*maybeMat2) + : defaultValue; + } + }); } /*static*/ float2x2 CesiumMetadataValueImpl::ConvertToFloat2x2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float2x2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float2x2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat2 = - MetadataConversions::convert( - trueValue); - return maybeMat2 ? UnityMetadataConversions::toFloat2x2(*maybeMat2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float2x2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat2 = + MetadataConversions::convert(trueValue); + return maybeMat2 ? UnityMetadataConversions::toFloat2x2(*maybeMat2) + : defaultValue; + } + }); } /*static*/ double2x2 CesiumMetadataValueImpl::ConvertToDouble2x2( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double2x2 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double2x2 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat2 = - MetadataConversions::convert( - trueValue); - return maybeMat2 ? UnityMetadataConversions::toDouble2x2(*maybeMat2) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double2x2 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat2 = + MetadataConversions::convert(trueValue); + return maybeMat2 ? UnityMetadataConversions::toDouble2x2(*maybeMat2) + : defaultValue; + } + }); } /*static*/ int3x3 CesiumMetadataValueImpl::ConvertToInt3x3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int3x3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int3x3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat3 = - MetadataConversions::convert( - trueValue); - return maybeMat3 ? UnityMetadataConversions::toInt3x3(*maybeMat3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int3x3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat3 = + MetadataConversions::convert(trueValue); + return maybeMat3 ? UnityMetadataConversions::toInt3x3(*maybeMat3) + : defaultValue; + } + }); } /*static*/ uint3x3 CesiumMetadataValueImpl::ConvertToUInt3x3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint3x3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint3x3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat3 = - MetadataConversions::convert( - trueValue); - return maybeMat3 ? UnityMetadataConversions::toUint3x3(*maybeMat3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint3x3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat3 = + MetadataConversions::convert(trueValue); + return maybeMat3 ? UnityMetadataConversions::toUint3x3(*maybeMat3) + : defaultValue; + } + }); } /*static*/ float3x3 CesiumMetadataValueImpl::ConvertToFloat3x3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float3x3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float3x3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat3 = - MetadataConversions::convert( - trueValue); - return maybeMat3 ? UnityMetadataConversions::toFloat3x3(*maybeMat3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float3x3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat3 = + MetadataConversions::convert(trueValue); + return maybeMat3 ? UnityMetadataConversions::toFloat3x3(*maybeMat3) + : defaultValue; + } + }); } /*static*/ double3x3 CesiumMetadataValueImpl::ConvertToDouble3x3( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double3x3 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double3x3 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat3 = - MetadataConversions::convert( - trueValue); - return maybeMat3 ? UnityMetadataConversions::toDouble3x3(*maybeMat3) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double3x3 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat3 = + MetadataConversions::convert(trueValue); + return maybeMat3 ? UnityMetadataConversions::toDouble3x3(*maybeMat3) + : defaultValue; + } + }); } /*static*/ int4x4 CesiumMetadataValueImpl::ConvertToInt4x4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, int4x4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> int4x4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat4 = - MetadataConversions::convert( - trueValue); - return maybeMat4 ? UnityMetadataConversions::toInt4x4(*maybeMat4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> int4x4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat4 = + MetadataConversions::convert(trueValue); + return maybeMat4 ? UnityMetadataConversions::toInt4x4(*maybeMat4) + : defaultValue; + } + }); } /*static*/ uint4x4 CesiumMetadataValueImpl::ConvertToUInt4x4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, uint4x4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> uint4x4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat4 = - MetadataConversions::convert( - trueValue); - return maybeMat4 ? UnityMetadataConversions::toUint4x4(*maybeMat4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> uint4x4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v) { + return defaultValue; + } else { + std::optional maybeMat4 = + MetadataConversions::convert(trueValue); + return maybeMat4 ? UnityMetadataConversions::toUint4x4(*maybeMat4) + : defaultValue; + } + }); } /*static*/ float4x4 CesiumMetadataValueImpl::ConvertToFloat4x4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, float4x4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> float4x4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat4 = - MetadataConversions::convert( - trueValue); - return maybeMat4 ? UnityMetadataConversions::toFloat4x4(*maybeMat4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> float4x4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v< + std::remove_cvref_t, + swl::monostate>) { + return defaultValue; + } else { + std::optional maybeMat4 = MetadataConversions< + glm::mat4, + std::remove_cvref_t>::convert(trueValue); + return maybeMat4 ? UnityMetadataConversions::toFloat4x4(*maybeMat4) + : defaultValue; + } + }); } /*static*/ double4x4 CesiumMetadataValueImpl::ConvertToDouble4x4( const DotNet::CesiumForUnity::CesiumMetadataValue& value, double4x4 defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> double4x4 { - if constexpr (std::is_same_v) { - return defaultValue; - } else { - std::optional maybeMat4 = - MetadataConversions::convert( - trueValue); - return maybeMat4 ? UnityMetadataConversions::toDouble4x4(*maybeMat4) - : defaultValue; - } - }, - nativeValue); + return getNativeValue(value, [&defaultValue](auto&& trueValue) -> double4x4 { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v< + std::remove_cvref_t, + swl::monostate>) { + return defaultValue; + } else { + std::optional maybeMat4 = MetadataConversions< + glm::dmat4, + std::remove_cvref_t>::convert(trueValue); + return maybeMat4 ? UnityMetadataConversions::toDouble4x4(*maybeMat4) + : defaultValue; + } + }); } /*static*/ DotNet::System::String CesiumMetadataValueImpl::ConvertToString( const DotNet::CesiumForUnity::CesiumMetadataValue& value, DotNet::System::String defaultValue) { - ValueType nativeValue = getNativeValue(value); - return std::visit( - [&defaultValue](auto trueValue) -> System::String { - if constexpr (std::is_same_v) { + return getNativeValue( + value, + [&defaultValue](auto&& trueValue) -> System::String { + using TValue = std::remove_cvref_t; + if constexpr (std::is_same_v< + std::remove_cvref_t, + swl::monostate>) { return defaultValue; } else { - auto maybeString = - MetadataConversions::convert( - trueValue); + auto maybeString = MetadataConversions< + std::string, + std::remove_cvref_t>::convert(trueValue); return maybeString ? System::String(*maybeString) : defaultValue; } - }, - nativeValue); + }); } } // namespace CesiumForUnityNative diff --git a/native~/Runtime/src/CesiumMetadataValueImpl.h b/native~/Runtime/src/CesiumMetadataValueImpl.h index f134c916..08f41250 100644 --- a/native~/Runtime/src/CesiumMetadataValueImpl.h +++ b/native~/Runtime/src/CesiumMetadataValueImpl.h @@ -3,8 +3,6 @@ #include #include -#include - namespace DotNet::CesiumForUnity { class CesiumMetadataValue; } // namespace DotNet::CesiumForUnity @@ -45,85 +43,6 @@ namespace CesiumForUnityNative { class CesiumMetadataValueImpl { public: -#pragma region ValueType declaration - // This definition excludes arrays because those are handled in C#. - using ValueType = std::variant< - std::monostate, - int8_t, - uint8_t, - int16_t, - uint16_t, - int32_t, - uint32_t, - int64_t, - uint64_t, - float, - double, - bool, - std::string, - glm::vec<2, int8_t>, - glm::vec<2, uint8_t>, - glm::vec<2, int16_t>, - glm::vec<2, uint16_t>, - glm::vec<2, int32_t>, - glm::vec<2, uint32_t>, - glm::vec<2, int64_t>, - glm::vec<2, uint64_t>, - glm::vec<2, float>, - glm::vec<2, double>, - glm::vec<3, int8_t>, - glm::vec<3, uint8_t>, - glm::vec<3, int16_t>, - glm::vec<3, uint16_t>, - glm::vec<3, int32_t>, - glm::vec<3, uint32_t>, - glm::vec<3, int64_t>, - glm::vec<3, uint64_t>, - glm::vec<3, float>, - glm::vec<3, double>, - glm::vec<4, int8_t>, - glm::vec<4, uint8_t>, - glm::vec<4, int16_t>, - glm::vec<4, uint16_t>, - glm::vec<4, int32_t>, - glm::vec<4, uint32_t>, - glm::vec<4, int64_t>, - glm::vec<4, uint64_t>, - glm::vec<4, float>, - glm::vec<4, double>, - glm::mat<2, 2, int8_t>, - glm::mat<2, 2, uint8_t>, - glm::mat<2, 2, int16_t>, - glm::mat<2, 2, uint16_t>, - glm::mat<2, 2, int32_t>, - glm::mat<2, 2, uint32_t>, - glm::mat<2, 2, int64_t>, - glm::mat<2, 2, uint64_t>, - glm::mat<2, 2, float>, - glm::mat<2, 2, double>, - glm::mat<3, 3, int8_t>, - glm::mat<3, 3, uint8_t>, - glm::mat<3, 3, int16_t>, - glm::mat<3, 3, uint16_t>, - glm::mat<3, 3, int32_t>, - glm::mat<3, 3, uint32_t>, - glm::mat<3, 3, int64_t>, - glm::mat<3, 3, uint64_t>, - glm::mat<3, 3, float>, - glm::mat<3, 3, double>, - glm::mat<4, 4, int8_t>, - glm::mat<4, 4, uint8_t>, - glm::mat<4, 4, int16_t>, - glm::mat<4, 4, uint16_t>, - glm::mat<4, 4, int32_t>, - glm::mat<4, 4, uint32_t>, - glm::mat<4, 4, int64_t>, - glm::mat<4, 4, uint64_t>, - glm::mat<4, 4, float>, - glm::mat<4, 4, double>>; -#pragma endregion - -#pragma region Partial function implementations static bool ConvertToBoolean( const DotNet::CesiumForUnity::CesiumMetadataValue& value, bool defaultValue); @@ -267,15 +186,5 @@ class CesiumMetadataValueImpl { static DotNet::System::String ConvertToString( const DotNet::CesiumForUnity::CesiumMetadataValue& value, DotNet::System::String defaultValue); -#pragma endregion - -private: - /** - * Retrieves the value from the System.Object in the C# - * class implementation as a C++-compatible type. std::monostate is used - * to indicate a null value. - */ - static ValueType - getNativeValue(const DotNet::CesiumForUnity::CesiumMetadataValue& value); }; } // namespace CesiumForUnityNative diff --git a/native~/extern/enum-flags b/native~/extern/enum-flags index 48d25b47..dafc0265 160000 --- a/native~/extern/enum-flags +++ b/native~/extern/enum-flags @@ -1 +1 @@ -Subproject commit 48d25b470ee6971d0db15f020937abf6017ebf51 +Subproject commit dafc026588e98534a5898ebaef93a4eda1de6359 diff --git a/native~/extern/swl-variant b/native~/extern/swl-variant new file mode 160000 index 00000000..8af20f43 --- /dev/null +++ b/native~/extern/swl-variant @@ -0,0 +1 @@ +Subproject commit 8af20f43129ec66159eecd62a48eafdb7a2f74ca From 39744957a24633c219c355a46425163306f74ac5 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 18:36:01 +1000 Subject: [PATCH 43/67] Make sure UWP directory has the correct name (WSA) in newer Unity. --- Editor/CompileCesiumForUnityNative.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index f0189fc5..deb689ae 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -418,6 +418,9 @@ private static string GetDirectoryNameForPlatform(BuildTargetGroup platformGroup return "Editor"; else if (IsIOS(platformGroup, platform)) return "iOS"; + // Make sure we use "WSA" and not "Metro" + else if (platformGroup == BuildTargetGroup.WSA) + return "WSA"; return platformGroup.ToString(); } From 7bbde8f200d051426482bdca16a58ae55017a3cb Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 19:13:38 +1000 Subject: [PATCH 44/67] Only include copies of Reinterop-generated code. Previously we were assuming all generated code was ours, and including it all in the built package. In Unity 2022.3, this assumption no longer holds. --- Build~/Package.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Build~/Package.cs b/Build~/Package.cs index 12fc7218..41274ca9 100644 --- a/Build~/Package.cs +++ b/Build~/Package.cs @@ -36,13 +36,16 @@ public void Run() Directory.CreateDirectory(outputPackagePath); Console.WriteLine("**** Modifying the csc.rsp files to write generated files to disk"); - string generatedRuntimePath = Path.Combine(tempPath, "generated", "Runtime"); - Directory.CreateDirectory(generatedRuntimePath); - string generatedEditorPath = Path.Combine(tempPath, "generated", "Editor"); - Directory.CreateDirectory(generatedEditorPath); + string generatedRuntimeBasePath = Path.Combine(tempPath, "generated", "Runtime"); + Directory.CreateDirectory(generatedRuntimeBasePath); + string generatedEditorBasePath = Path.Combine(tempPath, "generated", "Editor"); + Directory.CreateDirectory(generatedEditorBasePath); + + File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimeBasePath + "\"" + Environment.NewLine, Encoding.UTF8); + File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorBasePath + "\"" + Environment.NewLine, Encoding.UTF8); - File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimePath + "\"" + Environment.NewLine, Encoding.UTF8); - File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorPath + "\"" + Environment.NewLine, Encoding.UTF8); + string generatedRuntimePath = Path.Combine(generatedRuntimeBasePath, "Reinterop"); + string generatedEditorPath = Path.Combine(generatedEditorBasePath, "Reinterop"); string sceneDirectory = Path.Combine(Utility.ProjectRoot, "Assets", "Scenes"); Directory.CreateDirectory(sceneDirectory); From 5742086eaed8791dbf6c5e2a48160506a61efae7 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 19:14:12 +1000 Subject: [PATCH 45/67] Use Unity 2022.3.41f1 for the build. --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da056c33..6a212655 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,8 +63,8 @@ jobs: del ./UnityHubSetup.exe - name: Install Unity run: | - Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait - Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait + Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait + Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait - name: Create SSH tunnel to Unity License Server env: UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }} @@ -170,10 +170,10 @@ jobs: # This command sometimes returns exit code 130, despite actually succeeding. continue-on-error: true run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64 + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture x86_64 - name: Install Unity iOS Support run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64 + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture x86_64 - name: Configure Unity to Use the License Server run: | sudo mkdir -p "/Library/Application Support/Unity/config" From ba3d4808dcb473d1b64febdd6b0ef39819682020 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 21:22:15 +1000 Subject: [PATCH 46/67] Print name of build directory while compiling native code. --- Editor/CompileCesiumForUnityNative.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index deb689ae..1aa3ff30 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -443,7 +443,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library) string projectPath = Path.Combine(Application.dataPath, ".."); string logDisplayName = Path.GetRelativePath(projectPath, logFilename); - EditorUtility.DisplayProgressBar($"Building CesiumForUnityNative", $"See {logDisplayName}.", 0.0f); + EditorUtility.DisplayProgressBar($"Building CesiumForUnityNative: {Path.GetFileName(library.BuildDirectory)}", $"See {logDisplayName}.", 0.0f); using (StreamWriter log = new StreamWriter(logFilename, false, Encoding.UTF8)) { From 72121791622c4bcffe28ff705c7ed85f9d1256c8 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 12 Aug 2024 21:40:26 +1000 Subject: [PATCH 47/67] Attempt to install the correct JDK. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a212655..68526248 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: - name: Install Unity run: | Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait - Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait + Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk universal-windows-platform uwp-il2cpp" -Wait - name: Create SSH tunnel to Unity License Server env: UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }} From b6ab280db18e7f3e0f73107a24a4a2380814c9df Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 13 Aug 2024 08:34:11 +1000 Subject: [PATCH 48/67] Run tests using new Unity version. --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68526248..19ba8323 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,7 +130,7 @@ jobs: path: d:\cesium\CesiumForUnityBuildProject\*.tgz - name: Run Tests run: | - start -FilePath "C:\Program Files\Unity\Hub\Editor\2021.3.13f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait + start -FilePath "C:\Program Files\Unity\Hub\Editor\2022.3.41f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait cat d:\cesium\temp\test-log.txt - name: Test Report uses: kring/test-reporter@v1.6.2-kring @@ -166,7 +166,7 @@ jobs: sudo cp -R "./UnityHubSetup/Unity Hub.app" /Applications hdiutil detach ./UnityHubSetup rm ./UnityHubSetup.dmg - - name: Install Unity 2021.3.13f1 + - name: Install Unity 2022.3.41f1 # This command sometimes returns exit code 130, despite actually succeeding. continue-on-error: true run: | @@ -238,7 +238,7 @@ jobs: path: ~/cesium/CesiumForUnityBuildProject/*.tgz - name: Run Tests run: | - /Applications/Unity/Hub/Editor/2021.3.13f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt + /Applications/Unity/Hub/Editor/2022.3.41f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt cat ~/cesium/CesiumForUnityBuildProject/test-log.txt ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml - name: Test Report From 54c6998b532fea9e3276418fe20c44e53557fbeb Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 13 Aug 2024 08:44:39 +1000 Subject: [PATCH 49/67] Install correct JDK module, remove non-existent uwp-il2cpp module. The JDK module name was deduced by running: ``` "C:/Program Files/Unity Hub/Unity Hub.exe" -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk universal-windows-platform uwp-il2cpp ``` And replacing android-sdk-ndk-tools with Unity's recommendation. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19ba8323..9755cd7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: - name: Install Unity run: | Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait - Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk universal-windows-platform uwp-il2cpp" -Wait + Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-11.0.14.1+1 universal-windows-platform" -Wait - name: Create SSH tunnel to Unity License Server env: UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }} From fd9823503262f85d71374bad4444b93494b583ae Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 13 Aug 2024 10:54:28 +1000 Subject: [PATCH 50/67] Publish build logs as artifact. --- .github/workflows/build.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9755cd7c..5af6789f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,7 +121,12 @@ jobs: $ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg" # Run the build dotnet run --project Build~ - cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log + - name: Publish Logs + if: success() || failure() # run this step even if previous step failed + uses: actions/upload-artifact@v4 + with: + name: Native Build Logs - Windows + path: native~/build-*/build.log - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 @@ -224,12 +229,12 @@ jobs: cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity dotnet run --project Build~ ls -l ~/cesium/CesiumForUnityBuildProject - - name: Print log - if: ${{ failure() }} - run: | - cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-x86_64/build.log - cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-arm64/build.log - cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log + - name: Publish Logs + if: success() || failure() # run this step even if previous step failed + uses: actions/upload-artifact@v4 + with: + name: Native Build Logs - macOS + path: native~/build-*/build.log - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 From bc60225b7d73afcb111127bf09d711af6f358226 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 13 Aug 2024 14:07:20 +1000 Subject: [PATCH 51/67] Fix log path. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5af6789f..beb17f67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,7 +126,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Native Build Logs - Windows - path: native~/build-*/build.log + path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 @@ -234,7 +234,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Native Build Logs - macOS - path: native~/build-*/build.log + path: ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log - name: Publish package artifact if: ${{ success() }} uses: actions/upload-artifact@v4 From 9e98da21e423cbac51349e513df49a2ef9c441d1 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 13 Aug 2024 18:06:35 +1000 Subject: [PATCH 52/67] Fix CesiumIonSession race condition. Sometimes, during the tests, the managed CesiumIonSession could get garbage collected before the requests made as part of the "resume" completed. Because we were using the corresponding Impl class in the continuations, and the Impl class's lifetime is controlled by the lifetime of the managed object, this would sometimes cause a crash. The solution implemented here is to make sure the continuations also keep the managed instance alive. We also check to see if the held managed instance becomes nullptr, which handles causes like AppDomain unload. --- native~/Editor/src/CesiumEditorWindowImpl.cpp | 2 +- native~/Editor/src/CesiumIonSessionImpl.cpp | 167 +++++++++++------- native~/Editor/src/CesiumIonSessionImpl.h | 39 ++-- native~/Editor/src/IonAssetsTreeViewImpl.cpp | 2 +- .../Editor/src/SelectIonTokenWindowImpl.cpp | 3 +- 5 files changed, 129 insertions(+), 84 deletions(-) diff --git a/native~/Editor/src/CesiumEditorWindowImpl.cpp b/native~/Editor/src/CesiumEditorWindowImpl.cpp index b4c31dcf..0b59e296 100644 --- a/native~/Editor/src/CesiumEditorWindowImpl.cpp +++ b/native~/Editor/src/CesiumEditorWindowImpl.cpp @@ -134,7 +134,7 @@ void CesiumEditorWindowImpl::AddAssetFromIon( } tileset.ionAssetID(tilesetID); - getNativeSession().getAssets(); + getNativeSession().getAssets(getSession()); if (overlayID > 0) { // TODO: Need to fix this when we support multiple overlays diff --git a/native~/Editor/src/CesiumIonSessionImpl.cpp b/native~/Editor/src/CesiumIonSessionImpl.cpp index 797e2a84..0c92a2db 100644 --- a/native~/Editor/src/CesiumIonSessionImpl.cpp +++ b/native~/Editor/src/CesiumIonSessionImpl.cpp @@ -165,10 +165,13 @@ void CesiumIonSessionImpl::Connect( ionServerUrl); std::move(futureApiUrl) - .thenInMainThread([ionServerUrl, server, session, this]( + .thenInMainThread([ionServerUrl, + server, + session, + this, + asyncSystem = this->_asyncSystem]( std::optional&& ionApiUrl) { - CesiumAsync::Promise promise = - this->_asyncSystem.createPromise(); + CesiumAsync::Promise promise = asyncSystem.createPromise(); if (session == nullptr) { promise.reject( @@ -278,11 +281,15 @@ void CesiumIonSessionImpl::Resume( // Verify that the connection actually works. this->ensureAppDataLoaded(session) - .thenInMainThread([this, userAccessToken, server](bool loadedAppData) { - CesiumAsync::Promise promise = - this->_asyncSystem.createPromise(); - - if (!loadedAppData || !this->_appData.has_value()) { + .thenInMainThread([this, + session, + userAccessToken, + server, + asyncSystem = this->_asyncSystem](bool loadedAppData) { + CesiumAsync::Promise promise = asyncSystem.createPromise(); + + if (session == nullptr || !loadedAppData || + !this->_appData.has_value()) { promise.reject(std::runtime_error( "Failed to obtain _appData, can't resume connection")); return promise.getFuture(); @@ -290,8 +297,8 @@ void CesiumIonSessionImpl::Resume( if (this->_appData->needsOauthAuthentication() && System::String::IsNullOrEmpty(userAccessToken)) { - // No user access token was stored, so there's no existing session to - // resume. + // No user access token was stored, so there's no existing session + // to resume. promise.resolve(); this->_isResuming = false; return promise.getFuture(); @@ -306,9 +313,12 @@ void CesiumIonSessionImpl::Resume( server.apiUrl().ToStlString()); return pConnection->me().thenInMainThread( - [this, - pConnection](CesiumIonClient::Response&& - response) { + [this, session, pConnection]( + CesiumIonClient::Response&& + response) { + if (session == nullptr) + return; + logResponseErrors(response); if (response.value.has_value()) { this->_connection = std::move(*pConnection); @@ -317,10 +327,13 @@ void CesiumIonSessionImpl::Resume( this->_quickAddItems = nullptr; this->broadcastConnectionUpdate(); - this->startQueuedLoads(); + this->startQueuedLoads(session); }); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session](std::exception&& e) { + if (session == nullptr) + return; + logResponseErrors(e); this->_isResuming = false; }); @@ -356,7 +369,7 @@ void CesiumIonSessionImpl::Tick( System::String CesiumIonSessionImpl::GetProfileUsername( const DotNet::CesiumForUnity::CesiumIonSession& session) { - return System::String(this->getProfile().username); + return System::String(this->getProfile(session).username); } System::String CesiumIonSessionImpl::GetAuthorizeUrl( @@ -381,7 +394,7 @@ CesiumIonSessionImpl::GetQuickAddItems( DotNet::CesiumForUnity::QuickAddItem> result{}; - const CesiumIonClient::Defaults& defaults = this->getDefaults(); + const CesiumIonClient::Defaults& defaults = this->getDefaults(session); for (const CesiumIonClient::QuickAddAsset& asset : defaults.quickAddAssets) { if (asset.type == "3DTILES" || (asset.type == "TERRAIN" && !asset.rasterOverlays.empty())) { @@ -406,10 +419,11 @@ CesiumIonSessionImpl::GetQuickAddItems( void CesiumIonSessionImpl::RefreshProfile( const DotNet::CesiumForUnity::CesiumIonSession& session) { - this->refreshProfile(); + this->refreshProfile(session); } -void CesiumIonSessionImpl::refreshProfile() { +void CesiumIonSessionImpl::refreshProfile( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (!this->_connection || this->_isLoadingProfile) { this->_loadProfileQueued = true; return; @@ -420,29 +434,30 @@ void CesiumIonSessionImpl::refreshProfile() { this->_connection->me() .thenInMainThread( - [this]( + [this, session]( CesiumIonClient::Response&& profile) { this->_isLoadingProfile = false; this->_profile = std::move(profile.value); this->broadcastProfileUpdate(); if (this->_loadProfileQueued) - this->refreshProfile(); + this->refreshProfile(session); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session](std::exception&& e) { this->_isLoadingProfile = false; this->_profile = std::nullopt; this->broadcastProfileUpdate(); if (this->_loadProfileQueued) - this->refreshProfile(); + this->refreshProfile(session); }); } void CesiumIonSessionImpl::RefreshAssets( const DotNet::CesiumForUnity::CesiumIonSession& session) { - this->refreshAssets(); + this->refreshAssets(session); } -void CesiumIonSessionImpl::refreshAssets() { +void CesiumIonSessionImpl::refreshAssets( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (!this->_connection || this->_isLoadingAssets) { this->_loadAssetsQueued = true; return; @@ -453,33 +468,35 @@ void CesiumIonSessionImpl::refreshAssets() { this->_connection->assets() .thenInMainThread( - [this](CesiumIonClient::Response&& assets) { + [this, session]( + CesiumIonClient::Response&& assets) { this->_isLoadingAssets = false; this->_assets = std::move(assets.value); this->broadcastAssetsUpdate(); if (this->_loadAssetsQueued) - this->refreshAssets(); + this->refreshAssets(session); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session](std::exception&& e) { this->_isLoadingAssets = false; this->_assets = std::nullopt; this->broadcastAssetsUpdate(); if (this->_loadAssetsQueued) - this->refreshAssets(); + this->refreshAssets(session); }); } void CesiumIonSessionImpl::RefreshTokens( const DotNet::CesiumForUnity::CesiumIonSession& session) { - this->refreshTokens(); + this->refreshTokens(session); } void CesiumIonSessionImpl::RefreshDefaults( const DotNet::CesiumForUnity::CesiumIonSession& session) { - this->refreshDefaults(); + this->refreshDefaults(session); } -void CesiumIonSessionImpl::refreshTokens() { +void CesiumIonSessionImpl::refreshTokens( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (!this->_connection || this->_isLoadingTokens) { this->_loadTokensQueued = true; return; @@ -490,7 +507,7 @@ void CesiumIonSessionImpl::refreshTokens() { this->_connection->tokens() .thenInMainThread( - [this]( + [this, session]( CesiumIonClient::Response&& tokens) { this->_isLoadingTokens = false; this->_tokens = @@ -499,18 +516,19 @@ void CesiumIonSessionImpl::refreshTokens() { : std::nullopt; this->broadcastTokensUpdate(); if (this->_loadTokensQueued) - this->refreshTokens(); + this->refreshTokens(session); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session](std::exception&& e) { this->_isLoadingTokens = false; this->_tokens = std::nullopt; this->broadcastTokensUpdate(); if (this->_loadTokensQueued) - this->refreshTokens(); + this->refreshTokens(session); }); } -void CesiumIonSessionImpl::refreshDefaults() { +void CesiumIonSessionImpl::refreshDefaults( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (!this->_connection || this->_isLoadingDefaults) { this->_loadDefaultsQueued = true; return; @@ -521,7 +539,7 @@ void CesiumIonSessionImpl::refreshDefaults() { this->_connection->defaults() .thenInMainThread( - [this]( + [this, session]( CesiumIonClient::Response&& defaults) { logResponseErrors(defaults); this->_isLoadingDefaults = false; @@ -529,43 +547,47 @@ void CesiumIonSessionImpl::refreshDefaults() { this->_quickAddItems = nullptr; this->broadcastDefaultsUpdate(); if (this->_loadDefaultsQueued) - this->refreshDefaults(); + this->refreshDefaults(session); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session](std::exception&& e) { logResponseErrors(e); this->_isLoadingDefaults = false; this->_defaults = std::nullopt; this->_quickAddItems = nullptr; this->broadcastDefaultsUpdate(); if (this->_loadDefaultsQueued) - this->refreshDefaults(); + this->refreshDefaults(session); }); } -bool CesiumIonSessionImpl::refreshProfileIfNeeded() { +bool CesiumIonSessionImpl::refreshProfileIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (this->_loadProfileQueued || !this->_profile.has_value()) { - this->refreshProfile(); + this->refreshProfile(session); } return this->_profile.has_value(); } -bool CesiumIonSessionImpl::refreshAssetsIfNeeded() { +bool CesiumIonSessionImpl::refreshAssetsIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (this->_loadAssetsQueued || !this->_assets.has_value()) { - this->refreshAssets(); + this->refreshAssets(session); } return this->_assets.has_value(); } -bool CesiumIonSessionImpl::refreshTokensIfNeeded() { +bool CesiumIonSessionImpl::refreshTokensIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (this->_loadTokensQueued || !this->_tokens.has_value()) { - this->refreshTokens(); + this->refreshTokens(session); } return this->_tokens.has_value(); } -bool CesiumIonSessionImpl::refreshDefaultsIfNeeded() { +bool CesiumIonSessionImpl::refreshDefaultsIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (this->_loadDefaultsQueued || !this->_defaults.has_value()) { - this->refreshDefaults(); + this->refreshDefaults(session); } return this->_defaults.has_value(); } @@ -677,32 +699,35 @@ CesiumIonSessionImpl::getConnection() const { return this->_connection; } -const CesiumIonClient::Profile& CesiumIonSessionImpl::getProfile() { +const CesiumIonClient::Profile& CesiumIonSessionImpl::getProfile( + const DotNet::CesiumForUnity::CesiumIonSession& session) { static const CesiumIonClient::Profile empty{}; if (this->_profile) { return *this->_profile; } else { - this->refreshProfile(); + this->refreshProfile(session); return empty; } } -const CesiumIonClient::Assets& CesiumIonSessionImpl::getAssets() { +const CesiumIonClient::Assets& CesiumIonSessionImpl::getAssets( + const DotNet::CesiumForUnity::CesiumIonSession& session) { static const CesiumIonClient::Assets empty; if (this->_assets) { return *this->_assets; } else { - this->refreshAssets(); + this->refreshAssets(session); return empty; } } -const std::vector& CesiumIonSessionImpl::getTokens() { +const std::vector& CesiumIonSessionImpl::getTokens( + const DotNet::CesiumForUnity::CesiumIonSession& session) { static const std::vector empty; if (this->_tokens) { return *this->_tokens; } else { - this->refreshTokens(); + this->refreshTokens(session); return empty; } } @@ -715,12 +740,13 @@ const CesiumIonClient::ApplicationData& CesiumIonSessionImpl::getAppData() { return empty; } -const CesiumIonClient::Defaults& CesiumIonSessionImpl::getDefaults() { +const CesiumIonClient::Defaults& CesiumIonSessionImpl::getDefaults( + const DotNet::CesiumForUnity::CesiumIonSession& session) { static const CesiumIonClient::Defaults empty; if (this->_defaults) { return *this->_defaults; } else { - this->refreshDefaults(); + this->refreshDefaults(session); return empty; } } @@ -738,15 +764,16 @@ CesiumAsync::AsyncSystem& CesiumIonSessionImpl::getAsyncSystem() { return this->_asyncSystem; } -void CesiumIonSessionImpl::startQueuedLoads() { +void CesiumIonSessionImpl::startQueuedLoads( + const DotNet::CesiumForUnity::CesiumIonSession& session) { if (this->_loadProfileQueued) - this->refreshProfile(); + this->refreshProfile(session); if (this->_loadAssetsQueued) - this->refreshAssets(); + this->refreshAssets(session); if (this->_loadTokensQueued) - this->refreshTokens(); + this->refreshTokens(session); if (this->_loadDefaultsQueued) - this->refreshDefaults(); + this->refreshDefaults(session); } CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded( @@ -758,11 +785,18 @@ CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded( this->_pAssetAccessor, server.apiUrl().ToStlString()) .thenInMainThread( - [this, session]( + [this, session, asyncSystem = this->_asyncSystem]( CesiumIonClient::Response&& appData) { CesiumAsync::Promise promise = - this->_asyncSystem.createPromise(); + _asyncSystem.createPromise(); + + if (session == nullptr) { + UnityEngine::Debug::LogError( + System::String("CesiumIonSession unexpectedly nullptr")); + promise.resolve(false); + return promise.getFuture(); + } this->_appData = appData.value; if (!appData.value.has_value()) { @@ -776,9 +810,10 @@ CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded( return promise.getFuture(); }) - .catchInMainThread([this](std::exception&& e) { + .catchInMainThread([this, session, asyncSystem = this->_asyncSystem]( + std::exception&& e) { logResponseErrors(e); - return this->_asyncSystem.createResolvedFuture(false); + return asyncSystem.createResolvedFuture(false); }); } diff --git a/native~/Editor/src/CesiumIonSessionImpl.h b/native~/Editor/src/CesiumIonSessionImpl.h index 55559e2d..a17f9515 100644 --- a/native~/Editor/src/CesiumIonSessionImpl.h +++ b/native~/Editor/src/CesiumIonSessionImpl.h @@ -84,16 +84,6 @@ class CesiumIonSessionImpl { void RefreshTokens(const DotNet::CesiumForUnity::CesiumIonSession& session); void RefreshDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session); - void refreshProfile(); - void refreshAssets(); - void refreshTokens(); - void refreshDefaults(); - - bool refreshProfileIfNeeded(); - bool refreshAssetsIfNeeded(); - bool refreshTokensIfNeeded(); - bool refreshDefaultsIfNeeded(); - CesiumAsync::Future> findToken(const std::string& token) const; @@ -104,18 +94,37 @@ class CesiumIonSessionImpl { void invalidateProjectDefaultTokenDetails(); const std::optional& getConnection() const; - const CesiumIonClient::Profile& getProfile(); - const CesiumIonClient::Assets& getAssets(); - const std::vector& getTokens(); + const CesiumIonClient::Profile& + getProfile(const DotNet::CesiumForUnity::CesiumIonSession& session); + const CesiumIonClient::Assets& + getAssets(const DotNet::CesiumForUnity::CesiumIonSession& session); + const std::vector& + getTokens(const DotNet::CesiumForUnity::CesiumIonSession& session); const CesiumIonClient::ApplicationData& getAppData(); - const CesiumIonClient::Defaults& getDefaults(); + const CesiumIonClient::Defaults& + getDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session); const std::shared_ptr& getAssetAccessor() const; const CesiumAsync::AsyncSystem& getAsyncSystem() const; CesiumAsync::AsyncSystem& getAsyncSystem(); private: - void startQueuedLoads(); + void refreshProfile(const DotNet::CesiumForUnity::CesiumIonSession& session); + void refreshAssets(const DotNet::CesiumForUnity::CesiumIonSession& session); + void refreshTokens(const DotNet::CesiumForUnity::CesiumIonSession& session); + void refreshDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session); + + bool refreshProfileIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session); + bool refreshAssetsIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session); + bool refreshTokensIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session); + bool refreshDefaultsIfNeeded( + const DotNet::CesiumForUnity::CesiumIonSession& session); + + void + startQueuedLoads(const DotNet::CesiumForUnity::CesiumIonSession& session); /** * If the {@link _appData} field has no value, this method will request the diff --git a/native~/Editor/src/IonAssetsTreeViewImpl.cpp b/native~/Editor/src/IonAssetsTreeViewImpl.cpp index c282e903..2545da79 100644 --- a/native~/Editor/src/IonAssetsTreeViewImpl.cpp +++ b/native~/Editor/src/IonAssetsTreeViewImpl.cpp @@ -117,7 +117,7 @@ void IonAssetsTreeViewImpl::CellGUI( void IonAssetsTreeViewImpl::Refresh( const DotNet::CesiumForUnity::IonAssetsTreeView& treeView) { CesiumIonSessionImpl& session = getNativeSession(); - const CesiumIonClient::Assets& assets = session.getAssets(); + const CesiumIonClient::Assets& assets = session.getAssets(getSession()); this->_assets.resize(assets.items.size()); diff --git a/native~/Editor/src/SelectIonTokenWindowImpl.cpp b/native~/Editor/src/SelectIonTokenWindowImpl.cpp index 39c7404a..7099beaf 100644 --- a/native~/Editor/src/SelectIonTokenWindowImpl.cpp +++ b/native~/Editor/src/SelectIonTokenWindowImpl.cpp @@ -214,8 +214,9 @@ SelectIonTokenWindowImpl::~SelectIonTokenWindowImpl() { void SelectIonTokenWindowImpl::RefreshTokens( const DotNet::CesiumForUnity::SelectIonTokenWindow& window) { + CesiumForUnity::CesiumIonSession session = getSession(window); const std::vector& tokens = - getSession(window).NativeImplementation().getTokens(); + session.NativeImplementation().getTokens(session); this->_tokens.resize(tokens.size()); System::Collections::Generic::List1 tokenNames = From c5c7f521cd666e1de3ba17bfddb0f26ec69d275a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 05:58:56 +1000 Subject: [PATCH 53/67] Don't specify explicit Unity processor on macOS. So hopefully we'll get ARM on ARM. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index beb17f67..75a99553 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -175,10 +175,10 @@ jobs: # This command sometimes returns exit code 130, despite actually succeeding. continue-on-error: true run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture x86_64 + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf - name: Install Unity iOS Support run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture x86_64 + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios - name: Configure Unity to Use the License Server run: | sudo mkdir -p "/Library/Application Support/Unity/config" From c6a84374ab5c8a4640f3155bc177d9e3b65b6993 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 06:23:38 +1000 Subject: [PATCH 54/67] Explicitly specify Unity use arm64 on macOS. If we don't specify, it sits there waiting for us to choose. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 75a99553..b5dcdee8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -175,10 +175,10 @@ jobs: # This command sometimes returns exit code 130, despite actually succeeding. continue-on-error: true run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture arm64 - name: Install Unity iOS Support run: | - /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios + /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture arm64 - name: Configure Unity to Use the License Server run: | sudo mkdir -p "/Library/Application Support/Unity/config" From 46fc8ffe53d319ffc852850cafccf5af6313eae1 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 08:24:27 +1000 Subject: [PATCH 55/67] Disable Unity audio. This will hopefully drastically speed up the macOS build because it won't have to wait ages for the audio system to time out. --- Build~/Package.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Build~/Package.cs b/Build~/Package.cs index 41274ca9..baf37af8 100644 --- a/Build~/Package.cs +++ b/Build~/Package.cs @@ -60,6 +60,24 @@ public void Run() } } + // Disable Unity audio, because we don't need it and because it seems to take 10-20 minutes + // to time out on macOS on GitHub Actions every time we start up Unity. + string projectSettingsDirectory = Path.Combine(Utility.ProjectRoot, "ProjectSettings"); + Directory.CreateDirectory(projectSettingsDirectory); + string audioManagerPath = Path.Combine(projectSettingsDirectory, "AudioManager.asset"); + if (!File.Exists(audioManagerPath)) + { + Console.WriteLine("**** Creating AudioManager.asset to disable Unity audio"); + using (StreamWriter audioManager = new StreamWriter(audioManagerPath)) + { + audioManager.WriteLine("%YAML 1.1"); + audioManager.WriteLine("%TAG !u! tag:unity3d.com,2011:"); + audioManager.WriteLine("--- !u!11 &1"); + audioManager.WriteLine("AudioManager:"); + audioManager.WriteLine(" m_DisableAudio: 1"); + } + } + Console.WriteLine("**** Compiling C# code for the Editor"); unity.Run(new[] { From a175d90a459f2fcd98e4034ff688b3cbffbe815c Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 09:01:27 +1000 Subject: [PATCH 56/67] Disable Unity audio for running tests, too. --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5dcdee8..d16f6ae0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,6 +103,10 @@ jobs: run: | mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity + # Disable Unity audio + mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings + $text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n" + [IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text) - name: Build Reinterop run: | cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity @@ -218,6 +222,9 @@ jobs: run: | mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity mv $GITHUB_WORKSPACE/* ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity + # Disable Unity audio + mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings + echo '%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!11 &1\nAudioManager:\n m_DisableAudio: 1\n' > ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset - name: Build Reinterop run: | cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity From f94ab7b44173102cce783c3baecfbf8883a36732 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 15:03:58 +1000 Subject: [PATCH 57/67] Fix test failures on macOS/ARM. --- Tests/TestCesiumGeoreference.cs | 41 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Tests/TestCesiumGeoreference.cs b/Tests/TestCesiumGeoreference.cs index efeca57f..cf423ff1 100644 --- a/Tests/TestCesiumGeoreference.cs +++ b/Tests/TestCesiumGeoreference.cs @@ -24,21 +24,22 @@ public IEnumerator ChangingOriginAtRuntimeUpdatesGlobeAnchors() yield return null; - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f)); + IEqualityComparer epsilon8 = Comparers.Double(1e-8); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8)); georeference.SetOriginLongitudeLatitudeHeight(-55.1, 54.9, 1001.0); - Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f)); + Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8)); yield return null; - Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f)); + Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8)); } [UnityTest] @@ -56,9 +57,10 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo yield return null; - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f)); + IEqualityComparer epsilon8 = Comparers.Double(1e-8); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8)); // Change both the origin and the transform. georeference.transform.localPosition = new Vector3(100.0f, 200.0f, 300.0f); @@ -67,7 +69,6 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo yield return null; // The anchor should maintain its globe position. - IEqualityComparer epsilon8 = Comparers.Double(1e-8); Assert.That(anchor.longitudeLatitudeHeight.x, Is.EqualTo(-55.0).Using(epsilon8)); Assert.That(anchor.longitudeLatitudeHeight.y, Is.EqualTo(55.0).Using(epsilon8)); Assert.That(anchor.longitudeLatitudeHeight.z, Is.EqualTo(1000.0).Using(epsilon8)); @@ -97,16 +98,16 @@ public IEnumerator GeoreferenceScaleAffectsGlobeAnchors() yield return null; - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f)); + IEqualityComparer epsilon8 = Comparers.Double(1e-8); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f)); - Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f)); - Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f)); + Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f).Using(epsilon8)); // The globe anchor's scale initially matches the local scale. - IEqualityComparer epsilon8 = Comparers.Double(1e-8); Assert.That(anchor.scaleEastUpNorth.x, Is.EqualTo(4.0).Using(epsilon8)); Assert.That(anchor.scaleEastUpNorth.y, Is.EqualTo(5.0).Using(epsilon8)); Assert.That(anchor.scaleEastUpNorth.z, Is.EqualTo(6.0).Using(epsilon8)); From a7ccccef7c3c5e10ee28304706f9173a759e40c5 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 15:44:59 +1000 Subject: [PATCH 58/67] Don't try to compare float to double. --- Tests/TestCesiumGeoreference.cs | 52 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/Tests/TestCesiumGeoreference.cs b/Tests/TestCesiumGeoreference.cs index cf423ff1..4f67049d 100644 --- a/Tests/TestCesiumGeoreference.cs +++ b/Tests/TestCesiumGeoreference.cs @@ -24,22 +24,22 @@ public IEnumerator ChangingOriginAtRuntimeUpdatesGlobeAnchors() yield return null; - IEqualityComparer epsilon8 = Comparers.Double(1e-8); - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8)); + IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8f)); georeference.SetOriginLongitudeLatitudeHeight(-55.1, 54.9, 1001.0); - Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8f)); yield return null; - Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8f)); } [UnityTest] @@ -57,10 +57,10 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo yield return null; - IEqualityComparer epsilon8 = Comparers.Double(1e-8); - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8)); + IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8f)); // Change both the origin and the transform. georeference.transform.localPosition = new Vector3(100.0f, 200.0f, 300.0f); @@ -69,16 +69,17 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo yield return null; // The anchor should maintain its globe position. + IEqualityComparer epsilon8 = Comparers.Double(1e-8); Assert.That(anchor.longitudeLatitudeHeight.x, Is.EqualTo(-55.0).Using(epsilon8)); Assert.That(anchor.longitudeLatitudeHeight.y, Is.EqualTo(55.0).Using(epsilon8)); Assert.That(anchor.longitudeLatitudeHeight.z, Is.EqualTo(1000.0).Using(epsilon8)); // Its local local position should be affected by the georeference origin change // but not by the parent transform change. - IEqualityComparer epsilon4 = new FloatEqualityComparer(1e-3f); - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon4)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(-1000.0f).Using(epsilon4)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon4)); + IEqualityComparer epsilon3 = new FloatEqualityComparer(1e-3f); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon3)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(-1000.0f).Using(epsilon3)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon3)); } [UnityTest] @@ -98,16 +99,17 @@ public IEnumerator GeoreferenceScaleAffectsGlobeAnchors() yield return null; - IEqualityComparer epsilon8 = Comparers.Double(1e-8); - Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f).Using(epsilon8)); + IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f); + Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f).Using(epsilon8f)); - Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f).Using(epsilon8)); - Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f).Using(epsilon8)); + Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f).Using(epsilon8f)); + Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f).Using(epsilon8f)); // The globe anchor's scale initially matches the local scale. + IEqualityComparer epsilon8 = Comparers.Double(1e-8); Assert.That(anchor.scaleEastUpNorth.x, Is.EqualTo(4.0).Using(epsilon8)); Assert.That(anchor.scaleEastUpNorth.y, Is.EqualTo(5.0).Using(epsilon8)); Assert.That(anchor.scaleEastUpNorth.z, Is.EqualTo(6.0).Using(epsilon8)); From 04027637123770efd00b4a8686be319f5c2609b6 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 17:01:35 +1000 Subject: [PATCH 59/67] Fix macOS test, add another test. --- Runtime/CesiumFlyToController.cs | 5 ++- Tests/TestCesiumFlyToController.cs | 59 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Runtime/CesiumFlyToController.cs b/Runtime/CesiumFlyToController.cs index 51eb7c4d..740f7b25 100644 --- a/Runtime/CesiumFlyToController.cs +++ b/Runtime/CesiumFlyToController.cs @@ -219,8 +219,9 @@ private void Reset() private bool DetectMovementInput() { double3 currentPositionECEF = this._globeAnchor.positionGlobeFixed; - bool3 positionEquality = currentPositionECEF == this._previousPositionECEF; - return !positionEquality.x || !positionEquality.y || !positionEquality.z; + double distanceSquared = math.lengthsq(currentPositionECEF - this._previousPositionECEF); + const double distanceConsideredMovement = 1e-6; // 1/1000 of a millimeter + return distanceSquared >= (distanceConsideredMovement * distanceConsideredMovement); } /// diff --git a/Tests/TestCesiumFlyToController.cs b/Tests/TestCesiumFlyToController.cs index d2c6bd50..e7196ebe 100644 --- a/Tests/TestCesiumFlyToController.cs +++ b/Tests/TestCesiumFlyToController.cs @@ -74,4 +74,63 @@ public IEnumerator FlyToLocationLongitudeLatitudeHeight() Assert.That(goFlyer.transform.position.y, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance)); Assert.That(goFlyer.transform.position.z, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance)); } + + [UnityTest] + public IEnumerator FlyToLocationLongitudeLatitudeHeightInterrupted() + { + GameObject goGeoreference = new GameObject("Georeference"); + CesiumGeoreference georeference = goGeoreference.AddComponent(); + georeference.longitude = -55.0; + georeference.latitude = 55.0; + georeference.height = 1000.0; + + GameObject goFlyer = new GameObject("Flyer"); + goFlyer.transform.parent = goGeoreference.transform; + + CesiumGlobeAnchor anchor = goFlyer.AddComponent(); + goFlyer.AddComponent(); + CesiumFlyToController flyToController = goFlyer.AddComponent(); + + // Make the flight fast so the test doesn't take too long. + flyToController.flyToDuration = 0.25; + + anchor.adjustOrientationForGlobeWhenMoving = false; + anchor.longitudeLatitudeHeight = new double3(20.0, -25.0, 1000.0); + anchor.adjustOrientationForGlobeWhenMoving = true; + + yield return null; + + // The origin should have been shifted so the flyer is at the origin. + Assert.That(goFlyer.transform.position.x, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance)); + Assert.That(goFlyer.transform.position.y, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance)); + Assert.That(goFlyer.transform.position.z, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance)); + + // Start a flight to elsewhere + bool flightComplete = false; + flyToController.OnFlightComplete += () => + { + flightComplete = true; + }; + + bool flightInterrupted = false; + flyToController.OnFlightInterrupted += () => + { + flightInterrupted = true; + }; + + flyToController.FlyToLocationLongitudeLatitudeHeight(new double3(100.0, 25.0, 800.0), 0.0f, 0.0f, true); + + yield return null; + + Assert.IsFalse(flightComplete); + Assert.IsFalse(flightInterrupted); + + // Give the object a new position, which should abort the flight. + goFlyer.transform.position = new Vector3(100.0f, 200.0f, 300.0f); + + yield return null; + + Assert.IsFalse(flightComplete); + Assert.IsTrue(flightInterrupted); + } } From 638bd2373c295dd137c9c536ff4a4b06c8e95796 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 18:48:06 +1000 Subject: [PATCH 60/67] Attempt to target iOS 12 and macOS 10.15. --- Build~/Package.cs | 5 +++++ Editor/CompileCesiumForUnityNative.cs | 1 + native~/vcpkg/triplets/arm64-ios-unity.cmake | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Build~/Package.cs b/Build~/Package.cs index baf37af8..2225001b 100644 --- a/Build~/Package.cs +++ b/Build~/Package.cs @@ -131,6 +131,11 @@ public void Run() if (OperatingSystem.IsMacOS()) { + configureArgs = configureArgs.Concat(new[] + { + "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15" + }).ToList(); + // On macOS, we must build the native code twice, once for x86_64 and once for arm64. // In theory we can build universal binaries, but some of our third party libraries don't // handle this well. diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 1aa3ff30..9afad04f 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -356,6 +356,7 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, Library library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_NAME=iOS"); library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_PROCESSOR=aarch64"); library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=arm64"); + library.ExtraConfigureArgs.Add("-DOSX_DEPLOYMENT_TARGET=12"); } if (platform.platform == BuildTarget.StandaloneOSX) diff --git a/native~/vcpkg/triplets/arm64-ios-unity.cmake b/native~/vcpkg/triplets/arm64-ios-unity.cmake index ef884ac1..7eede653 100644 --- a/native~/vcpkg/triplets/arm64-ios-unity.cmake +++ b/native~/vcpkg/triplets/arm64-ios-unity.cmake @@ -4,4 +4,4 @@ set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME iOS) -set(VCPKG_OSX_DEPLOYMENT_TARGET 15) +set(VCPKG_OSX_DEPLOYMENT_TARGET 12) From e4fd568ed04e6cc21a9890631d98bdb895537c24 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 14 Aug 2024 20:02:12 +1000 Subject: [PATCH 61/67] Specify iOS 12 in toolchain, too. --- native~/extern/ios-toolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/extern/ios-toolchain.cmake b/native~/extern/ios-toolchain.cmake index dc9120b7..d9cb19b2 100644 --- a/native~/extern/ios-toolchain.cmake +++ b/native~/extern/ios-toolchain.cmake @@ -2,7 +2,7 @@ set(GENERATOR Xcode) set(CMAKE_SYSTEM_NAME iOS) set(CMAKE_OSX_ARCHITECTURES arm64) set(CMAKE_SYSTEM_PROCESSOR arm64) -set(CMAKE_OSX_DEPLOYMENT_TARGET 15) +set(CMAKE_OSX_DEPLOYMENT_TARGET 12) set(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) From 8f9ab6e8ff10c5226ca6315da7346e9d6774be5a Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 15 Aug 2024 07:57:02 +1000 Subject: [PATCH 62/67] Changes from review. --- Editor/CompileCesiumForUnityNative.cs | 28 ++++++++------------- native~/Editor/src/CesiumIonSessionImpl.cpp | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs index 9afad04f..1b8657ab 100644 --- a/Editor/CompileCesiumForUnityNative.cs +++ b/Editor/CompileCesiumForUnityNative.cs @@ -550,29 +550,23 @@ private static void ConfigureEnvironmentVariables(IDictionary en } #endif - // If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process. - // So map a drive letter and rewrite the path. - if (ndkRoot != null && ndkRoot.Contains(' ')) - { - if (!Directory.Exists("N:\\")) - { - Process.Start("subst", "N: \"" + ndkRoot + "\"").WaitForExit(); - } - - ndkRoot = "N:\\"; - } - // On Windows, use the make program included in the NDK. Because Visual Studio (which is usually // the default) won't work to build for Android. if (library.Platform == BuildTarget.Android && Environment.OSVersion.Platform == PlatformID.Win32NT) { library.ExtraConfigureArgs.Add("-G Ninja"); - // if (!string.IsNullOrEmpty(ndkRoot)) - // { - // string make = Path.Combine(ndkRoot, "prebuilt", "windows-x86_64", "bin", "make.exe").Replace('\\', '/'); - // library.ExtraConfigureArgs.Add($"-DCMAKE_MAKE_PROGRAM=\"{make}\""); - // } + // If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process. + // So map a drive letter and rewrite the path. + if (ndkRoot != null && ndkRoot.Contains(' ')) + { + if (!Directory.Exists("N:\\")) + { + Process.Start("subst", "N: \"" + ndkRoot + "\"").WaitForExit(); + } + + ndkRoot = "N:\\"; + } } if (!string.IsNullOrEmpty(ndkRoot)) diff --git a/native~/Editor/src/CesiumIonSessionImpl.cpp b/native~/Editor/src/CesiumIonSessionImpl.cpp index 0c92a2db..669c1c16 100644 --- a/native~/Editor/src/CesiumIonSessionImpl.cpp +++ b/native~/Editor/src/CesiumIonSessionImpl.cpp @@ -789,7 +789,7 @@ CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded( CesiumIonClient::Response&& appData) { CesiumAsync::Promise promise = - _asyncSystem.createPromise(); + asyncSystem.createPromise(); if (session == nullptr) { UnityEngine::Debug::LogError( From e9de747ff3f1efc4754d930dee162c99f2a76765 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 15 Aug 2024 08:04:06 +1000 Subject: [PATCH 63/67] Remove a pointless std::move. --- native~/Runtime/src/CesiumMetadataValueImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/Runtime/src/CesiumMetadataValueImpl.cpp b/native~/Runtime/src/CesiumMetadataValueImpl.cpp index 48571d94..0a6a7362 100644 --- a/native~/Runtime/src/CesiumMetadataValueImpl.cpp +++ b/native~/Runtime/src/CesiumMetadataValueImpl.cpp @@ -96,7 +96,7 @@ auto getNativeScalarValue(const DotNet::System::Object& object, F&& callback) { } if (maybeValue) { - return callback(std::move(*maybeValue)); + return callback(*maybeValue); } return callback(swl::monostate()); From aabbee13f368693c2459e73a8df02337899644d4 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 15 Aug 2024 08:32:19 +1000 Subject: [PATCH 64/67] Update CHANGES.md. --- CHANGES.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a5f7bc13..18b1dead 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,20 @@ # Change Log +## ? - ? + +##### Breaking Changes :mega: + +- Player builds for macOS now require macOS 10.15+. Previously, 10.13+ was supported. + +##### Additions :tada: + +- Editor builds for macOS now target macOS 10.15+. Previously, macOS 12.7+ was required. + +##### Fixes :wrench: + +- Fixed a bug that could cause a crash in `CesiumIonSession` when the object was garbage collected or the AppDomain was unloaded while network requests were in progress. +- Fixed a bug that could cause `CesiumFlyToController` to unexpectedly interrupt a flight. + ## v1.11.1 - 2024-08-01 ##### Fixes :wrench: From e4f193312de1bb049e94c6f284263b480eba3d6d Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 15 Aug 2024 09:49:40 +1000 Subject: [PATCH 65/67] Update cesium-native. --- native~/extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index 616ce113..ac74cc3c 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit 616ce1130a8ff336d2f78b91325e656832edc344 +Subproject commit ac74cc3cdaae0eb5ea0e342f8df48924bdcbacd2 From 6034e86d0dbfeab16ca1e115531bdfe0f2a8ae08 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 15 Aug 2024 11:48:30 +1000 Subject: [PATCH 66/67] Update cesium-native. --- native~/extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index ac74cc3c..b1d7da47 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit ac74cc3cdaae0eb5ea0e342f8df48924bdcbacd2 +Subproject commit b1d7da4795ee01bcbec58353a75bf72d3a3d4596 From 772619fdd8f4b4b84dc3a9076a08aa48a025e68b Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 16 Aug 2024 15:37:22 +1000 Subject: [PATCH 67/67] Update cesium-native. --- native~/extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native~/extern/cesium-native b/native~/extern/cesium-native index b1d7da47..3b364351 160000 --- a/native~/extern/cesium-native +++ b/native~/extern/cesium-native @@ -1 +1 @@ -Subproject commit b1d7da4795ee01bcbec58353a75bf72d3a3d4596 +Subproject commit 3b364351795b4c60d58f3ddba16526c56c317c9a