Esempio n. 1
0
void
execute_file_commands (struct file *file)
{
    const char *p;

    /* Don't go through all the preparations if
       the commands are nothing but whitespace.  */

    for (p = file->cmds->commands; *p != '\0'; ++p)
        if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
            break;
    if (*p == '\0')
    {
        /* If there are no commands, assume everything worked.  */
        set_command_state (file, cs_running);
        file->update_status = 0;
        notice_finished_file (file);
        return;
    }

    /* First set the automatic variables according to this file.  */

    initialize_file_variables (file, 0);

    set_file_variables (file);

    /* Start the commands running.  */
    new_job (file);
}
Esempio n. 2
0
void
execute_file_commands (struct file *file)
{
  const char *p;

  /* Don't go through all the preparations if
     the commands are nothing but whitespace.  */

  for (p = file->cmds->commands; *p != '\0'; ++p)
    if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
      break;
  if (*p == '\0')
    {
      /* If there are no commands, assume everything worked.  */
      set_command_state (file, cs_running);
      file->update_status = us_success;
      notice_finished_file (file);
      return;
    }

  /* First set the automatic variables according to this file.  */

  initialize_file_variables (file, 0);

  set_file_variables (file);

  /* If this is a loaded dynamic object, unload it before remaking.
     Some systems don't support overwriting a loaded object.  */
  if (file->loaded)
    unload_file (file->name);

  /* Start the commands running.  */
  new_job (file);
}
Esempio n. 3
0
File: fns.c Progetto: chaosAD/remake
/*! Show a expression. Set "expand" to 1 if you want variable
   definitions inside the displayed value expanded.
*/
bool
dbg_cmd_show_exp (char *psz_varname, bool expand) 
{
  if (!psz_varname || 0==strlen(psz_varname)) {
    printf(_("You need to supply a variable name.\n"));
    return false;
  } else {
    variable_t *p_v;
    variable_set_t *p_set = NULL;
    variable_set_list_t *p_file_vars = NULL;
    if (p_stack && p_stack->p_target && p_stack->p_target->name) {
      const char *psz_target = p_stack->p_target->name;
      file_t *p_target = lookup_file (psz_target);
      if (p_target) {
	initialize_file_variables (p_target, 0);
	set_file_variables (p_target);
	p_file_vars = p_target->variables;
	p_set = p_file_vars->set;
      }
    }
    if (p_set) {
      p_v = lookup_variable_in_set(psz_varname, strlen(psz_varname), p_set);
      if (!p_v) 
	/* May be a global variable. */
	p_v = lookup_variable (psz_varname, strlen (psz_varname));
    } else {
      p_v = lookup_variable (psz_varname, strlen (psz_varname));
    }
    if (p_v) {
      if (expand) {
	print_variable_expand(p_v);
      } else
	print_variable(p_v);
    } else {
      if (expand)
	printf("%s\n", variable_expand_set(psz_varname, p_file_vars));
      else {
	try_without_dollar(psz_varname);
	return false;
      }
    }
  }
  return true;
}
Esempio n. 4
0
/*!
  Print out the commands.

  @param p_cmds location of commands to print out.
  @param p_target used to set automatic variables if it is non-null.
  @param b_expand if true, expand the commands to remove MAKE variables.
*/
void
print_commands (file_t *p_target, commands_t *p_cmds, bool b_expand)
{
  char *s;

  fputs (_("#  commands to execute"), stdout);

  if (p_cmds->fileinfo.filenm == 0)
    puts (_(" (built-in):"));
  else
    printf (_(" (from `%s', line %lu):\n"),
            p_cmds->fileinfo.filenm, p_cmds->fileinfo.lineno);

  if (b_expand && p_target) {
    variable_set_list_t *p_file_vars = NULL;
    variable_set_t *p_set = NULL;
    initialize_file_variables (p_target, 0);
    set_file_variables (p_target);
    p_file_vars = p_target->variables;
    p_set = p_file_vars->set;
    if (p_set != NULL) {
      ; /* ??? */
    }
    s = variable_expand_set(p_cmds->commands, p_file_vars);
  } else {
    s = p_cmds->commands;
  }

  while (*s != '\0')
    {
      char *end;

      while (isspace ((unsigned char)*s))
	++s;

      end = strchr (s, '\n');
      if (end == 0)
	end = s + strlen (s);

      printf ("\t%.*s\n", (int) (end - s), s);

      s = end;
    }
}