Windows port using Conan and MXE. Part of #5807

This commit is contained in:
Pedro Pombeiro 2018-09-26 16:40:41 +02:00
parent 1f2e2728cb
commit d0f78445d4
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
20 changed files with 442 additions and 59 deletions

View File

@ -22,6 +22,7 @@ fixes #...
- iOS
- macOS
- Linux
- Windows
<!-- (Specify if some specific areas has to be tested, for example 1-1 chats) -->
#### Areas that maybe impacted (optional)

14
.gitignore vendored
View File

@ -129,13 +129,21 @@ cmake_install.cmake
CMakeCache.txt
**/CMakeFiles/
/StatusImPackage/*
*.AppImage
/desktop/bin/*
/desktop/lib/*
/desktop/modules/*
/desktop/Makefile
/desktop/run-app.bat
/desktop/run-app.sh
/desktop/CMakeFiles/
/desktop/reportApp/Makefile
/desktop/reportApp/reportApp
/desktop/reportApp/reportApp_autogen/
/linuxdeployqt-*.AppImage
*_autogen/
CompleteBundleWin.cmake
logger_settings.ini
# Conan
conan*.txt
conanbuildinfo.*
conan.cmake
/.conan_*/

View File

@ -82,6 +82,9 @@ release-ios: prod-build-ios ##@build build release for iOS release
release-desktop: prod-build-desktop ##@build build release for desktop release
scripts/build-desktop.sh
release-windows-desktop: prod-build-desktop ##@build build release for desktop release
TARGET_SYSTEM_NAME=Windows scripts/build-desktop.sh
prod-build:
lein prod-build

View File

