(** Represent a rule as found in the "implicit rules" and "files" section.
- TODO 2012-10-29: Do we need to store r_next?
+ TODO 2012-10-29: Do we need to store r_next? *)
let s_of_rule_commands (r : rule) : string =
String.concat "" (L.map s_of_command r.r_commands)
+(** Get a string list of commands to be executed by sh. *)
+let s_list_of_rule_commands (r : rule) : string list =
+ L.map s_of_command r.r_commands
(** Convert the rule targets to a string. *)
let s_of_rule_targets (r : rule) : string =
String.concat " " r.r_targets
S.global_replace (S.regexp "^.*$") (String.make i '\t' ^ "\\0") s
(** Create a list of commands based on our own data structures, not the data
-from the head of the database file. *)
+from the head of the database file. *)
let generate_commands (d : database) (ts : target list) : string =
let head = Printf.sprintf "# Generating commands for targets \"%s\"\n"
- let commands = s_of_rule_commands rule in
+ let commands = s_list_of_rule_commands rule in
+ let commands = replace_variables d.d_variables commands in
+ let commands = String.concat "\n" commands in
let commands = U.re_replace "\n+$" "\n" commands in