diff --git a/Atom-Linux/Makefile b/Atom-Linux/Makefile index a059f3f3a..1ffe23384 100644 --- a/Atom-Linux/Makefile +++ b/Atom-Linux/Makefile @@ -1,3 +1,5 @@ +INSTALLDIR=/usr/share/atom + CXXFLAGS := -Werror \ -pthread \ -fno-exceptions \ @@ -36,6 +38,7 @@ LDFLAGS := -pthread \ -Wl,-O1 \ -Wl,--as-needed \ -Wl,--gc-sections \ + -Wl,-rpath=$(INSTALLDIR) LIBS := -lX11 \ -lgtk-x11-2.0 \ @@ -61,24 +64,23 @@ LIBS := -lX11 \ SOURCES=atom.cpp native_handler.cpp client_handler.cpp onig_regexp_extension.cpp io_utils.cpp OBJECTS=$(SOURCES:.cpp=.o) -INSTALLDIR=/usr/local/atom all: g++ $(CXXFLAGS) -c $(SOURCES) mkdir -p bin - cp chrome.pak bin/ - cp -R locales bin/ - cp atom.png bin/ - g++ -o bin/atom $(OBJECTS) $(LDFLAGS) $(LIBS) + g++ -o atom $(OBJECTS) $(LDFLAGS) $(LIBS) clean: - rm -rf bin *.o + rm -rf atom *.o install: mkdir -p $(INSTALLDIR) - cp -R bin $(INSTALLDIR) - cp -R lib $(INSTALLDIR) - cp atom $(INSTALLDIR) + cp -R atom $(INSTALLDIR) + cp chrome.pak $(INSTALLDIR) + cp -R locales $(INSTALLDIR) + cp atom.png $(INSTALLDIR) + cp lib/libcef.so $(INSTALLDIR) + cp lib/libcef_dll_wrapper.a $(INSTALLDIR) cp -R ../src $(INSTALLDIR) cp -R ../static $(INSTALLDIR) cp -R ../vendor $(INSTALLDIR) diff --git a/Atom-Linux/atom b/Atom-Linux/atom deleted file mode 100755 index c482e57b3..000000000 --- a/Atom-Linux/atom +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -case $0 in - /* ) - root=${0%atom} - ;; - * ) - root=`pwd`/${0%atom} - ;; -esac -export LD_LIBRARY_PATH=$root'../atom/lib':$LD_LIBRARY_PATH -$root'../atom/bin/atom' $@ diff --git a/Atom-Linux/atom.cpp b/Atom-Linux/atom.cpp index 632b627ec..3457166fc 100644 --- a/Atom-Linux/atom.cpp +++ b/Atom-Linux/atom.cpp @@ -3,7 +3,6 @@ // can be found in the LICENSE file. #include -#include #include #include #include "atom.h" @@ -59,9 +58,11 @@ int main(int argc, char *argv[]) { if (szWorkingDir == NULL) return -1; - std::string fullPath = argv[0]; - fullPath = fullPath.substr(0, fullPath.length() - 5); - szPath = fullPath.c_str(); + std::string appDir = io_util_app_directory(); + if (appDir.empty()) + return -1; + + szPath = appDir.c_str(); std::string pathToOpen; if (argc >= 2) { @@ -111,7 +112,7 @@ int main(int argc, char *argv[]) { window_info.SetAsChild(vbox); - std::string path = io_utils_real_app_path("/../index.html"); + std::string path = io_utils_real_app_path("/index.html"); if (path.empty()) return -1; diff --git a/Atom-Linux/client_handler.cpp b/Atom-Linux/client_handler.cpp index b3611a11b..9183bd50b 100644 --- a/Atom-Linux/client_handler.cpp +++ b/Atom-Linux/client_handler.cpp @@ -11,7 +11,7 @@ #include "include/cef_frame.h" #include "atom.h" #include "native_handler.h" -#include "io_utils.h" +#include "atom.h" #include #include @@ -92,11 +92,8 @@ void ClientHandler::OnLoadStart(CefRefPtr browser, CefRefPtr atom = CefV8Value::CreateObject(NULL, NULL); global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE); - std::string realLoadPath = io_utils_real_app_path("/.."); - if (!realLoadPath.empty()) { - CefRefPtr loadPath = CefV8Value::CreateString(realLoadPath); - atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE); - } + CefRefPtr loadPath = CefV8Value::CreateString(AppPath()); + atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE); CefRefPtr bootstrapScript = CefV8Value::CreateString( "single-window-bootstrap"); diff --git a/Atom-Linux/io_utils.cpp b/Atom-Linux/io_utils.cpp index 6320fb948..494c00fff 100644 --- a/Atom-Linux/io_utils.cpp +++ b/Atom-Linux/io_utils.cpp @@ -33,4 +33,17 @@ string io_utils_real_app_path(string relativePath) { return realAppPath; } else return ""; +} + +string io_util_app_directory() { + char path[BUFFER_SIZE]; + if (readlink("/proc/self/exe", path, BUFFER_SIZE) < 2) + return ""; + + string appPath(path); + unsigned int lastSlash = appPath.rfind("/"); + if (lastSlash != string::npos) + return appPath.substr(0, lastSlash); + else + return appPath; } \ No newline at end of file diff --git a/Atom-Linux/io_utils.h b/Atom-Linux/io_utils.h index adca46a4c..f01a25e16 100644 --- a/Atom-Linux/io_utils.h +++ b/Atom-Linux/io_utils.h @@ -14,4 +14,9 @@ int io_utils_read(std::string path, std::string* output); */ std::string io_utils_real_app_path(std::string relativePath); +/** + * Get path to directory where atom app resides + */ +std::string io_util_app_directory(); + #endif diff --git a/Atom-Linux/onig_regexp_extension.cpp b/Atom-Linux/onig_regexp_extension.cpp index e46d6c210..686fe9f2f 100644 --- a/Atom-Linux/onig_regexp_extension.cpp +++ b/Atom-Linux/onig_regexp_extension.cpp @@ -127,7 +127,7 @@ IMPLEMENT_REFCOUNTING(OnigRegexpUserData) OnigRegexpExtension::OnigRegexpExtension() : CefV8Handler() { string realFilePath = io_utils_real_app_path( - "/../src/stdlib/onig-reg-exp-extension.js"); + "/src/stdlib/onig-reg-exp-extension.js"); if (!realFilePath.empty()) { string extensionCode; if (io_utils_read(realFilePath, &extensionCode) > 0)