@@ -26,7 +26,7 @@ use crate::{
2626 config:: { apply_splits, parse_symbol_line, write_splits, write_symbols} ,
2727 dol:: process_dol,
2828 elf:: { process_elf, write_elf} ,
29- file:: { map_file, map_reader} ,
29+ file:: { map_file, map_reader, touch } ,
3030 lcf:: { asm_path_for_unit, generate_ldscript, obj_path_for_unit} ,
3131 } ,
3232} ;
@@ -74,6 +74,9 @@ pub struct SplitArgs {
7474 #[ argp( option, short = 'e' ) ]
7575 /// ELF file to validate against (debugging only)
7676 elf_file : Option < PathBuf > ,
77+ #[ argp( switch) ]
78+ /// skip updating splits & symbol files (for build systems)
79+ no_update : bool ,
7780}
7881
7982pub fn run ( args : Args ) -> Result < ( ) > {
@@ -179,20 +182,22 @@ fn split(args: SplitArgs) -> Result<()> {
179182 log:: info!( "Detecting strings" ) ;
180183 detect_strings ( & mut obj) ?;
181184
182- if let Some ( symbols_path) = & args. symbols_file {
183- let mut symbols_writer = BufWriter :: new (
184- File :: create ( symbols_path)
185- . with_context ( || format ! ( "Failed to create '{}'" , symbols_path. display( ) ) ) ?,
186- ) ;
187- write_symbols ( & mut symbols_writer, & obj) ?;
188- }
185+ if !args. no_update {
186+ if let Some ( symbols_path) = & args. symbols_file {
187+ let mut symbols_writer = BufWriter :: new (
188+ File :: create ( symbols_path)
189+ . with_context ( || format ! ( "Failed to create '{}'" , symbols_path. display( ) ) ) ?,
190+ ) ;
191+ write_symbols ( & mut symbols_writer, & obj) ?;
192+ }
189193
190- if let Some ( splits_path) = & args. splits_file {
191- let mut splits_writer = BufWriter :: new (
192- File :: create ( splits_path)
193- . with_context ( || format ! ( "Failed to create '{}'" , splits_path. display( ) ) ) ?,
194- ) ;
195- write_splits ( & mut splits_writer, & obj) ?;
194+ if let Some ( splits_path) = & args. splits_file {
195+ let mut splits_writer = BufWriter :: new (
196+ File :: create ( splits_path)
197+ . with_context ( || format ! ( "Failed to create '{}'" , splits_path. display( ) ) ) ?,
198+ ) ;
199+ write_splits ( & mut splits_writer, & obj) ?;
200+ }
196201 }
197202
198203 log:: info!( "Adjusting splits" ) ;
@@ -202,6 +207,7 @@ fn split(args: SplitArgs) -> Result<()> {
202207 let split_objs = split_obj ( & obj) ?;
203208
204209 // Create out dirs
210+ touch ( & args. out_dir ) ?;
205211 let asm_dir = args. out_dir . join ( "asm" ) ;
206212 let include_dir = args. out_dir . join ( "include" ) ;
207213 let obj_dir = args. out_dir . join ( "obj" ) ;
0 commit comments