[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: gsch2pcb.c



  User: danmc   
  Date: 07/02/08 19:24:12

  Modified:    .        gsch2pcb.c
  Log:
  1)  add a new option to gsch2pcb "use-m4" for the project file or "--use-m4" for the
  
  command line.  By default now, gsch2pcb will not try to run m4 at all.  If you want
  
  the old behaviour of running m4, you'll have to use this option.  It seems that this
  
  is what most users want (no m4 involved at run time).
  
  
  
  2) rather than hard coding a number of paths like /usr/X11R6/lib and /usr/local/share
  
  into the code for places to look for PCB footprints, use a single default directory
  
  which is based on ${datadir}.  If the user wants to, they can override that with
  
  --with-pcb-datadir=/opt/pcb-20070204/share for example.
  
  
  
  3)  when searching for newlib footprints with, for example, a name like
  
  footprint=MY1206, match either "MY1206" or "MY1206.fp" so we can start having extensions
  
  on footprint files without needing to explicitly add the ".fp" part in the footprint=
  
  attribute.  All of the footprints in the pcb distribution which came from the m4
  
  libraries have .fp extensions now.
  
  
  
  4)  add some example schematic files in the gsch2pcb example directory
  
  
  
  
  Revision  Changes    Path
  1.13      +64 -46    eda/geda/gaf/utils/src/gsch2pcb.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: gsch2pcb.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/utils/src/gsch2pcb.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- gsch2pcb.c	5 Apr 2006 02:32:27 -0000	1.12
  +++ gsch2pcb.c	9 Feb 2007 00:24:11 -0000	1.13
  @@ -1,4 +1,4 @@
  -/* $Id: gsch2pcb.c,v 1.12 2006/04/05 02:32:27 danmc Exp $ */
  +/* $Id: gsch2pcb.c,v 1.13 2007/02/09 00:24:11 danmc Exp $ */
   
   /* gsch2pcb
   |
  @@ -41,10 +41,12 @@
   #include <dmalloc.h>
   #endif
   
  -#define	GSC2PCB_VERSION		"1.5"
  +#define	GSC2PCB_VERSION		"1.6"
   
   #define	DEFAULT_PCB_INC		"pcb.inc"
   
  +#define SEP_STRING 	"--------\n"
  +
   typedef struct
   	{
   	gchar		*refdes,
  @@ -88,6 +90,8 @@
   				*m4_files,
   				*m4_override_file;
   
  +static gboolean use_m4 = FALSE;
  +
   static gchar	*empty_footprint_name;
   
   static gint		verbose,
  @@ -118,8 +122,6 @@
   	{
   	FILE	*f;
   
  -	if (!m4_command && !m4_pcbdir && !m4_files)
  -		return;
   	m4_override_file = "gnet-gsch2pcb-tmp.scm";
   	f = fopen(m4_override_file, "w");
   	if (!f)
  @@ -133,6 +135,8 @@
   		fprintf(f, "(define m4-pcbdir \"%s\")\n", m4_pcbdir);
   	if (m4_files)
   		fprintf(f, "(define m4-files \"%s\")\n", m4_files);
  +	fprintf(f, "(define gsch2pcb:use-m4 %s)\n", use_m4 == TRUE ? "#t" : "#f");
  +
   	fclose(f);
   	if (verbose)
   		{
  @@ -144,6 +148,7 @@
   			printf("    (define m4-pcbdir \"%s\")\n", m4_pcbdir);
   		if (m4_files)
   			printf("    (define m4-files \"%s\")\n", m4_files);
  +		printf("    (define gsch2pcb:use-m4 %s)\n", use_m4 == TRUE ? "#t" : "#f");
   		}
   	}
   
  @@ -179,7 +184,7 @@
   		command = g_strconcat(
   					gnetlist, " -g pcbpins -o ", pins_file, " ", args, NULL);
   		printf("Running command:\n\t%s\n", command);
  -		printf("--------\n");
  +		printf(SEP_STRING);
   		}
   	else
   		command = g_strconcat(
  @@ -192,7 +197,7 @@
   		command = g_strconcat(
   					gnetlist, " -g PCB -o ", net_file, " ", args, NULL);
   		printf("Running command:\n\t%s\n", command);
  -		printf("--------\n");
  +		printf(SEP_STRING);
   		}
   	else
   		command = g_strconcat(
  @@ -210,11 +215,11 @@
   	
   	if (verbose)
   		{
  -		printf("--------\n");
  +		printf(SEP_STRING);
   		command = g_strconcat(gnetlist, " -g gsch2pcb -o ", pcb_file, 
   				" ", args1, NULL);
   		printf("Running command:\n\t%s\n", command);
  -		printf("--------\n");
  +		printf(SEP_STRING);
   		}
   	else
   		command = g_strconcat(gnetlist, " -q -g gsch2pcb -o ", pcb_file, 
  @@ -223,7 +228,7 @@
   	g_spawn_command_line_sync(command, NULL, NULL, NULL, NULL);
   
   	if (verbose)
  -		printf("--------\n");
  +		printf(SEP_STRING);
   
   	if (   stat(pcb_file, &st) != 0
   		|| mtime == st.st_mtime
  @@ -250,11 +255,11 @@
   
   		if (verbose)
   			{
  -			printf("--------\n");
  +			printf(SEP_STRING);
   			command = g_strconcat(gnetlist, " -g ", s, out_file,
   							" ", args, NULL);
   			printf("Running command:\n\t%s\n", command);
  -			printf("--------\n");
  +			printf(SEP_STRING);
   			}
   		else
   			command = g_strconcat(gnetlist, " -q -g ", s, out_file,
  @@ -264,7 +269,7 @@
   		g_free(command);
   		g_free(out_file);
   		if (verbose)
  -			printf("--------\n");
  +			printf(SEP_STRING);
   		}
   	}
   
  @@ -564,25 +569,37 @@
   
   	if ((dir = g_dir_open(dir_path, 0, NULL)) == NULL)
   		{
  -		s = g_strdup_printf("find_element can't open dir %s", dir_path);
  +		s = g_strdup_printf("find_element can't open dir \"%s\"", dir_path);
   		perror(s);
   		g_free(s);
   		return NULL;
   		}
   	if (verbose > 1)
  -			printf("\t  Searching: %s\n", dir_path);
  +			printf("\t  Searching: \"%s\" for \"%s\"\n", dir_path, element);
   	while ((name = (gchar *) g_dir_read_name(dir)) != NULL)
   		{
   		path = g_strconcat(dir_path, "/", name, NULL);
   		found = NULL;
  +
  +		/* if we got a directory name, then recurse down into it */
   		if (g_file_test(path, G_FILE_TEST_IS_DIR))
   			found = find_element(path, element);
  +
  +		/* otherwise assume it is a file and see if it is the one we want */
   		else
   			{
   			if (verbose > 1)
   				printf("\t           : %s\t", name);
   			if (!strcmp(name, element))
   				found = g_strdup(path);
  +			else
  +			  {
  +				gchar *tmps;
  +				tmps = g_strconcat (element, ".fp", NULL);
  +				if (!strcmp(name, tmps))
  +					found = g_strdup(path);
  +				g_free (tmps);
  +			  }
   			if (verbose > 1)
   				printf("%s\n", found ? "Yes" : "No");
   			}
  @@ -647,7 +664,7 @@
   		{
   		dir_path = (gchar *) list->data;
   		if (verbose > 1)
  -			printf("\tLooking in directory: %s\n", dir_path);
  +			printf("\tLooking in directory: \"%s\"\n", dir_path);
   		path = find_element(dir_path, elname);
   		if (path)
   			{
  @@ -1178,6 +1195,11 @@
   		force_element_files = TRUE;
   		return 0;
   		}
  +	if (!strcmp(config, "use-m4") || !strcmp(config, "f"))
  +		{
  +		use_m4 = TRUE;
  +		return 0;
  +		}
   	if (!strcmp(config, "elements-dir") || !strcmp(config, "d"))
   		{
   		if (verbose > 1)
  @@ -1301,6 +1323,8 @@
   "                         so you really shouldn't need this option.\n"
   "   -q, --quiet           Don't tell the user what to do next after running gsch2pcb.\n"
   "\n"
  +"   -m, --use-m4          Use m4 when looking for footprints.  The default is to not\n"
  +"                         run m4 at all.\n"
   "       --m4-file F.inc   Use m4 file F.inc in addition to the default m4\n"
   "                         files ./pcb.inc and ~/.pcb/pcb.inc.\n"
   "       --m4-pcbdir D     Use D as the PCB m4 files install directory\n"
  @@ -1409,21 +1433,16 @@
   	gint	i;
   	gboolean initial_pcb = TRUE;
   	gboolean created_pcb_file = TRUE;
  +	char *path, *p;
   
   	if (argc < 2)
   		usage();
   
  -	/* Default m4 dir was /usr/X11R6/lib/X11/pcb/m4, but in more recent
  -	|  pcb versions it's under /usr/share or /usr/local/share
  +	/* Use the default value passed in from the configure script instead
  +  	 * of trying to hard code a value which is very likely wrong
   	*/
  -	if (g_file_test("/usr/local/share/pcb/m4", G_FILE_TEST_IS_DIR))
  -		m4_pcbdir = g_strdup("/usr/local/share/pcb/m4");
  -	else if (g_file_test("/usr/share/pcb/m4", G_FILE_TEST_IS_DIR))
  -		m4_pcbdir = g_strdup("/usr/share/pcb/m4");
  -	default_m4_pcbdir = g_strdup(m4_pcbdir ?
  -		   m4_pcbdir
  -		: "/usr/X11R6/lib/X11/pcb/m4" /* hardwired in gnet-gsch2pcb.scm */);
  -
  +	m4_pcbdir = g_strconcat( PCBDATADIR, "/pcb/m4", NULL );
  +	default_m4_pcbdir = g_strdup(m4_pcbdir);
   
   	get_args(argc, argv);
   
  @@ -1434,29 +1453,28 @@
   		usage();
   
   
  -	/* Hardwire in directories from Pcb.ad.  PCB as of 20031113 uses share
  -	|  instead of lib.  Check for standard prefix dirs of /usr and /usr/local.
  -	|  If PCB is installed elsewhere (eg. /opt) there will need to be a project
  -	|  elements-dir line.
  -	*/
  +	/* Defaults for the search path if not configured in the project file */
   	if (g_file_test("packages", G_FILE_TEST_IS_DIR))
   		element_directory_list = g_list_append(element_directory_list,
   					"packages");
  -	if (g_file_test("/usr/local/share/pcb/newlib", G_FILE_TEST_IS_DIR))
  -		element_directory_list = g_list_append(element_directory_list,
  -					"/usr/local/share/pcb/newlib");
  -	if (g_file_test("/usr/share/pcb/newlib", G_FILE_TEST_IS_DIR))
  -		element_directory_list = g_list_append(element_directory_list,
  -					"/usr/share/pcb/newlib");
  -	if (g_file_test("/usr/local/lib/pcb_lib", G_FILE_TEST_IS_DIR))	/* old */
  -		element_directory_list = g_list_append(element_directory_list,
  -					"/usr/local/lib/pcb_lib");
  -	if (g_file_test("/usr/lib/pcb_lib", G_FILE_TEST_IS_DIR))		/* old */
  -		element_directory_list = g_list_append(element_directory_list,
  -					"/usr/lib/pcb_lib");
  -	if (g_file_test("/usr/local/pcb_lib", G_FILE_TEST_IS_DIR))		/* old */
  +
  +#define PCB_PATH_DELIMETER ":"
  +	if (verbose)
  +		printf ("Processing PCBLIBPATH=\"%s\"\n", PCBLIBPATH);
  +
  +	path = g_strdup (PCBLIBPATH);
  +	for (p = strtok (path, PCB_PATH_DELIMETER); p && *p;
  +		p = strtok (NULL, PCB_PATH_DELIMETER))
  +	  {
  +		if (g_file_test(p, G_FILE_TEST_IS_DIR))
  +		  {
  +			if (verbose)
  +				printf ("Adding %s to the newlib search path\n", p);
   		element_directory_list = g_list_append(element_directory_list,
  -					"/usr/local/pcb_lib");
  +					g_strdup(p));
  +		  }
  +	  }
  +	g_free (path);
   
   	pins_file_name = g_strconcat(basename, ".cmd", NULL);
   	net_file_name = g_strconcat(basename, ".net", NULL);
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs