Print this page
make: unifdef for MAKETOOL and DISTRIBUTED (undefined)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/doname.cc
          +++ new/usr/src/cmd/make/bin/doname.cc
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27   *      doname.c
  28   28   *
  29   29   *      Figure out which targets are out of date and rebuild them
  30   30   */
  31   31  
  32   32  /*
  33   33   * Included files
  34   34   */
  35   35  #include <alloca.h>             /* alloca() */
  36   36  
  37      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
  38      -#       include <avo/strings.h> /* AVO_STRDUP() */
  39      -#       include <dm/Avo_MToolJobResultMsg.h>
  40      -#       include <dm/Avo_MToolJobStartMsg.h>
  41      -#       include <dm/Avo_MToolRsrcInfoMsg.h>
  42      -#       include <dm/Avo_macro_defs.h> /* AVO_BLOCK_INTERUPTS & AVO_UNBLOCK_INTERUPTS */
  43      -#       include <dmthread/Avo_ServerState.h>
  44      -#       include <rw/pstream.h>
  45      -#       include <rw/xdrstrea.h>
  46      -#endif
  47   37  
  48   38  #include <fcntl.h>
  49   39  #include <mk/defs.h>
  50   40  #include <mksh/i18n.h>          /* get_char_semantics_value() */
  51   41  #include <mksh/macro.h>         /* getvar(), expand_value() */
  52   42  #include <mksh/misc.h>          /* getmem() */
  53   43  #include <poll.h>
  54   44  
  55   45  
  56   46  #include <signal.h>
↓ open down ↓ 7 lines elided ↑ open up ↑
  64   54  #include <sys/wait.h>
  65   55  #include <unistd.h>             /* close() */
  66   56  
  67   57  /*
  68   58   * Defined macros
  69   59   */
  70   60  #       define LOCALHOST "localhost"
  71   61  
  72   62  #define MAXRULES 100
  73   63  
  74      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
  75      -#define SEND_MTOOL_MSG(cmds) \
  76      -        if (send_mtool_msgs) { \
  77      -                cmds \
  78      -        }
  79      -#else
  80   64  #define SEND_MTOOL_MSG(cmds) 
  81      -#endif
  82   65  
  83   66  // Sleep for .1 seconds between stat()'s
  84   67  const int       STAT_RETRY_SLEEP_TIME = 100000;
  85   68  
  86   69  /*
  87   70   * typedefs & structs
  88   71   */
  89   72  
  90   73  /*
  91   74   * Static variables
  92   75   */
  93   76  static char     hostName[MAXNAMELEN] = "";
  94   77  static char     userName[MAXNAMELEN] = "";
  95   78  
  96      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
  97      -        static FILE     *mtool_msgs_fp;
  98      -        static XDR      xdrs;
  99      -        static int      sent_rsrc_info_msg = 0;
 100      -#endif
 101   79  
 102   80  static int      second_pass = 0;
 103   81  
 104   82  /*
 105   83   * File table of contents
 106   84   */
 107   85  extern  Doname          doname_check(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic);
 108   86  extern  Doname          doname(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic);
 109   87  static  Boolean         check_dependencies(Doname *result, Property line, Boolean do_get, Name target, Name true_target, Boolean doing_subtree, Chain *out_of_date_tail, Property old_locals, Boolean implicit, Property *command, Name less, Boolean rechecking_target, Boolean recheck_conditionals);
 110   88  void            dynamic_dependencies(Name target);
