Skip to content

Commit

Permalink
Update README - Single build step
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeedvh committed Dec 20, 2023
1 parent 802dc9f commit fa74b71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 55 deletions.
71 changes: 16 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
<img src=".assets/varnam-logo.png" alt="binserve logo" width="50" align="right">

# VarnamIME for Windows

Easily type Indian languages on Windows using [Varnam transliteration engine](https://varnamproject.github.io/).

> [!NOTE]
> This project is a hard-fork of [ime-rs](https://github.com/saschanaz/ime-rs) extended to support plugging Varnam as the transliteration engine on native Windows IME.
>
> **Project Status:** _Experimental_. Please refer to the [Checklist](#checklist) for pending tasks.
> This project is a hard-fork of [ime-rs](https://github.com/saschanaz/ime-rs) extended to support plugging [Varnam](https://github.com/varnamproject/govarnam) as the transliteration engine on native Windows IME.
## Build

**Prerequisites:**
- Windows 64bit
- Windows 64 bit
- [Visual Studio](https://visualstudio.microsoft.com/downloads/) (Including command-line utils: `lib.exe` and `gendef.exe`)
- [Rust](https://www.rust-lang.org/)
- [Rust](https://www.rust-lang.org/) and [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- [Go](https://go.dev/)
- [msys64](https://www.msys2.org/)
- [PowerShell](https://www.microsoft.com/store/productId/9MZ1SNWT0N5D)

### Setup:

**1.** Install cbindgen for Rust:

```
cargo install cbindgen
```
**1.** Open the project **Varnam Windows** by opening the file `cpp\VarnamWindows.sln` in Visual Studio.

**2.** Compile the libgovarnam shared library
**2.** Build and compile the bundle:

```
cd varnam-windows\govarnam
windows-build.bat
Build -> Build Varnam Windows
```

This will generate a dynamically linked DLL: `libgovarnam.dll`.
This should:
1. Build Govarnam, Rust native IME, and the SampleIME-cpp in sequence.
2. Build the necessary DLL, LIB, and PDB files into the `varnam-windows\cpp\x64\Debug` directory.
3. Fetch the latest language schemes from https://github.com/varnamproject/schemes.
4. Import words from the VLF files into the language schemes.
5. Setup language choice configuration.

**3.** Open the project **Varnam Windows** by opening the file `cpp\VarnamWindows.sln` in Visual Studio.

**4.** Build and compile the bundle:

```
Build -> Clean Varnam Windows
Build -> Rebuild Varnam Windows
```

This should install the `libgovarnam.dll` and `libgovarnam.lib` into the env configured PATH - `C:\lib` and fetch the latest language schemes from https://github.com/varnamproject/schemes and place them inside the `C:\Users\<username>\.libvarnam` directory.

**5.** Open "Command Prompt" as Administrator, navigate to `varnam-windows\cpp\x64\Debug` and register the DLL to install Varnam as the native IME for the supported languages.
**3.** Open "Command Prompt" as Administrator, navigate to `varnam-windows\cpp\x64\Debug` and register the DLL to install Varnam as the native IME for the supported languages.

```
regsvr32 "Varnam Windows.dll"
Expand All @@ -57,33 +45,6 @@ To unregister the DLL, run:
regsvr32 /u "Varnam Windows.dll"
```

> [!IMPORTANT]
> Only the x64/Debug configuration build is supported.
## Checklist

- [x] Compile [govarnam](https://github.com/varnamproject/govarnam) into a DLL and LIB to use as a shared library on Windows.
- [x] Call the DLL from Rust for transliteration via dynamic linking. This is extended from [govarnam-rust](https://github.com/varnamproject/govarnam-rust).
- [x] Link the Rust interface and SampleIME CPP to build an IME build dll.
- [x] Windows Setup Wizard script via Inno Setup.
- [x] Keyboard Layout shifting (Active/Disable toggle)
- [x] Resource files for icons (`*.ico`) for Registry Profile. (Currently the SampleIME 'Chinese Simplified' icon resources are loaded)
- [ ] Language Switching (Currently runs on just [Malayalam VST](https://github.com/varnamproject/schemes/tree/master/schemes/ml))
- [ ] Implement the supported CONSTANTS for languages from [`windows_sys::Win32::System::SystemServices`](https://docs.rs/windows-sys/latest/windows_sys/Win32/System/SystemServices/index.html) and trigger language switch on Language Settings change.
- [ ] 🔴Handle Govarnam `nil pointer dereference` and potential race conditions (due to early freeing?). An example stack trace:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x48 pc=0x7ffe9289dcfb]
goroutine 19 [running]:
github.com/varnamproject/govarnam/govarnam.(*Varnam).tokenizeWord(0x0, {0x7ffe92a55f20, 0xc0000520a0}, {0xc00000a100, 0xc}, 0x0?, 0x0)
libvarnam-windows/govarnam/govarnam/symbol.go:258 +0x15b
github.com/varnamproject/govarnam/govarnam.(*Varnam).channelTokenizeWord(0x0?, {0x7ffe92a55f20, 0xc0000520a0}, {0xc00000a100, 0xc}, 0x0?, 0x0?, 0x0?)
libvarnam-windows/govarnam/govarnam/channel.go:24 +0xb6
created by github.com/varnamproject/govarnam/govarnam.(*Varnam).transliterate in goroutine 7
libvarnam-windows/govarnam/govarnam/govarnam.go:281 +0x189
error: process didn't exit successfully: `target\debug\varnam_init.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
```
**4.** Compile the `varnam-windows.iss` using [Inno Setup](https://jrsoftware.org/isinfo.php) to package and generate the Varnam Setup Wizard (`Varnam Windows Install.exe`).

---
1 change: 1 addition & 0 deletions cpp/prebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Pop-Location

Push-Location $scriptDir/../rust
cargo build --release --target=x86_64-pc-windows-msvc
cargo install cbindgen
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
Expand Down

0 comments on commit fa74b71

Please sign in to comment.