diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a5880af795..60344fcf3a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,8 +15,8 @@ on: # Also trigger on push of release tags to any branch. Useful # for testing release builds before merging to main. tags: - - 'v[0-9]+\.[0-9]+\.[0-9]+' - - 'v[0-9]+\.[0-9]+\.[0-9]+-*' + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-*' paths-ignore: - .appveyor.yml - .travis.yml diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 0c24b06194..9dd715c1ff 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -15,8 +15,8 @@ on: # Also trigger on push of release tags to any branch. Useful # for testing release builds before merging to main. tags: - - 'v[0-9]+\.[0-9]+\.[0-9]+' - - 'v[0-9]+\.[0-9]+\.[0-9]+-*' + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-*' paths-ignore: - .appveyor.yml - .travis.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7fa3de7067..1ad0b57167 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,8 +15,8 @@ on: # Also trigger on push of release tags to any branch. Useful # for testing release builds before merging to main. tags: - - 'v[0-9]+\.[0-9]+\.[0-9]+' - - 'v[0-9]+\.[0-9]+\.[0-9]+-*' + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-*' paths-ignore: - .appveyor.yml - .travis.yml @@ -65,7 +65,9 @@ jobs: toolset: CLangCL arch: arm64 # No tests on arm64 since the host is x64 and can't run the - # built tests + # built tests. loadtests is OFF because CMake insists on + # choosing an older Windows SDK which is missing glu32.lib. + # Can set to OpenGL once issue is resolved. options: { config: 'Debug,Release', doc: ON, jni: ON, loadtests: OFF, tests: ON, tools: ON, tools_cts: ON, @@ -120,9 +122,26 @@ jobs: - name: Install NSIS with large string support shell: bash run: | - stack exec -- wget -O nsis-3.08-strlen_8192.zip https://downloads.sourceforge.net/nsis/NSIS%203/3.08/nsis-3.08-strlen_8192.zip - 7z x -aoa -o"/c/Program Files (x86)/NSIS" nsis-3.08-strlen_8192.zip - rm nsis-3.08-strlen_8192.zip + retryCount=4 + success=0 + for i in $(seq $retryCount) ; do + echo "Attempt no: $i" + stack exec -- wget -O nsis-3.08-strlen_8192.zip https://downloads.sourceforge.net/nsis/NSIS%203/3.08/nsis-3.08-strlen_8192.zip + if [[ $? -eq 0 ]] ; then + success=1 + 7z x -aoa -o"/c/Program Files (x86)/NSIS" nsis-3.08-strlen_8192.zip + rm nsis-3.08-strlen_8192.zip + echo "Installation successful." + break + else + echo "Installation failed. Retrying..." + sleep $(( 2*$i )) + fi + done + if (( ! $success )) ; then + echo "Installation failed after $retryCount attempts." + exit 1 + fi - name: Force fetch provoking tag's annotation. # Work around https://github.com/actions/checkout/issues/290. @@ -164,6 +183,15 @@ jobs: echo "CODE_SIGN_KEY_VAULT=Azure" >> $env:GITHUB_ENV } + - name: Install Dependencies for load tests on arm64 + if: matrix.arch == 'arm64' && matrix.options.loadtests != 'OFF' + run: | + pushd $env:VCPKG_INSTALLATION_ROOT + ./vcpkg install SDL2:arm64-windows assimp:arm64-windows glew:arm64-windows + cat buildtrees\glew\install-arm64-windows-rel-out.log + popd + echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV + - name: Install Dependencies # This script only installs what's needed by ON FEATUREs. run: ci_scripts/install_win.ps1 diff --git a/.travis.yml b/.travis.yml index ad1a6889d1..25e5b513c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,6 @@ addons: packages: - git-lfs - doxygen - - sdl2 #update: true env: @@ -217,6 +216,12 @@ install: fi ;; osx) + if [ "$PLATFORM" = "macOS" -a "$ARCHS" = $(uname -m) ]; then + # We're building for the host processor type. Safe to use + # brew installed libraries instead of repo included ones. + brew install sdl2 + brew install assimp + fi ./ci_scripts/install_macos.sh ;; esac diff --git a/ci_scripts/build_win.ps1 b/ci_scripts/build_win.ps1 index a8c1badc96..6615030aa8 100644 --- a/ci_scripts/build_win.ps1 +++ b/ci_scripts/build_win.ps1 @@ -144,6 +144,18 @@ if(!$?){ exit 1 } +# Find SDK version and ls it +#if ($FEATURE_LOADTESTS -ne "OFF") { +# $m = select-string -Pattern "(?(?[0-9][0-9])[0-9\.]*)-iphoneos/libSDL2.a + ) + else() + # These are universal binaries + set( SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) + set( SDL2_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/mac/$/libSDL2.dylib + ) + endif() + elseif(WIN32 AND ${CPU_ARCHITECTURE} STREQUAL "x86_64") + set( SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) + set( SDL2_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2main.lib + ${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2.lib + ) + else() + message( FATAL_ERROR "SDL2 not found. Can't build loadtest apps." ) + endif() endif() -if(LINUX) - find_package(assimp REQUIRED) +if(NOT assimp_FOUND) + if(APPLE) + if(IOS) + set( ASSIMP_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) + set( ASSIMP_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/ios/Release-iphoneos/libassimp.a + ) + else() + # These are universal binaries + set( ASSIMP_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) + set( ASSIMP_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/mac/Release/libassimp.a + ) + endif() + elseif(WIN32 AND ${CPU_ARCHITECTURE} STREQUAL "x86_64" ) + set( ASSIMP_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) + set( ASSIMP_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/assimp.lib + ) + elseif(NOT EMSCRIPTEN) + # There is no official libassimp for Emscripten yet and we've had + # no time to experiment so tests that use assimp are not included + # in the Emscripten build. + message( FATAL_ERROR "Assimp not found. Can't build loadtest apps." ) + endif() endif() - if(NOT EMSCRIPTEN AND NOT WIN32) # libassimp needs zlib. On Windows we use a dll which has zlib embedded. - # There is no official libassimp for Emscripten yet and we've had no - # time to experiment so tests that use assimp are not included in the - # Emscripten build. find_package( ZLIB REQUIRED ) set( KTX_ZLIB_LIBRARIES ZLIB::ZLIB ) endif() +if(${KTX_FEATURE_LOADTEST_APPS} MATCHES "OpenGL" AND WIN32) + if(NOT GLEW_FOUND) + if(${CPU_ARCHITECTURE} STREQUAL "x86_64") + set( GLEW_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/other_include ) + set( GLEW_LIBRARIES + ${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/glew32.lib + ) + else() + message( FATAL_ERROR "GLEW not found. Can't build gl3loadtests app." ) + endif() + endif() +endif() + if(APPLE AND IOS) if( CMAKE_OSX_ARCHITECTURES ) list(LENGTH CMAKE_OSX_ARCHITECTURES archs_len) @@ -53,24 +127,46 @@ if(APPLE AND IOS) endif() function( ensure_runtime_dependencies_windows target ) + # Custom copy commands to ensure all dependencies (DLLs, testimages, # shaders, models) are in correct location relative to executable. + + # When these packages are imported via vcpkg, something there is + # adding a post-build to copy their DLLs. These are for the repo + # included DLLs. + # + # It does not appear possible to use a genex to decide presence + # of an entire command so we use the long-winded way. + if (NOT TARGET SDL2::SDL2) + add_custom_command( TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2.dll" "$" + COMMENT "Copy SDL2 DLLs to build destination" + ) + endif() + if (NOT TARGET assimp::assimp) + add_custom_command( TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/assimp.dll" "$" + COMMENT "Copy assimp DLL to build destination" + ) + endif() + if (NOT TARGET GLEW::GLEW) + add_custom_command( TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E;copy "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/glew32.dll" "$" + COMMENT "Copy GLEW DLL to build destination" + ) + endif() + if(${KTX_FEATURE_LOADTEST_APPS} MATCHES "Vulkan") + add_custom_command( TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/shaders" "$/resources" + COMMENT "Copy shaders to build destination" + ) + endif() add_custom_command( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2.dll" "$" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/assimp.dll" "$" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/glew32.dll" "$" - COMMENT "Copy DLLs to build destination" - ) - add_custom_command( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/shaders" "$/shaders" - COMMENT "Copy shaders to build destination" - ) - add_custom_command( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests/testimages" "$/testimages" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests/testimages" "$/resources" COMMENT "Copy testimages to build destination" ) add_custom_command( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests/loadtests/common/models" "$/models" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests/loadtests/common/models" "$/resources" COMMENT "Copy models to build destination" ) endfunction() @@ -107,10 +203,8 @@ set_target_properties(appfwSDL PROPERTIES target_include_directories( appfwSDL PUBLIC - ${SDL2_INCLUDE_DIRS} appfwSDL - $ - ${PROJECT_SOURCE_DIR}/lib + $ ${PROJECT_SOURCE_DIR}/utils common geom @@ -118,8 +212,9 @@ PUBLIC target_include_directories( appfwSDL -SYSTEM PUBLIC - ${PROJECT_SOURCE_DIR}/other_include +SYSTEM AFTER PUBLIC + ${SDL2_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/other_include # For glm ) if(${KTX_FEATURE_LOADTEST_APPS} MATCHES "OpenGL") @@ -138,29 +233,24 @@ if(${KTX_FEATURE_LOADTEST_APPS} MATCHES "OpenGL") endif() target_link_libraries(GLAppSDL appfwSDL) + target_include_directories( GLAppSDL PUBLIC $ - common glloadtests glloadtests/utils ) + # The above appfwSDL include brings with it the + # INTERFACE_SYSTEM_INCLUDE_DIRECTORIES. target_include_directories( GLAppSDL - SYSTEM PRIVATE - $ + SYSTEM BEFORE PUBLIC + $,${GLEW_INCLUDE_DIR},${OPENGL_INCLUDE_DIR}> + #$ ) - if(OPENGL_FOUND) - target_include_directories( - GLAppSDL - PUBLIC - ${OPENGL_INCLUDE_DIR} - ) - endif() - set_target_properties(GLAppSDL PROPERTIES CXX_VISIBILITY_PRESET ${STATIC_APP_LIB_SYMBOL_VISIBILITY} ) @@ -170,35 +260,33 @@ set( LOAD_TEST_COMMON_LIBS ) if(APPLE) set( EXE_FLAG MACOSX_BUNDLE ) - set( SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/other_include ) if(IOS) # Do not set KTX_ICON here. On iOS the icon is not a single file. # Icon setup must be handled when creating a target. set( LOAD_TEST_COMMON_LIBS - ${CMAKE_SOURCE_DIR}/other_lib/ios/$-iphoneos/libSDL2.a - ${CMAKE_SOURCE_DIR}/other_lib/ios/Release-iphoneos/libassimp.a + ${ASSIMP_LIBRARIES} + ${SDL2_LIBRARIES} ) else() set( KTX_ICON ${PROJECT_SOURCE_DIR}/icons/mac/ktx_app.icns ) set( LOAD_TEST_COMMON_LIBS - ${CMAKE_SOURCE_DIR}/other_lib/mac/$/libSDL2.dylib - ${CMAKE_SOURCE_DIR}/other_lib/mac/Release/libassimp.a + ${ASSIMP_LIBRARIES} + ${SDL2_LIBRARIES} ${CMAKE_SOURCE_DIR}/other_lib/mac/Release/libminizip.a ) endif() elseif(LINUX) set( KTX_ICON ${PROJECT_SOURCE_DIR}/icons/linux/ktx_app.svg ) set( LOAD_TEST_COMMON_LIBS - ${assimp_LIBRARIES} + ${ASSIMP_LIBRARIES} ${SDL2_LIBRARIES} ) elseif(WIN32) set( EXE_FLAG WIN32 ) set( KTX_ICON ${PROJECT_SOURCE_DIR}/icons/win/ktx_app.ico ) set( LOAD_TEST_COMMON_LIBS - "${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2.lib" - "${CMAKE_SOURCE_DIR}/other_lib/win/$-x64/SDL2main.lib" - "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/assimp.lib" + ${ASSIMP_LIBRARIES} + ${SDL2_LIBRARIES} ) endif() @@ -237,4 +325,3 @@ endif() if(${KTX_FEATURE_LOADTEST_APPS} MATCHES "Vulkan") include(vkloadtests.cmake) endif() - diff --git a/tests/loadtests/appfwSDL/AppBaseSDL.cpp b/tests/loadtests/appfwSDL/AppBaseSDL.cpp index 4b03bb2be8..3223fb204b 100644 --- a/tests/loadtests/appfwSDL/AppBaseSDL.cpp +++ b/tests/loadtests/appfwSDL/AppBaseSDL.cpp @@ -34,6 +34,10 @@ AppBaseSDL::initialize(Args& /*args*/) #if __LINUX__ // TODO figure out best way to handle these resources sBasePath += "../resources/"; +#endif +#if __WINDOWS__ + // Ditto + sBasePath += "resources/"; #endif SDL_free((void *)basePath); return true; diff --git a/tests/loadtests/appfwSDL/GLAppSDL.cpp b/tests/loadtests/appfwSDL/GLAppSDL.cpp index 03eb0646af..b3a7e586fe 100644 --- a/tests/loadtests/appfwSDL/GLAppSDL.cpp +++ b/tests/loadtests/appfwSDL/GLAppSDL.cpp @@ -21,6 +21,7 @@ #define snprintf _snprintf #endif #define _CRT_SECURE_NO_WARNINGS +#include "windows.h" #include "GL/glew.h" #include "SDL2/SDL_loadso.h" #else @@ -132,7 +133,16 @@ GLAppSDL::initialize(Args& args) // So one build of this library can be linked in to applications using GLEW and // applications not using GLEW, do not call any GLEW functions directly. // Call via queried function pointers. - void* glewdll = SDL_LoadObject("glew32.dll"); + void* glewdll; +#if defined(_DEBUG) + glewdll = SDL_LoadObject("glew32d.dll"); + // KTX-Software repo only contains non-debug library for x64 hence this. + if (glewdll == NULL) { + glewdll = SDL_LoadObject("glew32.dll"); + } +#else + glewdll = SDL_LoadObject("glew32.dll"); +#endif if (glewdll == NULL) { std::string sName(szName); @@ -176,7 +186,6 @@ GLAppSDL::initialize(Args& args) NULL); return false; } - int iResult = pGlewInit(); if (iResult != GLEW_OK) { std::string sName(szName); diff --git a/tests/loadtests/glloadtests.cmake b/tests/loadtests/glloadtests.cmake index 01923aedae..71e8c9f7c4 100644 --- a/tests/loadtests/glloadtests.cmake +++ b/tests/loadtests/glloadtests.cmake @@ -19,31 +19,29 @@ function( create_gl_target target version sources common_resources test_images set_code_sign(${target}) + # Nota Bene. + # + # 1. With the Visual Studio generator, at least, The SDL and GLEW + # includes coming from GLAppSDL are being converted to system + # includes. To see them in VS, view the whole command line in + # the compile section of the project properties and look at the + # Additional Options pane at the bottom. + # 2. GL_APP_SDL's INTERFACE_INCLUDE_DIRECTORIES includes the SYSTEM + # include from appfwSDL. + # + # I do not understand the reasons for either of these. target_include_directories( ${target} PRIVATE $ - $ + $ $ ) - target_include_directories( - ${target} - SYSTEM PRIVATE - ${PROJECT_SOURCE_DIR}/other_include - ) - set_target_properties(${target} PROPERTIES CXX_VISIBILITY_PRESET ${STATIC_APP_LIB_SYMBOL_VISIBILITY} ) - if(OPENGL_FOUND) - target_include_directories( - ${target} - PRIVATE - ${OPENGL_INCLUDE_DIR} - ) - endif() target_link_libraries( ${target} @@ -54,7 +52,7 @@ function( create_gl_target target version sources common_resources test_images ${KTX_ZLIB_LIBRARIES} ) - if(OPENGL_FOUND AND NOT EMSCRIPTEN AND NOT EMULATE_GLES) + if(NOT EMSCRIPTEN AND NOT EMULATE_GLES) target_link_libraries( ${target} ${OPENGL_LIBRARIES} @@ -145,7 +143,7 @@ function( create_gl_target target version sources common_resources test_images else() target_link_libraries( ${target} - "${CMAKE_SOURCE_DIR}/other_lib/win/Release-x64/glew32.lib" + ${GLEW_LIBRARIES} ) endif() ensure_runtime_dependencies_windows(${target}) diff --git a/tools/ktx/CMakeLists.txt b/tools/ktx/CMakeLists.txt index b24a86587c..0b2dff1880 100644 --- a/tools/ktx/CMakeLists.txt +++ b/tools/ktx/CMakeLists.txt @@ -34,6 +34,7 @@ set_target_properties( ktxtools PROPERTIES OUTPUT_NAME ktx + PDB_NAME ktxtools # Avoid conflict with libktx's .pdb. CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES )