Skip to content

Commit

Permalink
[rust] fix a crash bug at plugin initialization on win32 (#86)
Browse files Browse the repository at this point in the history
* [rust] fix a crash bug at plugin initialization on win32

This bug causes in termcolor crate via env_logger crate due to stderr
is not present when console is not present. To resolve this, add
checking stderr is present using atty crate.

* [rust] bump all dependencies of plugin_wasm

* [rust] fix clippy warning

* [cmake] add NANOEM_ENABLE_PLUGIN_WASM option
  • Loading branch information
hkrn authored Oct 24, 2021
1 parent 45e3e7b commit 65b9d1d
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 139 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ option(NANOEM_ENABLE_TEST "Enable building unit test option." OFF)
option(NANOEM_ENABLE_TSAN "Enable clang/gcc TSan (thread sanitizer) option." OFF)
option(NANOEM_ENABLE_UBSAN "Enable clang/gcc UBSan (undefined behavior sanitizer) option." OFF)
option(NANOEM_ENABLE_UPDATE_CREDITS "Enable updating credits per cmake execution." OFF)
option(NANOEM_ENABLE_PLUGIN_WASM "Enable bundling release build of plugin_wasm" OFF)
option(NANOEM_MINIMAL "Builds nanoem library only." OFF)
option(SOKOL_ENABLE_DEBUG "Enable building sokol with debug validation layer." OFF)

Expand Down Expand Up @@ -350,6 +351,30 @@ set(NANOEM_SENTRY_AUTH_TOKEN "" CACHE STRING "Sentry authentication token")
set(NANOEM_GA_TRACKING_ID "" CACHE STRING "Google Analytics Tracking ID")
mark_as_advanced(NANOEM_SENTRY_DSN NANOEM_SENTRY_ORGANIZATION NANOEM_SENTRY_PROJECT NANOEM_SENTRY_AUTH_TOKEN NANOEM_GA_TRACKING_ID)

if(NANOEM_ENABLE_PLUGIN_WASM)
if(WIN32)
set(_plugin_wasm_filename_src "plugin_wasm.dll")
set(_plugin_wasm_filename_dst "plugin_wasm.dll")
elseif(APPLE)
set(_plugin_wasm_filename_src "libplugin_wasm.dylib")
set(_plugin_wasm_filename_dst "plugin_wasm.dylib")
else()
set(_plugin_wasm_filename_src "libplugin_wasm.so")
set(_plugin_wasm_filename_dst "plugin_wasm.so")
endif()
set(PLUGIN_WASM_PATH "${PROJECT_SOURCE_DIR}/rust/target/release/${_plugin_wasm_filename_src}")
set(_output_path "${CMAKE_CURRENT_BINARY_DIR}/intermediate/${_plugin_wasm_filename_dst}")
add_custom_command(OUTPUT ${_output_path}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${PLUGIN_WASM_PATH} ${_output_path}
DEPENDS ${_output_path})
add_custom_target(plugin_wasm_copy SOURCES ${_output_path})
set_property(TARGET plugin_wasm_copy PROPERTY FOLDER plugins/touch)
add_library(plugin_wasm SHARED IMPORTED GLOBAL)
add_dependencies(plugin_wasm plugin_wasm_copy)
set_target_properties(plugin_wasm PROPERTIES IMPORTED_LOCATION ${_output_path})
list(APPEND _plugins plugin_wasm)
endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/docs)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/nanoem)
if(NOT NANOEM_MINIMAL)
Expand Down
2 changes: 1 addition & 1 deletion macos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if(NANOEM_ENABLE_STATIC_BUNDLE_PLUGIN)
endif()
else()
foreach(_item ${_plugins})
set(touch_file "${CMAKE_CURRENT_BINARY_DIR}/${_item}.touch")
set(touch_file "${CMAKE_CURRENT_BINARY_DIR}/intermediate/${_item}.touch")
add_custom_command(OUTPUT ${touch_file}
COMMAND ${CMAKE_COMMAND} ARGS -E touch ${touch_file}
COMMAND ${CMAKE_COMMAND} ARGS -E touch ${CMAKE_CURRENT_SOURCE_DIR}/main.mm
Expand Down
Loading

0 comments on commit 65b9d1d

Please sign in to comment.