Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build.rs escaping OUT_DIR #2313

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix build.rs escaping OUT_DIR
  • Loading branch information
timbess authored and texodus committed Jul 24, 2023
commit dd8f59482a5573c5d146cff49219a27d45ee13d9
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")),
)
}};
}