Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile and use the rust version of IME #14

Open
sxhxliang opened this issue Apr 11, 2023 · 12 comments
Open

How to compile and use the rust version of IME #14

sxhxliang opened this issue Apr 11, 2023 · 12 comments

Comments

@sxhxliang
Copy link

No description provided.

@saschanaz
Copy link
Owner

@sxhxliang
Copy link
Author

See: https://github.com/saschanaz/ime-rs#build

Thank you for your reply,but I saw the code, Isn't this way just compiling the c++ part? Can I use cargo to compile the rust code into IME under the rust folder?

@saschanaz
Copy link
Owner

saschanaz commented Apr 13, 2023

The VS project will automatically trigger cargo build too. (Maybe this should be made clear)

<Command>pwsh.exe $(SolutionDir)prebuild.ps1</Command>

ime-rs/cpp/prebuild.ps1

Lines 1 to 11 in d77fef6

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
pushd $scriptDir/../rust
cargo build
cbindgen --crate composition_processor --output ../cpp/SampleIME/cbindgen/composition_processor.h
cbindgen --crate input_processor --output ../cpp/SampleIME/cbindgen/input_processor.h
cbindgen --crate itf_components --output ../cpp/SampleIME/cbindgen/itf_components.h
cbindgen --crate globals --output ../cpp/SampleIME/cbindgen/globals.h
cbindgen --crate ime --output ../cpp/SampleIME/cbindgen/ime.h
cbindgen --crate numberkey_windows --output ../cpp/SampleIME/cbindgen/numberkey_windows.h
cbindgen --crate ruststringrange --output ../cpp/SampleIME/cbindgen/ruststringrange.h
popd

@sxhxliang
Copy link
Author

@saschanaz hello, one more question, cannot open file "compare_with_wildcard.lib"

