Skip to content

Instantly share code, notes, and snippets.

@benj02
Created October 24, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benj02/f31e1ff5ac0cfe4d6ce152eddb97f52c to your computer and use it in GitHub Desktop.
Save benj02/f31e1ff5ac0cfe4d6ce152eddb97f52c to your computer and use it in GitHub Desktop.
#ifndef __TARGET_H_
#define __TARGET_H_
#include <stdlib.h>
#include <stdbool.h>
struct command {
struct command* next;
char* line;
};
typedef struct command command_st;
typedef struct command* command_list;
typedef void(*command_list_action)(command_st*);
struct target {
struct target* next;
char* name;
int depc;
char** deps;
char** lines;
command_list commands;
};
typedef struct target target_st;
typedef struct target* target_list;
typedef void(*target_list_action)(target_st*);
#define EMPTY NULL
/* targets_for_each
* This function applies action to each elem in the global targets list
*/
void targets_for_each(target_list_action action);
/* new_target
* This function creates a new target, returns it, and appends it to the
* global targets list
*/
target_st* new_target(char* name, int depc, char** deps);
/* free_target
* This function frees the memory allocated to a target, and removes it
* from the global targets list
*/
void free_target(target_st* target);
/* find_target
* This function finds a target in the global targets list by name, and
* returns it. Will return NULL when target not found
*/
target_st* find_target(char* name);
/* parse_target
* This function creates a target based on a line from a uMakefile passed
* to it, returns it, and adds it to the global targets list
*/
target_st* parse_target(char* line);
/* new_command
* This function creates a new command based on a command line from a
* uMakefile, and adds it to the command list passed to it
*/
command_st* new_command(command_list* commands, char* line);
/* free_command
* This function frees the memory allocated to a command, and removes it
* from the command list passed to it
*/
void free_command(command_list* commands, command_st* command);
/* command_list_for_each
* This function applies action to each elem in the command list passed
* to it
*/
void command_list_for_each(command_list list, command_list_action action);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment