Support ENV variables in CD names

This commit is contained in:
Jaby 2024-03-21 16:51:17 -05:00
parent cb6dbbb346
commit f865be0c7c
4 changed files with 13 additions and 4 deletions

View File

@ -12,14 +12,17 @@ endif
ifeq ($(REGION),SCEE) ifeq ($(REGION),SCEE)
export TV_FORMAT=PAL export TV_FORMAT=PAL
export LICENSE=LICENSEE export LICENSE=LICENSEE
export BOOT=SLES_000.25
endif endif
ifeq ($(REGION),SCEA) ifeq ($(REGION),SCEA)
export TV_FORMAT=NTSC export TV_FORMAT=NTSC
export LICENSE=LICENSEA export LICENSE=LICENSEA
export BOOT=SLUS_001.51
endif endif
ifeq ($(REGION),SCEI) ifeq ($(REGION),SCEI)
export TV_FORMAT=NTSC export TV_FORMAT=NTSC
export LICENSE=LICENSEJ export LICENSE=LICENSEJ
export BOOT=XXXX_AAA.AA
endif endif
ifndef TV_FORMAT ifndef TV_FORMAT

View File

@ -6,7 +6,7 @@
<Track> <Track>
<File name = "SYSTEM.CNF">System.cnf</File> <File name = "SYSTEM.CNF">System.cnf</File>
<!--For pkg use: SLES_000.25;1 or SLUS_001.51;1 - no japanse version yet. Otherwise leave as "XXXX_AAA.AA"--> <!--For pkg use: SLES_000.25;1 or SLUS_001.51;1 - no japanse version yet. Otherwise leave as "XXXX_AAA.AA"-->
<Main name = "SLES_000.25" lba_source = "../application/src/asset_mgr.cpp">../application/bin/%TV_FORMAT%/PSX-release/PoolBox.psexe</Main> <Main name = "%BOOT%" lba_source = "../application/src/asset_mgr.cpp">../application/bin/%TV_FORMAT%/PSX-release/PoolBox.psexe</Main>
<Overlay name = "CTO.BIN" lba_source = "../application/src/Overlay/ControllerTest/controller_test_assets.cpp">../application/bin/%TV_FORMAT%/PSX-release/Overlay.controller_tests</Overlay> <Overlay name = "CTO.BIN" lba_source = "../application/src/Overlay/ControllerTest/controller_test_assets.cpp">../application/bin/%TV_FORMAT%/PSX-release/Overlay.controller_tests</Overlay>
<Overlay name = "GTO.BIN" lba_source = "../application/src/Overlay/GPUTest/gpu_test_assets.cpp">../application/bin/%TV_FORMAT%/PSX-release/Overlay.gpu_tests</Overlay> <Overlay name = "GTO.BIN" lba_source = "../application/src/Overlay/GPUTest/gpu_test_assets.cpp">../application/bin/%TV_FORMAT%/PSX-release/Overlay.gpu_tests</Overlay>
<Overlay name = "GTE.BIN">../application/bin/%TV_FORMAT%/PSX-release/Overlay.gte_tests</Overlay> <Overlay name = "GTE.BIN">../application/bin/%TV_FORMAT%/PSX-release/Overlay.gte_tests</Overlay>

View File

@ -1,5 +1,5 @@
use std::path::PathBuf; use std::path::PathBuf;
use tool_helper::{format_if_error, path_with_env_from}; use tool_helper::{format_if_error, path_with_env_from, string_with_env_from};
use crate::config_reader::Directory; use crate::config_reader::Directory;
use super::{CommonProperties, Configuration, Error, File, FileKind, LZ4State}; use super::{CommonProperties, Configuration, Error, File, FileKind, LZ4State};
@ -132,7 +132,7 @@ fn read_common_properties(xml: &roxmltree::Node, is_hidden: bool, force_lz4_stat
}; };
Ok(CommonProperties{ Ok(CommonProperties{
name: String::from(xml.attribute(attribute_names::NAME).unwrap_or_default()), name: string_with_env_from(xml.attribute(attribute_names::NAME).unwrap_or_default()),
is_hidden: is_hidden | parse_boolean_attribute(&xml, attribute_names::HIDDEN)?, is_hidden: is_hidden | parse_boolean_attribute(&xml, attribute_names::HIDDEN)?,
lz4_state, lz4_state,
padded_size: read_padded_size(&xml)? padded_size: read_padded_size(&xml)?

View File

@ -38,6 +38,8 @@ macro_rules! format_if_error_drop_cause {
}; };
} }
const DEFAULT_ENV_EXPAND_OPTIONS : ExpandOptions = ExpandOptions{expansion_type: Some(ExpansionType::All), default_to_empty: false};
pub struct Error { pub struct Error {
pub exit_code: i32, pub exit_code: i32,
pub text: String, pub text: String,
@ -162,8 +164,12 @@ pub fn callback_if_any_error<F: Fn(String) -> String, T, E: std::string::ToStrin
} }
} }
pub fn string_with_env_from(str: &str) -> String {
String::from(envmnt::expand(str, Some(DEFAULT_ENV_EXPAND_OPTIONS)))
}
pub fn path_with_env_from(path: &str) -> PathBuf { pub fn path_with_env_from(path: &str) -> PathBuf {
PathBuf::from(envmnt::expand(path, Some(ExpandOptions{expansion_type: Some(ExpansionType::All), default_to_empty: false}))) PathBuf::from(envmnt::expand(path, Some(DEFAULT_ENV_EXPAND_OPTIONS)))
} }
pub fn open_output_file(output_path: &PathBuf) -> Result<BufWriter<std::fs::File>, Error> { pub fn open_output_file(output_path: &PathBuf) -> Result<BufWriter<std::fs::File>, Error> {