↓ open down ↓ 12 lines elided ↑ open up ↑
 123  101  static  void            add_pattern_conditionals(register Name target);
 124  102  extern  void            set_locals(register Name target, register Property old_locals);
 125  103  extern  void            reset_locals(register Name target, register Property old_locals, register Property conditional, register int index);
 126  104  extern  Boolean         check_auto_dependencies(Name target, int auto_count, Name *automatics);
 127  105  static  void            delete_query_chain(Chain ch);
 128  106  
 129  107  // From read2.cc
 130  108  extern  Name            normalize_name(register wchar_t *name_string, register int length);
 131  109  
 132  110  
 133      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
 134      -        static void             append_job_result_msg(Avo_MToolJobResultMsg *job_result_msg);
 135      -        static int              pollResults(char *outFn, char *errFn, char *hostNm);
 136      -        static void             pollResultsAction(char *outFn, char *errFn);
 137      -        static void             rxmGetNextResultsBlock(int fd);
 138      -        static int              us_sleep(unsigned int nusecs);
 139      -        extern "C" void         Avo_PollResultsAction_Sigusr1Handler(int foo);
 140      -#endif
 141  111  
 142  112  /*
 143  113   * DONE.
 144  114   *
 145  115   *      doname_check(target, do_get, implicit, automatic)
 146  116   *
 147  117   *      Will call doname() and then inspect the return value
 148  118   *
 149  119   *      Return value:
 150  120   *                              Indication if the build failed or not
↓ open down ↓ 861 lines elided ↑ open up ↑
1012  982                  }
1013  983  
1014  984                  if (dependency->name == wait_name) {
1015  985                          /*
1016  986                           * The special target .WAIT means finish all of
1017  987                           * the prior dependencies before continuing.
1018  988                           */
1019  989                          if (dependencies_running) {
1020  990                                  break;
1021  991                          }
1022      -#ifdef DISTRIBUTED
1023      -                } else if ((!parallel_ok(dependency->name, false)) &&
1024      -                           (dependencies_running)) {
1025      -                        /*
1026      -                         * If we can't execute the current dependency in
1027      -                         * parallel, hold off the dependency processing
1028      -                         * to preserve the order of the dependencies.
1029      -                         */
1030      -                        break;
1031      -#endif
1032  992                  } else {
1033  993                          timestruc_t     depe_time = file_doesnt_exist;
1034  994  
1035  995  
1036  996                          if (true_target->is_member) {
1037  997                                  depe_time = exists(dependency->name);
1038  998                          }
1039  999                          if (dependency->built ||
1040 1000                              (dependency->name->state == build_failed)) {
1041 1001                                  dep_result = (Doname) dependency->name->state;
↓ open down ↓ 795 lines elided ↑ open up ↑
1837 1797   *              do_not_exec_rule -n flag
1838 1798   *              report_dependencies -P flag
1839 1799   *              silent          Don't echo commands before executing
1840 1800   *              temp_file_name  Temp file for auto dependencies
1841 1801   *              vpath_defined   If true, translate path for command
1842 1802   */
1843 1803  Doname
1844 1804  execute_serial(Property line)
1845 1805  {
1846 1806          int                     child_pid = 0;
1847      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
1848      -        Avo_MToolJobResultMsg   *job_result_msg;
1849      -        RWCollectable           *xdr_msg;
1850      -#endif
1851 1807          Boolean                 printed_serial;
1852 1808          Doname                  result = build_ok;
1853 1809          Cmd_line                rule, cmd_tail, command = NULL;
1854 1810          char                    mbstring[MAXPATHLEN];
1855 1811          int                     filed;
1856 1812          Name                    target = line->body.line.target;
1857 1813  
1858 1814          SEND_MTOOL_MSG(
1859 1815                  if (!sent_rsrc_info_msg) {
1860 1816                          if (userName[0] == '\0') {
↓ open down ↓ 62 lines elided ↑ open up ↑
1923 1879                                  child_pid = pollResults(stdout_file,
1924 1880                                                          (char *)NULL,
1925 1881                                                          (char *)NULL);
1926 1882                          );
1927 1883                          /* Do assignment if command line prefixed with "=" */
1928 1884                          if (rule->assign) {
1929 1885                                  result = build_ok;
1930 1886                                  do_assign(rule->command_line, target);
1931 1887                          } else if (report_dependencies_level == 0) {
1932 1888                                  /* Execute command line. */
1933      -#ifdef DISTRIBUTED
1934      -                                setvar_envvar((Avo_DoJobMsg *)NULL);
1935      -#else
1936 1889                                  setvar_envvar();
1937      -#endif
1938 1890                                  result = dosys(rule->command_line,
1939 1891                                                 (Boolean) rule->ignore_error,
1940 1892                                                 (Boolean) rule->make_refd,
1941 1893                                                 /* ds 98.04.23 bug #4085164. make should always show error messages */
1942 1894                                                 false,
1943 1895                                                 /* BOOLEAN(rule->silent &&
1944 1896                                                         rule->ignore_error), */
1945 1897                                                 (Boolean) rule->always_exec,
1946 1898                                                 target,
1947 1899                                                 send_mtool_msgs);
↓ open down ↓ 83 lines elided ↑ open up ↑
2031 1983                           */
2032 1984                          //      retmem_mb(val);
2033 1985                          spro->body.env_mem.value = NULL;
2034 1986                  }
2035 1987          }
2036 1988          
2037 1989          return result;
2038 1990  }
2039 1991  
2040 1992  
2041      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
2042      -
2043      -/*
2044      - * Create and send an Avo_MToolRsrcInfoMsg.
2045      - */
2046      -void
2047      -send_rsrc_info_msg(int max_jobs, char *hostname, char *username)
2048      -{
2049      -        static int              first = 1;
2050      -        Avo_MToolRsrcInfoMsg    *msg;
2051      -        RWSlistCollectables     server_list;
2052      -        Avo_ServerState         *server_state;
2053      -        RWCollectable           *xdr_msg;
2054      -
2055      -        if (!first) {
2056      -                return;
2057      -        }
2058      -        first = 0;
2059      -
2060      -        create_xdrs_ptr();
2061      -
2062      -        server_state = new Avo_ServerState(max_jobs, hostname, username);
2063      -        server_list.append(server_state);
2064      -        msg = new Avo_MToolRsrcInfoMsg(&server_list);
2065      -
2066      -        xdr_msg = (RWCollectable *)msg;
2067      -        xdr(get_xdrs_ptr(), xdr_msg);
2068      -        (void) fflush(get_mtool_msgs_fp());
2069      -
2070      -        delete server_state;
2071      -        delete msg;
2072      -}
2073      -
2074      -/*
2075      - * Create and send an Avo_MToolJobStartMsg.
2076      - */
2077      -void
2078      -send_job_start_msg(Property line)
2079      -{
2080      -        int                     cmd_options = 0;
2081      -        Avo_MToolJobStartMsg    *msg;
2082      -        Cmd_line                rule;
2083      -        Name                    target = line->body.line.target;
2084      -        RWCollectable           *xdr_msg;
2085      -
2086      -        if (userName[0] == '\0') {
2087      -                avo_get_user(userName, NULL);
2088      -        }
2089      -        if (hostName[0] == '\0') {
2090      -                strcpy(hostName, avo_hostname());
2091      -        }
2092      -
2093      -        msg = new Avo_MToolJobStartMsg();
2094      -        msg->setJobId(++job_msg_id);
2095      -        msg->setTarget(AVO_STRDUP(target->string_mb));
2096      -        msg->setHost(AVO_STRDUP(hostName));
2097      -        msg->setUser(AVO_STRDUP(userName));
2098      -
2099      -        for (rule = line->body.line.command_used;
2100      -             rule != NULL;
2101      -             rule = rule->next) {
2102      -                if (posix && (touch || quest) && !rule->always_exec) {
2103      -                        continue;
2104      -                }
2105      -                if (vpath_defined) {
2106      -                        rule->command_line =
2107      -                          vpath_translation(rule->command_line);
2108      -                }
2109      -                cmd_options = 0;
2110      -                if (rule->ignore_error || ignore_errors) {
2111      -                        cmd_options |= ignore_mask;
2112      -                }
2113      -                if (rule->silent || silent) {
2114      -                        cmd_options |= silent_mask;
2115      -                }
2116      -                if (rule->command_line->meta) {
2117      -                        cmd_options |= meta_mask;
2118      -                }
2119      -                if (!touch && (rule->command_line->hash.length > 0)) {
2120      -                        msg->appendCmd(new Avo_DmakeCommand(rule->command_line->string_mb, cmd_options));
2121      -                }
2122      -        }
2123      -
2124      -        xdr_msg = (RWCollectable*) msg;
2125      -        xdr(&xdrs, xdr_msg);
2126      -        (void) fflush(mtool_msgs_fp);
2127      -
2128      -/* tolik, 08/39/2002.
2129      -   I commented out this code because it causes using unallocated memory.
2130      -        delete msg;
2131      -*/
2132      -}
2133      -
2134      -/*
2135      - * Append the stdout/err to Avo_MToolJobResultMsg.
2136      - */
2137      -static void
2138      -append_job_result_msg(Avo_MToolJobResultMsg *job_result_msg)
2139      -{
2140      -        FILE            *fp;
2141      -        char            line[MAXPATHLEN];
2142      -        char            stdout_file2[MAXPATHLEN];
2143      -
2144      -        if (stdout_file != NULL) {
2145      -                fp = fopen(stdout_file, "r");
2146      -                if (fp == NULL) {
2147      -                        /* Hmmm... what should we do here? */
2148      -                        warning(catgets(catd, 1, 326, "fopen() of stdout_file failed. Output may be lost"));
2149      -                        return;
2150      -                }
2151      -                while (fgets(line, MAXPATHLEN, fp) != NULL) {
2152      -                        if (line[strlen(line) - 1] == '\n') {
2153      -                                line[strlen(line) - 1] = '\0';
2154      -                        }
2155      -                        job_result_msg->appendOutput(AVO_STRDUP(line));
2156      -                }
2157      -                (void) fclose(fp);
2158      -                us_sleep(STAT_RETRY_SLEEP_TIME);
2159      -        } else {
2160      -                /* Hmmm... stdout_file shouldn't be NULL */
2161      -                warning(catgets(catd, 1, 327, "Internal stdout_file variable shouldn't be NULL. Output may be lost"));
2162      -        }
2163      -}
2164      -#endif /* TEAMWARE_MAKE_CMN */
2165 1993  
2166 1994  /*
2167 1995   *      vpath_translation(cmd)
2168 1996   *
2169 1997   *      Translates one command line by
2170 1998   *      checking each word. If the word has an alias it is translated.
2171 1999   *
2172 2000   *      Return value:
2173 2001   *                              The translated command
2174 2002   *
↓ open down ↓ 611 lines elided ↑ open up ↑
2786 2614  static Doname
2787 2615  touch_command(register Property line, register Name target, Doname result)
2788 2616  {
2789 2617          Name                    name;
2790 2618          register Chain          target_group;
2791 2619          String_rec              touch_string;
2792 2620          wchar_t                 buffer[MAXPATHLEN];
2793 2621          Name                    touch_cmd;
2794 2622          Cmd_line                rule;
2795 2623  
2796      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
2797      -        Avo_MToolJobResultMsg   *job_result_msg;
2798      -        RWCollectable           *xdr_msg;
2799      -        int                     child_pid = 0;
2800      -        wchar_t                 string[MAXPATHLEN];
2801      -        char                    mbstring[MAXPATHLEN];
2802      -        int                     filed;
2803      -#endif
2804 2624  
2805 2625          SEND_MTOOL_MSG(
2806 2626                  if (!sent_rsrc_info_msg) {
2807 2627                          if (userName[0] == '\0') {
2808 2628                                  avo_get_user(userName, NULL);
2809 2629                          }
2810 2630                          if (hostName[0] == '\0') {
2811 2631                                  strcpy(hostName, avo_hostname());
2812 2632                          }
2813 2633                          send_rsrc_info_msg(1, hostName, userName);
↓ open down ↓ 639 lines elided ↑ open up ↑
3453 3273                                  return true;
3454 3274                          }
3455 3275                  not_new:;
3456 3276                  }
3457 3277                  return false;
3458 3278          } else {
3459 3279                  return false;
3460 3280          }
3461 3281  }
3462 3282  
3463      -#if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
3464      -void
3465      -create_xdrs_ptr(void)
3466      -{
3467      -        static int      xdrs_init = 0;
3468      -
3469      -        if (!xdrs_init) {
3470      -                xdrs_init = 1;
3471      -                mtool_msgs_fp = fdopen(mtool_msgs_fd, "a");
3472      -                xdrstdio_create(&xdrs,
3473      -                                mtool_msgs_fp,
3474      -                                XDR_ENCODE);
3475      -        }
3476      -}
3477      -
3478      -XDR *
3479      -get_xdrs_ptr(void)
3480      -{
3481      -        return &xdrs;
3482      -}
3483      -
3484      -FILE *
3485      -get_mtool_msgs_fp(void)
3486      -{
3487      -        return mtool_msgs_fp;
3488      -}
3489      -
3490      -int
3491      -get_job_msg_id(void)
3492      -{
3493      -        return job_msg_id;
3494      -}
3495      -
3496      -// Continuously poll and show the results of remotely executing a job,
3497      -// i.e., output the stdout and stderr files.
3498      -
3499      -static int
3500      -pollResults(char *outFn, char *errFn, char *hostNm)
3501      -{
3502      -        int             child;
3503      -
3504      -        child = fork();
3505      -        switch (child) {
3506      -        case -1:
3507      -                break;
3508      -        case 0:
3509      -                enable_interrupt((void (*) (int))SIG_DFL);
3510      -                (void) sigset(SIGUSR1, Avo_PollResultsAction_Sigusr1Handler);
3511      -                pollResultsAction(outFn, errFn);
3512      -
3513      -                exit(0);
3514      -                break;
3515      -        default:
3516      -                break;
3517      -        }
3518      -        return child;
3519      -}
3520      -
3521      -// This is the PollResultsAction SIGUSR1 handler.
3522      -
3523      -static bool_t pollResultsActionTimeToFinish = FALSE;
3524      -
3525      -extern "C" void
3526      -Avo_PollResultsAction_Sigusr1Handler(int foo)
3527      -{
3528      -        pollResultsActionTimeToFinish = TRUE;
3529      -}
3530      -
3531      -static void
3532      -pollResultsAction(char *outFn, char *errFn)
3533      -{
3534      -        int                     fd;
3535      -        time_t                  file_time = 0;
3536      -        long                    file_time_nsec = 0;
3537      -        struct stat             statbuf;
3538      -        int                     stat_rc;
3539      -
3540      -        // Keep stat'ing until file exists.
3541      -        while (((stat_rc = stat(outFn, &statbuf)) != 0) &&
3542      -               (errno == ENOENT) && 
3543      -               !pollResultsActionTimeToFinish) {
3544      -                us_sleep(STAT_RETRY_SLEEP_TIME);
3545      -        }
3546      -        // The previous stat() could be failed due to EINTR
3547      -        // So one more try is needed
3548      -        if (stat_rc != 0 && stat(outFn, &statbuf) != 0) {
3549      -                // stat() failed
3550      -                warning(NOCATGETS("Internal error: stat(\"%s\", ...) failed: %s\n"),
3551      -                        outFn, strerror(errno));
3552      -                exit(1);
3553      -        }
3554      -
3555      -        if ((fd = open(outFn, O_RDONLY)) < 0
3556      -                && (errno != EINTR || (fd = open(outFn, O_RDONLY)) < 0)) {
3557      -                // open() failed
3558      -                warning(NOCATGETS("Internal error: open(\"%s\", O_RDONLY) failed: %s\n"),
3559      -                        outFn, strerror(errno));
3560      -                exit(1);
3561      -        }
3562      -
3563      -        while (!pollResultsActionTimeToFinish && stat(outFn, &statbuf) == 0) {
3564      -                if ((statbuf.st_mtim.tv_sec > file_time) ||
3565      -                    ((statbuf.st_mtim.tv_sec == file_time) &&
3566      -                    (statbuf.st_mtim.tv_nsec > file_time_nsec))
3567      -                   ) {
3568      -                        file_time = statbuf.st_mtim.tv_sec;
3569      -                        file_time_nsec = statbuf.st_mtim.tv_nsec;
3570      -                        rxmGetNextResultsBlock(fd);
3571      -                }
3572      -                us_sleep(STAT_RETRY_SLEEP_TIME);
3573      -        }
3574      -        // Check for the rest of output
3575      -        rxmGetNextResultsBlock(fd);
3576      -
3577      -        (void) close(fd);
3578      -}
3579      -
3580      -static void
3581      -rxmGetNextResultsBlock(int fd)
3582      -{
3583      -        size_t                  to_read = 8 * 1024;
3584      -        ssize_t                 bytes_read;
3585      -        ssize_t                 bytes_written;
3586      -        char                    results_buf[8 * 1024];
3587      -        sigset_t                newset;
3588      -        sigset_t                oldset;
3589      -
3590      -        // Read some more from the output/results file.
3591      -        // Hopefully the kernel managed to prefetch the stuff.
3592      -        bytes_read = read(fd, results_buf, to_read);
3593      -        while (bytes_read > 0) {
3594      -                AVO_BLOCK_INTERUPTS;
3595      -                bytes_written = write(1, results_buf, bytes_read);
3596      -                AVO_UNBLOCK_INTERUPTS;
3597      -                if (bytes_written != bytes_read) {
3598      -                        // write() failed
3599      -                        warning(NOCATGETS("Internal error: write(1, ...) failed: %s\n"),
3600      -                                strerror(errno));
3601      -                        exit(1);
3602      -                }
3603      -                bytes_read = read(fd, results_buf, to_read);
3604      -        }
3605      -}
3606      -
3607      -// Generic, interruptable microsecond resolution sleep member function.
3608      -
3609      -static int
3610      -us_sleep(unsigned int nusecs)
3611      -{
3612      -        struct pollfd dummy;
3613      -        int timeout;
3614      -
3615      -        if ((timeout = nusecs/1000) <= 0) {
3616      -                timeout = 1;
3617      -        }
3618      -        return poll(&dummy, 0, timeout);
3619      -}
3620      -#endif /* TEAMWARE_MAKE_CMN */
3621 3283  
3622 3284  // Recursively delete each of the Chain struct on the chain.
3623 3285  
3624 3286  static void
3625 3287  delete_query_chain(Chain ch)
3626 3288  {
3627 3289          if (ch == NULL) {
3628 3290                  return;
3629 3291          } else {
3630 3292                  delete_query_chain(ch->next);
↓ open down ↓ 85 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX