Skip to content

Commit

Permalink
Fix compilation error with package managers
Browse files Browse the repository at this point in the history
This commit will fix the compilation errors appearing when trying to
build wiki-tui for a package manager.

The underlying error is with the hard-coded path to the languages.json
in the proc-macro, which gets interpreted in multiple ways depending on
how wiki-tui is compiled (for example, `cargo publish` works, but
building through nixpkgs doesn't).

It fixes the issue by removing the path dependency completely and
instead passing the entire json file as a string literal to the
proc-macro

Signed-off-by: Builditluc <[email protected]>
  • Loading branch information
Builditluc committed Dec 5, 2024
1 parent 48bb060 commit 536deee
Show file tree
Hide file tree
Showing 7 changed files with 8,109 additions and 8,112 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["wiki-api", "wiki-api-macros"]

[package]
name = "wiki-tui"
version = "0.9.0"
version = "0.9.1"
authors = ["builditluc <[email protected]>"]
edition = "2018"
rust-version = "1.76.0"
Expand Down Expand Up @@ -42,4 +42,4 @@ bitflags = { version = "2.6.0", features = ["serde"] }

[dependencies.wiki-api]
path = "wiki-api"
version = "0.1.0"
version = "0.1.1"
2 changes: 1 addition & 1 deletion wiki-api-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wiki-api-macros"
version = "0.1.0"
version = "0.1.2"
authors = ["builditluc <[email protected]>"]
edition = "2018"
description = "Proc-macros for use within wiki-api"
Expand Down
10 changes: 2 additions & 8 deletions wiki-api-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::{
collections::{BTreeMap, HashMap},
fs::File,
io::BufReader,
};
use std::collections::{BTreeMap, HashMap};

use proc_macro::TokenStream;
use proc_macro2::Span;
Expand Down Expand Up @@ -40,9 +36,7 @@ struct SiteMatrixWrapper {
#[proc_macro]
pub fn parse_languages(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as LitStr).value();
let file = File::open(input).unwrap();
let reader = BufReader::new(file);
let sitematrix: SiteMatrixWrapper = serde_json::from_reader(reader).unwrap();
let sitematrix: SiteMatrixWrapper = serde_json::from_str(&input).unwrap();
let languages =
sitematrix
.site_matrix
Expand Down
4 changes: 2 additions & 2 deletions wiki-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wiki-api"
version = "0.1.0"
version = "0.1.1"
authors = ["builditluc <[email protected]>"]
edition = "2018"
description = "Backend for wiki-tui"
Expand Down Expand Up @@ -30,4 +30,4 @@ urlencoding = "2.1.3"

[dependencies.wiki-api-macros]
path = "../wiki-api-macros"
version = "0.1.0"
version = "0.1.2"
Loading

0 comments on commit 536deee

Please sign in to comment.