diff --git a/.travis.yml b/.travis.yml index 1149ebf0..52031a5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,9 @@ deploy: api_key: secure: b+fTcE73+5nkYufBNzGdxnwbx4a2BQr7iy28wdcr+8NrCxgq4mhmuZd+R3JzE7mt3ehEfUbUkXPLwefEcTFkqxXN6WdBjJYTa2JxAHkBuYiSG9X7voNCOU3SWaucY77FTdt5MlWKVOEzoKNT+tbBuLlWKNyPnFLE0JArc9w4DfvCbHos9ikTtiT1suE+OiIgt28SjD6MD4mIDmEHcKkZs1SfNxz8zhkJBp7y0iJOFPaZHZ9wE2DMox5h26ks13NMYP9mkYgZDTMppabuR8KtjGTJB7NSY3Uoj+6AYdGr5hfpzMIzLjfstagfBzLWpnuz29XwUhYR02MTRiJS6h8wXoO5twxWEKIeUT7xEjSZzdirynrErMDThz90vli0gaoZyIhU01sS9lOUozkdQJEg9Wosxs/586bShHOqhvhrfeCv2Z/7u9ftnpm7U+GaFxk3j1ZPHnSt6XcLz2wDcYIjKgsc8dvmMxYTJYLkXENU5XTkKXKfMHfweiZPWBUBjjMpcZWEyw8NQ/IsegMhXlptLsxr5N5A54KipnJK36b52vryIUzzQd4uM/pcWn5j2Il/KagM5U/kRhQDCxAozQ1Ub0HWqM+4WdCxzAg1FEUly7Y68FIVeeD19P7TAPRBGeljmr3vEdJHnr2z20dubWyhOlZ7NfTcd1drWthpN9ZvvT4= file_glob: true - file: "$TRAVIS_BUILD_DIR/release/Sourcetrail*.tar.gz" + file: + - "$TRAVIS_BUILD_DIR/release/Sourcetrail*.tar.gz" + - "$TRAVIS_BUILD_DIR/release/Sourcetrail*.AppImage" overwrite: true skip_cleanup: true on: diff --git a/CMakeLists.txt b/CMakeLists.txt index cc5ec013..ed1c614d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -516,6 +516,11 @@ configure_file( ) #configure the versioning file +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/version.txt.in + ${CMAKE_BINARY_DIR}/version.txt +) + configure_file( ${CMAKE_SOURCE_DIR}/cmake/productVersion.h.in ${CMAKE_BINARY_DIR}/src/lib_gui/productVersion.h @@ -779,8 +784,8 @@ set_property( if (WIN32) set_target_properties(${TEST_PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/bigobj") set_property( - TARGET ${TEST_PROJECT_NAME} - PROPERTY VS_DEBUGGER_WORKING_DIRECTORY + TARGET ${TEST_PROJECT_NAME} + PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/test") endif () diff --git a/bin/app/user/projects/tutorial/src/graph_tutorial_6.h b/bin/app/user/projects/tutorial/src/graph_tutorial_6.h index c40de1d2..0b6e4837 100644 --- a/bin/app/user/projects/tutorial/src/graph_tutorial_6.h +++ b/bin/app/user/projects/tutorial/src/graph_tutorial_6.h @@ -2,7 +2,7 @@ #define GRAPH_TUTORIAL_6_H -#include "String.h" +#include "string.h" class BoringClass { diff --git a/cmake/version.txt.in b/cmake/version.txt.in new file mode 100644 index 00000000..636ccfd2 --- /dev/null +++ b/cmake/version.txt.in @@ -0,0 +1 @@ +@VERSION_STRING@ \ No newline at end of file diff --git a/deployment/dockerfiles/linux/centos7_64/Dockerfile b/deployment/dockerfiles/linux/centos7_64/Dockerfile index c28df22a..7d4e0a8f 100755 --- a/deployment/dockerfiles/linux/centos7_64/Dockerfile +++ b/deployment/dockerfiles/linux/centos7_64/Dockerfile @@ -87,6 +87,15 @@ tar -xzf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz && cd boost_${BOOST_VERSION_UN ./b2 install cxxstd=14 --link=static --variant=release --threading=multi --runtime-link=static --cxxflags="-std=c++14 -fPIC" && \ cd .. && rm boost_${BOOST_VERSION_UNDERSCORE}.tar.gz && rm boost_${BOOST_VERSION_UNDERSCORE} -r +# linuxdeployqt +RUN wget https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage && \ +chmod a+x linuxdeployqt-6-x86_64.AppImage && \ +./linuxdeployqt-6-x86_64.AppImage --appimage-extract && \ +cp -r squashfs-root/usr/ /opt/linuxdeployqt && \ +chmod -R 755 /opt/linuxdeployqt && \ +rm linuxdeployqt-6-x86_64.AppImage && rm -rf squashfs-root +ENV PATH=/opt/linuxdeployqt/bin:${PATH} + #add user RUN useradd -u 1000 builder WORKDIR /home/builder diff --git a/deployment/dockerfiles/linux/centos7_64_base/Dockerfile b/deployment/dockerfiles/linux/centos7_64_base/Dockerfile index dd3f2a94..3252b725 100755 --- a/deployment/dockerfiles/linux/centos7_64_base/Dockerfile +++ b/deployment/dockerfiles/linux/centos7_64_base/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /opt RUN rpm --rebuilddb; yum install -y yum-plugin-ovl ca-certificates; RUN yum -y install centos-release-scl epel-release && \ -yum -y install make wget devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils \ +yum -y install make wget file devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils \ wget tar bzip2 git libtool which fuse fuse-devel libpng-devel automake \ glibc-headers libstdc++-devel gcc-c++ freetype-devel fontconfig-devel\ libxml2-devel libstdc++-devel libXrender libXrender-devel patch xcb-util-keysyms xcb-util-keysyms-devel \ diff --git a/deployment/dockerfiles/linux/travis_ci/Dockerfile b/deployment/dockerfiles/linux/travis_ci/Dockerfile index 3d7b4107..201dc9e0 100644 --- a/deployment/dockerfiles/linux/travis_ci/Dockerfile +++ b/deployment/dockerfiles/linux/travis_ci/Dockerfile @@ -1,5 +1,21 @@ FROM coatisoftware/centos7_64_qt_llvm:qt5126-llvm900 +# TODO: remove after full image rebuilt ------------------------------------ +USER root + +RUN yum -y install file + +RUN wget https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage && \ +chmod a+x linuxdeployqt-6-x86_64.AppImage && \ +./linuxdeployqt-6-x86_64.AppImage --appimage-extract && \ +cp -r squashfs-root/usr/ /opt/linuxdeployqt && \ +chmod -R 755 /opt/linuxdeployqt && \ +rm linuxdeployqt-6-x86_64.AppImage && rm -rf squashfs-root +ENV PATH=/opt/linuxdeployqt/bin:${PATH} + +USER builder +# -------------------------------------------------------------------------- + COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/deployment/dockerfiles/linux/travis_ci/entrypoint.sh b/deployment/dockerfiles/linux/travis_ci/entrypoint.sh index adb591b6..99fa1df7 100644 --- a/deployment/dockerfiles/linux/travis_ci/entrypoint.sh +++ b/deployment/dockerfiles/linux/travis_ci/entrypoint.sh @@ -14,5 +14,8 @@ git checkout $1 ./script/build.sh release test +./setup/Linux/createAppImage.sh + mkdir release cp ./Sourcetrail*.tar.gz ./release/ +cp ./Sourcetrail*.AppImage ./release/ diff --git a/setup/Linux/createAppImage.sh b/setup/Linux/createAppImage.sh new file mode 100755 index 00000000..b47108e5 --- /dev/null +++ b/setup/Linux/createAppImage.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +BIN_PATH=build/Release/app/Sourcetrail +PROJECTS_PATH=bin/app/user/projects + +./$BIN_PATH index --full $PROJECTS_PATH/tictactoe_cpp/tictactoe_cpp.srctrlprj +./$BIN_PATH index --full $PROJECTS_PATH/tictactoe_py/tictactoe_py.srctrlprj +./$BIN_PATH index --full $PROJECTS_PATH/tutorial/tutorial.srctrlprj +./$BIN_PATH index --full $PROJECTS_PATH/javaparser/javaparser.srctrlprj + +rm -rf AppDir + +mkdir AppDir +cd AppDir + +mkdir usr +cd usr + +mkdir bin +mkdir lib +mkdir share + +cd bin +cp ../../../build/Release/app/Sourcetrail sourcetrail +cp ../../../build/Release/app/sourcetrail_indexer . +cd .. + +cd share + +mkdir applications +cd applications +cp ../../../../setup/Linux/sourcetrail.desktop . +cd .. + +cp -r ../../../build/Release/share/icons/ . + +mkdir mime +cd mime +mkdir packages +cd packages +cp ../../../../../setup/Linux/sourcetrail-mime.xml . +cd ../.. + +mkdir data +cd data +cp -R ../../../../bin/app/data/color_schemes . +cp -R ../../../../bin/app/data/syntax_highlighting_rules . +cp -R ../../../../bin/app/data/fonts . +cp -R ../../../../bin/app/data/gui . +cp -R ../../../../bin/app/data/java . +cp -R ../../../../bin/app/data/python . +cp -R ../../../../bin/app/data/fallback . +cp -R ../../../../bin/app/user/projects fallback/ +cp -R ../../../../bin/app/data/license . +cp -R ../../../../bin/app/data/cxx . +cd .. + +cd ../../.. + +# find AppDir | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/" + +export VERSION=$(cat build/Release/version.txt) + +linuxdeployqt AppDir/usr/bin/sourcetrail_indexer -qmake=$Qt5_DIR/bin/qmake -ignore-glob=*python* +rm -f AppDir/AppRun +linuxdeployqt AppDir/usr/share/applications/sourcetrail.desktop -qmake=$Qt5_DIR/bin/qmake -ignore-glob=*python* -appimage + +rename x86_64 Linux_64bit *.AppImage +rename - _ *.AppImage +rename - _ *.AppImage +rename . _ *.AppImage +rename . _ *.AppImage diff --git a/setup/Linux/sourcetrail.desktop b/setup/Linux/sourcetrail.desktop index 5962eeb5..3413c328 100644 --- a/setup/Linux/sourcetrail.desktop +++ b/setup/Linux/sourcetrail.desktop @@ -8,5 +8,5 @@ Icon=sourcetrail Terminal=false Type=Application MimeType=application/x-sourcetrail; -Categories=Development;IDE;Utilities; +Categories=Development; StartupNotify=true diff --git a/src/app/main.cpp b/src/app/main.cpp index 4e75ad12..00c28b34 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -97,7 +97,8 @@ int main(int argc, char *argv[]) #pragma warning(push) #pragma warning(disable : 4996) - if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr) + if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr && + !FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/../share").exists()) { std::cout << "ERROR: Please run Sourcetrail via the Sourcetrail.sh script!" << std::endl; } diff --git a/src/indexer/main.cpp b/src/indexer/main.cpp index e4246d9b..68296479 100644 --- a/src/indexer/main.cpp +++ b/src/indexer/main.cpp @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) logFilePath = argv[5]; } - AppPath::setAppPath(FilePath(appPath)); + AppPath::setSharedDataPath(FilePath(appPath)); UserPaths::setUserDataPath(FilePath(userDataPath)); if (!logFilePath.empty()) @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) appSettings->load(FilePath(UserPaths::getAppSettingsPath())); LogManager::getInstance()->setLoggingEnabled(appSettings->getLoggingEnabled()); - LOG_INFO(L"appPath: " + AppPath::getAppPath().wstr()); + LOG_INFO(L"sharedDataPath: " + AppPath::getSharedDataPath().wstr()); LOG_INFO(L"userDataPath: " + UserPaths::getUserDataPath().wstr()); diff --git a/src/lib/app/paths/AppPath.cpp b/src/lib/app/paths/AppPath.cpp index e140561b..62ddc3dc 100644 --- a/src/lib/app/paths/AppPath.cpp +++ b/src/lib/app/paths/AppPath.cpp @@ -1,17 +1,43 @@ #include "AppPath.h" -FilePath AppPath::m_appPath(L""); +FilePath AppPath::m_sharedDataPath(L""); +FilePath AppPath::m_cxxIndexerPath(L""); -FilePath AppPath::getAppPath() +FilePath AppPath::getSharedDataPath() { - return m_appPath; + return m_sharedDataPath; } -bool AppPath::setAppPath(const FilePath& path) +bool AppPath::setSharedDataPath(const FilePath& path) { if (!path.empty()) { - m_appPath = path; + m_sharedDataPath = path; + return true; + } + return false; +} + +FilePath AppPath::getCxxIndexerPath() +{ +#if _WIN32 +const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe"); +#else +const std::wstring cxxIndexerName(L"sourcetrail_indexer"); +#endif + + if (!m_cxxIndexerPath.empty()) + { + return m_cxxIndexerPath.getConcatenated(cxxIndexerName); + } + return m_sharedDataPath.getConcatenated(cxxIndexerName); +} + +bool AppPath::setCxxIndexerPath(const FilePath& path) +{ + if (!path.empty()) + { + m_cxxIndexerPath = path; return true; } return false; diff --git a/src/lib/app/paths/AppPath.h b/src/lib/app/paths/AppPath.h index 6c40a9f4..20dd8935 100644 --- a/src/lib/app/paths/AppPath.h +++ b/src/lib/app/paths/AppPath.h @@ -6,11 +6,15 @@ class AppPath { public: - static FilePath getAppPath(); - static bool setAppPath(const FilePath& path); + static FilePath getSharedDataPath(); + static bool setSharedDataPath(const FilePath& path); + + static FilePath getCxxIndexerPath(); + static bool setCxxIndexerPath(const FilePath& path); private: - static FilePath m_appPath; + static FilePath m_sharedDataPath; + static FilePath m_cxxIndexerPath; }; #endif // APP_PATH_H diff --git a/src/lib/app/paths/ResourcePaths.cpp b/src/lib/app/paths/ResourcePaths.cpp index 99c288ce..593a8f75 100644 --- a/src/lib/app/paths/ResourcePaths.cpp +++ b/src/lib/app/paths/ResourcePaths.cpp @@ -4,45 +4,45 @@ FilePath ResourcePaths::getColorSchemesPath() { - return AppPath::getAppPath().concatenate(L"data/color_schemes/"); + return AppPath::getSharedDataPath().concatenate(L"data/color_schemes/"); } FilePath ResourcePaths::getSyntaxHighlightingRulesPath() { - return AppPath::getAppPath().concatenate(L"data/syntax_highlighting_rules/"); + return AppPath::getSharedDataPath().concatenate(L"data/syntax_highlighting_rules/"); } FilePath ResourcePaths::getFallbackPath() { - return AppPath::getAppPath().concatenate(L"data/fallback/"); + return AppPath::getSharedDataPath().concatenate(L"data/fallback/"); } FilePath ResourcePaths::getFontsPath() { - return AppPath::getAppPath().concatenate(L"data/fonts/"); + return AppPath::getSharedDataPath().concatenate(L"data/fonts/"); } FilePath ResourcePaths::getGuiPath() { - return AppPath::getAppPath().concatenate(L"data/gui/"); + return AppPath::getSharedDataPath().concatenate(L"data/gui/"); } FilePath ResourcePaths::getLicensePath() { - return AppPath::getAppPath().concatenate(L"data/license/"); + return AppPath::getSharedDataPath().concatenate(L"data/license/"); } FilePath ResourcePaths::getJavaPath() { - return AppPath::getAppPath().concatenate(L"data/java/"); + return AppPath::getSharedDataPath().concatenate(L"data/java/"); } FilePath ResourcePaths::getPythonPath() { - return AppPath::getAppPath().concatenate(L"data/python/"); + return AppPath::getSharedDataPath().concatenate(L"data/python/"); } FilePath ResourcePaths::getCxxCompilerHeaderPath() { - return AppPath::getAppPath().concatenate(L"data/cxx/include/").getCanonical(); + return AppPath::getSharedDataPath().concatenate(L"data/cxx/include/").getCanonical(); } diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index c6ef090b..55f597c0 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -13,13 +13,6 @@ #include "UserPaths.h" #include "utilityApp.h" - -#if _WIN32 -const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer.exe"); -#else -const std::wstring TaskBuildIndex::s_processName(L"sourcetrail_indexer"); -#endif - TaskBuildIndex::TaskBuildIndex( size_t processCount, std::shared_ptr storageProvider, @@ -185,7 +178,7 @@ void TaskBuildIndex::handleMessage(MessageIndexingInterrupted* message) void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath) { - const FilePath indexerProcessPath = AppPath::getAppPath().concatenate(s_processName); + const FilePath indexerProcessPath = AppPath::getCxxIndexerPath(); if (!indexerProcessPath.exists()) { m_interrupted = true; @@ -199,7 +192,7 @@ void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFil std::vector commandArguments; commandArguments.push_back(std::to_wstring(processId)); commandArguments.push_back(utility::decodeFromUtf8(m_appUUID)); - commandArguments.push_back(L"\"" + AppPath::getAppPath().getAbsolute().wstr() + L"\""); + commandArguments.push_back(L"\"" + AppPath::getSharedDataPath().getAbsolute().wstr() + L"\""); commandArguments.push_back(L"\"" + UserPaths::getUserDataPath().getAbsolute().wstr() + L"\""); if (!logFilePath.empty()) diff --git a/src/lib_gui/platform_includes/includesLinux.h b/src/lib_gui/platform_includes/includesLinux.h index 5e98f56e..2835085b 100644 --- a/src/lib_gui/platform_includes/includesLinux.h +++ b/src/lib_gui/platform_includes/includesLinux.h @@ -44,8 +44,15 @@ void setupPlatform(int argc, char* argv[]) void setupApp(int argc, char* argv[]) { - AppPath::setAppPath( - FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute()); + FilePath appPath = FilePath(QCoreApplication::applicationDirPath().toStdWString() + L"/").getAbsolute(); + AppPath::setSharedDataPath(appPath); + AppPath::setCxxIndexerPath(appPath); + + // Check if bundled as Linux AppImage + if (appPath.getConcatenated(L"/../share/data").exists()) + { + AppPath::setSharedDataPath(appPath.getConcatenated(L"/../share").getAbsolute()); + } std::string userdir(std::getenv("HOME")); userdir.append("/.config/sourcetrail/"); @@ -60,7 +67,7 @@ void setupApp(int argc, char* argv[]) utility::copyNewFilesFromDirectory( QString::fromStdWString(ResourcePaths::getFallbackPath().wstr()), userDataPath); utility::copyNewFilesFromDirectory( - QString::fromStdWString(AppPath::getAppPath().concatenate(L"user/").wstr()), userDataPath); + QString::fromStdWString(AppPath::getSharedDataPath().concatenate(L"user/").wstr()), userDataPath); } #endif // INCLUDES_DEFAULT_H diff --git a/src/lib_gui/platform_includes/includesMac.h b/src/lib_gui/platform_includes/includesMac.h index 9cb1b712..e1f63bd6 100644 --- a/src/lib_gui/platform_includes/includesMac.h +++ b/src/lib_gui/platform_includes/includesMac.h @@ -77,7 +77,7 @@ void setupPlatform(int argc, char* argv[]) void setupApp(int argc, char* argv[]) { const FilePath path(QDir::currentPath().toStdWString() + L"/"); - AppPath::setAppPath(path.getAbsolute()); + AppPath::setSharedDataPath(path.getAbsolute()); } #endif // INCLUDES_MAC_H diff --git a/src/lib_gui/platform_includes/includesWindows.h b/src/lib_gui/platform_includes/includesWindows.h index f6e5629f..dccae272 100644 --- a/src/lib_gui/platform_includes/includesWindows.h +++ b/src/lib_gui/platform_includes/includesWindows.h @@ -34,11 +34,11 @@ void setupApp(int argc, char* argv[]) { appPath = appPath.substr(0, pos + 1); } - AppPath::setAppPath(FilePath(appPath)); + AppPath::setSharedDataPath(FilePath(appPath)); } { - FilePath userDataPath = AppPath::getAppPath().concatenate(L"user/"); + FilePath userDataPath = AppPath::getSharedDataPath().concatenate(L"user/"); if (!userDataPath.exists()) { #pragma warning(push) @@ -65,7 +65,7 @@ void setupApp(int argc, char* argv[]) } else { - userDataPath = AppPath::getAppPath().concatenate(L"user_fallback/"); + userDataPath = AppPath::getSharedDataPath().concatenate(L"user_fallback/"); LOG_ERROR( L"The \"%LOCALAPPDATA%\" path could not be found. Falling back to \"" + userDataPath.wstr() + L"\" to store settings data."); diff --git a/src/test/SourceGroupTestSuite.cpp b/src/test/SourceGroupTestSuite.cpp index e7a25b03..b5c5562a 100644 --- a/src/test/SourceGroupTestSuite.cpp +++ b/src/test/SourceGroupTestSuite.cpp @@ -505,8 +505,8 @@ TEST_CASE("sourcegroup java gradle generates expected output") std::shared_ptr applicationSettings = ApplicationSettings::getInstance(); - const FilePath storedAppPath = AppPath::getAppPath(); - AppPath::setAppPath(storedAppPath.getConcatenated(L"../app").makeAbsolute()); + const FilePath storedAppPath = AppPath::getSharedDataPath(); + AppPath::setSharedDataPath(storedAppPath.getConcatenated(L"../app").makeAbsolute()); std::vector storedJreSystemLibraryPaths = applicationSettings->getJreSystemLibraryPaths(); @@ -516,7 +516,7 @@ TEST_CASE("sourcegroup java gradle generates expected output") projectName, std::make_shared(sourceGroupSettings)); applicationSettings->setJreSystemLibraryPaths(storedJreSystemLibraryPaths); - AppPath::setAppPath(storedAppPath); + AppPath::setSharedDataPath(storedAppPath); # endif }