Conditionally compile with a cfg variable instead.
This commit is contained in:
parent
6256110bd2
commit
92a17e782f
2 changed files with 29 additions and 11 deletions
|
|
@ -10,6 +10,16 @@ use webbrowser;
|
|||
|
||||
macro_rules! resource {
|
||||
($name: tt, $path: tt) => {
|
||||
#[cfg(TREE_SITTER_EMBED_WASM_BINDING)]
|
||||
fn $name(tree_sitter_dir: &Option<PathBuf>) -> Vec<u8> {
|
||||
if let Some(tree_sitter_dir) = tree_sitter_dir {
|
||||
fs::read(tree_sitter_dir.join($path)).unwrap()
|
||||
} else {
|
||||
include_bytes!(concat!("../../", $path)).to_vec()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(TREE_SITTER_EMBED_WASM_BINDING))]
|
||||
fn $name(tree_sitter_dir: &Option<PathBuf>) -> Vec<u8> {
|
||||
if let Some(tree_sitter_dir) = tree_sitter_dir {
|
||||
fs::read(tree_sitter_dir.join($path)).unwrap()
|
||||
|
|
@ -22,7 +32,7 @@ macro_rules! resource {
|
|||
|
||||
macro_rules! posix_resource {
|
||||
($name: tt, $path: tt) => {
|
||||
#[cfg(unix)]
|
||||
#[cfg(all(unix, TREE_SITTER_EMBED_WASM_BINDING))]
|
||||
fn $name(tree_sitter_dir: &Option<PathBuf>) -> Vec<u8> {
|
||||
if let Some(tree_sitter_dir) = tree_sitter_dir {
|
||||
fs::read(tree_sitter_dir.join($path)).unwrap()
|
||||
|
|
@ -31,6 +41,15 @@ macro_rules! posix_resource {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(TREE_SITTER_EMBED_WASM_BINDING)))]
|
||||
fn $name(tree_sitter_dir: &Option<PathBuf>) -> Vec<u8> {
|
||||
if let Some(tree_sitter_dir) = tree_sitter_dir {
|
||||
fs::read(tree_sitter_dir.join($path)).unwrap()
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn $name(_: &Option<PathBuf>) -> Vec<u8> {
|
||||
Vec::new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue