add "--command" command line option to execute commands after initialization (whereas "--tcl" executes commands before initialization)

This commit is contained in:
Stefan Frederik 2022-05-06 23:19:41 +02:00
parent 21a8885b65
commit d0b273c2c5
8 changed files with 33 additions and 6 deletions

View File

@ -66,6 +66,10 @@ Set netlist type to Verilog.
Execute specified tcl instructions before any other action, this can be used to change xschemrc variables.
.TP
.B --command <tcl_cmd>
Execute specified tcl commands after completing startup.
.TP
.B --script <file>
Execute specified tcl file as a command script (perhaps with xschem commands).
.TP
@ -94,6 +98,10 @@ Set netlist type to tEDAx.
Set netlist type to SPICE.
.TP
.B -y, --symbol
Set netlist type to symbol global property edit.
.TP
.B -x, --no_x
Dont use X (only command mode).
.TP

View File

@ -57,6 +57,7 @@ Options:
-w --verilog Set netlist type to Verilog.
--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.
--script &lt;file&gt; Execute specified tcl file as a command script (perhaps with xschem commands).
--tcp_port &lt;number&gt; Listen to specified tcp port for client connections. (number &gt;=1024).
-i --no_rcload Do not load any xschemrc file.

View File

@ -184,6 +184,7 @@ 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_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 */
int cli_opt_do_simulation=0;

View File

@ -77,6 +77,10 @@ static void check_opt(char *opt, char *optval, int type)
dbg(1, "process_options(): passing tcl script file to interpreter: %s\n", optval);
if(optval) my_strncpy(cli_opt_tcl_script, optval, S(cli_opt_tcl_script));
} else if( (type == LONG && !strcmp("command", opt)) ) {
dbg(1, "process_options(): passing tcl command to interpreter: %s\n", optval);
if(optval) my_strdup(661, &cli_opt_tcl_post_command, optval);
} else if( (type == LONG && !strcmp("tcp_port", opt)) ) {
dbg(1, "process_options(): setting tcp port: %s\n", optval);
if(optval) tcp_port=atoi(optval);
@ -179,6 +183,9 @@ int process_options(int argc, char *argv[])
else if(!strcmp("script", opt)) {
optval = argv[++i];
}
else if(!strcmp("command", opt)) {
optval = argv[++i];
}
else if(!strcmp("tcp_port", opt)) {
optval = argv[++i];
}

View File

@ -1244,6 +1244,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"hier_psprint"))
{
cmd_found = 1;
if(argc > 2) {
my_strncpy(xctx->plotfile, argv[2], S(xctx->plotfile));
}
hier_psprint();
Tcl_ResetResult(interp);
}

View File

@ -687,6 +687,7 @@ static void xwin_exit(void)
}
my_free(1122, &pixdata);
my_free(1138, &cli_opt_tcl_command);
my_free(1070, &cli_opt_tcl_post_command);
clear_expandlabel_data();
get_sym_template(NULL, NULL); /* clear static data in function */
list_tokens(NULL, 0); /* clear static data in function */
@ -2317,16 +2318,20 @@ int Tcl_AppInit(Tcl_Interp *inter)
tcleval(str);
}
if(quit) {
tcleval("exit");
}
/* load additional files */
if(has_x) for(i = 2; i < cli_opt_argc; i++) {
tclvareval("xschem load_new_window ", cli_opt_argv[i], NULL);
}
/* Execute tcl script given on command line with --command */
if(cli_opt_tcl_post_command) {
tcleval(cli_opt_tcl_post_command);
}
if(quit) {
tcleval("exit");
}
/* */
/* END PROCESSING USER OPTIONS */

View File

@ -1000,6 +1000,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_tcl_post_command;
extern int cli_opt_do_print;
extern int cli_opt_do_netlist;
extern int cli_opt_do_simulation;

View File

@ -9,9 +9,10 @@ Options:
(spice/Verilog/VHDL, depending on the netlist
type chosen).
-w --verilog Set netlist type to Verilog.
--tcl <tcl_script> Execute specified tcl instructions before any other action,
--tcl <tcl_cmd> Execute specified tcl instructions before any other action,
this can be used to change xschemrc variables.
--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).
-i --no_rcload Do not load any xschemrc file.
--netlist_path <path>