Speed up CI by using ninja and parallel build (#1347)

* chore(CI): speed up CI by using ninja and parallel build

* chore(CI): align compiler for c and cxx

* fix(samples): add dependency to generator

* fix(cmake): get rid of file glob

* chore(CI): use clang on mac

glfw don't support gcc on mac

* fix(sample): add depencency on build_vulkan_hpp

* fix(cmake): make sure every target in tests and samples link to utils
This commit is contained in:
Jinesi Yelizati 2022-07-07 16:22:21 +08:00 committed by GitHub
parent 193c8e4628
commit 9748e47228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 194 additions and 67 deletions

View File

@ -9,7 +9,9 @@ jobs:
strategy:
matrix:
build_type: [Debug, Release]
cxx_compiler: [g++-11, clang++]
compiler:
- {cxx: "g++-11", c: "clang"}
- {cxx: "clang++", c: "clang"}
cxx_standard: [11, 14, 17, 20]
steps:
@ -21,9 +23,14 @@ jobs:
- name: Update Submodules
run: git submodule update --init --recursive
- name: Install Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.11.0
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build
run: cmake -B ${{github.workspace}}/build -GNinja
-DSAMPLES_BUILD=ON
-DSAMPLES_BUILD_ONLY_DYNAMIC=ON
-DSAMPLES_BUILD_WITH_LOCAL_VULKAN_HPP=ON
@ -31,8 +38,10 @@ jobs:
-DTESTS_BUILD_ONLY_DYNAMIC=ON
-DTESTS_BUILD_WITH_LOCAL_VULKAN_HPP=ON
-DVULKAN_HPP_RUN_GENERATOR=ON
-DCMAKE_CXX_COMPILER=${{matrix.cxx_compiler}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}}
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
run: cmake --build ${{github.workspace}}/build --parallel

View File

@ -12,7 +12,12 @@ jobs:
strategy:
matrix:
build_type: [Debug, Release]
cxx_compiler: [g++-9, g++-10, clang++-10, clang++-11, clang++-12]
compiler:
- {cxx: "g++-9", c: "gcc-9"}
- {cxx: "g++-10", c: "gcc-10"}
- {cxx: "clang++-10", c: "clang-10"}
- {cxx: "clang++-11", c: "clang-11"}
- {cxx: "clang++-12", c: "clang-12"}
cxx_standard: [11, 14, 17, 20]
steps:
@ -23,9 +28,14 @@ jobs:
- name: Update Submodules
run: git submodule update --init --recursive
- name: Install Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.11.0
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build
run: cmake -B ${{github.workspace}}/build -GNinja
-DSAMPLES_BUILD=ON
-DSAMPLES_BUILD_ONLY_DYNAMIC=ON
-DSAMPLES_BUILD_WITH_LOCAL_VULKAN_HPP=ON
@ -33,8 +43,10 @@ jobs:
-DTESTS_BUILD_ONLY_DYNAMIC=ON
-DTESTS_BUILD_WITH_LOCAL_VULKAN_HPP=ON
-DVULKAN_HPP_RUN_GENERATOR=ON
-DCMAKE_CXX_COMPILER=${{matrix.cxx_compiler}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}}
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
run: cmake --build ${{github.workspace}}/build --parallel

View File

@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, windows-2019]
architecture: [Win32, x64]
architecture: [x86, x64]
build_type: [Debug, Release]
cxx_standard: [11, 14, 17, 20]
steps:
@ -20,10 +20,19 @@ jobs:
- name: Update Submodules
run: git submodule update --init --recursive
- name: Install Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.11.0
- name: Setup MSVC
uses: TheMrMilchmann/setup-msvc-dev@v1
with:
arch: ${{matrix.architecture}}
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build
-A ${{matrix.architecture}}
run: cmake -B ${{github.workspace}}/build -GNinja
-DSAMPLES_BUILD=ON
-DSAMPLES_BUILD_ONLY_DYNAMIC=ON
-DSAMPLES_BUILD_WITH_LOCAL_VULKAN_HPP=ON
@ -32,6 +41,7 @@ jobs:
-DTESTS_BUILD_WITH_LOCAL_VULKAN_HPP=ON
-DVULKAN_HPP_RUN_GENERATOR=ON
-DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}}
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
run: cmake --build ${{github.workspace}}/build --parallel