1>EXEC : warning : `itf_components` (lib) generated 2 warnings
1>    Finished dev [unoptimized + debuginfo] target(s) in 1.80s
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:4�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   4 | �[0m �[36;1mcbindgen�[0m --crate composition_processor --output ../cpp/SampleIME/cbin .�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:5�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   5 | �[0m �[36;1mcbindgen�[0m --crate input_processor --output ../cpp/SampleIME/cbindgen/i .�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:6�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   6 | �[0m �[36;1mcbindgen�[0m --crate itf_components --output ../cpp/SampleIME/cbindgen/it .�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:7�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   7 | �[0m �[36;1mcbindgen�[0m --crate globals --output ../cpp/SampleIME/cbindgen/globals.h�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:8�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   8 | �[0m �[36;1mcbindgen�[0m --crate ime --output ../cpp/SampleIME/cbindgen/ime.h�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:9�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m   9 | �[0m �[36;1mcbindgen�[0m --crate numberkey_windows --output ../cpp/SampleIME/cbindgen .�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>�[31;1mcbindgen: �[0mX:\IME\ime-rs\cpp\prebuild.ps1:10�[0m
1>�[31;1m�[0m�[36;1mLine |�[0m
1>�[31;1m�[0m�[36;1m�[36;1m  10 | �[0m �[36;1mcbindgen�[0m --crate ruststringrange --output ../cpp/SampleIME/cbindgen/r .�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m ~~~~~~~~�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mThe term 'cbindgen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check�[0m
1>�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m     | �[31;1mthe spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m
1>ActiveLanguageProfileNotifySink.cpp
1>BaseWindow.cpp
1>ButtonWindow.cpp
1>CandidateListUIPresenter.cpp
1>CandidateWindow.cpp
1>Compartment.cpp
1>Composition.cpp
1>CompositionProcessorEngine.cpp
1>EnumTfCandidates.cpp
1>KeyStateCategory.cpp
1>RustStringRange.cpp
1>SampleIMEBaseStructure.cpp
1>X:\IME\ime-rs\cpp\SampleIME\SampleIMEBaseStructure.cpp(44,31): warning C4996: 'std::codecvt_utf8_utf16<char16_t,1114111,(std::codecvt_mode)0>': warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using MultiByteToWideChar() and WideCharToMultiByte() from <Windows.h> instead. You can define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\codecvt(444,5): message : see declaration of 'std::codecvt_utf8_utf16'
1>X:\IME\ime-rs\cpp\SampleIME\SampleIMEBaseStructure.cpp(44,10): warning C4996: 'std::wstring_convert<std::codecvt_utf8_utf16<char16_t,1114111,(std::codecvt_mode)0>,char16_t,std::allocator<char16_t>,std::allocator<char>>': warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using MultiByteToWideChar() and WideCharToMultiByte() from <Windows.h> instead. You can define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xlocbuf(304,55): message : see declaration of 'std::wstring_convert'
1>X:\IME\ime-rs\cpp\SampleIME\SampleIMEBaseStructure.cpp(44,70): warning C4996: 'std::wstring_convert<std::codecvt_utf8_utf16<char16_t,1114111,(std::codecvt_mode)0>,char16_t,std::allocator<char16_t>,std::allocator<char>>::wstring_convert': warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using MultiByteToWideChar() and WideCharToMultiByte() from <Windows.h> instead. You can define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
1>X:\IME\ime-rs\cpp\SampleIME\SampleIMEBaseStructure.cpp(45,39): warning C4996: 'std::wstring_convert<std::codecvt_utf8_utf16<char16_t,1114111,(std::codecvt_mode)0>,char16_t,std::allocator<char16_t>,std::allocator<char>>::from_bytes': warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using MultiByteToWideChar() and WideCharToMultiByte() from <Windows.h> instead. You can define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
1>SearchCandidateProvider.cpp
1>DisplayAttribute.cpp
1>DisplayAttributeInfo.cpp
1>DisplayAttributeProvider.cpp
1>DllMain.cpp
1>EditSession.cpp
1>EndComposition.cpp
1>EnumDisplayAttributeInfo.cpp
1>Generating Code...
1>Compiling...
1>FunctionProviderSink.cpp
1>GetTextExtentEditSession.cpp
1>Globals.cpp
1>KeyEventSink.cpp
1>KeyHandler.cpp
1>KeyHandlerEditSession.cpp
1>LanguageBar.cpp
1>ScrollBarWindow.cpp
1>Server.cpp
1>ShadowWindow.cpp
1>StartComposition.cpp
1>SampleIME.cpp
1>TextEditSink.cpp
1>TfInputProcessorProfile.cpp
1>TfTextLayoutSink.cpp
1>ThreadFocusSink.cpp
1>ThreadMgrEventSink.cpp
1>TipCandidateList.cpp
1>TipCandidateString.cpp
1>Generating Code...
1>LINK : fatal error LNK1104: cannot open file 'X:\IME\ime-rs\cpp\..\rust\target\debug\compare_with_wildcard.lib'
1>Done building project "SampleIME.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 2:58 PM and took 36.778 seconds ==========

@saschanaz
Copy link
Owner

Oh, oops, you need to do cargo install cbindgen first.

@sxhxliang
Copy link
Author

Oh, oops, you need to do cargo install cbindgen first.

I installed cbindgen and get same issues, cargo build did not generate this file "X:\IME\ime-rs\cpp..\rust\target\debug\compare_with_wildcard.lib"

btw... your reply is super fast!!!!

@saschanaz
Copy link
Owner

Does X:\IME\ime-rs\rust\target\debug\ have any files?

@sxhxliang
Copy link
Author

yes, cargo build will generate many files.
image
but can not find a crate named "compare_with_wildcard"

image

@saschanaz
Copy link
Owner

saschanaz commented Apr 19, 2023

Oh oops, 247704d merged it to dictionary_parser but did not remove this reference. I'll fix it very quick

@saschanaz
Copy link
Owner

Done: f61b6c9

@sxhxliang
Copy link
Author

Done: f61b6c9

Nice work! It's perfectly fine to work on my Windows 10 PC
btw, I test it on Windows 11 PC with arm64 architecture, but it doesn't work ...

@saschanaz
Copy link
Owner

Ah yes, for now the configuration only supports x86-64. It shouldn't be too hard to add ARM64 support, PRs welcome.

I expect vcxproj and prebuild.ps1 to be modified in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants