From 220ecbd09393ae0d8cc43d26cfe7c8427888c744 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 7 Jun 2011 13:08:29 -0500 Subject: [PATCH] Add gnetlist:get-input-files scheme function. Returns the list of files loaded by gnetlist. This returns the last elements of gnetlist:get-command-line not consumed by getopt. Affects-bug: lp-698740 Reviewed-by: Peter TB Brett --- gnetlist/include/globals.h | 2 ++ gnetlist/include/prototype.h | 2 ++ gnetlist/src/g_netlist.c | 20 ++++++++++++++++++++ gnetlist/src/g_register.c | 1 + gnetlist/src/globals.c | 3 +++ gnetlist/src/gnetlist.c | 5 +++++ 6 files changed, 33 insertions(+) diff --git a/gnetlist/include/globals.h b/gnetlist/include/globals.h index 7ab92bf37..d04296726 100644 --- a/gnetlist/include/globals.h +++ b/gnetlist/include/globals.h @@ -38,3 +38,5 @@ extern SCM pre_rc_list; /* before rc loaded */ extern SCM pre_backend_list; /* before backend loaded */ extern SCM post_backend_list; /* after backend loaded, before execute */ extern GSList *backend_params; /* Parameters passed to the backend from the command line */ + +extern GSList *input_files; diff --git a/gnetlist/include/prototype.h b/gnetlist/include/prototype.h index 99e009442..d775c5ee7 100644 --- a/gnetlist/include/prototype.h +++ b/gnetlist/include/prototype.h @@ -2,6 +2,7 @@ void g_set_project_current(TOPLEVEL *pr_current); SCM g_scm_c_get_uref(TOPLEVEL *toplevel, OBJECT *object); SCM g_get_backend_arguments (); +SCM g_get_input_files(); SCM g_get_packages(SCM level); SCM g_get_non_unique_packages(SCM level); SCM g_get_pins(SCM uref); @@ -42,6 +43,7 @@ int main(int argc, char *argv[]); void i_vars_set(TOPLEVEL *pr_current); /* parsecmd.c */ void usage(char *cmd); +GSList *create_input_files_list(int argi, int argc, char *argv[]); int parse_commandline(int argc, char *argv[]); /* s_cpinlist.c */ CPINLIST *s_cpinlist_return_tail(CPINLIST *head); diff --git a/gnetlist/src/g_netlist.c b/gnetlist/src/g_netlist.c index 8b97a3737..01cdeb167 100644 --- a/gnetlist/src/g_netlist.c +++ b/gnetlist/src/g_netlist.c @@ -749,6 +749,26 @@ g_get_backend_arguments() } +/*! \brief Get input files from command line. + * \par Function Description + * This function returns a list of the files named on the command line. + * + * \return A list of filenames as strings. + */ +SCM g_get_input_files() +{ + SCM list = SCM_EOL; + GSList *current = input_files; + + while (current != NULL) { + list = scm_cons (scm_from_locale_string (current->data), list); + current = g_slist_next(current); + } + + return scm_reverse_x (list, SCM_EOL); +} + + /* given a net name, an attribute, and a wanted attribute, return all the given attribute of all the graphical objects connected to that net name */ diff --git a/gnetlist/src/g_register.c b/gnetlist/src/g_register.c index 71a204929..9c0d9e504 100644 --- a/gnetlist/src/g_register.c +++ b/gnetlist/src/g_register.c @@ -94,6 +94,7 @@ static struct gsubr_t gnetlist_funcs[] = { /* SDB -- 9.1.2003 */ { "gnetlist:get-backend-arguments", 0, 0, 0, g_get_backend_arguments }, + { "gnetlist:get-input-files", 0, 0, 0, g_get_input_files }, { NULL, 0, 0, 0, NULL } }; diff --git a/gnetlist/src/globals.c b/gnetlist/src/globals.c index 2d7a2af1b..e24f5491f 100644 --- a/gnetlist/src/globals.c +++ b/gnetlist/src/globals.c @@ -63,5 +63,8 @@ SCM pre_backend_list = SCM_EOL; * before the execution of the backend procedure */ SCM post_backend_list = SCM_EOL; +/* List of input filenames */ +GSList *input_files; + /* Parameters passed to the backend from the command line */ GSList *backend_params = NULL; diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c index 79eec78ed..cb6ff5083 100644 --- a/gnetlist/src/gnetlist.c +++ b/gnetlist/src/gnetlist.c @@ -54,6 +54,8 @@ void gnetlist_quit(void) /* Free GSList *backend_params */ g_slist_free (backend_params); + + g_slist_free (input_files); } @@ -228,6 +230,9 @@ void main_prog(void *closure, int argc, char *argv[]) g_error_free (err); } + /* collect input filenames for backend use */ + input_files = g_slist_append(input_files, argv[i]); + i++; g_free (filename); } -- 2.11.4.GIT