Skip to content

Commit

Permalink
[ci] Try enabling MSVC and check build times (taichi-dev#6905)
Browse files Browse the repository at this point in the history
Issue: #

### Brief Summary

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and feisuzhu committed Jan 5, 2023
1 parent bdc8c8b commit 862b3fe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scripts/common-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/win_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ci/windows/win_build_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 18 additions & 0 deletions cmake/TaichiCAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand Down

0 comments on commit 862b3fe

Please sign in to comment.