set $SHARE_DIR
This commit is contained in:
parent
1ac247400d
commit
ea585d0f5b
10
src/main.cc
10
src/main.cc
@ -73,6 +73,8 @@ std::string get_exe_path()
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string share_dir;
|
||||||
|
|
||||||
const char * read_bootstrap_file()
|
const char * read_bootstrap_file()
|
||||||
{
|
{
|
||||||
auto exe_path = get_exe_path();
|
auto exe_path = get_exe_path();
|
||||||
@ -82,15 +84,16 @@ const char * read_bootstrap_file()
|
|||||||
index = exe_path.rfind('/', index - 1u);
|
index = exe_path.rfind('/', index - 1u);
|
||||||
if (index != std::string::npos)
|
if (index != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string path = std::string(exe_path, 0u, index) + SHARE_BOOTSTRAP;
|
share_dir = std::string(exe_path, 0u, index) + "/share/svi";
|
||||||
char * bootstrap = read_file(path.c_str());
|
char * bootstrap = read_file((share_dir + "/bootstrap.rb").c_str());
|
||||||
if (bootstrap != nullptr)
|
if (bootstrap != nullptr)
|
||||||
{
|
{
|
||||||
return bootstrap;
|
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[])
|
int main(int argc, char * argv[])
|
||||||
@ -105,6 +108,7 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
RUBY_INIT_STACK;
|
RUBY_INIT_STACK;
|
||||||
ruby_init();
|
ruby_init();
|
||||||
|
rb_gv_set("$SHARE_DIR", rb_str_new(share_dir.c_str(), share_dir.size()));
|
||||||
ruby_protect_eval_string(ruby_startup, &exception);
|
ruby_protect_eval_string(ruby_startup, &exception);
|
||||||
}
|
}
|
||||||
delete[] ruby_startup;
|
delete[] ruby_startup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user