10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER START
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The contents of this file are subject to the terms of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Common Development and Distribution License (the "License").
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You may not use this file except in compliance with the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See the License for the specific language governing permissions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and limitations under the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER END
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Use is subject to license terms.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Deal with the parallel processing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Defined macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This const should be in avo_dms/include/AvoDmakeCommand.h
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * typedefs & structs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dependency_conflict(Name target);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Doname distribute_process(char **commands, Property line);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void doname_subtree(Name target, Boolean do_get, Boolean implicit);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void dump_out_file(char *filename, Boolean err);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void maybe_reread_make_state(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void process_next(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void reset_conditionals(int cnt, Name *targets, Property *locals);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic pid_t run_rule_commands(char *host, char **commands);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Property *set_conditionals(int cnt, Name *targets);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * execute_parallel(line, waitflg)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMake 2.x:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel mode: spawns a parallel process to execute the command group.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The result of the execution
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command group to execute
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweexecute_parallel(Property line, Boolean waitflg, Boolean local)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((dmake_value = prop->body.macro.value) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("DMAKE_MAX_JOBS cannot be less than or equal to zero."));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("setting DMAKE_MAX_JOBS to %d."), PMAKE_DEF_MAX_JOBS);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * For backwards compatibility w/ PMake 1.x, when
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMake 2.x is being run in parallel mode, DMake
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * should parse the PMake startup file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * $(HOME)/.make.machines to get the pmake_max_jobs.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((dmake_value = prop->body.macro.value) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((pmake_max_jobs = read_make_machines(make_machines_name)) <= 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((dmake_mode_type == parallel_mode) && (waitflg))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (posix && (touch || quest) && !rule->always_exec) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* XXX - need to add support for + prefix */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) strcpy(cp, rule->command_line->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((argcnt == 0) ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Doname res = distribute_process(commands, line);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return only those memory that were specially allocated
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * for part of commands.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <unistd.h> /* sysconf(_SC_NPROCESSORS_ONLN) */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <sys/shm.h> /* shmget(), shmat(), shmdt(), shmctl() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <semaphore.h> /* sem_init(), sem_trywait(), sem_post(), sem_destroy() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * adjust_pmake_max_jobs (int pmake_max_jobs)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * pmake_max_jobs - max jobs limit set by user
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * External functions used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * getloadavg()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((ncpu = sysconf(_SC_NPROCESSORS_ONLN)) <= 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (getloadavg(loadavg, 3) != 3) return(pmake_max_jobs);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe adjusted_max_jobs = pmake_max_jobs - adjustment;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (adjusted_max_jobs < 1) adjusted_max_jobs = 1;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * M2 adjust mode data and functions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_init() - initializes M2 shared semaphore
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_acquire_job() - decrements M2 semaphore counter
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_release_job() - increments M2 semaphore counter
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_fini() - destroys M2 semaphore and shared memory*
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Environment variables:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * __DMAKE_M2_FILE__
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * External functions:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ftok(), shmget(), shmat(), shmdt(), shmctl()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sem_init(), sem_trywait(), sem_post(), sem_destroy()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * creat(), close(), unlink()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * getenv(), putenv()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_file - tmp file name to create ipc key for shared memory
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_shm_id - shared memory id
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * m2_shm_sem - shared memory semaphore
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((var = getenv("__DMAKE_M2_FILE__")) == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* compose tmp file name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sprintf(m2_file, "%s/dmake.m2.%d.XXXXXX", tmpdir, getpid());
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* create tmp file */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* using existing semaphore */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* combine IPC key */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* create shared memory */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((m2_shm_id = shmget(key, sizeof(*m2_shm_sem), 0666 | (var ? 0 : IPC_CREAT|IPC_EXCL))) == -1) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* attach shared memory */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((m2_shm_sem = (sem_t*) shmat(m2_shm_id, 0, 0666)) == (sem_t*)-1) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* root process */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* initialize semaphore */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* alloc memory for env variable */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* put key to env */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* determine the number of attached processes */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* destroy semaphore */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* destroy shared memory */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* remove tmp file created for the key */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* detach shared memory */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * job adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Possible values:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ADJUST_M1 - adjustment by system load (default)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ADJUST_M2 - fixed limit of jobs for the group of nested dmakes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ADJUST_NONE - no adjustment - fixed limit of jobs for the current dmake
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic enum {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * void job_adjust_fini()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Description:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Cleans up job adjust data.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * job_adjust_mode Current job adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * void job_adjust_error()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Description:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Prints warning message, cleans up job adjust data, and disables job adjustment
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Environment:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMAKE_ADJUST_MAX_JOBS
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * External functions:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * job_adjust_mode Current job adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* cleanup internals */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* warning message for the user */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Encountered max jobs auto adjustment error - disabling auto adjustment."));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* switch off job adjustment for the children */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* and for this dmake */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * void job_adjust_init()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Description:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parses DMAKE_ADJUST_MAX_JOBS env variable
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and performs appropriate initializations.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Environment:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMAKE_ADJUST_MAX_JOBS
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMAKE_ADJUST_MAX_JOBS == "NO" - no adjustment
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * DMAKE_ADJUST_MAX_JOBS == "M2" - M2 adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * other - M1 adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * External functions:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * job_adjust_mode Current job adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* default mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* determine adjust mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (char *var = getenv("DMAKE_ADJUST_MAX_JOBS")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* M2 specific initialization */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * distribute_process(char **commands, Property line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * commands argv vector of commands to execute
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The result of the execution
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * process_running Set to the pid of the process set running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * job_adjust_mode Current job adjust mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedistribute_process(char **commands, Property line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* initialize adjust mode, if not initialized */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* actions depend on adjust mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (parallel_process_cnt >= adjust_pmake_max_jobs (pmake_max_jobs)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* job adjustment error */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* no adjustment */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (parallel_process_cnt >= pmake_max_jobs) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (parallel_process_cnt >= pmake_max_jobs) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Tell the user what DMake is doing.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Print local_host --> x job(s).
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (parallel_process_cnt == 0) ? gettext("job") : gettext("jobs"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Print command line(s). */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* No @ char. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* XXX - need to add [2] when + prefix is added */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((commands[tmp_index][0] != (int) at_char) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) fprintf(stdout, "%s\n", tmp_index_str_ptr);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe "%s/dmake.stdout.%d.%d.XXXXXX",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe "%s/dmake.stderr.%d.%d.XXXXXX",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe process_running = run_rule_commands(local_host, commands);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doname_parallel(target, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Processes the given target and finishes up any parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * processes left running.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Result of target build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get True if sccs get to be done
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit True if this is an implicit target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedoname_parallel(Name target, Boolean do_get, Boolean implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = doname_check(target, do_get, implicit, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (result == build_ok || result == build_failed) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doname_subtree(target, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Completely computes an object and its dependents for a
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * serial subtree build.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get True if sccs get to be done
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit True if this is an implicit target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail Tail of the list of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list The list of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedoname_subtree(Name target, Boolean do_get, Boolean implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while(doname_check(target, do_get, implicit, false) == build_running) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * finish_running()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Keeps processing until the running_list is emptied out.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list The list of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * process_next()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Searches the running list for any targets which can start processing.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This can be a pending target, a serial target, or a subtree target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail The end of the list of running procs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * subtree_conflict A target which conflicts with a subtree
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * subtree_conflict2 The other target which conflicts
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * commands_done True if commands executed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Controls debug output
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel_process_cnt Number of parallel process running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Indentation for debug output
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If nothing currently running, build a serial target, if any.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp_prev = &running_list, rp = running_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Find a target to build. The target must be pending, have all
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * its dependencies built, and not be in a target group with a target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * currently building.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp_prev = &running_list, rp = running_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (target_group = line->body.line.target_group;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If nothing has been found to build and there exists a subtree
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target with no dependency conflicts, build it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp_prev = &running_list, rp = running_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If still nothing found to build, we either have a deadlock
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * or a subtree with a dependency conflict with something waiting
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Internal error: deadlock detected in process_next"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Conditional macro conflict encountered for %s between %s and %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe doname_subtree(rp->target, rp->do_get, rp->implicit);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * set_conditionals(cnt, targets)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Sets the conditional macros for the targets given in the array of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * targets. The old macro values are returned in an array of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Properties for later resetting.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Array of conditional macro settings
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cnt Number of targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * targets Array of targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe locals = (Property *) getmem(cnt * sizeof(Property));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe *lp = (Property) getmem((*tp)->conditional_cnt *
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sizeof(struct _Property));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * reset_conditionals(cnt, targets, locals)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Resets the conditional macros as saved in the given array of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Properties. The resets are done in reverse order. Afterwards the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * data structures are freed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cnt Number of targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * targets Array of targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * locals Array of dependency macro settings
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowereset_conditionals(int cnt, Name *targets, Property *locals)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (tp = targets + (cnt - 1), lp = locals + (cnt - 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dependency_conflict(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Returns true if there is an intersection between
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the subtree of the target and any dependents of the pending targets.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True if conflict found
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Subtree target to check
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * subtree_conflict Target conflict found
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * subtree_conflict2 Second conflict found
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * wait_name .WAIT, not a real dependency
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Return if we are already checking this target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check each dependency of the target for conflicts */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dp = line->body.line.dependencies; dp != NULL; dp = dp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Ignore .WAIT dependency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * For each pending target, look for a dependency which
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is the same as a dependency of the subtree target. Since
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we can't build the subtree until all pending targets have
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * finished which depend on the same dependency, this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * a conflict.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp = running_list; rp != NULL; rp = rp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * await_parallel(waitflg)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Waits for parallel children to exit and finishes their processing.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If waitflg is false, the function returns after update_delay.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * waitflg dwight
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for ( ; ; ) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Internal error: returned child pid not in running_list"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->state = (WIFEXITED(status) && WEXITSTATUS(status) == 0) ? build_ok : build_failed;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * finish_children(docheck)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Finishes the processing for all targets which were running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and have now completed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * docheck Completely check the finished target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail The tail of the running list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * continue_after_error -k flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fatal_in_progress True if we are finishing up after fatal err
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp_prev = &running_list, rp = running_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the state is ok or failed, then this target has
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * finished building.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * In parallel_mode, output the accumulated stdout/stderr.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read the auto dependency stuff, handle a failed build,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * update the target, then finish the doname process for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * that target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (rp->state == build_ok || rp->state == build_failed) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if there were any job output
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * from the parallel build.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe cmds_length += rule->command_line->hash.length + 1;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe silent_flag = BOOLEAN(silent_flag || rule->silent);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (out_buf.st_size != cmds_length || silent_flag ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!out_err_same && (rp->stderr_file != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Command failed for target `%s'"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->command ? line2->body.line.target->string_mb : rp->target->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * XXX??? - DMake needs to exit(),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * but shouldn't call fatal().
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning("I'm in finish_children. rp->state == build_failed.");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Command failed for target `%s'"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->command ? line2->body.line.target->string_mb : rp->target->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe update_target(get_prop(rp->target->prop, line_prop),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dump_out_file(filename, err)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Write the contents of the file to stdout, then unlink the file.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * filename Name of temp file containing output
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("open failed for output file %s: %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read buffers from the source file until end or error.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("write failed for output file %s: %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * finish_doname(rp)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Completes the processing for a target which was left running.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rp Running list entry for target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Debug flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Indentation for debug output
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf("Target = %s\n", target->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal("Internal error: NULL true_target in finish_doname");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If all went OK, set a nice timestamp */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->stat.time == file_doesnt_exist) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Propagate the timestamp from the member file to the member */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(target->prop, member_prop)) != NULL) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(member->body.member.member) > file_doesnt_exist)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe exists(member->body.member.member);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if we found any new auto dependencies when we
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * built the target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((result == build_ok) && check_auto_dependencies(target,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sTarget `%s' acquired new dependencies from build, checking all dependencies\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* [tolik, Tue Mar 25 1997]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Fix for bug 4038824:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command line options set by conditional macros get dropped
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rp->conditional_cnt and rp->conditional_targets must be copied
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to new 'rp' during add_pending(). Set_conditionals() stores
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rp->conditional_targets to the global variable 'conditional_targets'
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Add_pending() will use this variable to set up 'rp'.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe conditionals = set_conditionals(rp->conditional_cnt, rp->conditional_targets);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe reset_conditionals(rp->conditional_cnt, rp->conditional_targets, conditionals);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * new_running_struct()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Constructor for Running struct. Creates a structure and initializes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * its fields.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * add_running(target, true_target, command, recursion_level, auto_count,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * automatics, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Adds a record on the running list for this target, which
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * was just spawned and is running.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target being built
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * true_target True target for target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command Running command.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Debug indentation level
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * auto_count Count of automatic dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * automatics List of automatic dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Sccs get flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Implicit flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail Tail of running list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * process_running PID of process
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_line Current line for target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_target Current target being built
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * stderr_file Temporary file for stdout
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * stdout_file Temporary file for stdout
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_name Temporary file for auto dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweadd_running(Name target, Name true_target, Property command, int recursion_level, int auto_count, Name *automatics, Boolean do_get, Boolean implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->automatics = (Name *) getmem(auto_count * sizeof (Name));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (p = rp->automatics; auto_count > 0; auto_count--) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * add_pending(target, recursion_level, do_get, implicit, redo)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Adds a record on the running list for a pending target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * (waiting for its dependents to finish running).
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target being built
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Debug indentation level
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Sccs get flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Implicit flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * redo True if this target is being redone
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail Tail of running list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweadd_pending(Name target, int recursion_level, Boolean do_get, Boolean implicit, Boolean redo)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * add_serial(target, recursion_level, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Adds a record on the running list for a target which must be
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * executed in serial after others have finished.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target being built
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Debug indentation level
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Sccs get flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Implicit flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail Tail of running list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweadd_serial(Name target, int recursion_level, Boolean do_get, Boolean implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * add_subtree(target, recursion_level, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Adds a record on the running list for a target which must be
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * executed in isolation after others have finished.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target being built
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Debug indentation level
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Sccs get flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Implicit flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_tail Tail of running list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweadd_subtree(Name target, int recursion_level, Boolean do_get, Boolean implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * store_conditionals(rp)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Creates an array of the currently active targets with conditional
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * macros (found in the chain conditional_targets) and puts that
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * array in the Running struct.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rp Running struct for storing chain
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * conditional_targets Chain of current dynamic conditionals
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->conditional_targets = (Name *) getmem(cnt * sizeof(Name));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->conditional_targets[--cnt] = cond_name->name;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel_ok(target, line_prop_must_exists)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Returns true if the target can be run in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True if can run in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target being tested
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * all_parallel True if all targets default to parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * only_parallel True if no targets default to parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweparallel_ok(Name target, Boolean line_prop_must_exists)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (((line = get_prop(target->prop, line_prop)) == NULL) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is_running(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Returns true if the target is running.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True if target is running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to check
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (rp->state == build_running) ? true : false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This function replaces the makesh binary.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Could not fork child process for dmake job: %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case 0: /* Child */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* To control the processed targets list is not the child's business */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((length = strlen(*commands)) >= MAXPATHLEN) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) mbstowcs(tmp_wcs_buffer, *commands, length + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe command = GETNAME(tmp_wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe false, /* bugs #4085164 & #4990057 */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* BOOLEAN(silent_flag && ignore), */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("The following command caused the error:\n%s\n"), command->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Copying dosys()... */