execmac.c #7

  • //
  • guest/
  • miklos_fazekas/
  • jam/
  • src/
  • execmac.c
  • View
  • Commits
  • Open Download .zip Download (3 KB)
/*
 * Copyright 1993, 1995 Christopher Seiwald.
 *
 * This file is part of Jam - see jam.c for Copyright information.
 */



/*
 * As there's no documnented way of executing script on MPW, we just write commands to the
 * standard output.
 *
 * External routines:
 *	execcmd() - launch an async command execution
 * 	execwait() - wait and drive at most one execution completion
 *
 * Internal routines:
 *	onintr() - bump intr to note command interruption
 *
 * 04/08/94 (seiwald) - Coherent/386 support added.
 * 05/04/94 (seiwald) - async multiprocess interface
 * 01/22/95 (seiwald) - $(JAMSHELL) support
 * 01/20/00 (seiwald) - Upgraded from K&R to ANSI C
 */

# include "jam.h"
# include "lists.h"

# ifdef OS_MAC

#ifdef GRAPHISOFT_MPW_FIX
# include "parse.h"
# include "rules.h"
# include "command.h"
#endif
# include "execcmd.h"

# include <errno.h>
#ifdef GRAPHISOFT_MPW_FIX
# include <stdio.h>
# include <stdlib.h>
#endif


#ifdef GRAPHISOFT_MPW_FIX
/*
 * printexeccmd() - prints a command execution script
 */
void
printexeccmd (
	FILE*	f,
	CMD*	cmd)
{
	bool first = true;
	char *string = cmd->buf;
	
	while (*string)
	{
		char *command;
		/* Strip trailing comments */
		while ((*string == '\t') || (*string == ' ')) {
			string++;
		}
		command = string;
		while ((*string != '\n') && (*string != '\r') && (*string != 0)) {
			string++;
		}
		if (command != string)
		{
			if (*string)
			{
				*string = 0;
				string++;
			}
			if (!first)
				fprintf (f,"&& %s\n",command);
			else
				fprintf (f,"%s\n",command);
				
			first = false;
		}
		else if (*string) {
			string++;	
		}
	}
	
	if (!first)
	{
		fprintf (f,"|| (");
		if ( !( cmd->rule->flags & RULE_IGNORE ) )
		{
			fprintf (f,"Set JamMakeFailed 1");
			if (DEBUG_MAKE)
			{
				fprintf (f," ; Echo \'...failed %s ",cmd->rule->name);
				list_print( lol_get( &cmd->args, 0 ) );
				fprintf (f,"...\'");
			}
			
			/* If the command was interrupted or failed and the target */
			/* is not "precious", remove the targets. */
			/* Precious == 'actions updated' -- the target maintains state. */
		
			if (!(cmd->rule->flags & RULE_UPDATED))	
			{
				LIST *targets = lol_get( &cmd->args, 0 );
					for (; targets; targets = list_next(targets))
				{
					fprintf (f," ; If  \"`exists -f \'%s\'`\" ; Delete \'%s\' ; end if ",targets->string,targets->string);
				}
			}
		}
		fprintf (f,")\n");
	}		
} 
#endif

/*
 * execcmd() - launch an async command execution
 */

#ifdef GRAPHISOFT_MPW_FIX
void
execcmd( 
	char *string,
	void (*func)( void *closure, int status ),
	void *closure,
	LIST *shell )
{
	TARGET	*t = (TARGET *)closure;
	CMD	*cmd = (CMD *)t->cmds;
	
	printexeccmd (stdout, cmd); 
	(*func)( closure, EXEC_CMD_OK );
}
#endif

#ifndef GRAPHISOFT_MPW_FIX
void
execcmd( 
	char *string,
	void (*func)( void *closure, int status ),
	void *closure,
	LIST *shell )
{
	
	printf( "%s", string );
	(*func)( closure, EXEC_CMD_OK );
}

#endif

/*
 * execwait() - wait and drive at most one execution completion
 */

int
execwait()
{
	return 0;
}

# endif /* OS_MAC */
# Change User Description Committed
#8 2578 Miklos Fazekas Integrate new lexical scanner code to GSJam
#7 2521 Miklos Fazekas Compile error fixes after merge
#6 2519 Miklos Fazekas Sync to 2.5rc1
#5 1573 Miklos Fazekas Merge to jam mainline.
#4 1398 Miklos Fazekas Cleanup.
#3 1395 Miklos Fazekas Merge with main jam
#2 1320 Miklos Fazekas MacOS related fixes:
- emulation of jam's behaviour in MPW shell's scripting language (ie.: failed targets are removed)
- fix for out of memory errors on MacOS.
- together targets are removed
#1 1212 Miklos Fazekas Created a Jam branch
//guest/perforce_software/jam/src/execmac.c
#3 486 Perforce staff Jam 2.3.
 See RELNOTES for a list of changes from 2.2.x.

Just about every source file was touched when jam got ANSI-fied.
#2 212 Perforce staff An interpretative integration of Peter Glasscock's -o file support.
This is handled in the make1() routine, rather than in all the
exec*.c files.  -o x writes the actions to file x rather than
actually running them.  Implies -n (but not -d2).
#1 2 laura Add Jam/MR 2.2 source