Skip to content

Commit

Permalink
flux: use FLUX_TOP_BUILDDIR for Lua
Browse files Browse the repository at this point in the history
Get the value of FLUX_TOP_BUILDDIR and use it, if set, instead of
hardwired ../../.  Fall back to the old /proc/self/exe method.
Intended for unit test environment where we can set it in
TESTS_ENVIRONMENT to $(top_builddir).
  • Loading branch information
garlick committed Sep 30, 2014
1 parent 368c0b0 commit a81aac7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/cmd/flux.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void usage (void)
);
}

int setup_lua_env (const char *exedir)
int setup_lua_env (const char *topdir)
{
char *s;

Expand All @@ -96,9 +96,9 @@ int setup_lua_env (const char *exedir)
* paths configurable on installation.
*/
s = getenv ("LUA_CPATH");
setenvf ("LUA_CPATH", 1, "%s/../bindings/lua/.libs/?.so;%s", exedir, s ? s : ";;");
setenvf ("LUA_CPATH", 1, "%s/src/bindings/lua/.libs/?.so;%s", topdir, s ? s : ";;");
s = getenv ("LUA_PATH");
setenvf ("LUA_PATH", 1, "%s/../bindings/lua/?.lua;%s", exedir, s ? s : ";;");
setenvf ("LUA_PATH", 1, "%s/src/bindings/lua/?.lua;%s", topdir, s ? s : ";;");
return (0);
}

Expand All @@ -108,10 +108,14 @@ int main (int argc, char *argv[])
bool hopt = false;
bool vopt = false;
char *flux_exe_dir = dir_self ();
char *flux_top_builddir = getenv ("FLUX_TOP_BUILDDIR");

log_init ("flux");

setup_lua_env (flux_exe_dir);
if (!flux_top_builddir && strcmp (flux_exe_dir, X_BINDIR) != 0)
flux_top_builddir = "../..";

setup_lua_env (flux_top_builddir);

while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
switch (ch) {
Expand Down Expand Up @@ -149,10 +153,6 @@ int main (int argc, char *argv[])
argc -= optind;
argv += optind;

/* We are executing 'flux' from a path that is not the installed path.
* Presume we are in $top_builddir/src/cmd and set up environment
* accordingly.
*/
if (strcmp (flux_exe_dir, X_BINDIR) != 0) {
glob_t gl;
char *modpath;
Expand Down

0 comments on commit a81aac7

Please sign in to comment.