From 7ebf635ed69de90ad99b28c3c94e84df77e7a55c Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Fri, 6 May 2022 18:05:44 +0800 Subject: [PATCH 1/6] Fix Win32 API calls for non-unicode builds --- taichi/gui/win32.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/taichi/gui/win32.cpp b/taichi/gui/win32.cpp index b7fa7fa6b6696..77809e74f8dc8 100644 --- a/taichi/gui/win32.cpp +++ b/taichi/gui/win32.cpp @@ -153,7 +153,7 @@ void GUI::process_event() { } void GUI::create_window() { - auto CLASS_NAME = L"Taichi Win32 Window"; + const char* CLASS_NAME = "Taichi Win32 Window"; DWORD dwVersion = 0; DWORD dwMajorVersion = 0; @@ -164,13 +164,13 @@ void GUI::create_window() { dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); - WNDCLASS wc = {}; + WNDCLASSA wc = {}; wc.lpfnWndProc = WindowProc; - wc.hInstance = GetModuleHandle(0); + wc.hInstance = GetModuleHandleA(0); wc.lpszClassName = CLASS_NAME; - RegisterClass(&wc); + RegisterClassA(&wc); RECT window_rect; window_rect.left = 0; @@ -180,10 +180,9 @@ void GUI::create_window() { AdjustWindowRect(&window_rect, WS_OVERLAPPEDWINDOW, false); - hwnd = CreateWindowEx(0, // Optional window styles. + hwnd = CreateWindowExA(0, // Optional window styles. CLASS_NAME, // Window class - std::wstring(window_name.begin(), window_name.end()) - .data(), // Window text + window_name.c_str(), // Window text WS_OVERLAPPEDWINDOW, // Window style // Size and position CW_USEDEFAULT, CW_USEDEFAULT, @@ -191,7 +190,7 @@ void GUI::create_window() { window_rect.bottom - window_rect.top, NULL, // Parent window NULL, // Menu - GetModuleHandle(0), // Instance handle + GetModuleHandleA(0), // Instance handle NULL // Additional application data ); TI_ERROR_IF(hwnd == NULL, "Window creation failed"); @@ -201,7 +200,7 @@ void GUI::create_window() { // https://www.cnblogs.com/lidabo/archive/2012/07/17/2595452.html LONG style = GetWindowLong(hwnd, GWL_STYLE); style &= ~WS_CAPTION & ~WS_SIZEBOX; - SetWindowLong(hwnd, GWL_STYLE, style); + SetWindowLongA(hwnd, GWL_STYLE, style); SetWindowPos(hwnd, NULL, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_NOZORDER); } @@ -235,7 +234,7 @@ void GUI::redraw() { } void GUI::set_title(std::string title) { - SetWindowText(hwnd, std::wstring(title.begin(), title.end()).data()); + SetWindowTextA(hwnd, title.c_str()); } GUI::~GUI() { From 179f903ee32eae09ec761a331d25c4c6e9681cdc Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Fri, 6 May 2022 19:48:46 +0800 Subject: [PATCH 2/6] Fix variable names when NDK clang is used in prior --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d12963aee94b7..494535cb4187c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,11 +139,11 @@ if (${CLANG_VERSION_MAJOR} VERSION_GREATER ${CLANG_HIGHEST_VERSION}) unset(CLANG_EXECUTABLE) find_program(CLANG_EXECUTABLE NAMES clang-10 clang-11 clang-9 clang-8 clang-7) if (NOT CLANG_EXECUTABLE) - message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Condider passing -DCLANG_PATH=/path/to/clang to cmake to use a specific clang.") + message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Consider passing -DCLANG_EXECUTABLE=/path/to/clang to cmake to use a specific clang.") else() check_clang_version() if (${CLANG_VERSION_MAJOR} VERSION_GREATER ${CLANG_HIGHEST_VERSION}) - message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Condider passing -DCLANG_PATH=/path/to/clang to cmake to use a specific clang.") + message(FATAL_ERROR "${CLANG_EXECUTABLE} version: ${CLANG_VERSION}, required: <=${CLANG_HIGHEST_VERSION}. Consider passing -DCLANG_EXECUTABLE=/path/to/clang to cmake to use a specific clang.") endif() endif() endif() From 8ff48c188bddc85c1684fc1a238972151239ce06 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Sat, 7 May 2022 10:27:12 +0800 Subject: [PATCH 3/6] Fixed output directory retargeting --- cmake/TaichiExportCore.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/TaichiExportCore.cmake b/cmake/TaichiExportCore.cmake index b4f646fb92e2b..baf0f52589375 100644 --- a/cmake/TaichiExportCore.cmake +++ b/cmake/TaichiExportCore.cmake @@ -5,4 +5,5 @@ set(TAICHI_EXPORT_CORE_NAME taichi_export_core) add_library(${TAICHI_EXPORT_CORE_NAME} SHARED) target_link_libraries(${TAICHI_EXPORT_CORE_NAME} PRIVATE taichi_isolated_core) set_target_properties(${TAICHI_EXPORT_CORE_NAME} PROPERTIES - CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build") + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build") From 69e0a6a4eaf5536574e035a08aabfbc360b6770b Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Sat, 7 May 2022 10:28:28 +0800 Subject: [PATCH 4/6] Added CMake option for export core (as a hint) --- cmake/TaichiCore.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index 1a41bc2020552..ca9f91cf81608 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -8,6 +8,7 @@ option(TI_WITH_CC "Build with the C backend" ON) option(TI_WITH_VULKAN "Build with the Vulkan backend" OFF) option(TI_WITH_DX11 "Build with the DX11 backend" OFF) option(TI_EMSCRIPTENED "Build using emscripten" OFF) +option(TI_EXPORT_CORE "Export Taichi core library for AOT runtime" OFF) # Force symbols to be 'hidden' by default so nothing is exported from the Taichi # library including the third-party dependencies. From bc70fd3262901d21ee9b94ec4b797c61d2da5c48 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 7 May 2022 02:34:03 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- taichi/gui/win32.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/taichi/gui/win32.cpp b/taichi/gui/win32.cpp index 77809e74f8dc8..3708d62fa7620 100644 --- a/taichi/gui/win32.cpp +++ b/taichi/gui/win32.cpp @@ -153,7 +153,7 @@ void GUI::process_event() { } void GUI::create_window() { - const char* CLASS_NAME = "Taichi Win32 Window"; + const char *CLASS_NAME = "Taichi Win32 Window"; DWORD dwVersion = 0; DWORD dwMajorVersion = 0; @@ -180,18 +180,18 @@ void GUI::create_window() { AdjustWindowRect(&window_rect, WS_OVERLAPPEDWINDOW, false); - hwnd = CreateWindowExA(0, // Optional window styles. - CLASS_NAME, // Window class - window_name.c_str(), // Window text - WS_OVERLAPPEDWINDOW, // Window style - // Size and position - CW_USEDEFAULT, CW_USEDEFAULT, - window_rect.right - window_rect.left, - window_rect.bottom - window_rect.top, - NULL, // Parent window - NULL, // Menu - GetModuleHandleA(0), // Instance handle - NULL // Additional application data + hwnd = CreateWindowExA(0, // Optional window styles. + CLASS_NAME, // Window class + window_name.c_str(), // Window text + WS_OVERLAPPEDWINDOW, // Window style + // Size and position + CW_USEDEFAULT, CW_USEDEFAULT, + window_rect.right - window_rect.left, + window_rect.bottom - window_rect.top, + NULL, // Parent window + NULL, // Menu + GetModuleHandleA(0), // Instance handle + NULL // Additional application data ); TI_ERROR_IF(hwnd == NULL, "Window creation failed"); gui_from_hwnd[hwnd] = this; From d2d43330700daf1715de709780b8ba53959393b7 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Sat, 7 May 2022 13:14:21 +0800 Subject: [PATCH 6/6] Removed `TI_EXPORT_CORE` option --- cmake/TaichiCore.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index ca9f91cf81608..1a41bc2020552 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -8,7 +8,6 @@ option(TI_WITH_CC "Build with the C backend" ON) option(TI_WITH_VULKAN "Build with the Vulkan backend" OFF) option(TI_WITH_DX11 "Build with the DX11 backend" OFF) option(TI_EMSCRIPTENED "Build using emscripten" OFF) -option(TI_EXPORT_CORE "Export Taichi core library for AOT runtime" OFF) # Force symbols to be 'hidden' by default so nothing is exported from the Taichi # library including the third-party dependencies.