add cmdline option --preinit <commands> to execute given commands before executing xschemrc file. This can be used to switch library search paths depending on a variable setting.

This commit is contained in:
Stefan Frederik 2022-10-11 00:26:06 +02:00
parent b93c9af97c
commit 137ca971d3
8 changed files with 1935 additions and 1898 deletions

File diff suppressed because it is too large Load Diff

View File

@ -389,6 +389,12 @@
<Component Id="cmpEE71F9B2266EB5D5942CCFD07E500A7B" Guid="{2F5161AB-FDE5-4F23-BFA7-BAB51687A35A}">
<File Id="fil3E54C9EB76BA0C4948F348194C65BC0C" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cmos_inv.sym" />
</Component>
<Component Id="cmp7B638600CF97F07A1A28630B8B0AA89D" Guid="{13525D30-3B86-4CF2-95EA-C1FA17E82CD1}">
<File Id="fil336C8A349DF3CF8C433D345DEDC3BA60" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cross.sch" />
</Component>
<Component Id="cmp9EA5369C321EA6C92B5E5252E1232CCE" Guid="{9883ECAA-3FD6-4F6E-82E8-0AACCAC690DD}">
<File Id="fil7C5844700BE513415386982411303722" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cross.sym" />
</Component>
<Component Id="cmp6758C5CAFB49CCFE98ED4A0CB79444A2" Guid="{8A248740-7FDF-4900-A491-2C5FF43270D2}">
<File Id="filB0C628ED9C6CE9A400A928741D85657E" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\diode_1.sch" />
</Component>
@ -5552,6 +5558,8 @@
<ComponentRef Id="cmp32F04546D3D34E506668FDCAF140AD26" />
<ComponentRef Id="cmp691FABAD9E70CAB633C4951FA945525F" />
<ComponentRef Id="cmpEE71F9B2266EB5D5942CCFD07E500A7B" />
<ComponentRef Id="cmp7B638600CF97F07A1A28630B8B0AA89D" />
<ComponentRef Id="cmp9EA5369C321EA6C92B5E5252E1232CCE" />
<ComponentRef Id="cmp6758C5CAFB49CCFE98ED4A0CB79444A2" />
<ComponentRef Id="cmpDAB9FD1BFB650AB1F914EC01154D3191" />
<ComponentRef Id="cmpADED9789CB9FCC2F3F7C192D39844489" />

View File

@ -55,6 +55,8 @@ Options:
(spice/Verilog/VHDL, depending on the netlist
type chosen).
-w --verilog Set netlist type to Verilog.
--preinit &lt;tcl_cmd&gt; Execute specified tcl instructions before any other action,
and before loading xschemrc.
--tcl &lt;tcl_script&gt; Execute specified tcl instructions before any other action,
this can be used to change xschemrc variables.
--command &lt;tcl_cmd&gt; Execute specified tcl commands after completing startup.

View File

@ -184,6 +184,8 @@ char cli_opt_netlist_dir[PATH_MAX] = "";
char cli_opt_filename[PATH_MAX] = ""; /* filename given on cmdline */
int cli_opt_no_readline=0;
char *cli_opt_tcl_command = NULL; /* tcl command given on command line with --tcl <script> */
char *cli_opt_preinit_command = NULL; /* tcl command given on command line with --preinit <script>
* this commands will be executed before loading xschemrc */
char *cli_opt_tcl_post_command = NULL; /* tcl command given on command line with --command <script> */
int cli_opt_do_print=0;
int cli_opt_do_netlist=0; /* set by process_options if user wants netllist from cmdline */

View File

@ -69,6 +69,10 @@ static void check_opt(char *opt, char *optval, int type)
dbg(1, "process_options(): will print png\n");
cli_opt_do_print=2;
} else if( (type == LONG && !strcmp("preinit", opt)) ) {
dbg(1, "process_options(): passing tcl command to interpreter: %s\n", optval);
if(optval) my_strdup(1565, &cli_opt_preinit_command, optval);
} else if( (type == LONG && !strcmp("tcl", opt)) ) {
dbg(1, "process_options(): passing tcl command to interpreter: %s\n", optval);
if(optval) my_strdup(110, &cli_opt_tcl_command, optval);
@ -180,6 +184,9 @@ int process_options(int argc, char *argv[])
else if(!strcmp("tcl", opt)) {
optval = argv[++i];
}
else if(!strcmp("preinit", opt)) {
optval = argv[++i];
}
else if(!strcmp("script", opt)) {
optval = argv[++i];
}

View File

@ -867,6 +867,7 @@ static void xwin_exit(void)
}
my_free(1122, &pixdata);
my_free(1138, &cli_opt_tcl_command);
my_free(1566, &cli_opt_preinit_command);
my_free(1070, &cli_opt_tcl_post_command);
clear_expandlabel_data();
get_sym_template(NULL, NULL); /* clear static data in function */
@ -2049,8 +2050,14 @@ int Tcl_AppInit(Tcl_Interp *inter)
fprintf(errfp, "Tcl_AppInit(): failure creating %s\n", user_conf_dir);
Tcl_Exit(EXIT_FAILURE);
}
}
}
/* Execute tcl script given on command line with --preinit, before sourcing xschemrc */
if(cli_opt_preinit_command) {
tcleval(cli_opt_preinit_command);
}
/* */
/* SOURCE xschemrc file */
/* */

View File

@ -1038,6 +1038,7 @@ extern char cli_opt_netlist_dir[PATH_MAX];
extern char cli_opt_filename[PATH_MAX];
extern int cli_opt_no_readline;
extern char *cli_opt_tcl_command;
extern char *cli_opt_preinit_command;
extern char *cli_opt_tcl_post_command;
extern int cli_opt_do_print;
extern int cli_opt_do_netlist;

View File

@ -10,7 +10,9 @@ Options:
type chosen).
-w --verilog Set netlist type to Verilog.
--tcl <tcl_cmd> Execute specified tcl instructions before any other action,
this can be used to change xschemrc variables.
after sourcing xschemrc, this can be used to change xschemrc variables.
--preinit <tcl_cmd> Execute specified tcl instructions before any other action,
and before loading xschemrc.
--script <file> Execute specified tcl file as a command script (perhaps with xschem commands).
--command <tcl_cmd> Execute specified tcl commands after completing startup.
--tcp_port <number> Listen to specified tcp port for client connections. (number >=1024).