Give 'ghc -E' the traditional behaviour: the output is dumped to
stdout. The new driver also generates <file>.cpp.
let (basename,ext) = split_filename input_fn
let (basename,ext) = split_filename input_fn
- split <- readIORef split_object_files
+ split <- readIORef split_object_files
mangle <- readIORef do_asm_mangling
mangle <- readIORef do_asm_mangling
- lang <- readIORef hsc_lang
+ lang <- readIORef hsc_lang
-- figure out what the next phase is. This is
-- straightforward, apart from the fact that hsc can generate
-- either C or assembler direct, and assembly mangling is
-- figure out what the next phase is. This is
-- straightforward, apart from the fact that hsc can generate
-- either C or assembler direct, and assembly mangling is
+ -- optional, and splitting involves one extra phase and an alternate
+ -- assembler.
let next_phase =
case phase of
Hsc -> case lang of
let next_phase =
case phase of
Hsc -> case lang of
- -- filename extension for the output
+ -- filename extension for the output, determined by next_phase
let new_ext = phase_input_ext next_phase
-- Figure out what the output from this pass should be called.
let new_ext = phase_input_ext next_phase
-- Figure out what the output from this pass should be called.
osuf_ify f
-- .o files are always kept. .s files and .hc file may be kept.
osuf_ify f
-- .o files are always kept. .s files and .hc file may be kept.
- else if keep_this_output
+ else if keep_this_output
then odir_ify (orig_basename ++ '.':new_ext)
else do filename <- newTempName new_ext
add files_to_clean filename
then odir_ify (orig_basename ++ '.':new_ext)
else do filename <- newTempName new_ext
add files_to_clean filename
run_phase phase orig_basename input_fn output_fn
run_phase phase orig_basename input_fn output_fn
+ -- sadly, ghc -E is supposed to write the file to stdout. We
+ -- generate <file>.cpp, so we also have to cat the file here.
+ if (next_phase > last_phase && last_phase == Cpp)
+ then run_something "Dump pre-processed file to stdout"
+ ("cat " ++ output_fn)
+ else return ()
+
run_pipeline last_phase do_linking use_ofile
orig_basename (next_phase, output_fn)
run_pipeline last_phase do_linking use_ofile
orig_basename (next_phase, output_fn)