Skip to content

Commit a0b8c83

Browse files
committed
Changed to work with crates.io version of MathCAT
It now extracts the Rules dir from MathCAT. The build should now be done using buld-addon.sh.
1 parent 52b2cd7 commit a0b8c83

File tree

8 files changed

+50
-81
lines changed

8 files changed

+50
-81
lines changed

.cargo/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# first run "rustup target add i686-pc-windows-msvc" to download needed files
2+
#
3+
# NVDA only runs on windows and only supports 32 bit builds (at this time)
4+
# Because of this, we force the target architecture.
5+
[build]
6+
target = "i686-pc-windows-msvc"

Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "MathCatForPython"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["Neil Soiffer <soiffer@alum.mit.edu>"]
55
edition = "2018"
66

@@ -13,12 +13,16 @@ name = "libmathcat_py"
1313
crate-type = ["cdylib"]
1414

1515
[dependencies]
16-
mathcat = "0.1.2"
16+
mathcat = "0.1.6"
1717

1818
[dependencies.pyo3]
1919
version = "0.15.1"
2020
features = ["extension-module", "abi3"]
2121

22-
# 32 bit target stable-i686-pc-windows-msvc
23-
# if changing to building 32 bit python version, change .cargo/config.toml
24-
# along with changing env variable PYO3_PYTHON
22+
[build-dependencies]
23+
mathcat = "0.1.6"
24+
zip = "0.5.8"
25+
26+
[profile.release]
27+
lto = true
28+
# opt-level = "z" # Optimize for size.
57.5 KB
Binary file not shown.

NVDA-addon/build.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

build-addon.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/csh
2+
# RUN THIS FILE to build the NVDA addon
3+
4+
cargo build --target i686-pc-windows-msvc --release
5+
6+
cp target/i686-pc-windows-msvc/release/libmathcat_py.dll NVDA-addon/addon/globalPlugins/MathCAT/libmathcat.pyd
7+
cd NVDA-addon
8+
rm mathCAT-*.nvda-addon
9+
scons
10+

build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! The build.rs file is necessary to unzip the rules.
2+
//! rules.zip are needed so there is a way to get the rules dir into the build since you can't get it from the crate.
3+
//!
4+
//! Note: this only creates the Rules dir. Run build-addon.sh to actually build the addon.
5+
6+
use std::path::PathBuf;
7+
use zip::ZipArchive;
8+
9+
fn main() {
10+
// first remove the Rules directory
11+
std::fs::remove_dir_all("NVDA-addon/addon/globalPlugins/MathCAT/Rules")
12+
.expect("Failed to remove directory 'NVDA-addon/addon/globalPlugins/MathCAT/Rules'");
13+
let archive = libmathcat::ZIPPED_RULE_FILES;
14+
let archive = std::io::Cursor::new(archive);
15+
let location = PathBuf::from("NVDA-addon/addon/globalPlugins/MathCAT");
16+
17+
let mut zip_archive = ZipArchive::new(archive).unwrap();
18+
zip_archive.extract(&location).expect("Zip extraction failed");
19+
20+
// the test dir 'zz' doesn't need to be part of the addon
21+
std::fs::remove_dir_all("NVDA-addon/addon/globalPlugins/MathCAT/Rules/zz")
22+
.expect("Failed to remove directory 'NVDA-addon/addon/globalPlugins/MathCAT/Rules/zz'");
23+
}

mc.toml

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ mod py_tests {
165165
// this isn't a real test
166166
pyo3::prepare_freethreaded_python();
167167
let mathml_str = "<math><mo>(</mo><mrow><mn>451</mn><mo>,</mo><mn>231</mn></mrow><mo>)</mo></math>";
168-
match convert_error( libmathcat::interface::SetMathML(mathml_str.to_string()) ) {
168+
match convert_error( libmathcat::interface::set_mathml(mathml_str.to_string()) ) {
169169
Ok(_mathml_with_ids) => println!("MathML is set w/o error"),
170170
Err(e) => println!("Error is {}", e.to_string()),
171171
}
172172
// still alive?
173-
match convert_error( libmathcat::interface::SetMathML(mathml_str.to_string()) ) {
173+
match convert_error( libmathcat::interface::set_mathml(mathml_str.to_string()) ) {
174174
Ok(_mathml_with_ids) => panic!("MathML is set 2nd time w/o error"),
175175
Err(e) => panic!("Error remains {}", e.to_string()),
176176
}

0 commit comments

Comments
 (0)