示例#1
0
int depsAreFiles(queue_t * dep){
	int i= 0;
	if(queue_size(dep) <= 0)
		return 0;
	for( ; i < queue_size(dep); i++){
		if(isRule(queue_at(dep, i)))
			return 0;
	}
	return 1;
}
示例#2
0
void ProjectAST::writeBack(QString &buffer)
{
	if ( isRule() )
		buffer += scopedID;
	else
		buffer += indentation();
	
	AST::writeBack(buffer);

}
示例#3
0
int depsReady(rule_struct * myRule){
	int i= 0;
	char * currDep =NULL;
	for( ; i < queue_size(myRule->rule->deps); i++){
		currDep= queue_at(myRule->rule->deps, i);
		if(isRule(currDep)){
			if(ruleReady(currDep) == 0)
				return 0;
		}
	}
	return 1;
}
示例#4
0
文件: action.cpp 项目: ArildF/masters
void
addItemToList()
{
    STRINGLIST *p;                  // from lexer
    STRINGLIST *NewList;

    if (name) {
        SET(actionFlags, A_TARGET);
        startNameList();
        name = NULL;
    }
    if (ON(actionFlags, A_TARGET)) {
        if (isRule(buf)) {
            if (ON(actionFlags, A_RULE))
                makeError(currentLine, TOO_MANY_RULE_NAMES);
            makeError(currentLine, MIXED_RULES);
        }
    }
    p = makeNewStrListElement();
    if (ON(actionFlags, A_STRING)) {    // we collect macros
        p->text = string;               // for dependents &
        string = NULL;                  // build lines for
    } else                              // non-implicit rules
        p->text = makeString(buf);

    NewList = p;                        // build lines for
    if (OFF(actionFlags, A_RULE)        // rules get expanded
        || ON(actionFlags, A_TARGET))   // after entire make-
    {
        findMacroValues(p->text, &macros, NULL, NULL, 0, 0, 0); //  file parsed
    }

    if (ON(actionFlags, A_TARGET)) {
        p = macros;
        expandFileNames("$", &NewList, &macros);
        expandFileNames("*?", &NewList, NULL);
        while ((macros = p)) {
            p = p->next;
            FREE_STRINGLIST(macros);
        }
    }

    appendItem(&list, NewList);
}
示例#5
0
文件: action.cpp 项目: ArildF/masters
void
startNameList()
{
    STRINGLIST *p;

    currentFlags = flags;               // set flags for cur target
    p = makeNewStrListElement();
    p->text = name;
    list = p;                           // list contains name
    p = macros;
    expandFileNames("$", &list, &macros);   // expand macros in name
    expandFileNames("*?", &list, NULL);     // expand wildcards
    while ((macros = p)) {          // free macro list
        p = p->next;
        FREE_STRINGLIST(macros);
    }
    if (!list && OFF(actionFlags, A_TARGET))
        makeError(line, TARGET_MACRO_IS_NULL, name);    // target null & 1 target

    if (list && isRule(list->text))
        SET(actionFlags, A_RULE);
}
示例#6
0
void process_queues(queue_t *rest_r, queue_t *ready_r, queue_t *complete_t)
{
	int i = 0;
	while(i < queue_size(rest_r))
	{
		int satify = 1;
		int dependR = 0; 
		rule_t *rule = queue_at(rest_r, i);
		int j;
		
		for (j = 0; j < queue_size(rule->deps); j++)
		{
			char *dep = queue_at(rule->deps, j);

			int complete = 0;
			if (isRule(dep))
			{
				int k;
				for (k = 0; k < queue_size(complete_t); k++)
				{
					char *target = queue_at(complete_t, k);
					if (strcmp(dep, target) == 0)
					{
						dependR = 1;
						complete = 1;
						break;
					}
				}
			}
			else
			{
				if (access(dep, R_OK) == 0)
				{
					complete = 1;		
				}
				else 
				{
					fprintf(stderr,"dependency file does not exist!");
					exit(1);	
				}
			}

			if (!complete)
			{
				satify = 0;	
				break;
			}
			
		}
		
		if (satify)
		{
			if (dependR)
			{
				queue_enqueue(ready_r, rule);	
				queue_remove_at(rest_r, i);
			}
			else 
			{
				if (access(rule->target, R_OK) == -1)
				{
					queue_enqueue(ready_r, rule);	
					queue_remove_at(rest_r, i);
				}
				else 
				{
					struct stat statbuf;
					stat(rule->target, &statbuf);
					time_t rule_time = statbuf.st_mtime; 	
					
					int run = 0;
					int j;
					for (j = 0; j < queue_size(rule->deps); j++)
					{
						char *dep = queue_at(rule->deps, j);
						stat(dep, &statbuf);
						time_t dep_time = statbuf.st_mtime;
						if (dep_time > rule_time)
						{
							run = 1;
							queue_enqueue(ready_r, rule);	
							queue_remove_at(rest_r, i);
							break;
						}
					}
					
					if (!run)
					{
						queue_remove_at(rest_r, i);
						queue_enqueue(complete_t, rule->target);
						
						while(queue_size(rule->deps))
						{
							char *dep = queue_dequeue(rule->deps);
							free(dep);
						}
						while(queue_size(rule->commands))
						{
							char *command = queue_dequeue(rule->commands);
							free(command);
						}
						rule_destroy(rule);
						free(rule);
					}
				}
			}
		}
		else
		{
			i++;	
		}
	}
}
示例#7
0
文件: action.cpp 项目: ArildF/masters
void
expandFileNames(
    char *string,
    STRINGLIST **sourceList,
    STRINGLIST **macroList
    )
{
    char *s,
     *t = NULL;
    STRINGLIST *p;                  // Main list pointer
    STRINGLIST *pNew,               // Pointer to new list
               *pBack;              // Pointer to one element back
    char *saveText = NULL;

    for (pBack = NULL, p = *sourceList; p;) {

        // If no expand-character is found, continue to next list element.
        if (!_tcspbrk(p->text, string)) {
            pBack = p;
            p = pBack->next;
            continue;
        }

        // Either expand macros or wildcards.
        if (*string == '$') {
            t = expandMacros(p->text, macroList);
            FREE(p->text);
        } else {

            // If the wildcard string does not expand to anything, go to
            // next list elment.  Do not remove p from the original list
            // else we must check for null elsewhere.

            //                                   -- do not attempt to expand wildcards that
            // occur in inference rules

            if (isRule(p->text) || (pNew = expandWildCards(p->text)) == NULL) {
                pBack = p;
                p = pBack->next;
                continue;
            }
            saveText = p->text;
        }

        // At this point we have a list of expanded names to replace p with.
        if (pBack) {
            pBack->next = p->next;
            FREE_STRINGLIST(p);
            p = pBack->next;
        } else {
            *sourceList = p->next;
            FREE_STRINGLIST(p);
            p = *sourceList;
        }

        if (*string == '$') {       // if expanding macros
            char *str = t;
            if ((s = nextComponent(&str))) {
                do {                // put expanded names
                    pNew = makeNewStrListElement();     //  at front of list
                    pNew->text = makeString(s);         //  so we won't try to
                    prependItem(sourceList, pNew);      //  re-expand them
                    if (!pBack)
                        pBack = pNew;
                } while ((s = nextComponent(&str)));
            }
            FREE(t);
            continue;
        }
        else if (pNew) {            // if matches for * ?
            if (!pBack)
                for (pBack = pNew; pBack->next; pBack = pBack->next)
                    ;
            appendItem(&pNew, *sourceList);     // put at front of old list
            *sourceList = pNew;
        }
        FREE(saveText);
    }
}