Skip to content

Commit

Permalink
staMain init_filename arg
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Nov 5, 2019
1 parent e7d8689 commit bbdb4ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ main(int argc,
}
else {
Sta *sta = new Sta;
staMain(sta, argc, argv, Sta_Init, sta::tcl_inits);
staMain(sta, argc, argv, ".sta", Sta_Init, sta::tcl_inits);
return 0;
}
}
15 changes: 10 additions & 5 deletions app/StaMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ typedef sta::Vector<SwigInitFunc> SwigInitFuncSeq;
// "Arguments" passed to staTclAppInit.
static int sta_argc;
static char **sta_argv;
static const char *sta_init_filename;
static const char **sta_tcl_inits;
static SwigInitFunc sta_swig_init;

static const char *init_filename = "[file join $env(HOME) .sta]";

void
staMain(Sta *sta,
int argc,
char *argv[],
const char *init_filename,
SwigInitFunc swig_init,
const char *tcl_inits[])
{
Expand All @@ -49,7 +49,7 @@ staMain(Sta *sta,
int thread_count = parseThreadsArg(argc, argv);
sta->setThreadCount(thread_count);

staSetupAppInit(argc, argv, swig_init, tcl_inits);
staSetupAppInit(argc, argv, init_filename, swig_init, tcl_inits);
// Set argc to 1 so Tcl_Main doesn't source any files.
// Tcl_Main never returns.
Tcl_Main(1, argv, staTclAppInit);
Expand All @@ -75,11 +75,13 @@ parseThreadsArg(int &argc,
void
staSetupAppInit(int argc,
char *argv[],
const char *init_filename,
SwigInitFunc swig_init,
const char *tcl_inits[])
{
sta_argc = argc;
sta_argv = argv;
sta_init_filename = init_filename;
sta_tcl_inits = tcl_inits;
sta_swig_init = swig_init;
}
Expand Down Expand Up @@ -110,8 +112,11 @@ staTclAppInit(Tcl_Interp *interp)
Tcl_Eval(interp, "sta::define_sta_cmds");
Tcl_Eval(interp, "namespace import sta::*");

if (!findCmdLineFlag(argc, argv, "-no_init"))
sourceTclFile(init_filename, true, true, interp);
if (!findCmdLineFlag(argc, argv, "-no_init")) {
char *init_path = stringPrintTmp("[file join $env(HOME) %s]",
sta_init_filename);
sourceTclFile(init_path, true, true, interp);
}

bool exit_after_cmd_file = findCmdLineFlag(argc, argv, "-exit");

Expand Down
2 changes: 2 additions & 0 deletions app/StaMain.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ void
staMain(Sta *sta,
int argc,
char *argv[],
const char *init_filename,
SwigInitFunc swig_init,
const char *tcl_inits[]);

// Set arguments passed to staTclAppInit inside the tcl interpreter.
void
staSetupAppInit(int argc,
char *argv[],
const char *init_filename,
SwigInitFunc swig_init,
const char *tcl_inits[]);

Expand Down

0 comments on commit bbdb4ea

Please sign in to comment.