Changeset 1993 for trunk/src/kmk/job.c


Ignore:
Timestamp:
Oct 29, 2008, 1:37:51 AM (17 years ago)
Author:
bird
Message:

Merged in current GNU Make code (CVS from 2008-10-28). Ref #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/job.c

    r1980 r1993  
    11/* Job execution and handling for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    44Foundation, Inc.
    55This file is part of GNU Make.
     
    77GNU Make is free software; you can redistribute it and/or modify it under the
    88terms of the GNU General Public License as published by the Free Software
    9 Foundation; either version 2, or (at your option) any later version.
     9Foundation; either version 3 of the License, or (at your option) any later
     10version.
    1011
    1112GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     
    1415
    1516You should have received a copy of the GNU General Public License along with
    16 GNU Make; see the file COPYING.  If not, write to the Free Software
    17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
     17this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1818
    1919#include "make.h"
     
    10911091    argv = p;
    10921092#else
    1093     argv = construct_command_argv (p, &end, child->file, &child->sh_batch_file);
     1093    argv = construct_command_argv (p, &end, child->file,
     1094                                   child->file->cmds->lines_flags[child->command_line - 1],
     1095                                   &child->sh_batch_file);
    10941096#endif
    10951097    if (end == NULL)
     
    15661568  struct file *f = c->file;
    15671569#ifdef DB_KMK
    1568   DB (DB_KMK, (_("start_waiting_job %p (`%s') command_flags=%#x slots=%d/%d\n"), c, c->file->name, c->file->command_flags, job_slots_used, job_slots));
     1570  DB (DB_KMK, (_("start_waiting_job %p (`%s') command_flags=%#x slots=%d/%d\n"),
     1571               (void *)c, c->file->name, c->file->command_flags, job_slots_used, job_slots));
    15691572#endif
    15701573
     
    15791582    {
    15801583      DB (DB_KMK, (_("not_parallel %d -> %d (file=%p `%s') [start_waiting_job]\n"),
    1581                    not_parallel, not_parallel + 1, c->file, c->file->name));
     1584                   not_parallel, not_parallel + 1, (void *)c->file, c->file->name));
    15821585      assert(not_parallel >= 0);
    15831586      ++not_parallel;
     
    16211624      else /* FIXME: insert after the last node with COMMANDS_NOTPARALLEL set */
    16221625        waiting_jobs = c;
    1623       DB (DB_KMK, (_("queued child %p (`%s')\n"), c, c->file->name));
     1626      DB (DB_KMK, (_("queued child %p (`%s')\n"), (void *)c, c->file->name));
    16241627#endif /* CONFIG_WITH_EXTENDED_NOTPARALLEL */
    16251628      return 0;
     
    19051908
    19061909  /* The job is now primed.  Start it running.
    1907      (This will notice if there are in fact no commands.)  */
     1910     (This will notice if there is in fact no recipe.)  */
    19081911  if (cmds->fileinfo.filenm)
    1909     DB (DB_BASIC, (_("Invoking commands from %s:%lu to update target `%s'.\n"),
     1912    DB (DB_BASIC, (_("Invoking recipe from %s:%lu to update target `%s'.\n"),
    19101913                   cmds->fileinfo.filenm, cmds->fileinfo.lineno,
    19111914                   c->file->name));
    19121915  else
    1913     DB (DB_BASIC, (_("Invoking builtin commands to update target `%s'.\n"),
     1916    DB (DB_BASIC, (_("Invoking builtin recipe to update target `%s'.\n"),
    19141917                   c->file->name));
    19151918
     
    21182121
    21192122/* EMX: Start a child process. This function returns the new pid.  */
    2120 # if defined __MSDOS__ || defined __EMX__
     2123# if defined __EMX__
    21212124int
    21222125child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
     
    24212424
    24222425   SHELL is the shell to use, or nil to use the default shell.
    2423    IFS is the value of $IFS, or nil (meaning the default).  */
     2426   IFS is the value of $IFS, or nil (meaning the default).
     2427
     2428   FLAGS is the value of lines_flags for this command line.  It is
     2429   used in the WINDOWS32 port to check whether + or $(MAKE) were found
     2430   in this command line, in which case the effect of just_print_flag
     2431   is overridden.  */
    24242432
    24252433static char **
    24262434construct_command_argv_internal (char *line, char **restp, char *shell,
    2427                                  char *ifs, char **batch_filename_ptr)
     2435                                 char *ifs, int flags,
     2436                                 char **batch_filename_ptr)
    24282437{
    24292438#ifdef __MSDOS__
     
    27192728                  *(ap++) = *p;
    27202729                }
    2721               /* If there's a command prefix char here, skip it.  */
    2722               if (p[1] == cmd_prefix)
    2723                 ++p;
    27242730            }
    27252731          else if (*p == '\n' && restp != NULL)
     
    27872793                ++p;
    27882794
    2789                 /* If there is a command prefix after a backslash-newline,
    2790                    remove it.  */
    2791                 if (p[1] == cmd_prefix)
    2792                   ++p;
    2793 
    27942795                /* If there's nothing in this argument yet, skip any
    27952796                   whitespace before the start of the next word.  */
     
    30243025        else if (*p == '\\' && p[1] == '\n')
    30253026          {
    3026             /* POSIX says we keep the backslash-newline, but throw out
    3027                the next char if it's a TAB.  If we don't have a POSIX
    3028                shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
     3027            /* POSIX says we keep the backslash-newline.  If we don't have a
     3028               POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
    30293029               and remove the backslash/newline.  */
    30303030#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
     
    30363036              {
    30373037                *(ap++) = '\\';
    3038 #ifdef KMK /* see test in Makefile.kmk, required on windows. */
    3039                 if (!batch_mode_shell)
    3040 #endif
    3041                 *(ap++) = '\\';
     3038                /* Only non-batch execution needs another backslash,
     3039                   because it will be passed through a recursive
     3040                   invocation of this function.  */
     3041                if (!batch_mode_shell)
     3042                  *(ap++) = '\\';
    30423043                *(ap++) = '\n';
    30433044              }
    3044 
    30453045            ++p;
    3046             if (p[1] == cmd_prefix)
    3047               ++p;
    3048 
    30493046            continue;
    30503047          }
     
    30763073       command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems).  In these
    30773074       cases, run commands via a script file.  */
    3078     if (just_print_flag) {
     3075    if (just_print_flag && !(flags & COMMANDS_RECURSE)) {
    30793076      /* Need to allocate new_argv, although it's unused, because
    30803077        start_job_command will want to free it and its 0'th element.  */
     
    31093106      fputc ('\n', batch);
    31103107      fclose (batch);
     3108      DB (DB_JOBS, (_("Batch file contents:%s\n\t%s\n"),
     3109                    !unixy_shell ? "\n\t@echo off" : "", command_ptr));
    31113110
    31123111      /* create argv */
     
    31233122#endif /* WINDOWS32 */
    31243123    if (unixy_shell)
    3125       new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0);
     3124      new_argv = construct_command_argv_internal (new_line, 0, 0, 0, flags, 0);
    31263125#ifdef __EMX__
    31273126    else if (!unixy_shell)
     
    31383137          {
    31393138            if (q[0] == '\\' && q[1] == '\n')
    3140               {
    3141                 q += 2; /* remove '\\' and '\n' */
    3142                 /* Remove any command prefix in the next line */
    3143                 if (q[0] == cmd_prefix)
    3144                   q++;
    3145               }
     3139              q += 2; /* remove '\\' and '\n' */
    31463140            else
    31473141              *p++ = *q++;
     
    32343228char **
    32353229construct_command_argv (char *line, char **restp, struct file *file,
    3236                         char **batch_filename_ptr)
     3230                        int cmd_flags, char **batch_filename_ptr)
    32373231{
    32383232  char *shell, *ifs;
     
    33663360    unixy_shell = 1;
    33673361    batch_mode_shell = 0;
    3368     argv = construct_command_argv_internal (line, restp, shell, ifs, batch_filename_ptr);
     3362    argv = construct_command_argv_internal (line, restp, shell, ifs,
     3363                                            cmd_flags, batch_filename_ptr);
    33693364    batch_mode_shell = saved_batch_mode_shell;
    33703365    unixy_shell = saved_unixy_shell;
     
    33753370  else
    33763371#endif /* CONFIG_WITH_KMK_BUILTIN */
    3377   argv = construct_command_argv_internal (line, restp, shell, ifs, batch_filename_ptr);
     3372  argv = construct_command_argv_internal (line, restp, shell, ifs,
     3373                                          cmd_flags, batch_filename_ptr);
    33783374
    33793375  free (shell);
Note: See TracChangeset for help on using the changeset viewer.