si ca passe pas jsui cuit
This commit is contained in:
parent
bb1591a96a
commit
57c7743ba0
1 changed files with 27 additions and 0 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "files/files.h"
|
||||
|
|
@ -337,6 +338,7 @@ size_t expand_variable(struct line *line, size_t index, char **value)
|
|||
|
||||
// Get corresponding value
|
||||
*value = get_variable_value(var_name, line->number);
|
||||
free(var_name);
|
||||
}
|
||||
|
||||
return 2;
|
||||
|
|
@ -460,9 +462,34 @@ void make_parse(char *path)
|
|||
|
||||
// ==== Runtime ====
|
||||
|
||||
// Return 1 if rule is up to date, 0 otherwise
|
||||
static int uptodate(struct rule *rule)
|
||||
{
|
||||
struct stat path_stat;
|
||||
|
||||
if (lstat(rule->name, &path_stat) != 0) // target doesn't exists
|
||||
return 0;
|
||||
|
||||
struct list *dependencies = rule->dependencies;
|
||||
while (dependencies != NULL)
|
||||
{
|
||||
char *depname = dependencies->data;
|
||||
if (lstat(depname, &path_stat) != 0) // Dependecy doesn't exists
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Expands and run a specified rule
|
||||
static int run_rule(struct rule *rule)
|
||||
{
|
||||
// Check if p to date
|
||||
if (uptodate(rule))
|
||||
{
|
||||
printf("%s: '%s' is up to date.", program_name, rule->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct list *commands = rule->recipe;
|
||||
struct list *dependencies = rule->dependencies;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue