From 05fcff6020096c310b4f415a22ca6cf2d349e10e Mon Sep 17 00:00:00 2001 From: "hkrn (a.k.a shimacpyon)" <129939+hkrn@users.noreply.github.com> Date: Fri, 21 Jan 2022 23:31:13 +0900 Subject: [PATCH] [win32] add vs2022 build helper scripts + ASAN (#99) * [win32] add vs2022 build helper scripts * [win32] simplify ASAN detection on MSVC * [cmake] add ASAN_OPTIONS for bin2c not to be crashed by ASAN --- CMakeLists.txt | 12 ++++-------- emapp/resources/fonts/CMakeLists.txt | 6 ++++-- emapp/resources/toons/CMakeLists.txt | 3 ++- ...build-vs2019-arm64.ps1 => build-vs2022-arm64.ps1} | 5 +++-- scripts/run/windows/build-vs2022.ps1 | 8 ++++++++ 5 files changed, 21 insertions(+), 13 deletions(-) rename scripts/run/windows/{build-vs2019-arm64.ps1 => build-vs2022-arm64.ps1} (64%) create mode 100644 scripts/run/windows/build-vs2022.ps1 diff --git a/CMakeLists.txt b/CMakeLists.txt index fffb0599..dc55e096 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ if(MSVC) elseif(${MSVC_VERSION} GREATER_EQUAL 1800) set(NANOEM_TARGET_COMPILER "vs2013" CACHE STRING "Target architecture to build nanoem") endif() - set_property(CACHE NANOEM_TARGET_COMPILER PROPERTY STRINGS "clang;vs2019;vs2017;vs2015;vs2013") + set_property(CACHE NANOEM_TARGET_COMPILER PROPERTY STRINGS "clang;vs2022;vs2019;vs2017;vs2015;vs2013") else() if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") set(NANOEM_TARGET_COMPILER "clang" CACHE STRING "Target architecture to build nanoem") @@ -166,13 +166,9 @@ function(nanoem_cmake_bootstrap _project_name_prefix _build_type) set(${_project_name_prefix} NANOEM PARENT_SCOPE) if(NANOEM_ENABLE_ASAN) if(MSVC) - find_library(ASAN_LIBRARY_DLL_CRT clang_rt.asan_dll_thunk-${NANOEM_TARGET_ARCHITECTURE}) - find_library(ASAN_LIBRARY_EXE_CXX_CRT clang_rt.asan_cxx-${NANOEM_TARGET_ARCHITECTURE}) - set(CMAKE_C_FLAGS_ASAN "-fsanitize=address" CACHE STRING "Flags used by the C compiler during ASan builds." FORCE) - set(CMAKE_CXX_FLAGS_ASAN "-fsanitize=address" CACHE STRING "Flags used by the C++ compiler during ASan builds." FORCE) - set(CMAKE_EXE_LINKER_FLAGS_ASAN "-incremental:no /wholearchive:\"${ASAN_LIBRARY_EXE_CXX_CRT}\"" CACHE STRING "") - set(CMAKE_SHARED_LINKER_FLAGS_ASAN "-incremental:no /wholearchive:\"${ASAN_LIBRARY_DLL_CRT}\"" CACHE STRING "") - mark_as_advanced(ASAN_LIBRARY_DLL_CRT ASAN_LIBRARY_EXE_CXX_CRT CMAKE_C_FLAGS_ASAN CMAKE_CXX_FLAGS_ASAN CMAKE_EXE_LINKER_FLAGS_ASAN CMAKE_STATIC_LINKER_FLAGS_ASAN CMAKE_SHARED_LINKER_FLAGS_ASAN) + set(CMAKE_C_FLAGS_ASAN "/fsanitize=address" CACHE STRING "Flags used by the C compiler during ASan builds." FORCE) + set(CMAKE_CXX_FLAGS_ASAN "/fsanitize=address" CACHE STRING "Flags used by the C++ compiler during ASan builds." FORCE) + mark_as_advanced(CMAKE_C_FLAGS_ASAN CMAKE_CXX_FLAGS_ASAN) else() find_package(ASan) endif() diff --git a/emapp/resources/fonts/CMakeLists.txt b/emapp/resources/fonts/CMakeLists.txt index 17d0fa6f..d1d61fe3 100644 --- a/emapp/resources/fonts/CMakeLists.txt +++ b/emapp/resources/fonts/CMakeLists.txt @@ -4,13 +4,15 @@ function(nanoem_emapp_build_emarb_font) # font_awesome (v4.7) add_custom_command(OUTPUT ${output_path_prefix}/font_awesome.h COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/font_awesome.ttf ${intermediate_path_prefix}/font_awesome.ttf - COMMAND $ --input=${intermediate_path_prefix}/font_awesome.ttf --symbol=font_awesome_ttf --compressed=true + COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0" + $ --input=${intermediate_path_prefix}/font_awesome.ttf --symbol=font_awesome_ttf --compressed=true > ${output_path_prefix}/font_awesome.h MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/font_awesome.ttf) # genei_gothic_p_semi_bold (v1.1) add_custom_command(OUTPUT ${output_path_prefix}/genei_gothic_p_semi_bold.h COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/genei_gothic_p_semi_bold.otf ${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf - COMMAND $ --input=${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf --symbol=genei_gothic_p_semi_bold_otf --compressed=true + COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0" + $ --input=${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf --symbol=genei_gothic_p_semi_bold_otf --compressed=true > ${output_path_prefix}/genei_gothic_p_semi_bold.h MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/genei_gothic_p_semi_bold.otf) add_custom_target(emarb_fonts DEPENDS ${output_path_prefix}/font_awesome.h ${output_path_prefix}/genei_gothic_p_semi_bold.h) diff --git a/emapp/resources/toons/CMakeLists.txt b/emapp/resources/toons/CMakeLists.txt index 5dce6a3d..ebc44881 100644 --- a/emapp/resources/toons/CMakeLists.txt +++ b/emapp/resources/toons/CMakeLists.txt @@ -8,7 +8,8 @@ function(nanoem_emapp_build_emarb_toon) add_custom_command(OUTPUT ${output_path_prefix}/${_name}.h COMMAND ${CMAKE_COMMAND} -E make_directory ${output_path_prefix} COMMAND ${CMAKE_COMMAND} ARGS -E copy ${_item} ${intermediate_path_prefix}/${_filename} - COMMAND $ --input=${intermediate_path_prefix}/${_filename} --symbol=${_name} --compressed=false + COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0" + $ --input=${intermediate_path_prefix}/${_filename} --symbol=${_name} --compressed=false > ${output_path_prefix}/${_name}.h MAIN_DEPENDENCY ${_item}) list(APPEND _sources ${output_path_prefix}/${_name}.h) diff --git a/scripts/run/windows/build-vs2019-arm64.ps1 b/scripts/run/windows/build-vs2022-arm64.ps1 similarity index 64% rename from scripts/run/windows/build-vs2019-arm64.ps1 rename to scripts/run/windows/build-vs2022-arm64.ps1 index 6223e35d..dcf9a40f 100644 --- a/scripts/run/windows/build-vs2019-arm64.ps1 +++ b/scripts/run/windows/build-vs2022-arm64.ps1 @@ -1,9 +1,10 @@ # Set-ExecutionPolicy RemoteSigned -Scope Process $env:NANOEM_DISABLE_BUILD_SENTRY_NATIVE=1 +$env:NANOEM_DISABLE_BUILD_TBB=1 $env:NANOEM_TARGET_ARCHITECTURES="arm64" -$env:NANOEM_TARGET_COMPILER="vs2019" -$env:NANOEM_TARGET_GENERATOR="Visual Studio 16 2019" +$env:NANOEM_TARGET_COMPILER="vs2022" +$env:NANOEM_TARGET_GENERATOR="Visual Studio 17 2022" $build_cmake_path = (Join-Path $PSScriptRoot ../../build.cmake) cmake -P $build_cmake_path diff --git a/scripts/run/windows/build-vs2022.ps1 b/scripts/run/windows/build-vs2022.ps1 new file mode 100644 index 00000000..49a918e1 --- /dev/null +++ b/scripts/run/windows/build-vs2022.ps1 @@ -0,0 +1,8 @@ +# Set-ExecutionPolicy RemoteSigned -Scope Process + +$env:NANOEM_TARGET_ARCHITECTURES="x86_64" +$env:NANOEM_TARGET_COMPILER="vs2022" +$env:NANOEM_TARGET_GENERATOR="Visual Studio 17 2022" +$build_cmake_path = (Join-Path $PSScriptRoot ../../build.cmake) + +cmake -P $build_cmake_path