Print this page
make: remove maketool support

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/doname.cc
          +++ new/usr/src/cmd/make/bin/doname.cc
↓ open down ↓ 53 lines elided ↑ open up ↑
  54   54  #include <sys/wait.h>
  55   55  #include <unistd.h>             /* close() */
  56   56  
  57   57  /*
  58   58   * Defined macros
  59   59   */
  60   60  #       define LOCALHOST "localhost"
  61   61  
  62   62  #define MAXRULES 100
  63   63  
  64      -#define SEND_MTOOL_MSG(cmds) 
  65      -
  66   64  // Sleep for .1 seconds between stat()'s
  67   65  const int       STAT_RETRY_SLEEP_TIME = 100000;
  68   66  
  69   67  /*
  70   68   * typedefs & structs
  71   69   */
  72   70  
  73   71  /*
  74   72   * Static variables
  75   73   */
↓ open down ↓ 1690 lines elided ↑ open up ↑
1766 1764  execute_serial(Property line)
1767 1765  {
1768 1766          int                     child_pid = 0;
1769 1767          Boolean                 printed_serial;
1770 1768          Doname                  result = build_ok;
1771 1769          Cmd_line                rule, cmd_tail, command = NULL;
1772 1770          char                    mbstring[MAXPATHLEN];
1773 1771          int                     filed;
1774 1772          Name                    target = line->body.line.target;
1775 1773  
1776      -        SEND_MTOOL_MSG(
1777      -                if (!sent_rsrc_info_msg) {
1778      -                        if (userName[0] == '\0') {
1779      -                                avo_get_user(userName, NULL);
1780      -                        }
1781      -                        if (hostName[0] == '\0') {
1782      -                                strcpy(hostName, avo_hostname());
1783      -                        }
1784      -                        send_rsrc_info_msg(1, hostName, userName);
1785      -                        sent_rsrc_info_msg = 1;
1786      -                }
1787      -                send_job_start_msg(line);
1788      -                job_result_msg = new Avo_MToolJobResultMsg();
1789      -        );
1790      -
1791 1774          target->has_recursive_dependency = false;
1792 1775          // We have to create a copy of the rules chain for processing because
1793 1776          // the original one can be destroyed during .make.state file rereading.
1794 1777          for (rule = line->body.line.command_used;
1795 1778               rule != NULL;
1796 1779               rule = rule->next) {
1797 1780                  if (command == NULL) {
1798 1781                          command = cmd_tail = ALLOC(Cmd_line);
1799 1782                  } else {
1800 1783                          cmd_tail->next = ALLOC(Cmd_line);
↓ open down ↓ 11 lines elided ↑ open up ↑
1812 1795                  if (vpath_defined) {
1813 1796                          rule->command_line =
1814 1797                            vpath_translation(rule->command_line);
1815 1798                  }
1816 1799                  /* Echo command line, maybe. */
1817 1800                  if ((rule->command_line->hash.length > 0) &&
1818 1801                      !silent &&
1819 1802                      (!rule->silent || do_not_exec_rule) &&
1820 1803                      (report_dependencies_level == 0)) {
1821 1804                          (void) printf("%s\n", rule->command_line->string_mb);
1822      -                        SEND_MTOOL_MSG(
1823      -                                job_result_msg->appendOutput(AVO_STRDUP(rule->command_line->string_mb));
1824      -                        );
1825 1805                  }
1826 1806                  if (rule->command_line->hash.length > 0) {
1827      -                        SEND_MTOOL_MSG(
1828      -                                (void) sprintf(mbstring,
1829      -                                                NOCATGETS("%s/make.stdout.%d.%d.XXXXXX"),
1830      -                                                tmpdir,
1831      -                                                getpid(),
1832      -                                                file_number++);
1833      -
1834      -                                int tmp_fd = mkstemp(mbstring);
1835      -                                if(tmp_fd) {
1836      -                                        (void) close(tmp_fd);
1837      -                                }
1838      -
1839      -                                stdout_file = strdup(mbstring);
1840      -                                stderr_file = NULL;
1841      -                                child_pid = pollResults(stdout_file,
1842      -                                                        (char *)NULL,
1843      -                                                        (char *)NULL);
1844      -                        );
1845 1807                          /* Do assignment if command line prefixed with "=" */
1846 1808                          if (rule->assign) {
1847 1809                                  result = build_ok;
1848 1810                                  do_assign(rule->command_line, target);
1849 1811                          } else if (report_dependencies_level == 0) {
1850 1812                                  /* Execute command line. */
1851 1813                                  setvar_envvar();
1852 1814                                  result = dosys(rule->command_line,
1853 1815                                                 (Boolean) rule->ignore_error,
1854 1816                                                 (Boolean) rule->make_refd,
1855 1817                                                 /* ds 98.04.23 bug #4085164. make should always show error messages */
1856 1818                                                 false,
1857 1819                                                 /* BOOLEAN(rule->silent &&
1858 1820                                                         rule->ignore_error), */
1859 1821                                                 (Boolean) rule->always_exec,
1860      -                                               target,
1861      -                                               send_mtool_msgs);
     1822 +                                               target);
1862 1823                                  check_state(temp_file_name);
1863 1824                          }
1864      -                        SEND_MTOOL_MSG(
1865      -                                append_job_result_msg(job_result_msg);
1866      -                                if (child_pid > 0) {
1867      -                                        kill(child_pid, SIGUSR1);
1868      -                                        while (!((waitpid(child_pid, 0, 0) == -1)
1869      -                                                && (errno == ECHILD)));
1870      -                                }
1871      -                                child_pid = 0;
1872      -                                (void) unlink(stdout_file);
1873      -                                retmem_mb(stdout_file);
1874      -                                stdout_file = NULL;
1875      -                        );
1876 1825                  } else {
1877 1826                          result = build_ok;
1878 1827                  }
1879 1828                  if (result == build_failed) {
1880 1829                          if (silent || rule->silent) {
1881 1830                                  (void) printf(catgets(catd, 1, 242, "The following command caused the error:\n%s\n"),
1882 1831                                                rule->command_line->string_mb);
1883      -                                SEND_MTOOL_MSG(
1884      -                                        job_result_msg->appendOutput(AVO_STRDUP(catgets(catd, 1, 243, "The following command caused the error:")));
1885      -                                        job_result_msg->appendOutput(AVO_STRDUP(rule->command_line->string_mb));
1886      -                                );
1887 1832                          }
1888 1833                          if (!rule->ignore_error && !ignore_errors) {
1889 1834                                  if (!continue_after_error) {
1890      -                                        SEND_MTOOL_MSG(
1891      -                                                job_result_msg->setResult(job_msg_id, (result == build_ok) ? 0 : 1, DONE);
1892      -                                                xdr_msg = (RWCollectable*)
1893      -                                                        job_result_msg;
1894      -                                                xdr(&xdrs, xdr_msg);
1895      -                                                (void) fflush(mtool_msgs_fp);
1896      -                                                delete job_result_msg;
1897      -                                        );
1898 1835                                          fatal(catgets(catd, 1, 244, "Command failed for target `%s'"),
1899 1836                                                target->string_mb);
1900 1837                                  }
1901 1838                                  /*
1902 1839                                   * Make sure a failing command is not
1903 1840                                   * saved in .make.state.
1904 1841                                   */
1905 1842                                  line->body.line.command_used = NULL;
1906 1843                                  break;
1907 1844                          } else {
1908 1845                                  result = build_ok;
1909 1846                          }
1910 1847                  }
1911 1848          }
1912 1849          for (rule = command; rule != NULL; rule = cmd_tail) {
1913 1850                  cmd_tail = rule->next;
1914 1851                  free(rule);
1915 1852          }
1916 1853          command = NULL;
1917      -        SEND_MTOOL_MSG(
1918      -                job_result_msg->setResult(job_msg_id, (result == build_ok) ? 0 : 1, DONE);
1919      -                xdr_msg = (RWCollectable*) job_result_msg;
1920      -                xdr(&xdrs, xdr_msg);
1921      -                (void) fflush(mtool_msgs_fp);
1922      -
1923      -                delete job_result_msg;
1924      -        );
1925 1854          if (temp_file_name != NULL) {
1926 1855                  free_name(temp_file_name);
1927 1856          }
1928 1857          temp_file_name = NULL;
1929 1858  
1930 1859          Property spro = get_prop(sunpro_dependencies->prop, macro_prop);
1931 1860          if(spro != NULL) {
1932 1861                  Name val = spro->body.macro.value;
1933 1862                  if(val != NULL) {
1934 1863                          free_name(val);
↓ open down ↓ 641 lines elided ↑ open up ↑
2576 2505  static Doname
2577 2506  touch_command(register Property line, register Name target, Doname result)
2578 2507  {
2579 2508          Name                    name;
2580 2509          register Chain          target_group;
2581 2510          String_rec              touch_string;
2582 2511          wchar_t                 buffer[MAXPATHLEN];
2583 2512          Name                    touch_cmd;
2584 2513          Cmd_line                rule;
2585 2514  
2586      -
2587      -        SEND_MTOOL_MSG(
2588      -                if (!sent_rsrc_info_msg) {
2589      -                        if (userName[0] == '\0') {
2590      -                                avo_get_user(userName, NULL);
2591      -                        }
2592      -                        if (hostName[0] == '\0') {
2593      -                                strcpy(hostName, avo_hostname());
2594      -                        }
2595      -                        send_rsrc_info_msg(1, hostName, userName);
2596      -                        sent_rsrc_info_msg = 1;
2597      -                }
2598      -                send_job_start_msg(line);
2599      -                job_result_msg = new Avo_MToolJobResultMsg();
2600      -        );
2601 2515          for (name = target, target_group = NULL; name != NULL;) {
2602 2516                  if (!name->is_member) {
2603 2517                          /*
2604 2518                           * Build a touch command that can be passed
2605 2519                           * to dosys(). If KEEP_STATE is on, "make -t"
2606 2520                           * will save the proper command, not the
2607 2521                           * "touch" in .make.state.
2608 2522                           */
2609 2523                          INIT_STRING_FROM_STACK(touch_string, buffer);
2610 2524                          MBSTOWCS(wcs_buffer, NOCATGETS("touch "));
↓ open down ↓ 9 lines elided ↑ open up ↑
2620 2534                                        FIND_LENGTH);
2621 2535                          touch_cmd = GETNAME(touch_string.buffer.start,
2622 2536                                              FIND_LENGTH);
2623 2537                          if (touch_string.free_after_use) {
2624 2538                                  retmem(touch_string.buffer.start);
2625 2539                          }
2626 2540                          if (!silent ||
2627 2541                              do_not_exec_rule &&
2628 2542                              (target_group == NULL)) {
2629 2543                                  (void) printf("%s\n", touch_cmd->string_mb);
2630      -                                SEND_MTOOL_MSG(
2631      -                                        job_result_msg->appendOutput(AVO_STRDUP(touch_cmd->string_mb));
2632      -                                );
2633 2544                          }
2634 2545                          /* Run the touch command, or simulate it */
2635 2546                          if (!do_not_exec_rule) {
2636      -
2637      -                                SEND_MTOOL_MSG(
2638      -                                        (void) sprintf(mbstring,
2639      -                                                        NOCATGETS("%s/make.stdout.%d.%d.XXXXXX"),
2640      -                                                        tmpdir,
2641      -                                                        getpid(),
2642      -                                                        file_number++);
2643      -                                
2644      -                                        int tmp_fd = mkstemp(mbstring);
2645      -                                        if(tmp_fd) {
2646      -                                                (void) close(tmp_fd);
2647      -                                        }
2648      -
2649      -                                        stdout_file = strdup(mbstring);
2650      -                                        stderr_file = NULL;
2651      -                                        child_pid = pollResults(stdout_file,
2652      -                                                                (char *)NULL,
2653      -                                                                (char *)NULL);
2654      -                                );
2655      -
2656 2547                                  result = dosys(touch_cmd,
2657 2548                                                 false,
2658 2549                                                 false,
2659 2550                                                 false,
2660 2551                                                 false,
2661      -                                               name,
2662      -                                               send_mtool_msgs);
2663      -
2664      -                                SEND_MTOOL_MSG(
2665      -                                        append_job_result_msg(job_result_msg);
2666      -                                        if (child_pid > 0) {
2667      -                                                kill(child_pid, SIGUSR1);
2668      -                                                while (!((waitpid(child_pid, 0, 0) == -1)
2669      -                                                        && (errno == ECHILD)));
2670      -                                        }
2671      -                                        child_pid = 0;
2672      -                                        (void) unlink(stdout_file);
2673      -                                        retmem_mb(stdout_file);
2674      -                                        stdout_file = NULL;
2675      -                                );
2676      -
     2552 +                                               name);
2677 2553                          } else {
2678 2554                                  result = build_ok;
2679 2555                          }
2680 2556                  } else {
2681 2557                          result = build_ok;
2682 2558                  }
2683 2559                  if (target_group == NULL) {
2684 2560                          target_group = line->body.line.target_group;
2685 2561                  } else {
2686 2562                          target_group = target_group->next;
2687 2563                  }
2688 2564                  if (target_group != NULL) {
2689 2565                          name = target_group->name;
2690 2566                  } else {
2691 2567                          name = NULL;
2692 2568                  }
2693 2569          }
2694      -        SEND_MTOOL_MSG(
2695      -                job_result_msg->setResult(job_msg_id, (result == build_ok) ? 0 : 1, DONE);
2696      -                xdr_msg = (RWCollectable*) job_result_msg;
2697      -                xdr(&xdrs, xdr_msg);
2698      -                (void) fflush(mtool_msgs_fp);
2699      -                delete job_result_msg;
2700      -        );
2701 2570          return result;
2702 2571  }
2703 2572  
2704 2573  /*
2705 2574   *      update_target(line, result)
2706 2575   *
2707 2576   *      updates the status of a target after executing its commands.
2708 2577   *
2709 2578   *      Parameters:
2710 2579   *              line            The command line block to update
↓ open down ↓ 629 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX