From c697eb1086c1b9c959495480bb6a3e01f8e04375 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 26 Mar 2021 09:54:42 +1000 Subject: [PATCH] embed strings.json into write_json.rs It appears that including the build script as a dependency is not enough to make the file available at runtime, so the build breaks if ts/ is built first. --- rslib/i18n/build/write_json.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rslib/i18n/build/write_json.rs b/rslib/i18n/build/write_json.rs index d282bec49..973c21e94 100644 --- a/rslib/i18n/build/write_json.rs +++ b/rslib/i18n/build/write_json.rs @@ -1,16 +1,12 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -use std::{ - env, fs, - path::{Path, PathBuf}, -}; +use std::{env, fs, path::Path}; pub fn main() { let args: Vec<_> = env::args().collect(); let target_file = Path::new(args.get(1).expect("output path not provided")); + let strings_json = include_str!(concat!(env!("OUT_DIR"), "/strings.json")); - let dir = PathBuf::from(env!("OUT_DIR")); - let path = dir.join("strings.json"); - fs::copy(path, target_file).unwrap(); + fs::write(target_file, strings_json).unwrap(); }