From 862b3fe60914e8860afc6496d8ec614457d42ce2 Mon Sep 17 00:00:00 2001 From: Bob Cao Date: Sat, 31 Dec 2022 00:06:35 -0800 Subject: [PATCH] [ci] Try enabling MSVC and check build times (#6905) Issue: # ### Brief Summary Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/scripts/common-utils.ps1 | 2 +- .github/workflows/scripts/win_build.ps1 | 3 ++- ci/windows/win_build_test.ps1 | 1 + cmake/TaichiCAPI.cmake | 18 ++++++++++++++++++ setup.py | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scripts/common-utils.ps1 b/.github/workflows/scripts/common-utils.ps1 index e8e5dd95556283..44b50b1dd78266 100644 --- a/.github/workflows/scripts/common-utils.ps1 +++ b/.github/workflows/scripts/common-utils.ps1 @@ -71,7 +71,7 @@ function Setup-VS { Info "Setting up Visual Studio" foreach($progRoot in $env:ProgramFiles, ${env:ProgramFiles(x86)}) { $vsBase = Join-Path $progRoot 'Microsoft Visual Studio' - foreach($ver in '2022','2019') { + foreach($ver in '2022') { foreach($edition in 'Enterprise','Professional','Community','BuildTools') { $vsPath = Join-Path $vsBase $ver $edition $clangPath = Join-Path $vsPath "VC\Tools\Llvm\x64\bin\clang.exe" diff --git a/.github/workflows/scripts/win_build.ps1 b/.github/workflows/scripts/win_build.ps1 index b7b652f139ce67..cd1c922013a0ce 100644 --- a/.github/workflows/scripts/win_build.ps1 +++ b/.github/workflows/scripts/win_build.ps1 @@ -69,7 +69,8 @@ if ($llvmVer -eq "10") { throw "Unsupported LLVM version" } -$env:TAICHI_CMAKE_ARGS += " -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang" +$env:TAICHI_USE_MSBUILD = 1 +# $env:TAICHI_CMAKE_ARGS += " -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang" if ($installVulkan) { $env:VULKAN_SDK = "C:\VulkanSDK\1.3.236.0" diff --git a/ci/windows/win_build_test.ps1 b/ci/windows/win_build_test.ps1 index a1d784fbc6abe9..e2704388275e0a 100644 --- a/ci/windows/win_build_test.ps1 +++ b/ci/windows/win_build_test.ps1 @@ -61,6 +61,7 @@ if (!$llvmVer.CompareTo("10")) { $env:LLVM_DIR = "C://taichi_llvm_15" } +$env:TAICHI_USE_MSBUILD = 1 $env:TAICHI_CMAKE_ARGS =' -DCMAKE_CXX_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang++.exe -DCMAKE_C_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang.exe' if (!$llvmVer.CompareTo("10")) { $env:TAICHI_CMAKE_ARGS += " -DCLANG_EXECUTABLE=C:\\taichi_clang\\bin\\clang++.exe" diff --git a/cmake/TaichiCAPI.cmake b/cmake/TaichiCAPI.cmake index dd25ddf7468013..c1015ce7292f53 100644 --- a/cmake/TaichiCAPI.cmake +++ b/cmake/TaichiCAPI.cmake @@ -49,6 +49,8 @@ add_library(${TAICHI_C_API_NAME} SHARED ${C_API_SOURCE}) if (${CMAKE_GENERATOR} STREQUAL "Xcode") target_link_libraries(${TAICHI_C_API_NAME} PRIVATE taichi_core) message(WARNING "Static wrapping does not work on Xcode, using object linking instead.") +elseif (MSVC) + target_link_libraries(${TAICHI_C_API_NAME} PRIVATE taichi_core) else() target_link_static_library(${TAICHI_C_API_NAME} taichi_core) endif() @@ -71,6 +73,22 @@ set_target_properties(${TAICHI_C_API_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${C_API_OUTPUT_DIRECTORY} ARCHIVE_OUTPUT_DIRECTORY ${C_API_OUTPUT_DIRECTORY}) +if (${CMAKE_GENERATOR} MATCHES "^Visual Studio") + # Visual Studio is a multi-config generator, which appends ${CMAKE_BUILD_TYPE} to the output folder + add_custom_command( + TARGET ${TAICHI_C_API_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${C_API_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${TAICHI_C_API_NAME}.dll + ${C_API_OUTPUT_DIRECTORY}/${TAICHI_C_API_NAME}.dll) +elseif (${CMAKE_GENERATOR} STREQUAL "XCode") + # XCode is also a multi-config generator + add_custom_command( + TARGET ${TAICHI_C_API_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${C_API_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/lib${TAICHI_C_API_NAME}.dylib + ${C_API_OUTPUT_DIRECTORY}/lib${TAICHI_C_API_NAME}.dylib) +endif() + target_include_directories(${TAICHI_C_API_NAME} PUBLIC # Used when building the library: diff --git a/setup.py b/setup.py index 12b159d4a5882d..eaef9c9b0b8583 100644 --- a/setup.py +++ b/setup.py @@ -162,7 +162,7 @@ def get_cmake_args(): def cmake_install_manifest_filter(manifest_files): return [ f for f in manifest_files - if f.endswith(('.so', 'pyd', '.bc', '.h', + if f.endswith(('.so', 'pyd', '.dll', '.bc', '.h', '.hpp')) or os.path.basename(f) == 'libMoltenVK.dylib' ]