@ -11,9 +11,21 @@ cmake_minimum_required(VERSION 2.8.11)
set(APP_NAME Status)
set(JS_APP_NAME StatusIm)
set(REACT_BUILD_STATIC_LIB ON)
project(${APP_NAME} CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNICODE -std=c++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNICODE -std=c11")
set(CMAKE_INSTALL_PREFIX bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}" CACHE PATH "Where to place compiled executables.")
set(${APP_NAME}_BINARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
set(USED_QT_MODULES Core Qml Quick WebSockets Svg)
include(QtConfiguration)
message(STATUS "EXTERNAL_MODULES_DIR: ${EXTERNAL_MODULES_DIR}")
string(REGEX MATCH "BUILD_FOR_BUNDLE" BUILD_FOR_BUNDLE "${CMAKE_CXX_FLAGS}")
@ -38,12 +50,23 @@ endforeach(external_module)
add_subdirectory(reportApp)
# Import any new Qt modules that have been added by external dependencies
import_qt_modules()
# APPLICATION_MAIN_CPP_PATH contains absolute path to generated template copy of main.cpp for application executable
get_filename_component(APPLICATION_MAIN_CPP_PATH main.cpp ABSOLUTE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../node_modules/react-native/React/Layout)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../node_modules/react-native/ReactQt/runtime/src ${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../node_modules/react-native/ReactQt/application/src ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(REACTQT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../node_modules/react-native/React)
include_directories(${REACTQT_DIR}/Layout)
add_subdirectory(${REACTQT_DIR}Qt/runtime/src ${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(${REACTQT_DIR}Qt/application/src ${CMAKE_CURRENT_BINARY_DIR}/bin)
if (Qt5_POSITION_INDEPENDENT_CODE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif(Qt5_POSITION_INDEPENDENT_CODE)
#set(SOURCE_ROOT ${CMAKE_SOURCE_DIR})
include(CompleteBundle)
if (WIN32)
set(RUN_SCRIPT_FILE_NAME "run-app.bat")
@ -56,4 +79,3 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/${RUN_SCRIPT_FILE_NAME}
@ONLY
)

View File

@ -0,0 +1,12 @@
if(APPLE)
set(SCRIPT CompleteBundleOSX)
elseif(WIN32)
set(SCRIPT CompleteBundleWin)
elseif(UNIX)
set(SCRIPT CompleteBundleLinux)
endif(APPLE)
if(SCRIPT AND EXISTS ${CMAKE_SOURCE_DIR}/CMakeModules/${SCRIPT}.cmake.in)
configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/${SCRIPT}.cmake.in ${SCRIPT}.cmake @ONLY)
include(${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT}.cmake)
endif(SCRIPT)

View File

@ -0,0 +1,55 @@
# windeployqt should be used here, but since we get the `Not implemented` error from it, we're trying to manually copy artifacts to output directory
set(TARGET_DIR "${@APP_NAME@_BINARY_DIR}")
set(qtmodules Core Quick QuickTemplates2 QuickControls2 WebSockets Widgets Gui Network Svg Qml Concurrent)
if(USE_QTWEBKIT)
set(qtmodules ${qtmodules} Multimedia WebKit WebKitWidgets WebChannel)
add_custom_command(TARGET @APP_NAME@ POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"@CONAN_BIN_DIRS_QT5-MXE@/QtWebProcess.exe"
${TARGET_DIR})
endif()
foreach(qtmodule ${qtmodules})
message(STATUS "Copying ${qtmodule} module to ${TARGET_DIR}")
file(COPY "@CONAN_BIN_DIRS_QT5-MXE@/Qt5${qtmodule}.dll" DESTINATION "${TARGET_DIR}")
endforeach(qtmodule ${qtmodules})
if(EXISTS "@QTROOT@/translations")
message(STATUS "Copying translations module to ${TARGET_DIR}")
file(COPY "@QTROOT@/translations" DESTINATION "${TARGET_DIR}")
endif()
set(qtplugindirs "bearer" "platforms" "styles" "iconengines" "imageformats")
foreach(qtplugindir ${qtplugindirs})
message(STATUS "Copying plugin ${qtplugindir} to ${TARGET_DIR}/${qtplugindir}")
file(COPY "@CONAN_BIN_DIRS_QT5-MXE@/../plugins/${qtplugindir}/" DESTINATION "${TARGET_DIR}/${qtplugindir}")
endforeach()
set(qtqmldirs "QtQuick" "QtQuick.2" "QtGraphicalEffects" "QtWebSockets" "QtQml")
if(USE_QTWEBKIT)
set(qtqmldirs ${qtqmldirs} "QtWebKit" "QtWebChannel")
endif()
foreach(qtqmldir ${qtqmldirs})
message(STATUS "Copying QML dir for ${qtqmldir} to ${TARGET_DIR}/${qtqmldir}")
file(COPY "@CONAN_BIN_DIRS_QT5-MXE@/../qml/${qtqmldir}/" DESTINATION "${TARGET_DIR}/${qtqmldir}")
endforeach()
set(deps_qt5 "libpng16-16" "libharfbuzz-0" "zlib1" "libpcre2-16-0"
"libpcre-1" "libcrypto-1_1-x64" "libssl-1_1-x64" "libfreetype-6"
"libglib-2.0-0" "libstdc++-6" "libbz2" "libintl-8" "libiconv-2"
"icuin56" "icuuc56" "icudt56" "libjpeg-9" "libsqlite3-0" "libwebp-5" "libgcc_s_seh-1")
set(TOOLCHAIN_BINDIRS "@CONAN_BIN_DIRS_MXETOOLCHAIN-X86_64-W64-MINGW32@")
separate_arguments(TOOLCHAIN_BINDIRS)
foreach(lib ${deps_qt5})
foreach(bindir ${TOOLCHAIN_BINDIRS})
set(lib_full_path "${bindir}/${lib}.dll")
if(EXISTS "${lib_full_path}")
break()
endif()
endforeach()
if(NOT EXISTS "${lib_full_path}")
set(lib_full_path "@CONAN_BIN_DIRS_QT5-MXE@/${lib}.dll")
endif()
message(STATUS "Copying ${lib_full_path} to ${TARGET_DIR}")
file(COPY ${lib_full_path} DESTINATION ${TARGET_DIR})
endforeach(lib ${deps_qt5})

View File

@ -0,0 +1,81 @@
macro(import_qt_modules)
set(REQUIRED_QT_VERSION "5.9.1")
set(QTCONFIGROOT ${QTROOT}/lib/cmake/Qt5)
foreach(COMP ${USED_QT_MODULES})
set(mod Qt5${COMP})
# look for the config files in the QtConfigRoot defined above
set(${mod}_DIR ${QTCONFIGROOT}${COMP})
# look for the actual package
find_package(${mod} ${REQUIRED_QT_VERSION} REQUIRED)
#message("${mod}_INCLUDE_DIRS: include_directories(${${mod}_INCLUDE_DIRS})")
include_directories(${${mod}_INCLUDE_DIRS})
list(APPEND QT5_LIBRARIES ${${mod}_LIBRARIES})
list(APPEND QT5_CFLAGS ${${mod}_EXECUTABLE_COMPILE_FLAGS})
endforeach(COMP ${USED_QT_MODULES})
endmacro(import_qt_modules)
if(WIN32)
# Download automatically, you can also just copy the conan.cmake file
# TODO: Create packages of qt5 for Linux and MacOS too, so that we can rely strictly on this branch of code
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_check()
if(USE_QTWEBKIT)
set(_QT_PACKAGE_OPTIONS "qt5-mxe:webkit=True")
endif()
conan_cmake_run(REQUIRES qt5-mxe/5.11.2@status-im/stable
PROFILE ../node_modules/status-conan/profiles/status-mingw32-x86_64
BASIC_SETUP
SETTINGS "qt5-mxe:os=Windows qt5-mxe:arch=x86_64"
OPTIONS ${_QT_PACKAGE_OPTIONS}
BUILD never)
set(QTROOT "${CONAN_QT5-MXE_ROOT}")
else(WIN32)
set(QTROOT "$ENV{QT_PATH}")
endif(WIN32)
if(NOT EXISTS ${QTROOT}/bin/qt.conf)
if(EXISTS ${QTROOT}/gcc_64/bin/qt.conf)
set(QTROOT "${QTROOT}/gcc_64")
else()
message(FATAL_ERROR "Could not find qt.conf in ${QTROOT}/bin nor in ${QTROOT}/gcc_64/bin. Is QTROOT correctly defined?")
endif()
endif()
if(WIN32)
set(WINARCHSTR ARCHSTR windows-x86_64)
endif(WIN32)
message(STATUS "Qt root directory: ${QTROOT}")
list(APPEND CMAKE_FIND_ROOT_PATH ${QTROOT})
list(APPEND CMAKE_PREFIX_PATH ${QTROOT})
include_directories(${QTROOT}/include)
import_qt_modules()
if(QT5_CFLAGS)
list(REMOVE_DUPLICATES QT5_CFLAGS)
if(WIN32)
list(REMOVE_ITEM QT5_CFLAGS -fPIC)
endif(WIN32)
endif(QT5_CFLAGS)
message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT5_CFLAGS}")
set(CMAKE_REQUIRED_LIBRARIES ${QT5_LIBRARIES})

View File

@ -0,0 +1,19 @@
# Toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..
message(STATUS "Cross-compiling for Windows")
set(CMAKE_SYSTEM_NAME Windows)
if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
message(FATAL_ERROR "Can only cross-compile to Windows from Linux")
endif()
set(USE_QTWEBKIT ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/toolchain/")
include(conanbuildinfo)
#conan_basic_setup()
conan_global_flags()

View File

@ -0,0 +1,56 @@
FROM ubuntu:16.04
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LEIN_HOME /var/tmp/lein
ENV NPM_CONFIG_CACHE /var/tmp/npm
# We have to do this because Jenkins doesn't let us
# https://issues.jenkins-ci.org/browse/JENKINS-49076
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN apt-get update && apt-get -q -y --no-install-recommends install curl software-properties-common && \
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
add-apt-repository -y ppa:longsleep/golang-backports && \
apt-get remove -y software-properties-common && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -q -y --no-install-recommends install \
wget git zip unzip golang-go nodejs yarn file jq \
python python3-pip python3-setuptools python3-wheel \
apt-transport-https locales openjdk-8-jdk-headless \
extra-cmake-modules build-essential fuse \
libx11-xcb1 libxss1 libasound2 libgl-dev libsm6 libxrandr2 python-dev \
libjasper-dev libegl1-mesa libxcomposite-dev libxcursor-dev && \
locale-gen en_US.UTF-8 && \
npm install -g npm@5.5.1 && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man && \
python3 -m pip install --upgrade pip && \
pip3 install conan==1.9.0
RUN cd /tmp && wget -q https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz && \
tar xf cmake-3.12.2-Linux-x86_64.tar.gz --strip 1 -C /usr/local && \
rm -fr /usr/local/doc/cmake && rm cmake-3.12.2-Linux-x86_64.tar.gz
RUN curl -sL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -o /usr/bin/lein && \
chmod +x /usr/bin/lein && /usr/bin/lein version
RUN cd /tmp && \
git clone --depth=1 https://github.com/status-im/react-native-desktop.git && \
cp -r /tmp/react-native-desktop/react-native-cli /opt && \
cd /opt/react-native-cli && \
npm update && npm install -g && \
cd && rm -r /tmp/react-native-desktop
# These are the UID and GID values used by Jenkins
RUN addgroup --gid 1002 jenkins && \
adduser --shell /bin/bash \
--disabled-password --gecos "" \
--uid 1001 --gid 1002 \
--home /var/tmp/jenkins jenkins
LABEL source="https://github.com/status-im/status-react/tree/develop/desktop/windows/docker" \
description="Image for building Windows Desktop version of Status app." \
maintainer="jakub@status.im"

View File

@ -190,7 +190,7 @@ bool redirectLogIntoFile() {
QString getDataStoragePath() {
QString dataStoragePath =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
QDir dir(dataStoragePath);
if (!dir.exists()) {
dir.mkpath(".");

View File

@ -13,12 +13,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(APP_NAME "reportApp")
find_package(Qt5Core REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5WebSockets REQUIRED)
find_package(Qt5Svg REQUIRED)
set(MAIN_CPP_SOURCE reportpublisher.cpp
reportpublisher.cpp
main.cpp)

View File

@ -45,7 +45,7 @@ void ReportPublisher::restartAndQuit() {
bundleExtension.size());
}
QString cmd = QString("open %1").arg(appPath);
#elif defined(Q_OS_LINUX)
#else
QString cmd = appPath;
#endif
@ -95,7 +95,7 @@ bool ReportPublisher::prepareLogFiles(QString reportDirPath) {
QString ReportPublisher::resolveDataStoragePath() {
QFileInfo minidumpFileInfo(m_minidumpFilePath);
QString dataStoragePath =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) +
QDir::separator() + minidumpFileInfo.baseName();
QDir dir(dataStoragePath);
if (!dir.exists()) {

View File

@ -11065,7 +11065,7 @@
}
},
"react-native": {
"version": "git+https://github.com/status-im/react-native-desktop.git#c034f0db54a201eb54e6241bf120d55de44a30c0",
"version": "git+https://github.com/status-im/react-native-desktop.git#19d3b0aef918d910fb53755d394507d555e28fde",
"requires": {
"absolute-path": "0.0.0",
"art": "0.10.3",
@ -12908,6 +12908,9 @@
}
}
},
"status-conan": {
"version": "git+https://github.com/status-im/status-conan.git#ff7778cf2a5189d48f8d916faa0b623084470045"
},
"statuses": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",

View File

@ -55,7 +55,7 @@
"querystring-es3": "0.2.1",
"react": "16.4.1",
"react-dom": "16.4.2",
"react-native": "git+https://github.com/status-im/react-native-desktop.git#v0.56.1_2",
"react-native": "git+https://github.com/status-im/react-native-desktop.git#v0.56.1_3",
"react-native-background-timer": "2.0.0",
"react-native-camera": "0.10.0",
"react-native-config": "git+https://github.com/status-im/react-native-config.git",
@ -81,6 +81,7 @@
"react-native-webview-bridge": "github:status-im/react-native-webview-bridge#react-native-0.49-desktop",
"realm": "git+https://github.com/status-im/realm-js.git",
"rn-snoopy": "github:status-im/rn-snoopy",
"status-conan": "git+https://github.com/status-im/status-conan.git#master",
"string_decoder": "0.10.31",
"text-encoding": "^0.6.4",
"url": "0.10.3",

View File

@ -9,6 +9,11 @@ set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC ${REACT_NATIVE_DESKTOP_EXTERNAL_MO
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
set(SN_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/SnoreNotify_ep-prefix/src/SnoreNotify_ep)
if (WIN32)
set(SnoreNotify_CMAKE_ARGS -DMINGW=1 -DBUILD_osxnotificationcenter=OFF -DBUILD_sound=OFF -DBUILD_speech=OFF -DBUILD_toasty=OFF -DBUILD_snoretoast=OFF
-DBUILD_freedesktop_backend=OFF -DBUILD_snarl=OFF -DBUILD_growl=OFF -DBUILD_trayicon=OFF -DBUILD_pushover_backend=OFF)
endif()
if (UNIX AND NOT APPLE)
set(SN_LIBPATHSUFFIX /${CMAKE_LIBRARY_ARCHITECTURE})
set(SnoreNotifyFreedesktop_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snore_backend_freedesktop${CMAKE_STATIC_LIBRARY_SUFFIX})
@ -33,7 +38,29 @@ set(SnoreNotifyBackendSettings_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${
set(SnoreNotifySettings_STATIC_LIB ${SN_PREFIX}/lib${SN_LIBPATHSUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}snoresettings-qt5${CMAKE_STATIC_LIBRARY_SUFFIX})
set(SnoreNotify_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SN_PREFIX} -DSNORE_STATIC=ON -DBUILD_daemon=OFF -DBUILD_settings=OFF
-DBUILD_snoresend=OFF ${SnoreNotify_CMAKE_ARGS})
if (CMAKE_CROSSCOMPILING)
set(SnoreNotify_CMAKE_ARGS ${SnoreNotify_CMAKE_ARGS}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}"
# These are only useful if you're cross-compiling.
# They, however, will not hurt regardless.
"-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}"
"-DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}"
"-DCMAKE_AR=${CMAKE_AR}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_COMPILER_AR=${CMAKE_C_COMPILER_AR}"
"-DCMAKE_C_COMPILER_RANLIB=${CMAKE_C_COMPILER_RANLIB}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_COMPILER_AR=${CMAKE_CXX_COMPILER_AR}"
"-DCMAKE_CXX_COMPILER_RANLIB=${CMAKE_CXX_COMPILER_RANLIB}"
"-DCMAKE_LINKER=${CMAKE_LINKER}"
"-DCMAKE_RC_COMPILER=${CMAKE_RC_COMPILER}"
"-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
"-DCMAKE_COMPILER_PREFIX=${CMAKE_COMPILER_PREFIX}"
"-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}")
endif()
ExternalProject_Add(SnoreNotify_ep
GIT_REPOSITORY https://github.com/status-im/snorenotify.git

View File

@ -11,9 +11,6 @@ set(REACT_NATIVE_DESKTOP_EXTERNAL_MODULES_SRC ${REACT_NATIVE_DESKTOP_EXTERNAL_MO
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
if (WIN32 AND NOT CUSTOM_STATUSGO_BUILD_DIR_PATH)
set(CUSTOM_STATUSGO_BUILD_DIR_PATH "C:/srd-build/StatusGo")
endif()
if (CUSTOM_STATUSGO_BUILD_DIR_PATH)
set(StatusGo_ROOT ${CUSTOM_STATUSGO_BUILD_DIR_PATH})
else()
@ -27,11 +24,7 @@ set(StatusGo_STATIC_LIB
include_directories(${StatusGo_INCLUDE_DIR})
if (WIN32)
set(CONFIGURE_SCRIPT build-status-go.bat)
else()
set(CONFIGURE_SCRIPT build-status-go.sh)
endif()
set(CONFIGURE_SCRIPT build-status-go.sh)
file (STRINGS "../../../STATUS_GO_VERSION" STATUS_GO_VERSION)
@ -40,7 +33,7 @@ ExternalProject_Add(StatusGo_ep
SOURCE_DIR ${StatusGo_SOURCE_DIR}
URL https://github.com/status-im/status-go/releases/download/${STATUS_GO_VERSION}/status-go-desktop.zip
BUILD_BYPRODUCTS ${StatusGo_STATIC_LIB}
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR}
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${CMAKE_SYSTEM_NAME} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER}
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
@ -53,7 +46,7 @@ if (APPLE)
"-framework IOKit"
"-framework Security" pthread)
elseif (WIN32)
set(STATUSGO_DEPS_LIBS -lWinMM -lWS2_32 -lsetupapi)
set(STATUSGO_DEPS_LIBS -lwinmm -lws2_32 -lsetupapi)
else()
set(STATUSGO_DEPS_LIBS pthread)
endif()

View File

@ -1,8 +0,0 @@
set GOROOT=%1
set GOPATH=%2
set PATH=%GOROOT%/bin;%GOROOT%;%GOPATH%;%PATH%
cd %3/lib
go get .
cd ..
mingw32-make statusgo-library

View File

@ -1,10 +1,19 @@
#!/bin/bash
export GOROOT=$1
export GOPATH=$2
export GOROOT=$2
export GOPATH=$3
export PATH=$GOROOT/bin:$GOROOT:$GOPATH:$PATH
if [ "$1" = 'Windows' ]; then
export GOOS=windows
export GOARCH=amd64
export CGO_ENABLED=1
export CC=$5
export CC_FOR_TARGET=$5
export CXX_FOR_TARGET=$6
fi
cd $3/lib
cd $4/lib
go get ./
cd ..
make statusgo-library
make statusgo-library

View File

@ -92,7 +92,7 @@ void RCTStatus::startNode(QString configString) {
if (!relativeDataDirPath.startsWith("/"))
relativeDataDirPath.prepend("/");
QString rootDirPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString rootDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
QDir rootDir(rootDirPath);
QString absDataDirPath = rootDirPath + relativeDataDirPath;
QDir dataDir(absDataDirPath);

View File

@ -10,6 +10,10 @@ YELLOW='\033[1;33m'
NC='\033[0m'
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
OS=$(uname -s)
if [ -z $TARGET_SYSTEM_NAME ]; then
TARGET_SYSTEM_NAME=$OS
fi
WINDOWS_CROSSTOOLCHAIN_PKG_NAME='mxetoolchain-x86_64-w64-mingw32'
external_modules_dir=( \
'node_modules/react-native-i18n/desktop' \
@ -39,6 +43,10 @@ function is_linux() {
[[ "$OS" =~ Linux ]]
}
function is_windows_target() {
[[ "$TARGET_SYSTEM_NAME" =~ Windows ]]
}
function program_exists() {
local program=$1
command -v "$program" >/dev/null 2>&1
@ -66,11 +74,18 @@ DEPLOYQT="$(joinPath . 'linuxdeployqt-continuous-x86_64.AppImage')"
APPIMAGETOOL="$(joinPath . 'appimagetool-x86_64.AppImage')"
function init() {
if [ -z $QT_PATH ]; then
echo "${RED}QT_PATH environment variable is not defined!${NC}"
if [ -z $STATUSREACTPATH ]; then
echo "${RED}STATUSREACTPATH environment variable is not defined!${NC}"
exit 1
fi
if ! is_windows_target; then
if [ -z $QT_PATH ]; then
echo "${RED}QT_PATH environment variable is not defined!${NC}"
exit 1
fi
fi
if is_macos; then
if [ -z $MACDEPLOYQT ]; then
set +e
@ -81,10 +96,39 @@ function init() {
fi
set -e
fi
fi
if is_macos; then
DEPLOYQT="$MACDEPLOYQT"
elif is_linux; then
rm -rf ./desktop/toolchain/
# TODO: Use Conan for Linux and MacOS builds too
if is_windows_target; then
if ! program_exists 'python3'; then
echo "${RED}python3 prerequisite is missing. Exiting.${NC}"
exit 1
fi
export PATH=$STATUSREACTPATH:$PATH
if ! program_exists 'conan'; then
if ! program_exists 'pip3'; then
echo "${RED}pip3 package manager not found. Exiting.${NC}"
exit 1
fi
echo "${RED}Conan package manager not found. Installing...${NC}"
pip3 install conan==1.9.0
fi
conan remote add --insert 0 -f status-im https://conan.status.im
echo "Generating cross-toolchain profile..."
conan install -if ./desktop/toolchain/ -g json $WINDOWS_CROSSTOOLCHAIN_PKG_NAME/5.5.0-1@status-im/stable \
-pr ./node_modules/status-conan/profiles/status-mingw32-x86_64
python3 ./node_modules/status-conan/profiles/generate-profiles.py ./node_modules/status-conan/profiles ./desktop/toolchain/conanbuildinfo.json
echo "Installing cross-toolchain..."
conan install -if ./desktop/toolchain/ -g json -g cmake $WINDOWS_CROSSTOOLCHAIN_PKG_NAME/5.5.0-1@status-im/stable \
-pr ./node_modules/status-conan/profiles/status-mxe-mingw32-x86_64-gcc55-libstdcxx
fi
fi
}
@ -129,14 +173,73 @@ function buildClojureScript() {
function compile() {
pushd desktop
rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile modules
cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DEXTERNAL_MODULES_DIR="$(joinStrings ${external_modules_dir[@]})" \
-DDESKTOP_FONTS="$(joinStrings ${external_fonts[@]})" \
-DJS_BUNDLE_PATH="$WORKFOLDER/Status.jsbundle" \
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1 -std=c++11'
make -j5
rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile modules reportApp/CMakeFiles desktop/node_modules/google-breakpad/CMakeFiles desktop/node_modules/react-native-keychain/desktop/qtkeychain-prefix/src/qtkeychain-build/CMakeFiles desktop/node_modules/react-native-keychain/desktop/qtkeychain
EXTERNAL_MODULES_DIR="$(joinStrings ${external_modules_dir[@]})"
DESKTOP_FONTS="$(joinStrings ${external_fonts[@]})"
JS_BUNDLE_PATH="$WORKFOLDER/Status.jsbundle"
if is_windows_target; then
export PATH=$STATUSREACTPATH:$PATH
# Get the toolchain bin folder from toolchain/conanbuildinfo.json
bin_dirs=$(jq -r '.dependencies[0].bin_paths | .[]' toolchain/conanbuildinfo.json)
while read -r bin_dir; do
if [ ! -d $bin ]; then
echo -e "${RED}Could not find $bin_dir directory from 'toolchain/conanbuildinfo.json', aborting${NC}"
exit 1
fi
export PATH=$bin_dir:$PATH
done <<< "$bin_dirs"
cmake -Wno-dev \
-DCMAKE_TOOLCHAIN_FILE='Toolchain-Ubuntu-mingw64.cmake' \
-DCMAKE_C_COMPILER='x86_64-w64-mingw32.shared-gcc' \
-DCMAKE_CXX_COMPILER='x86_64-w64-mingw32.shared-g++' \
-DCMAKE_RC_COMPILER='x86_64-w64-mingw32.shared-windres' \
-DCMAKE_BUILD_TYPE=Release \
-DEXTERNAL_MODULES_DIR="$EXTERNAL_MODULES_DIR" \
-DDESKTOP_FONTS="$DESKTOP_FONTS" \
-DJS_BUNDLE_PATH="$JS_BUNDLE_PATH" \
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1' || exit 1
else
cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DEXTERNAL_MODULES_DIR="$EXTERNAL_MODULES_DIR" \
-DDESKTOP_FONTS="$DESKTOP_FONTS" \
-DJS_BUNDLE_PATH="$JS_BUNDLE_PATH" \
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1' || exit 1
fi
make -j5 || exit 1
popd
}
function bundleWindows() {
# TODO: Produce a setup program instead of a ZIP
pushd $WORKFOLDER
rm -rf Windows
mkdir Windows
if [ -z $STATUSIM_WINDOWS_BASEIMAGE_ZIP ]; then
STATUSIM_WINDOWS_BASEIMAGE_ZIP=./StatusIm-Windows-base-image.zip
[ -f $STATUSIM_WINDOWS_BASEIMAGE_ZIP ] || wget https://desktop-app-files.ams3.digitaloceanspaces.com/StatusIm-Windows-base-image.zip
fi
unzip "$STATUSIM_WINDOWS_BASEIMAGE_ZIP" -d Windows/
rm -f Status-Windows-x86_64.zip
pushd Windows
cp $STATUSREACTPATH/.env .
mkdir -p assets/resources notifier
cp $STATUSREACTPATH/node_modules/node-notifier/vendor/snoreToast/SnoreToast.exe \
$STATUSREACTPATH/node_modules/node-notifier/vendor/notifu/*.exe \
notifier/
cp -r $STATUSREACTPATH/resources/fonts \
$STATUSREACTPATH/resources/icons \
$STATUSREACTPATH/resources/images \
assets/resources/
local _bin=$STATUSREACTPATH/desktop/bin
rm -rf $_bin/cmake_install.cmake $_bin/Makefile $_bin/CMakeFiles $_bin/Status_autogen && \
cp -r $_bin/* .
zip -mr9 ../../Status-Windows-x86_64.zip .
popd
rm -rf Windows
popd
}
@ -154,8 +257,8 @@ function bundleLinux() {
rm -rf StatusImAppImage
# TODO this needs to be fixed: status-react/issues/5378
if [ -z $STATUSIM_APPIMAGE ]; then
[ -f ./StatusImAppImage.zip ] || wget https://desktop-app-files.ams3.digitaloceanspaces.com/StatusImAppImage.zip
STATUSIM_APPIMAGE=./StatusImAppImage.zip
[ -f $STATUSIM_APPIMAGE ] || wget https://desktop-app-files.ams3.digitaloceanspaces.com/StatusImAppImage.zip
fi
unzip "$STATUSIM_APPIMAGE" -d .
rm -rf AppDir
@ -167,7 +270,7 @@ function bundleLinux() {
cp -r ./deployment/linux/usr $WORKFOLDER/AppDir
cp ./.env $usrBinPath
cp ./desktop/bin/Status $usrBinPath
cp ./desktop/reportApp/reportApp $usrBinPath
cp ./desktop/bin/reportApp $usrBinPath
if [ ! -f $DEPLOYQT ]; then
wget --output-document="$DEPLOYQT" --show-progress -q https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
@ -239,7 +342,7 @@ function bundleMacOS() {
ln -sf ../Resources/assets ../Resources/ubuntu-server ../Resources/node_modules Status.app/Contents/MacOS
chmod +x Status.app/Contents/Resources/ubuntu-server
cp ../desktop/bin/Status Status.app/Contents/MacOS/Status
cp ../desktop/reportApp/reportApp Status.app/Contents/MacOS
cp ../desktop/bin/reportApp Status.app/Contents/MacOS
cp ../.env Status.app/Contents/Resources
ln -sf ../Resources/.env Status.app/Contents/MacOS/.env
cp -f ../deployment/macos/qt-reportApp.conf Status.app/Contents/Resources
@ -264,8 +367,12 @@ function bundleMacOS() {
function bundle() {
if is_macos; then
bundleMacOS
else
bundleLinux
elif is_linux; then
if is_windows_target; then
bundleWindows
else
bundleLinux
fi
fi
}