From ea585d0f5b956f4e523a76120078f58097243719 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 6 Feb 2018 21:31:20 -0500 Subject: [PATCH] set $SHARE_DIR --- src/main.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 892fa4d..a990274 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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;