commit 4efddda8c27bb37dc8b11b67e448aff2a4392bbb Author: fanlusky <1730976608@qq.com> Date: Wed Mar 11 14:05:03 2026 +0800 init project diff --git a/log/.clang-format b/log/.clang-format new file mode 100644 index 00000000..ee44fe02 --- /dev/null +++ b/log/.clang-format @@ -0,0 +1,6 @@ +--- +BasedOnStyle: Microsoft +IndentWidth: 4 + +SortIncludes: false +ColumnLimit: 300 diff --git a/log/.clangd b/log/.clangd new file mode 100644 index 00000000..a0d19b95 --- /dev/null +++ b/log/.clangd @@ -0,0 +1,15 @@ +CompileFlags: + Add: [ + -DUNICODE, + -D_UNICODE, + "-std=c++17", # needed when using MSVC + "-IC:/Users/sonnycalcr/EDisk/CppCodes/IMECodes/MetasequoiaImeLog/build/vcpkg_installed/x64-windows/include", + -Wno-microsoft-goto, + -Wno-nonportable-include-path, + -Wno-microsoft-extra-qualification, + -Wunused-variable, + # -Wno-unused-value, + ] # ignore some specific warnings + CompilationDatabase: build/ # Search build/ directory for compile_commands.json +# Diagnostics: +# UnusedIncludes: None # ignore unused includes diff --git a/log/.gitignore b/log/.gitignore new file mode 100644 index 00000000..567609b1 --- /dev/null +++ b/log/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/log/.vscode/custom.code-snippets b/log/.vscode/custom.code-snippets new file mode 100644 index 00000000..c191c9ff --- /dev/null +++ b/log/.vscode/custom.code-snippets @@ -0,0 +1,27 @@ +{ + "Debug snippets": { + "scope": "c,cpp", + "prefix": "dbug", + "body": [ + "#ifdef FANY_DEBUG", + "#endif", + ], + "description": "Add debug macro" + }, + "Win32 log": { + "scope": "c,cpp", + "prefix": "dlog", + "body": [ + "OutputDebugString(L\"$0\");", + ], + "description": "Debugview log" + }, + "Win32 log with fmt": { + "scope": "c,cpp", + "prefix": "flog", + "body": [ + "OutputDebugString(fmt::format(L\"$0\").c_str());", + ], + "description": "Debugview log with fmt" + } +} \ No newline at end of file diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt new file mode 100644 index 00000000..94e0ce01 --- /dev/null +++ b/log/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.25.0) +project(MetasequoiaImeLog VERSION 1.0) + +# Specify the C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +add_definitions( + /D_UNICODE=1 + /DUNICODE=1 +) + +# fmt +find_package(fmt REQUIRED) + +set(MY_EXECUTABLE_NAME "MetasequoiaImeLog") +set( + SOURCE_FILES + "./src/main.cpp" +) + +add_executable(${MY_EXECUTABLE_NAME} ${SOURCE_FILES}) + +target_link_libraries(${MY_EXECUTABLE_NAME} PRIVATE fmt::fmt) \ No newline at end of file diff --git a/log/CMakePresets.json b/log/CMakePresets.json new file mode 100644 index 00000000..d1bfa970 --- /dev/null +++ b/log/CMakePresets.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "vcpkg", + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/build", + "environment": { + "VCPKG_ROOT": "C:/Users/SonnyCalcr/scoop/apps/vcpkg/current" + }, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "C:/Users/SonnyCalcr/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake", + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} \ No newline at end of file diff --git a/log/CMakeUserPresets.json b/log/CMakeUserPresets.json new file mode 100644 index 00000000..c8b022de --- /dev/null +++ b/log/CMakeUserPresets.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "inherits": "vcpkg", + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/build" + } + ] +} \ No newline at end of file diff --git a/log/README.md b/log/README.md new file mode 100644 index 00000000..7150c174 --- /dev/null +++ b/log/README.md @@ -0,0 +1,3 @@ +# MetasequoiaImeLog + +Capture logs for Metasequoia IME modules. diff --git a/log/scripts/config_files/.clangd b/log/scripts/config_files/.clangd new file mode 100644 index 00000000..7227a326 --- /dev/null +++ b/log/scripts/config_files/.clangd @@ -0,0 +1,18 @@ +CompileFlags: + Add: [ + -DUNICODE, + -D_UNICODE, + -DFANY_DEBUG, + "-std=c++17", + "-IC:/Users/SonnyCalcr/EDisk/CppCodes/Win32Codes/Win32WebviewTemplate/src", + "-IC:/Users/SonnyCalcr/EDisk/CppCodes/Win32Codes/Win32WebviewTemplate/build/vcpkg_installed/x64-windows/include", + "-IC:/Users/SonnyCalcr/.nuget/packages/microsoft.web.webview2/1.0.3240.44/build/native/include", + "-IC:/Users/SonnyCalcr/.nuget/packages/microsoft.windows.implementationlibrary/1.0.240803.1/include", + -Wno-microsoft-goto, + -Wno-nonportable-include-path, + -Wno-microsoft-extra-qualification, + # -Wno-unused-value, + ] # ignore some specific warnings + # CompilationDatabase: build/ # Search build/ directory for compile_commands.json +# Diagnostics: +# UnusedIncludes: None # ignore unused includes diff --git a/log/scripts/config_files/CMakeLists.txt b/log/scripts/config_files/CMakeLists.txt new file mode 100644 index 00000000..8a82c51c --- /dev/null +++ b/log/scripts/config_files/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.25.0) +project(WinCppTemplateWithVcpkg VERSION 1.0) + +# Specify the C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +add_definitions( + /D_UNICODE=1 + /DUNICODE=1 +) + +# fmt and spdlog +find_package(fmt REQUIRED) + +set(MY_EXECUTABLE_NAME "WinCppTemplateWithVcpkg") +set( + SOURCE_FILES + "./src/main.cpp" +) + +add_executable(${MY_EXECUTABLE_NAME} ${SOURCE_FILES}) diff --git a/log/scripts/config_files/CMakePresets.json b/log/scripts/config_files/CMakePresets.json new file mode 100644 index 00000000..0131c3c8 --- /dev/null +++ b/log/scripts/config_files/CMakePresets.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "vcpkg", + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/build", + "environment": { + "VCPKG_ROOT": "C:/Users/sonnycalcr/scoop/apps/vcpkg/current/" + }, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "C:/Users/sonnycalcr/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake", + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} \ No newline at end of file diff --git a/log/scripts/lcompile.ps1 b/log/scripts/lcompile.ps1 new file mode 100644 index 00000000..b2145229 --- /dev/null +++ b/log/scripts/lcompile.ps1 @@ -0,0 +1,39 @@ +# +# generate, compile and run exe files +# +function getExePathFromCMakeLists() { + $content = Get-Content -Raw -Path "./CMakeLists.txt" + $exePath = "" + foreach ($line in $content -split "`n") { + if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') { + $exeName = $matches[1] + $exePath = "./build/bin/Debug/$exeName" + ".exe" + break + } + } + return $exePath +} + +$currentDirectory = Get-Location +$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt" + +if (-not (Test-Path $cmakeListsPath)) { + Write-Host("No CMakeLists.txt in current directory, please check.") + return +} + +Write-Host "Start generating and compiling..." + +$buildFolderPath = ".\build" + +if (-not (Test-Path $buildFolderPath)) { + New-Item -ItemType Directory -Path $buildFolderPath | Out-Null + Write-Host "build folder created." +} + +# cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/ +cmake --preset=default + +if ($LASTEXITCODE -eq 0) { + cmake --build build +} \ No newline at end of file diff --git a/log/scripts/llaunch.ps1 b/log/scripts/llaunch.ps1 new file mode 100644 index 00000000..f6ca4413 --- /dev/null +++ b/log/scripts/llaunch.ps1 @@ -0,0 +1,45 @@ +# +# generate, compile and run exe files +# +function getExePathFromCMakeLists() { + $content = Get-Content -Raw -Path "./CMakeLists.txt" + $exePath = "" + foreach ($line in $content -split "`n") { + if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') { + $exeName = $matches[1] + $exePath = "./build/bin/Debug/$exeName" + ".exe" + break + } + } + return $exePath +} + +$currentDirectory = Get-Location +$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt" + +if (-not (Test-Path $cmakeListsPath)) { + Write-Host("No CMakeLists.txt in current directory, please check.") + return +} + +Write-Host "Start generating and compiling..." + +$buildFolderPath = ".\build" + +if (-not (Test-Path $buildFolderPath)) { + New-Item -ItemType Directory -Path $buildFolderPath | Out-Null + Write-Host "build folder created." +} + +# cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/ +cmake --preset=default + +if ($LASTEXITCODE -eq 0) { + cmake --build build + if ($LASTEXITCODE -eq 0) { + $exePath = getExePathFromCMakeLists + Write-Host "start running as follows..." + Write-Host "==================================================" + Invoke-Expression $exePath + } +} \ No newline at end of file diff --git a/log/scripts/lrun.ps1 b/log/scripts/lrun.ps1 new file mode 100644 index 00000000..7ecb39b7 --- /dev/null +++ b/log/scripts/lrun.ps1 @@ -0,0 +1,20 @@ +# +# run exe file that has already been compiled before +# +function getExePathFromCMakeLists() { + $content = Get-Content -Raw -Path "./CMakeLists.txt" + $exePath = "" + foreach ($line in $content -split "`n") { + if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') { + $exeName = $matches[1] + $exePath = "./build/bin/Debug/$exeName" + ".exe" + break + } + } + return $exePath +} + +$exePath = getExePathFromCMakeLists +#Write-Host "start running as follows..." +#Write-Host "==================================================" +Invoke-Expression $exePath \ No newline at end of file diff --git a/log/scripts/prepare_env.py b/log/scripts/prepare_env.py new file mode 100644 index 00000000..e6064791 --- /dev/null +++ b/log/scripts/prepare_env.py @@ -0,0 +1,111 @@ +import os + + +def normpath(path): + return path.replace("\\", "/") + + +local_app_data_dir = os.environ.get("LOCALAPPDATA") +home_dir = os.path.expanduser("~") + +cur_file_path = os.path.dirname(os.path.abspath(__file__)) +project_root_path = os.path.dirname(cur_file_path) + +user_home = os.path.expanduser("~") + +Win32WebviewTemplate_root_path = normpath(project_root_path) +Win32WebviewTemplate_src_path = normpath( + os.path.join(Win32WebviewTemplate_root_path, "src") +) +vcpkg_include_path = normpath( + os.path.join( + Win32WebviewTemplate_root_path, + "build", + "vcpkg_installed", + "x64-windows", + "include", + ) +) +utfcpp_path = normpath(os.path.join(Win32WebviewTemplate_root_path, "utfcpp", "source")) +webview2_path = normpath( + os.path.join( + user_home, + ".nuget", + "packages", + "microsoft.web.webview2", + "1.0.3240.44", + "build", + "native", + "include", + ) +) +wim_path = normpath( + os.path.join( + user_home, + ".nuget", + "packages", + "microsoft.windows.implementationlibrary", + "1.0.240803.1", + "include", + ) +) +boost_path = normpath(os.path.join(user_home, "scoop", "apps", "boost", "current")) +vcpkg_root_path = normpath(os.path.join(user_home, "scoop", "apps", "vcpkg", "current")) +cmake_toolchain_file_path = normpath( + os.path.join( + user_home, + "scoop", + "apps", + "vcpkg", + "current", + "scripts", + "buildsystems", + "vcpkg.cmake", + ) +) + +# +# project_root/.clangd +# line 7, 8, 9, 10 +# +dot_clangd_file = os.path.join( + Win32WebviewTemplate_root_path, "scripts", "config_files", ".clangd" +) +dot_clangd_output_file = os.path.join(Win32WebviewTemplate_root_path, ".clangd") +with open(dot_clangd_file, "r", encoding="utf-8") as f: + lines = f.readlines() +lines[6] = f' "-I{Win32WebviewTemplate_src_path}",\n' +lines[7] = f' "-I{vcpkg_include_path}",\n' +lines[8] = f' "-I{webview2_path}",\n' +lines[9] = f' "-I{wim_path}",\n' +with open(dot_clangd_output_file, "w", encoding="utf-8") as f: + f.writelines(lines) + +# +# project_root/CMakeLists.txt +# +CMakeLists_file = os.path.join( + Win32WebviewTemplate_root_path, "scripts", "config_files", "CMakeLists.txt" +) +CMakeLists_output_file = os.path.join(Win32WebviewTemplate_root_path, "CMakeLists.txt") +with open(CMakeLists_file, "r", encoding="utf-8") as f: + lines = f.readlines() +with open(CMakeLists_output_file, "w", encoding="utf-8") as f: + f.writelines(lines) + +# +# CMakePresets.json +# lines 9 12 +# +CMakePresets_file = os.path.join( + Win32WebviewTemplate_root_path, "scripts", "config_files", "CMakePresets.json" +) +CMakePresets_file_output_file = os.path.join( + Win32WebviewTemplate_root_path, "CMakePresets.json" +) +with open(CMakePresets_file, "r", encoding="utf-8") as f: + lines = f.readlines() +lines[8] = f' "VCPKG_ROOT": "{vcpkg_root_path}"\n' +lines[11] = f' "CMAKE_TOOLCHAIN_FILE": "{cmake_toolchain_file_path}",\n' +with open(CMakePresets_file_output_file, "w", encoding="utf-8") as f: + f.writelines(lines) diff --git a/log/src/main.cpp b/log/src/main.cpp new file mode 100644 index 00000000..df28b276 --- /dev/null +++ b/log/src/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} \ No newline at end of file diff --git a/log/vcpkg-configuration.json b/log/vcpkg-configuration.json new file mode 100644 index 00000000..765033c4 --- /dev/null +++ b/log/vcpkg-configuration.json @@ -0,0 +1,3 @@ +{ + "default-triplet": "x64-windows" +} \ No newline at end of file diff --git a/log/vcpkg.json b/log/vcpkg.json new file mode 100644 index 00000000..70f7126e --- /dev/null +++ b/log/vcpkg.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "fmt" + ] +} \ No newline at end of file