View File

@ -66,7 +66,7 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message("CMAKE_CXX_STANDARD = <${CMAKE_CXX_STANDARD}>")
message(STATUS "CMAKE_CXX_STANDARD = <${CMAKE_CXX_STANDARD}>")
if (NOT DEFINED VulkanRegistry_DIR)
if (DEFINED VULKAN_HPP_VULKAN_HEADERS_SRC_DIR)

View File

@ -39,8 +39,6 @@ else()
message(FATAL_ERROR, "Vulkan-Hpp: unhandled platform for samples!")
endif()
FILE (GLOB linkunits ${CMAKE_CURRENT_SOURCE_DIR}/*)
if (SAMPLES_BUILD_WITH_LOCAL_VULKAN_HPP)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../Vulkan-Headers/include")
@ -48,11 +46,54 @@ else()
include_directories("${Vulkan_INCLUDE_DIRS}")
endif()
FOREACH( linkunit ${linkunits} )
if( IS_DIRECTORY ${linkunit} )
if( EXISTS ${linkunit}/CMakeLists.txt )
string( REGEX REPLACE "^.*/([^/]*)$" "\\1" LINK_NAME ${linkunit} )
add_subdirectory( ${LINK_NAME} )
endif()
endif()
ENDFOREACH( linkunit ${linkunits} )
add_subdirectory(utils)
add_subdirectory(01_InitInstance)
add_subdirectory(02_EnumerateDevices)
add_subdirectory(03_InitDevice)
add_subdirectory(04_InitCommandBuffer)
add_subdirectory(05_InitSwapchain)
add_subdirectory(06_InitDepthBuffer)
add_subdirectory(07_InitUniformBuffer)
add_subdirectory(08_InitPipelineLayout)
add_subdirectory(09_InitDescriptorSet)
add_subdirectory(10_InitRenderPass)
add_subdirectory(11_InitShaders)
add_subdirectory(12_InitFrameBuffers)
add_subdirectory(13_InitVertexBuffer)
add_subdirectory(14_InitPipeline)
add_subdirectory(15_DrawCube)
add_subdirectory(16_Vulkan_1_1)
add_subdirectory(CopyBlitImage)
add_subdirectory(CreateDebugUtilsMessenger)
add_subdirectory(DebugUtilsObjectName)
add_subdirectory(DrawTexturedCube)
add_subdirectory(DynamicUniform)
add_subdirectory(EnableValidationWithCallback)
add_subdirectory(EnumerateDevicesAdvanced)
add_subdirectory(Events)
add_subdirectory(ImmutableSampler)
add_subdirectory(InitTexture)
add_subdirectory(InputAttachment)
add_subdirectory(InstanceExtensionProperties)
add_subdirectory(InstanceLayerExtensionProperties)
add_subdirectory(InstanceLayerProperties)
add_subdirectory(InstanceVersion)
add_subdirectory(MultipleSets)
add_subdirectory(OcclusionQuery)
add_subdirectory(PhysicalDeviceExtensions)
add_subdirectory(PhysicalDeviceFeatures)
add_subdirectory(PhysicalDeviceGroups)
add_subdirectory(PhysicalDeviceMemoryProperties)
add_subdirectory(PhysicalDeviceProperties)
add_subdirectory(PhysicalDeviceQueueFamilyProperties)
add_subdirectory(PipelineCache)
add_subdirectory(PipelineDerivative)
add_subdirectory(PushConstants)
add_subdirectory(PushDescriptors)
add_subdirectory(RayTracing)
add_subdirectory(SecondaryCommandBuffer)
add_subdirectory(SeparateImageSampler)
add_subdirectory(SurfaceCapabilities)
add_subdirectory(SurfaceFormats)
add_subdirectory(Template)
add_subdirectory(TexelBuffer)

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(01_InitInstance PROPERTIES FOLDER "Samples")
target_link_libraries(01_InitInstance "${Vulkan_LIBRARIES}")
target_link_libraries(01_InitInstance PRIVATE utils)
endif()

View File

@ -39,8 +39,6 @@ else()
message(FATAL_ERROR, "Vulkan-Hpp: unhandled platform for samples!")
endif()
FILE (GLOB linkunits ${CMAKE_CURRENT_SOURCE_DIR}/*)
if (SAMPLES_BUILD_WITH_LOCAL_VULKAN_HPP)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../Vulkan-Headers/include")
@ -48,11 +46,54 @@ else()
include_directories("${Vulkan_INCLUDE_DIRS}")
endif()
FOREACH( linkunit ${linkunits} )
if( IS_DIRECTORY ${linkunit} )
if( EXISTS ${linkunit}/CMakeLists.txt )
string( REGEX REPLACE "^.*/([^/]*)$" "\\1" LINK_NAME ${linkunit} )
add_subdirectory( ${LINK_NAME} )
endif()
endif()
ENDFOREACH( linkunit ${linkunits} )
add_subdirectory(utils)
add_subdirectory(01_InitInstance)
add_subdirectory(02_EnumerateDevices)
add_subdirectory(03_InitDevice)
add_subdirectory(04_InitCommandBuffer)
add_subdirectory(05_InitSwapchain)
add_subdirectory(06_InitDepthBuffer)
add_subdirectory(07_InitUniformBuffer)
add_subdirectory(08_InitPipelineLayout)
add_subdirectory(09_InitDescriptorSet)
add_subdirectory(10_InitRenderPass)
add_subdirectory(11_InitShaders)
add_subdirectory(12_InitFrameBuffers)
add_subdirectory(13_InitVertexBuffer)
add_subdirectory(14_InitPipeline)
add_subdirectory(15_DrawCube)
add_subdirectory(16_Vulkan_1_1)
add_subdirectory(CopyBlitImage)
add_subdirectory(CreateDebugUtilsMessenger)
add_subdirectory(DebugUtilsObjectName)
add_subdirectory(DrawTexturedCube)
add_subdirectory(DynamicUniform)
add_subdirectory(EnableValidationWithCallback)
add_subdirectory(EnumerateDevicesAdvanced)
add_subdirectory(Events)
add_subdirectory(ImmutableSampler)
add_subdirectory(InitTexture)
add_subdirectory(InputAttachment)
add_subdirectory(InstanceExtensionProperties)
add_subdirectory(InstanceLayerExtensionProperties)
add_subdirectory(InstanceLayerProperties)
add_subdirectory(InstanceVersion)
add_subdirectory(MultipleSets)
add_subdirectory(OcclusionQuery)
add_subdirectory(PhysicalDeviceExtensions)
add_subdirectory(PhysicalDeviceFeatures)
add_subdirectory(PhysicalDeviceGroups)
add_subdirectory(PhysicalDeviceMemoryProperties)
add_subdirectory(PhysicalDeviceProperties)
add_subdirectory(PhysicalDeviceQueueFamilyProperties)
add_subdirectory(PipelineCache)
add_subdirectory(PipelineDerivative)
add_subdirectory(PushConstants)
add_subdirectory(PushDescriptors)
add_subdirectory(RayTracing)
add_subdirectory(SecondaryCommandBuffer)
add_subdirectory(SeparateImageSampler)
add_subdirectory(SurfaceCapabilities)
add_subdirectory(SurfaceFormats)
add_subdirectory(Template)
add_subdirectory(TexelBuffer)

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(CreateDebugUtilsMessenger PROPERTIES FOLDER "Samples")
target_link_libraries(CreateDebugUtilsMessenger "${Vulkan_LIBRARIES}")
target_link_libraries(CreateDebugUtilsMessenger PRIVATE utils)
endif()

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(InstanceExtensionProperties PROPERTIES FOLDER "Samples")
target_link_libraries(InstanceExtensionProperties "${Vulkan_LIBRARIES}")
target_link_libraries(InstanceExtensionProperties PRIVATE utils)
endif()

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(InstanceLayerExtensionProperties PROPERTIES FOLDER "Samples")
target_link_libraries(InstanceLayerExtensionProperties "${Vulkan_LIBRARIES}")
target_link_libraries(InstanceLayerExtensionProperties PRIVATE utils)
endif()

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(InstanceLayerProperties PROPERTIES FOLDER "Samples")
target_link_libraries(InstanceLayerProperties "${Vulkan_LIBRARIES}")
target_link_libraries(InstanceLayerProperties PRIVATE utils)
endif()

View File

@ -34,6 +34,6 @@ if(NOT SAMPLES_BUILD_ONLY_DYNAMIC)
)
set_target_properties(InstanceVersion PROPERTIES FOLDER "Samples")
target_link_libraries(InstanceVersion "${Vulkan_LIBRARIES}")
target_link_libraries(InstanceVersion PRIVATE utils)
endif()

View File

@ -36,6 +36,10 @@ add_library(utils
${HEADERS}
)
if (VULKAN_HPP_RUN_GENERATOR)
add_dependencies(utils build_vulkan_hpp)
endif()
target_link_libraries(utils PUBLIC glm)
target_link_libraries(utils PUBLIC glfw)
target_link_libraries(utils PUBLIC glslang)

View File

@ -33,5 +33,5 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
set_target_properties(ArrayProxy PROPERTIES FOLDER "Tests")
target_link_libraries(ArrayProxy "${Vulkan_LIBRARIES}")
target_link_libraries(ArrayProxy PRIVATE utils)
endif()

View File

@ -33,5 +33,5 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
set_target_properties(ArrayProxyNoTemporaries PROPERTIES FOLDER "Tests")
target_link_libraries(ArrayProxyNoTemporaries "${Vulkan_LIBRARIES}")
target_link_libraries(ArrayProxyNoTemporaries PRIVATE utils)
endif()

View File

@ -38,8 +38,6 @@ elseif(UNIX)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
endif()
FILE (GLOB linkunits ${CMAKE_CURRENT_SOURCE_DIR}/*)
if (TESTS_BUILD_WITH_LOCAL_VULKAN_HPP)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../Vulkan-Headers/include")
@ -49,11 +47,17 @@ endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../glm")
FOREACH( linkunit ${linkunits} )
if( IS_DIRECTORY ${linkunit} )
if( EXISTS ${linkunit}/CMakeLists.txt )
string( REGEX REPLACE "^.*/([^/]*)$" "\\1" LINK_NAME ${linkunit} )
add_subdirectory( ${LINK_NAME} )
endif()
endif()
ENDFOREACH( linkunit ${linkunits} )
add_subdirectory(ArrayProxy)
add_subdirectory(ArrayProxyNoTemporaries)
add_subdirectory(DesignatedInitializers)
add_subdirectory(DeviceFunctions)
add_subdirectory(DispatchLoaderDynamic)
add_subdirectory(DispatchLoaderDynamicSharedLibrary)
add_subdirectory(DispatchLoaderDynamicSharedLibraryClient)
add_subdirectory(DispatchLoaderStatic)
add_subdirectory(FormatTraits)
add_subdirectory(Hash)
add_subdirectory(NoExceptions)
add_subdirectory(StructureChain)
add_subdirectory(UniqueHandle)
add_subdirectory(UniqueHandleDefaultArguments)

View File

@ -35,5 +35,5 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
set_target_properties(DesignatedInitializers PROPERTIES FOLDER "Tests")
target_link_libraries(DesignatedInitializers "${Vulkan_LIBRARIES}")
target_link_libraries(DesignatedInitializers PRIVATE utils)
endif()

View File

@ -33,5 +33,5 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
set_target_properties(DeviceFunctions PROPERTIES FOLDER "Tests")
target_link_libraries(DeviceFunctions "${Vulkan_LIBRARIES}")
target_link_libraries(DeviceFunctions PRIVATE utils)
endif()

View File

@ -32,7 +32,8 @@ add_executable(DispatchLoaderDynamic
)
if (UNIX)
target_link_libraries(DispatchLoaderDynamic "-ldl")
target_link_libraries(DispatchLoaderDynamic PRIVATE ${CMAKE_DL_LIBS})
endif()
set_target_properties(DispatchLoaderDynamic PROPERTIES FOLDER "Tests")
target_link_libraries(DispatchLoaderDynamic PRIVATE utils)

View File

@ -34,7 +34,8 @@ add_library(DispatchLoaderDynamicSharedLibrary SHARED
target_compile_definitions(DispatchLoaderDynamicSharedLibrary PRIVATE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_STORAGE_SHARED VULKAN_HPP_STORAGE_SHARED_EXPORT )
if (UNIX)
target_link_libraries(DispatchLoaderDynamicSharedLibrary "-ldl")
target_link_libraries(DispatchLoaderDynamicSharedLibrary PRIVATE ${CMAKE_DL_LIBS})
endif()
set_target_properties(DispatchLoaderDynamicSharedLibrary PROPERTIES FOLDER "Tests")
target_link_libraries(DispatchLoaderDynamicSharedLibrary PRIVATE utils)

View File

@ -33,10 +33,11 @@ add_executable(DispatchLoaderDynamicSharedLibraryClient
target_compile_definitions(DispatchLoaderDynamicSharedLibraryClient PRIVATE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_STORAGE_SHARED)
target_link_libraries(DispatchLoaderDynamicSharedLibraryClient DispatchLoaderDynamicSharedLibrary)
target_link_libraries(DispatchLoaderDynamicSharedLibraryClient PRIVATE DispatchLoaderDynamicSharedLibrary)
if (UNIX)
target_link_libraries(DispatchLoaderDynamicSharedLibraryClient "-ldl")
target_link_libraries(DispatchLoaderDynamicSharedLibraryClient PRIVATE ${CMAKE_DL_LIBS})
endif()
set_target_properties(DispatchLoaderDynamicSharedLibraryClient PROPERTIES FOLDER "Tests")
target_link_libraries(DispatchLoaderDynamicSharedLibraryClient PRIVATE utils)

View File

@ -34,11 +34,10 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
if (UNIX)
target_link_libraries(DispatchLoaderStatic "-ldl")
target_link_libraries(DispatchLoaderStatic PRIVATE ${CMAKE_DL_LIBS})
endif()
target_link_libraries(DispatchLoaderStatic "${Vulkan_LIBRARIES}")
set_target_properties(DispatchLoaderStatic PROPERTIES FOLDER "Tests")
target_link_libraries(DispatchLoaderStatic PRIVATE utils)
endif()

View File

@ -32,4 +32,4 @@ add_executable(FormatTraits
)
set_target_properties(FormatTraits PROPERTIES FOLDER "Tests")
target_link_libraries(FormatTraits "${Vulkan_LIBRARIES}")
target_link_libraries(FormatTraits PRIVATE utils)

View File

@ -33,5 +33,5 @@ if (NOT TESTS_BUILD_ONLY_DYNAMIC)
)
set_target_properties(Hash PROPERTIES FOLDER "Tests")
target_link_libraries(Hash "${Vulkan_LIBRARIES}")
target_link_libraries(Hash PRIVATE utils)
endif()

View File

@ -30,7 +30,9 @@ add_executable(NoExceptions
${HEADERS}
${SOURCES}
)
target_link_libraries(NoExceptions ${CMAKE_DL_LIBS})
if (UNIX)
target_link_libraries(NoExceptions PRIVATE ${CMAKE_DL_LIBS})
endif ()
set_target_properties(NoExceptions PROPERTIES FOLDER "Tests")
target_link_libraries(NoExceptions PRIVATE utils)

View File

@ -32,7 +32,8 @@ add_executable(StructureChain
)
if (UNIX)
target_link_libraries(StructureChain "-ldl")
target_link_libraries(StructureChain PRIVATE ${CMAKE_DL_LIBS})
endif()
set_target_properties(StructureChain PROPERTIES FOLDER "Tests")
target_link_libraries(StructureChain PRIVATE utils)

View File

@ -32,7 +32,8 @@ add_library(UniqueHandleDefaultArguments
)
if (UNIX)
target_link_libraries(UniqueHandleDefaultArguments "-ldl")
target_link_libraries(UniqueHandleDefaultArguments PRIVATE ${CMAKE_DL_LIBS})
endif()
set_target_properties(UniqueHandleDefaultArguments PROPERTIES FOLDER "Tests")
target_link_libraries(UniqueHandleDefaultArguments PRIVATE utils)