62 * dosys(command, ignore_error, call_make, silent_error, target)
63 *
64 * Check if command string contains meta chars and dispatch to
65 * the proper routine for executing one command line.
66 *
67 * Return value:
68 * Indicates if the command execution failed
69 *
70 * Parameters:
71 * command The command to run
72 * ignore_error Should make abort when an error is seen?
73 * call_make Did command reference $(MAKE) ?
74 * silent_error Should error messages be suppressed for pmake?
75 * target Target we are building
76 *
77 * Global variables used:
78 * do_not_exec_rule Is -n on?
79 * working_on_targets We started processing real targets
80 */
81 Doname
82 dosys(register Name command, register Boolean ignore_error, register Boolean call_make, Boolean silent_error, Boolean always_exec, Name target, Boolean redirect_out_err)
83 {
84 timestruc_t before;
85 register int length = command->hash.length;
86 Wstring wcb(command);
87 register wchar_t *p = wcb.get_string();
88 register wchar_t *q;
89 Doname result;
90
91 /* Strip spaces from head of command string */
92 while (iswspace(*p)) {
93 p++, length--;
94 }
95 if (*p == (int) nul_char) {
96 return build_failed;
97 }
98 /* If we are faking it we just return */
99 if (do_not_exec_rule &&
100 working_on_targets &&
101 !call_make &&
102 !always_exec) {
107
108 /* Copy string to make it OK to write it. */
109 q = ALLOC_WC(length + 1);
110 (void) wscpy(q, p);
111 /* Write the state file iff this command uses make. */
112 if (call_make && command_changed) {
113 write_state_file(0, false);
114 }
115 make_state->stat.time = file_no_time;
116 (void)exists(make_state);
117 before = make_state->stat.time;
118 /*
119 * Run command directly if it contains no shell meta chars,
120 * else run it using the shell.
121 */
122 if (await(ignore_error,
123 silent_error,
124 target,
125 wcb.get_string(),
126 command->meta ?
127 doshell(q, ignore_error, redirect_out_err,
128 stdout_file, stderr_file, 0) :
129 doexec(q, ignore_error, redirect_out_err,
130 stdout_file, stderr_file,
131 vroot_path, 0),
132 send_mtool_msgs,
133 NULL,
134 -1
135 )) {
136 result = build_ok;
137 } else {
138 result = build_failed;
139 }
140 retmem(q);
141
142 if ((report_dependencies_level == 0) &&
143 call_make) {
144 make_state->stat.time = file_no_time;
145 (void)exists(make_state);
146 if (before == make_state->stat.time) {
147 return result;
148 }
149 makefile_type = reading_statefile;
150 if (read_trace_level > 1) {
151 trace_reader = true;
152 }
|
62 * dosys(command, ignore_error, call_make, silent_error, target)
63 *
64 * Check if command string contains meta chars and dispatch to
65 * the proper routine for executing one command line.
66 *
67 * Return value:
68 * Indicates if the command execution failed
69 *
70 * Parameters:
71 * command The command to run
72 * ignore_error Should make abort when an error is seen?
73 * call_make Did command reference $(MAKE) ?
74 * silent_error Should error messages be suppressed for pmake?
75 * target Target we are building
76 *
77 * Global variables used:
78 * do_not_exec_rule Is -n on?
79 * working_on_targets We started processing real targets
80 */
81 Doname
82 dosys(register Name command, register Boolean ignore_error, register Boolean call_make, Boolean silent_error, Boolean always_exec, Name target)
83 {
84 timestruc_t before;
85 register int length = command->hash.length;
86 Wstring wcb(command);
87 register wchar_t *p = wcb.get_string();
88 register wchar_t *q;
89 Doname result;
90
91 /* Strip spaces from head of command string */
92 while (iswspace(*p)) {
93 p++, length--;
94 }
95 if (*p == (int) nul_char) {
96 return build_failed;
97 }
98 /* If we are faking it we just return */
99 if (do_not_exec_rule &&
100 working_on_targets &&
101 !call_make &&
102 !always_exec) {
107
108 /* Copy string to make it OK to write it. */
109 q = ALLOC_WC(length + 1);
110 (void) wscpy(q, p);
111 /* Write the state file iff this command uses make. */
112 if (call_make && command_changed) {
113 write_state_file(0, false);
114 }
115 make_state->stat.time = file_no_time;
116 (void)exists(make_state);
117 before = make_state->stat.time;
118 /*
119 * Run command directly if it contains no shell meta chars,
120 * else run it using the shell.
121 */
122 if (await(ignore_error,
123 silent_error,
124 target,
125 wcb.get_string(),
126 command->meta ?
127 doshell(q, ignore_error,
128 stdout_file, stderr_file, 0) :
129 doexec(q, ignore_error,
130 stdout_file, stderr_file,
131 vroot_path, 0),
132 NULL,
133 -1
134 )) {
135 result = build_ok;
136 } else {
137 result = build_failed;
138 }
139 retmem(q);
140
141 if ((report_dependencies_level == 0) &&
142 call_make) {
143 make_state->stat.time = file_no_time;
144 (void)exists(make_state);
145 if (before == make_state->stat.time) {
146 return result;
147 }
148 makefile_type = reading_statefile;
149 if (read_trace_level > 1) {
150 trace_reader = true;
151 }
|