diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe9733..4f3fcdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,12 +172,23 @@ endif() # Tor/torsocks set(TOR_TAG "tor-0.4.3.5") set(TOR_DIR "${CMAKE_SOURCE_DIR}/contrib/tor") + +if(BUILD_TOR AND APPLE) + execute_process(COMMAND bash -c "touch ${CMAKE_SOURCE_DIR}/src/tor/libevent-2.1.7.dylib") +ENDIF() + if(UNIX AND NOT APPLE) set(TOR_LIB "libtorsocks.so") elseif(APPLE) set(TOR_LIB "libtorsocks.dylib") endif() -if("$ENV{DRONE}" STREQUAL "true" AND STATIC AND BUILD_TOR) + +if("$ENV{DRONE}" STREQUAL "true" AND APPLE) + message(STATUS "We are inside a static compile with Drone CI") + # @TODO: taken from Tor Browser official release for now + execute_process(COMMAND bash -c "cp ~/tor/libevent-2.1.7.dylib ${CMAKE_SOURCE_DIR}/src/tor/libevent-2.1.7.dylib") + execute_process(COMMAND bash -c "cp ~/tor/tor ${CMAKE_SOURCE_DIR}/src/tor/tor") +elseif("$ENV{DRONE}" STREQUAL "true" AND BUILD_TOR) message(STATUS "We are inside a static compile with Drone CI") if(MINGW) execute_process(COMMAND bash -c "cp /mxe/usr/x86_64-w64-mingw32.static/bin/tor.exe ${CMAKE_SOURCE_DIR}/src/tor/tor.exe") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c9ecc6..020ba8d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,7 @@ file(GLOB SOURCE_FILES "dialog/*.cpp" ) -if(APPLE AND BUILD_TOR) +if((APPLE AND BUILD_TOR) OR (APPLE AND "$ENV{DRONE}" STREQUAL "true")) set(ASSETS_OS "assets_macos_tor.qrc") elseif(UNIX AND NOT APPLE AND BUILD_TOR) set(ASSETS_OS "assets_linux_tor.qrc") @@ -138,6 +138,10 @@ if(STATIC) target_compile_definitions(feather PRIVATE STATIC=1) endif() +if("$ENV{DRONE}" STREQUAL "true") + target_compile_definitions(feather PRIVATE DRONE=1) +endif() + if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_definitions(feather PRIVATE QT_NO_DEBUG=1) endif() diff --git a/src/assets_macos_tor.qrc b/src/assets_macos_tor.qrc index 4539da6..5acecc2 100644 --- a/src/assets_macos_tor.qrc +++ b/src/assets_macos_tor.qrc @@ -1,5 +1,6 @@ tor/tor + tor/libevent-2.1.7.dylib diff --git a/src/utils/tor.cpp b/src/utils/tor.cpp index 1175982..3e763ed 100644 --- a/src/utils/tor.cpp +++ b/src/utils/tor.cpp @@ -174,6 +174,22 @@ void Tor::handleProcessError(QProcess::ProcessError error) { bool Tor::unpackBins() { QString torFile; + + // @TODO: refactor for Mac OS - should compile Tor statically. +#if defined(Q_OS_MAC) && defined(DRONE) + // Tor on Mac requires libevent.dylib, borrowed the executable from + // the official Tor Browser release for now. + QString libEvent = ":/tor/libevent-2.1.7.dylib"; + if (Utils::fileExists(libEvent)) { + QFile e(libEvent); + QFileInfo eventInfo(e); + auto libEventPath = QDir(this->torDir).filePath(eventInfo.fileName()); + qDebug() << libEventPath; + e.copy(libEventPath); + e.close(); + } +#endif + #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) torFile = ":/tor/tor"; #elif defined(Q_OS_WIN) diff --git a/utils/build_macos.sh b/utils/build_macos.sh index 11234aa..cdcbafd 100644 --- a/utils/build_macos.sh +++ b/utils/build_macos.sh @@ -3,11 +3,12 @@ HASH="$1" echo "[+] hash: $HASH" +export DRONE=true echo "[+] Building" rm ~/feather.zip 2>&1 >/dev/null cd ~/feather -git fetch +git fetch --all git reset --hard "$HASH" git submodule update --init --depth 50 contrib/tor git submodule update --init --depth 50 contrib/torsocks