-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
57 lines (52 loc) · 1.61 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
extern crate cbindgen;
use cbindgen::{Config, EnumConfig, ExportConfig, ItemType, Language, Style};
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut config = Config {
language: Language::C,
header: Some(
"/*\nCopyright (C) 2024 Signal Messenger, LLC.\nSPDX-License-Identifier: AGPL-3.0-only\n*/"
.into(),
),
style: Style::Type,
cpp_compat: true,
enumeration: EnumConfig {
prefix_with_name: true,
..Default::default()
},
include_guard: Some("SIGNAL_FTS5_TOKENIZER_H_".into()),
export: ExportConfig {
item_types: vec![
ItemType::Functions,
ItemType::OpaqueItems,
ItemType::Structs,
ItemType::Typedefs,
],
..Default::default()
},
..Default::default()
};
config
.export
.rename
.insert("Sqlite3".into(), "sqlite3".into());
config
.export
.rename
.insert("SqliteAPIRoutines3".into(), "sqlite3_api_routines".into());
config
.export
.rename
.insert("TokenFunction".into(), "sqlite3__fts5_token_fn".into());
config.defines.insert(
"feature = extension".into(),
"SIGNAL_FTS5_TOKENIZER_EXTENSION_H_".into(),
);
cbindgen::Builder::new()
.with_crate_and_name(crate_dir, "signal-tokenizer")
.with_config(config)
.generate()
.expect("Unable to generate bindings")
.write_to_file("target/signal-tokenizer.h");
}