difftreelog
fix build without codegenerated-stdlib feature
in: master
2 files changed
crates/jrsonnet-stdlib/build.rsdiffbeforeafterboth1use std::{env, fs::File, io::Write, path::Path};23use jrsonnet_parser::{parse, ParserSettings, Source};4use structdump::CodegenResult;56fn main() {7 let parsed = parse(8 include_str!("./src/std.jsonnet"),9 &ParserSettings {10 source: Source::new_virtual("<std>".into(), include_str!("./src/std.jsonnet").into()),11 },12 )13 .expect("parse");1415 let mut out = CodegenResult::default();1617 let v = out.codegen(&parsed, true);1819 {20 let out_dir = env::var("OUT_DIR").unwrap();21 let dest_path = Path::new(&out_dir).join("stdlib.rs");22 let mut f = File::create(dest_path).unwrap();23 f.write_all(24 ("#[allow(clippy::redundant_clone)]".to_owned() + &v.to_string())25 .replace(';', ";\n")26 .as_bytes(),27 )28 .unwrap();29 }30}crates/jrsonnet-stdlib/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/expr.rs
+++ b/crates/jrsonnet-stdlib/src/expr.rs
@@ -1,11 +1,5 @@
use jrsonnet_parser::LocExpr;
-mod structdump_import {
- pub(super) use std::{option::Option, rc::Rc, vec};
-
- pub(super) use jrsonnet_parser::*;
-}
-
pub fn stdlib_expr() -> LocExpr {
#[cfg(feature = "serialized-stdlib")]
{
@@ -85,15 +79,25 @@
#[cfg(feature = "codegenerated-stdlib")]
{
+ mod structdump_import {
+ pub(super) use std::{option::Option, rc::Rc, vec};
+
+ pub(super) use jrsonnet_parser::*;
+ };
+
include!(concat!(env!("OUT_DIR"), "/stdlib.rs"))
}
#[cfg(not(feature = "codegenerated-stdlib"))]
{
+ use jrsonnet_parser::Source;
+
+ const STDLIB_STR: &str = include_str!("./std.jsonnet");
+
jrsonnet_parser::parse(
STDLIB_STR,
- &ParserSettings {
- file_name: Source::new_virtual(Cow::Borrowed("<std>"), STDLIB_STR.into()),
+ &jrsonnet_parser::ParserSettings {
+ source: Source::new_virtual("<std>".into(), STDLIB_STR.into()),
},
)
.unwrap()