Skip to content

Commit

Permalink
Fix build.rs escaping OUT_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
timbess authored and texodus committed Jul 20, 2023
1 parent e8ae29a commit 169673f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
4 changes: 2 additions & 2 deletions rust/perspective-viewer/Cargo.lock

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

7 changes: 5 additions & 2 deletions rust/perspective-viewer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ fn glob_with_wd(indir: &str, input: &str) -> Vec<String> {
}

fn main() -> Result<(), anyhow::Error> {
let out_dir = std::env::var("OUT_DIR").unwrap();
let out_path = std::path::Path::new(&out_dir);

let mut build = BuildCss::new("./src/less");
let files = glob_with_wd("./src/less", "**/*.less");
for src in files.iter() {
build.add_file(src);
}

build.compile()?.write("./target/css")?;
build.compile()?.write(out_path.join("css"))?;

let mut build = BuildCss::new("./src/themes");
build.add_file("variables.less");
Expand All @@ -62,7 +65,7 @@ fn main() -> Result<(), anyhow::Error> {
build.add_file("solarized-dark.less");
build.add_file("vaporwave.less");
build.add_file("themes.less");
build.compile()?.write("./target/themes")?;
build.compile()?.write(out_path.join("themes"))?;

println!(
"cargo:rustc-env=PKG_VERSION={}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::modal::*;
use crate::utils::WeakScope;
use crate::*;

static CSS: &str = include_str!("../../../target/css/column-dropdown.css");
static CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/css/column-dropdown.css"));

pub enum ColumnDropDownMsg {
SetValues(Vec<InPlaceColumn>, f64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::modal::*;
use crate::utils::WeakScope;
use crate::*;

static CSS: &str = include_str!("../../../target/css/filter-dropdown.css");
static CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/css/filter-dropdown.css"));

pub enum FilterDropDownMsg {
SetValues(Vec<String>),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::exprtk::CompletionItemSuggestion;
use crate::utils::WeakScope;
use crate::*;

static CSS: &str = include_str!("../../../target/css/function-dropdown.css");
static CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/css/function-dropdown.css"));

pub enum FunctionDropDownMsg {
SetValues(Vec<CompletionItemSuggestion>),
Expand Down
16 changes: 2 additions & 14 deletions rust/perspective-viewer/src/rust/components/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,13 @@ macro_rules! css {
($name:expr) => {{
(
$name,
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/target/css/",
$name,
".css"
)),
include_str!(concat!(env!("OUT_DIR"), "/css/", $name, ".css")),
)
}};
($path:expr, $name:expr) => {{
(
$name,
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
$path,
"/",
$name,
".css"
)),
include_str!(concat!(env!("OUT_DIR"), "/", $path, "/", $name, ".css")),
)
}};
}

0 comments on commit 169673f

Please sign in to comment.