Skip to content

Commit

Permalink
Merge pull request #2313 from finos/feature/fix-build-rs
Browse files Browse the repository at this point in the history
Fix build.rs escaping OUT_DIR
  • Loading branch information
texodus authored Jul 24, 2023
2 parents e8ae29a + dd8f594 commit 28510cb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 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.

4 changes: 2 additions & 2 deletions rust/perspective-viewer/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async function build_all() {

// legacy compat
const { default: cpy } = await cpy_mod;
cpy("target/themes/*", "dist/css");
cpy("dist/pkg/*", "dist/esm");
await cpy("target/themes/*", "dist/css");
await cpy("dist/pkg/*", "dist/esm");
}

build_all();
28 changes: 16 additions & 12 deletions rust/perspective-viewer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,29 @@ 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");
build.add_file("fonts.less");
build.add_file("pro.less");
build.add_file("pro-dark.less");
build.add_file("monokai.less");
build.add_file("solarized.less");
build.add_file("solarized-dark.less");
build.add_file("vaporwave.less");
build.add_file("themes.less");
build.compile()?.write("./target/themes")?;
if !cfg!(feature = "define_custom_elements_async") {
build.add_file("variables.less");
build.add_file("fonts.less");
build.add_file("pro.less");
build.add_file("pro-dark.less");
build.add_file("monokai.less");
build.add_file("solarized.less");
build.add_file("solarized-dark.less");
build.add_file("vaporwave.less");
build.add_file("themes.less");
build.compile()?.write("./target/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 28510cb

Please sign in to comment.