set(_c ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.c)
if (_ext STREQUAL ".cpkg")
add_custom_command(
- OUTPUT ${_li}
+ OUTPUT ${_li} ${_c}
MAIN_DEPENDENCY ${_abs}
- COMMAND ${madmutt_SOURCE_DIR}/tools/cpkg2c -h ${_abs} -o ${_li}
- COMMENT "Generating ${_li} from ${_abs}"
- )
- add_custom_command(
- OUTPUT ${_c}
- MAIN_DEPENDENCY ${_abs}
- COMMAND ${madmutt_SOURCE_DIR}/tools/cpkg2c -c ${_abs} -o ${_c}
- COMMENT "Generating ${_c} from ${_abs}"
+ COMMAND ${madmutt_SOURCE_DIR}/tools/cpkg2c ${_abs} ${_li} ${_c}
+ COMMENT "Preprocessing ${_abs}"
)
list(APPEND ${_result} ${_li} ${_c})
list(APPEND ${_gen} ${_li} ${_c})
(* }}} *)
let usage () =
- output_string stderr "usage: cpkg2c (-h | -c) file.cpkg -o output\n";
+ output_string stderr "usage: cpkg2c file.cpkg header.out source.out\n";
exit 1
+ let warn ob = output_endline ob "/*** THIS FILE IS AUTOGENERATED !!! ***/"
+
+ let process fn file l =
+ try Unix.unlink file with _ -> ();
+ let ob = open_out_gen [ Open_trunc ; Open_wronly; Open_creat ] 0o444 file in
+ warn ob; fn ob l; close_out ob
+
let _ =
- let warn ob = output_endline ob "/*** THIS FILE IS AUTOGENERATED !!! ***/" in
- if Array.length Sys.argv != 5 then usage();
- let file = Sys.argv.(2) in
+ if Array.length Sys.argv != 4 then usage();
+ let file = Sys.argv.(1) in
let lexbuf = L.from_channel (open_in file) in
let l = (startchunk cLine file lexbuf) in
- if Sys.argv.(3) = "-o" then (
- try Unix.unlink Sys.argv.(4) with _ -> ();
- let ob = open_out_gen [ Open_trunc ; Open_wronly; Open_creat ] 0o444 Sys.argv.(4) in
- match Sys.argv.(1) with
- | "-h" -> warn ob; do_h ob l; close_out ob
- | "-c" -> warn ob; do_c ob l; close_out ob
- | _ -> usage ()
- ) else
- usage();
+ process do_h Sys.argv.(2) l;
+ process do_c Sys.argv.(3) l
}