set $SHARE_DIR

This commit is contained in:
Josh Holtrop 2018-02-06 21:31:20 -05:00
parent 1ac247400d
commit ea585d0f5b

View File

@ -73,6 +73,8 @@ std::string get_exe_path()
return "";
}
static std::string share_dir;
const char * read_bootstrap_file()
{
auto exe_path = get_exe_path();
@ -82,15 +84,16 @@ const char * read_bootstrap_file()
index = exe_path.rfind('/', index - 1u);
if (index != std::string::npos)
{
std::string path = std::string(exe_path, 0u, index) + SHARE_BOOTSTRAP;
char * bootstrap = read_file(path.c_str());
share_dir = std::string(exe_path, 0u, index) + "/share/svi";
char * bootstrap = read_file((share_dir + "/bootstrap.rb").c_str());
if (bootstrap != nullptr)
{
return bootstrap;
}
}
}
return read_file(SHARE_DIR SHARE_BOOTSTRAP);
share_dir = SHARE_DIR;
return read_file(SHARE_DIR "/bootstrap.rb");
}
int main(int argc, char * argv[])
@ -105,6 +108,7 @@ int main(int argc, char * argv[])
{
RUBY_INIT_STACK;
ruby_init();
rb_gv_set("$SHARE_DIR", rb_str_new(share_dir.c_str(), share_dir.size()));
ruby_protect_eval_string(ruby_startup, &exception);
}
delete[] ruby_startup;