From 17a8d3a9c9436aff661aa34ed511a5b1ff443cf7 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Thu, 13 Sep 2018 11:44:33 +0200 Subject: [PATCH] Unify desktop builds. Closes #5406 - Replace Linux and MacOS scripts in `ci/desktop.groovy` with calls to `scripts/create-desktop-package.sh` - Replace use of `deployment/env` with `.env` to avoid confusion and be coherent with mobile platforms Signed-off-by: Pedro Pombeiro --- .gitignore | 16 ++ Makefile | 21 ++- ci/Jenkinsfile.linux | 4 +- ci/Jenkinsfile.macos | 4 +- ci/desktop.groovy | 137 +------------- deployment/env | 20 -- desktop/CMakeLists.txt | 6 +- doc/desktop/DevEnvSetup.md | 60 ------ doc/desktop/Troubleshooting.md | 136 -------------- scripts/build-desktop.sh | 269 +++++++++++++++++++++++++++ scripts/create-desktop-mac-bundle.sh | 89 --------- scripts/lib/setup/installers.sh | 14 +- scripts/setup | 3 +- src/status_im/node/core.cljs | 5 +- src/status_im/utils/config.cljs | 3 +- 15 files changed, 332 insertions(+), 455 deletions(-) delete mode 100644 deployment/env delete mode 100644 doc/desktop/DevEnvSetup.md delete mode 100644 doc/desktop/Troubleshooting.md create mode 100755 scripts/build-desktop.sh delete mode 100755 scripts/create-desktop-mac-bundle.sh diff --git a/.gitignore b/.gitignore index ebc9683a47..b38e4591e8 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,19 @@ fastlane/README.md # Jenkins pkg + +# Status Desktop +cmake_install.cmake +CMakeCache.txt +**/CMakeFiles/ +/StatusImPackage/* +/desktop/bin/* +/desktop/lib/* +/desktop/modules/* +/desktop/Makefile +/desktop/run-app.sh +/desktop/CMakeFiles/ +/desktop/reportApp/Makefile +/desktop/reportApp/reportApp +/desktop/reportApp/reportApp_autogen/ +/linuxdeployqt-*.AppImage diff --git a/Makefile b/Makefile index dffd5f91e9..9e765d26d4 100644 --- a/Makefile +++ b/Makefile @@ -29,24 +29,30 @@ HELP_FUN = \ # Main targets clean: ##@prepare Remove all output folders - git clean -qdxf -f android/ modules/react-native-status/ node_modules/ target/ desktop/modules/ desktop/node_modules/ + git clean -qdxf -f android/ modules/react-native-status/ node_modules/ target/ desktop/ StatusImPackage/ setup: ##@prepare Install all the requirements for status-react ./scripts/setup -prepare: ##@prepare Install dependencies and prepare workspace +prepare-desktop: ##@prepare Install desktop platform dependencies and prepare workspace + scripts/prepare-for-platform.sh desktop + npm install + +_prepare-mobile: ##@prepare Install mobile platform dependencies and prepare workspace scripts/prepare-for-platform.sh mobile npm install -prepare-ios: prepare ##@prepare Install iOS specific dependencies +prepare-ios: _prepare-mobile ##@prepare Install and prepare iOS-specific dependencies mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack ifeq ($(OS),Darwin) cd ios && pod install endif -prepare-android: prepare ##@prepare Install Android specific dependencies +prepare-android: _prepare-mobile ##@prepare Install and prepare Android-specific dependencies cd android && ./gradlew react-native-android:installArchives +prepare-mobile: prepare-android prepare-ios ##@prepare Install and prepare mobile platform specific dependencies + #---------------- # Release builds #---------------- @@ -58,6 +64,9 @@ release-android: prod-build-android ##@build build release for Android release-ios: prod-build-ios ##@build build release for iOS release @echo "Build in XCode, see https://wiki.status.im/TBD for instructions" +release-desktop: prod-build-desktop ##@build build release for desktop release + scripts/build-desktop.sh + prod-build: lein prod-build @@ -75,6 +84,10 @@ full-prod-build: ##@build build prod for both Android and iOS rm -r ./modules/react-native-status/ios/RCTStatus/Statusgo.framework/ 2> /dev/null || true rm ./modules/react-native-status/android/libs/status-im/status-go/local/status-go-local.aar 2> /dev/null +prod-build-desktop: + git clean -qdxf -f ./index.desktop.js desktop/ + lein prod-build-desktop + #-------------- # REPL # ------------- diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 6f64e6a267..fceeb2ad65 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -32,6 +32,8 @@ pipeline { LC_ALL = 'en_US.UTF-8' NPM_CONFIG_CACHE = '/var/tmp/npm' LEIN_HOME = '/var/tmp/lein' + QT_PATH = '/opt/qt59' + STATUSIM_APPIMAGE = '/opt/StatusImAppImage.zip' } stages { @@ -53,7 +55,7 @@ pipeline { } stage('Compile') { steps { - script { desktop.compileLinux() } + script { desktop.compile() } } } stage('Bundle') { diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index 396aa76d88..21e16ed443 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -13,6 +13,8 @@ pipeline { LANG = 'en_US.UTF-8' LANGUAGE = 'en_US.UTF-8' LC_ALL = 'en_US.UTF-8' + QT_PATH = '/Users/administrator/qt/5.9.1' + PATH = "${env.QT_PATH}/clang_64/bin:${env.PATH}" } stages { @@ -33,7 +35,7 @@ pipeline { } stage('Compile') { steps { - script { desktop.compileMacOS() } + script { desktop.compile() } } } stage('Bundle') { diff --git a/ci/desktop.groovy b/ci/desktop.groovy index 6d797dca8b..b4c93b62d1 100644 --- a/ci/desktop.groovy +++ b/ci/desktop.groovy @@ -1,29 +1,8 @@ common = load 'ci/common.groovy' -qtBin = '/opt/qt59/bin' packageFolder = './StatusImPackage' -external_modules_dir = [ - 'node_modules/react-native-i18n/desktop', - 'node_modules/react-native-config/desktop', - 'node_modules/react-native-fs/desktop', - 'node_modules/react-native-http-bridge/desktop', - 'node_modules/react-native-webview-bridge/desktop', - 'node_modules/react-native-keychain/desktop', - 'node_modules/react-native-securerandom/desktop', - 'modules/react-native-status/desktop', - 'node_modules/google-breakpad', -] - -external_fonts = [ - '../../../../../resources/fonts/SF-Pro-Text-Regular.otf', - '../../../../../resources/fonts/SF-Pro-Text-Medium.otf', - '../../../../../resources/fonts/SF-Pro-Text-Light.otf', -] def cleanupBuild() { - sh """ - rm -rf ${packageFolder} - """ sh 'make clean' } @@ -43,16 +22,8 @@ def slackNotify(message, color = 'good') { } def buildClojureScript() { - sh 'rm -f index.desktop.js' - sh 'lein prod-build-desktop' - sh "mkdir ${packageFolder}" - sh """ - react-native bundle \\ - --entry-file index.desktop.js \\ - --dev false --platform desktop \\ - --bundle-output ${packageFolder}/StatusIm.jsbundle \\ - --assets-dest ${packageFolder}/assets - """ + sh 'make prod-build-desktop' + sh './scripts/build-desktop.sh buildClojureScript' } def uploadArtifact(filename) { @@ -85,121 +56,25 @@ def prepDeps() { cleanupAndDeps() } -def compileLinux() { - dir('desktop') { - sh 'rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile' - sh """ - cmake -Wno-dev \\ - -DCMAKE_BUILD_TYPE=Release \\ - -DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\ - -DDESKTOP_FONTS='${external_fonts.join(";")}' \\ - -DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\ - -DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1' - """ - sh 'make' - } +def compile() { + sh './scripts/build-desktop.sh compile' } def bundleLinux(type = 'nightly') { def pkg + sh './scripts/build-desktop.sh bundle' dir(packageFolder) { - sh 'rm -rf StatusImAppImage' - /* TODO this needs to be fixed: status-react/issues/5378 */ - sh 'cp /opt/StatusImAppImage.zip ./' - sh 'unzip ./StatusImAppImage.zip' - sh 'rm -rf AppDir' - sh 'mkdir AppDir' - } - sh "cp -r ./deployment/linux/usr ${packageFolder}/AppDir" - sh "cp ./deployment/env ${packageFolder}/AppDir/usr/bin" - sh "cp ./desktop/bin/StatusIm ${packageFolder}/AppDir/usr/bin" - sh "cp ./desktop/reportApp/reportApp ${packageFolder}/AppDir/usr/bin" - sh 'wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage' - sh 'chmod a+x ./linuxdeployqt-continuous-x86_64.AppImage' - - sh 'rm -f Application-x86_64.AppImage' - sh 'rm -f StatusIm-x86_64.AppImage' - - sh "ldd ${packageFolder}/AppDir/usr/bin/StatusIm" - sh """ - ./linuxdeployqt-continuous-x86_64.AppImage \\ - ${packageFolder}/AppDir/usr/bin/reportApp \\ - -verbose=3 -always-overwrite -no-strip -no-translations -qmake=${qtBin}/qmake \\ - -qmldir='${workspace}/desktop/reportApp' - """ - sh """ - ./linuxdeployqt-continuous-x86_64.AppImage \\ - ${packageFolder}/AppDir/usr/share/applications/StatusIm.desktop \\ - -verbose=3 -always-overwrite -no-strip \\ - -no-translations -bundle-non-qt-libs \\ - -qmake=${qtBin}/qmake \\ - -extra-plugins=imageformats/libqsvg.so \\ - -qmldir='${workspace}/node_modules/react-native' - """ - dir(packageFolder) { - sh 'ldd AppDir/usr/bin/StatusIm' - sh 'cp -r assets/share/assets AppDir/usr/bin' - sh 'cp -rf StatusImAppImage/* AppDir/usr/bin' - sh 'rm -f AppDir/usr/bin/StatusIm.AppImage' - } - sh """ - ./linuxdeployqt-continuous-x86_64.AppImage \\ - ${packageFolder}/AppDir/usr/share/applications/StatusIm.desktop \\ - -verbose=3 -appimage -qmake=${qtBin}/qmake - """ - dir(packageFolder) { - sh 'ldd AppDir/usr/bin/StatusIm' - sh 'rm -rf StatusIm.AppImage' pkg = common.pkgFilename(type, 'AppImage') sh "mv ../StatusIm-x86_64.AppImage ${pkg}" } return "${packageFolder}/${pkg}".drop(2) } -def compileMacOS() { - /* add path for QT installation binaries */ - env.PATH = "/Users/administrator/qt/5.9.1/clang_64/bin:${env.PATH}" - dir('desktop') { - sh 'rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile' - sh """ - cmake -Wno-dev \\ - -DCMAKE_BUILD_TYPE=Release \\ - -DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\ - -DDESKTOP_FONTS='${external_fonts.join(";")}' \\ - -DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\ - -DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1' - """ - sh 'make' - } -} - def bundleMacOS(type = 'nightly') { def pkg = common.pkgFilename(type, 'dmg') + sh './scripts/build-desktop.sh bundle' dir(packageFolder) { - sh 'curl -L -O "https://github.com/status-im/StatusAppFiles/raw/PR5702/Status.app.zip"' - sh 'unzip Status.app.zip' - sh 'cp -r assets/share/assets Status.app/Contents/Resources' - sh 'ln -sf ../Resources/assets ../Resources/ubuntu-server ../Resources/node_modules ' + - 'Status.app/Contents/MacOS' - sh 'chmod +x Status.app/Contents/Resources/ubuntu-server' - sh 'cp ../desktop/bin/StatusIm Status.app/Contents/MacOS/Status' - sh 'cp ../desktop/reportApp/reportApp Status.app/Contents/MacOS' - sh "cp ../deployment/env Status.app/Contents/Resources" - sh 'ln -sf ../Resources/env Status.app/Contents/MacOS/env' - sh 'cp -f ../deployment/macos/qt-reportApp.conf Status.app/Contents/Resources' - sh 'ln -sf ../Resources/qt-reportApp.conf Status.app/Contents/MacOS/qt.conf' - sh 'install_name_tool -add_rpath "@executable_path/../Frameworks" ' + - '-delete_rpath "/Users/administrator/qt/5.9.1/clang_64/lib" ' + - 'Status.app/Contents/MacOS/reportApp' - sh 'cp -f ../deployment/macos/Info.plist Status.app/Contents' - sh 'cp -f ../deployment/macos/status-icon.icns Status.app/Contents/Resources' - sh """ - macdeployqt Status.app -verbose=1 \\ - -qmldir='${workspace}/node_modules/react-native/ReactQt/runtime/src/qml/' - """ - sh 'rm -f Status.app.zip' - withCredentials([ string(credentialsId: 'desktop-gpg-outer-pass', variable: 'GPG_PASS_OUTER'), string(credentialsId: 'desktop-gpg-inner-pass', variable: 'GPG_PASS_INNER'), diff --git a/deployment/env b/deployment/env deleted file mode 100644 index 967cba460c..0000000000 --- a/deployment/env +++ /dev/null @@ -1,20 +0,0 @@ -TESTFAIRY_ENABLED=0 -STUB_STATUS_GO=0 -ETHEREUM_DEV_CLUSTER=1 -MAINNET_NETWORKS_ENABLED=1 -OFFLINE_INBOX_ENABLED=1 -OFFLINE_INBOX_MANY_ENABLED=1 -LOG_LEVEL=debug -LOG_LEVEL_STATUS_GO=info -FLEET=eth.beta -JSC_ENABLED=1 -QUEUE_MESSAGE_ENABLED=1 -MANY_WHISPER_TOPICS_ENABLED=0 -RN_BRIDGE_THRESHOLD_WARNINGS=0 -COMPILE_VIEWS_ENABLED=0 -POW_TARGET=0.002 -POW_TIME=1 -MIXPANEL_TOKEN=3f2e1a8970f159aa2a3d5dc5d65eab38 -DEFAULT_NETWORK=mainnet_rpc -TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55 -INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c diff --git a/desktop/CMakeLists.txt b/desktop/CMakeLists.txt index 5e09861b93..3496e0aa70 100644 --- a/desktop/CMakeLists.txt +++ b/desktop/CMakeLists.txt @@ -16,11 +16,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") message(STATUS "EXTERNAL_MODULES_DIR: ${EXTERNAL_MODULES_DIR}") string(REGEX MATCH "BUILD_FOR_BUNDLE" BUILD_FOR_BUNDLE "${CMAKE_CXX_FLAGS}") -if(${BUILD_FOR_BUNDLE} MATCHES "BUILD_FOR_BUNDLE") - set(ENVFILE "/env") -else() - set(ENVFILE "/../../.env") -endif() +set(ENVFILE "/.env") foreach(external_module ${EXTERNAL_MODULES_DIR}) message(STATUS "external_module: ${external_module}") diff --git a/doc/desktop/DevEnvSetup.md b/doc/desktop/DevEnvSetup.md deleted file mode 100644 index 3fbe4a9320..0000000000 --- a/doc/desktop/DevEnvSetup.md +++ /dev/null @@ -1,60 +0,0 @@ -# Prerequisites: -lein, node.js v.8 , cmake, Qt 5.9.1 (with QtWebEngine components installed), Qt's qmake available in PATH - -Note: add qmake to PATH via -`export PATH=/clang_64/bin:$PATH` - -Caveats: - - if npm hangs at some step, check the version. If it's 5.6.0 or higher, try downgrading to 5.5.1 via `npm install -g npm@5.5.1` - -# To install react-native-cli with desktop commands support: -1. git clone https://github.com/status-im/react-native-desktop.git -2. cd react-native-desktop/react-native-cli -3. npm update -4. npm install -g - -# To setup re-natal dev builds of status-react for Desktop: -1. git clone https://github.com/status-im/status-react.git -2. cd status-react -3. scripts/prepare-for-platform.sh desktop -4. npm install -5. ln -sf './node_modules/re-natal/index.js' './re-natal' -6. ./re-natal use-figwheel -7. ./re-natal enable-source-maps -8. In separate terminal tab: `npm start` (note: it starts react-native packager ) -9. In separate terminal tab: node ./ubuntu-server.js -10. In separate terminal tab: lein figwheel-repl desktop (note: wait until sources are compiled) -11. In separate terminal tab: react-native run-desktop - -# Editor setup -Running `lein figwheel-repl desktop` will run a REPL on port 7888 by default. Some additional steps might be needed to connect to it. - -## emacs-cider -In order to get REPL working, use the below elisp code: -``` -(defun custom-cider-jack-in () - (interactive) - (let ((status-desktop-params "with-profile +figwheel repl")) - (set-variable 'cider-lein-parameters status-desktop-params) - (message "setting 'cider-lein-parameters") - (cider-jack-in))) - -(defun start-figwheel-cljs-repl () - (interactive) - (set-buffer "*cider-repl status-react*") - (goto-char (point-max)) - (insert "(do (use 'figwheel-api) - (start [:desktop]) - (start-cljs-repl))") - (cider-repl-return)) -``` - -`custom-cider-jack-in` sets the correct profile for leiningen, and can be run as soon as emacs is open. -run `start-figwheel-cljs-repl` once you already have a cider repl session from the jack-in - -## vim-fireplace -For some reason there is no `.nrepl-port` file in project root, so `vim-fireplace` will not be able to connect automatically. You can either: - - run `:Connect` and answer a couple of interactive prompts - - create `.nrepl-port` file manually and add a single line containing `7888` (or whatever port REPL is running on) - -After Figwheel has connected to the app, run `:Piggieback (figwheel-sidecar.repl-api/repl-env)` inside Vim, and you should be all set. diff --git a/doc/desktop/Troubleshooting.md b/doc/desktop/Troubleshooting.md deleted file mode 100644 index 6d6b466913..0000000000 --- a/doc/desktop/Troubleshooting.md +++ /dev/null @@ -1,136 +0,0 @@ -These are some common issues you may run into while setting up React Native Qt. - -## Initial setup issues - -### `npm install` hangs -Downgrade to version 5.5.1: `npm install -g npm@5.5.1`. - -### `re-natal` missing -Create a link: -`ln -sf node_modules/re-natal/index.js re-natal` - - -### `react-native run desktop` complaining about missing `qmldir`: -```Command failed: ./build.sh -e "node_modules/react-native-i18n/desktop;node_modules/react-native-config/desktop;node_modules/react-native-fs/desktop;node_modules/react-native-http-bridge/desktop;node_modules/react-native-webview-bridge/desktop;modules/react-native-status/desktop" -Error copying directory from "/path-to-status-react/node_modules/react-native/ReactQt/runtime/src/qmldir" to "/path-to-status-react/desktop/lib/React". -make[2]: *** [lib/CMakeFiles/copy-qmldir] Error 1 -make[1]: *** [lib/CMakeFiles/copy-qmldir.dir/all] Error 2 -make: *** [all] Error 2 -``` -Can be solved by re-running `npm install react-native` which put the `ReactQt/runtime/src/qmldir` file back. - -### Missing web3 package issue - -After last upgrade of react-native-desktop to the v.0.53.3 of original react-native appeared some incompatibility between `react-native` and `web3` packages on npm install. Initially it installed usually fine, but after `react-native desktop` command execution `web3` package is get removed from `node_modules`. Manual install of web3 by `npm install web3` installs `web3` package, but removes `react-native` package. Workaround or solution? - -### Go problem -``` -panic: runloop has just unexpectedly stopped - -goroutine 50 [running]: -github.com/status-im/status-go/vendor/github.com/rjeczalik/notify.init.0.func1() - /path-to-status-react/desktop/modules/react-native-status/desktop/StatusGo/src/github.com/status-im/status-go/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:69 +0x79 -created by github.com/status-im/status-go/vendor/github.com/rjeczalik/notify.init.0 - /path-to-status-react/desktop/modules/react-native-status/desktop/StatusGo/src/github.com/status-im/status-go/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:65 +0x4e -events.js:183 - throw er; // Unhandled 'error' event -``` -Related to https://github.com/rjeczalik/notify/issues/139. Solution: re-run. - -## App issues - -### Eth node crashing -`node ./ubuntu_server.js` log: -``` -DEBUG [status-im.utils.handlers:36] - Handling re-frame event: :signal-event {"type":"node.crashed","event":{"error":"node is already running"}} -DEBUG [status-im.ui.screens.events:350] - :event-str {"type":"node.crashed","event":{"error":"node is already running"}} -DEBUG [status-im.utils.instabug:8] - Signal event: {"type":"node.crashed","event":{"error":"node is already running"}} -DEBUG [status-im.ui.screens.events:362] - Event node.crashed not handled -``` -Solution: prevent starting Ethereum local node when there is an instance already running. - -### Reload JS - blank screen -Console log for `react-native run-desktop` shows error 533. -Solution: reload again. Still, might hang at `Signing you in...` step (due to node attempted to be restarted). Re-run Figwheel and `react-native run-desktop` - -### ReactButton.qml non-existent property "elide" error upon startup -``` -qrc:/qml/ReactButton.qml:33: Error: Cannot assign to non-existent property "elide" -"Component for qrc:/qml/ReactWebView.qml is not loaded" -QQmlComponent: Component is not ready -"Unable to construct item from component qrc:/qml/ReactWebView.qml" -"Can't create QML item for componenet qrc:/qml/ReactWebView.qml" -"RCTWebViewView" has no view for inspecting! -``` -Reload JS does not help, restarting Figwheel/react-native might not as well. Restarting Metro bundler solved it for me. - -### After login when several contacts are available: realm errors -1. `attempting to create an object of type 'chat'...` -2. `attempting to create an object of type 'transport'...` -3. Error text containing only the public key. -The realm stack trace follows. - -### Error: spawn gnome-terminal ENOENT -In node server log: -``` -ignoring exception: Error: read ECONNRESET -``` -In react-native log: -``` -./run-app.sh: line 72: 56660 Segmentation fault: 11 /path-to-status-react/desktop/bin/StatusIm $args -events.js:183 - throw er; // Unhandled 'error' event - ^ - -Error: spawn gnome-terminal ENOENT - at _errnoException (util.js:992:11) - at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) - at onErrorNT (internal/child_process.js:372:16) - at _combinedTickCallback (internal/process/next_tick.js:138:11) - at process._tickCallback (internal/process/next_tick.js:180:9) -``` -or -``` -StatusIm(7924,0x70000c1cd000) malloc: *** error for object 0x7f8b1539bd10: incorrect checksum for freed object - object was probably modified after being freed. -*** set a breakpoint in malloc_error_break to debug -./run-app.sh: line 72: 7924 Abort trap: 6 /path-to-status-react/desktop/bin/StatusIm $args -events.js:183 - throw er; // Unhandled 'error' event - ^ - -Error: spawn gnome-terminal ENOENT - at _errnoException (util.js:992:11) - at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) - at onErrorNT (internal/child_process.js:372:16) - at _combinedTickCallback (internal/process/next_tick.js:138:11) - at process._tickCallback (internal/process/next_tick.js:180:9) -``` - -### statusgo error during `react-native run-desktop` - -``` -Command failed: build(.)sh -e "node_modules/react-native-i18n/desktop;node_modules/react-native-config/desktop;node_modules/react-native-fs/desktop;node_modules/react-native-http-bridge/desktop;node_modules/react-native-webview-bridge/desktop;modules/react-native-status/desktop" -# github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/crypto/bn256 -../vendor/github.com/ethereum/go-ethereum/crypto/bn256/bn256_fast.go:26: syntax error: unexpected = in type declaration -../vendor/github.com/ethereum/go-ethereum/crypto/bn256/bn256_fast.go:30: syntax error: unexpected = in type declaration -# github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/crypto/bn256 -vendor/github.com/ethereum/go-ethereum/crypto/bn256/bn256_fast.go:26: syntax error: unexpected = in type declaration -vendor/github.com/ethereum/go-ethereum/crypto/bn256/bn256_fast.go:30: syntax error: unexpected = in type declaration -make[3]: *** [statusgo-library] Error 2 -make[2]: *** [modules/react-native-status/desktop/StatusGo/src/github.com/status-im/src/StatusGo_ep-stamp/StatusGo_ep-configure] Error 2 -make[1]: *** [modules/react-native-status/desktop/CMakeFiles/StatusGo_ep(.)dir/all] Error 2 -make: *** [all] Error 2 -``` - -### inotify errors - -upon running `npm start` on linux, watchman may indicate: "The user limit on the total number of inotify watches was reached" - -This can be fixed by running the below command. Note, changes will only be as valid as the current terminal session. - -``` -echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches && echo 999999 | sudo tee -a -/proc/sys/fs/inotify/max_queued_events && echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_instances && -watchman shutdown-server && sudo sysctl -p -``` - diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh new file mode 100755 index 0000000000..e0fe2119e4 --- /dev/null +++ b/scripts/build-desktop.sh @@ -0,0 +1,269 @@ +#!/bin/bash + +set -e + +VERBOSE_LEVEL=${VERBOSE_LEVEL:-1} + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +OS=$(uname -s) + +external_modules_dir=( \ + 'node_modules/react-native-i18n/desktop' \ + 'node_modules/react-native-config/desktop' \ + 'node_modules/react-native-fs/desktop' \ + 'node_modules/react-native-http-bridge/desktop' \ + 'node_modules/react-native-webview-bridge/desktop' \ + 'node_modules/react-native-keychain/desktop' \ + 'node_modules/react-native-securerandom/desktop' \ + 'modules/react-native-status/desktop' \ + 'node_modules/google-breakpad' \ +) + +external_fonts=( \ + '../../../../../resources/fonts/SF-Pro-Text-Regular.otf' \ + '../../../../../resources/fonts/SF-Pro-Text-Medium.otf' \ + '../../../../../resources/fonts/SF-Pro-Text-Light.otf' \ +) + +function is_macos() { + [[ "$OS" =~ Darwin ]] +} + +function is_linux() { + [[ "$OS" =~ Linux ]] +} + +function program_exists() { + local program=$1 + command -v "$program" >/dev/null 2>&1 +} + +function joinPath() { + if program_exists 'realpath'; then + realpath -m "$1/$2" + else + echo "$1/$2" | tr -s / + fi +} + +function joinExistingPath() { + if program_exists 'realpath'; then + realpath "$1/$2" + else + echo "$1/$2" | tr -s / + fi +} + +STATUSREACTPATH="$(joinExistingPath "$SCRIPTPATH" '..')" +WORKFOLDER="$(joinExistingPath "$STATUSREACTPATH" 'StatusImPackage')" +DEPLOYQT="$(joinPath . 'linuxdeployqt-continuous-x86_64.AppImage')" + +function init() { + if [ -z $QT_PATH ]; then + echo "${RED}QT_PATH environment variable is not defined!${NC}" + exit 1 + fi + + if is_macos; then + if [ -z $MACDEPLOYQT ]; then + set +e + MACDEPLOYQT=$(which macdeployqt) + if [ -z $MACDEPLOYQT ]; then + echo "${RED}MACDEPLOYQT environment variable is not defined and macdeployqt executable not found in path!${NC}" + exit 1 + fi + set -e + fi + fi + + if is_macos; then + DEPLOYQT="$MACDEPLOYQT" + fi +} + +function joinStrings() { + local arr=("$@") + printf -v var "%s;" "${arr[@]}" + var=${var%?} + echo ${var[@]} +} + +function buildClojureScript() { + # create directory for all work related to bundling + rm -rf $WORKFOLDER + mkdir -p $WORKFOLDER + echo -e "${GREEN}Work folder created: $WORKFOLDER${NC}" + echo "" + + # from index.desktop.js create javascript bundle and resources folder + echo "Generating StatusIm.jsbundle and assets folder..." + react-native bundle --entry-file index.desktop.js --bundle-output "$WORKFOLDER/StatusIm.jsbundle" \ + --dev false --platform desktop --assets-dest "$WORKFOLDER/assets" + echo -e "${GREEN}Generating done.${NC}" + echo "" + + # Add path to javascript bundle to package.json + jsBundleLine="\"desktopJSBundlePath\": \"$WORKFOLDER/StatusIm.jsbundle\"" + jsPackagePath=$(joinExistingPath "$STATUSREACTPATH" 'desktop_files/package.json') + if grep -Fq "$jsBundleLine" "$jsPackagePath"; then + echo -e "${GREEN}Found line in package.json.${NC}" + else + # Add line to package.json just before "dependencies" line + if is_macos; then + sed -i '' -e "/\"dependencies\":/i\\ + \ $jsBundleLine," "$jsPackagePath" + else + sed -i -- "/\"dependencies\":/i\ $jsBundleLine," "$jsPackagePath" + fi + echo -e "${YELLOW}Added 'desktopJSBundlePath' line to $jsPackagePath:${NC}" + echo "" + fi +} + +function compile() { + pushd desktop + rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile + cmake -Wno-dev \ + -DCMAKE_BUILD_TYPE=Release \ + -DEXTERNAL_MODULES_DIR="$(joinStrings ${external_modules_dir[@]})" \ + -DDESKTOP_FONTS="$(joinStrings ${external_fonts[@]})" \ + -DJS_BUNDLE_PATH="$WORKFOLDER/StatusIm.jsbundle" \ + -DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1 -std=c++11' + make + popd +} + +function bundleLinux() { + local QTBIN=$(joinExistingPath "$QT_PATH" 'gcc_64/bin') + if [ ! -d "$QTBIN" ]; then + # CI environment doesn't contain gcc_64 path component + QTBIN=$(joinExistingPath "$QT_PATH" 'bin') + fi + + # invoke linuxdeployqt to create StatusIm.AppImage + echo "Creating AppImage..." + + pushd $WORKFOLDER + 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 + fi + unzip "$STATUSIM_APPIMAGE" -d . + rm -rf AppDir + mkdir AppDir + popd + + qmakePath="$(joinExistingPath "${QTBIN}" 'qmake')" + usrBinPath=$(joinPath "$WORKFOLDER" "AppDir/usr/bin") + cp -r ./deployment/linux/usr $WORKFOLDER/AppDir + cp ./.env $usrBinPath + cp ./desktop/bin/StatusIm $usrBinPath + cp ./desktop/reportApp/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 + chmod a+x $DEPLOYQT + fi + + rm -f Application-x86_64.AppImage + rm -f StatusIm-x86_64.AppImage + + [ $VERBOSE_LEVEL -ge 1 ] && ldd $(joinExistingPath "$usrBinPath" 'StatusIm') + $DEPLOYQT \ + $(joinExistingPath "$usrBinPath" 'reportApp') \ + -verbose=$VERBOSE_LEVEL -always-overwrite -no-strip -no-translations -qmake="$(joinExistingPath "${QTBIN}" 'qmake')" \ + -qmldir="$STATUSREACTPATH/desktop/reportApp" + + desktopFilePath="$(joinExistingPath "$WORKFOLDER" 'AppDir/usr/share/applications/StatusIm.desktop')" + $DEPLOYQT \ + $desktopFilePath \ + -verbose=$VERBOSE_LEVEL -always-overwrite -no-strip \ + -no-translations -bundle-non-qt-libs \ + -qmake="$qmakePath" \ + -extra-plugins=imageformats/libqsvg.so \ + -qmldir="$(joinExistingPath "$STATUSREACTPATH" 'node_modules/react-native')" + + pushd $WORKFOLDER + [ $VERBOSE_LEVEL -ge 1 ] && ldd AppDir/usr/bin/StatusIm + cp -r assets/share/assets AppDir/usr/bin + cp -rf StatusImAppImage/* AppDir/usr/bin + rm -f AppDir/usr/bin/StatusIm.AppImage + popd + + $DEPLOYQT \ + $desktopFilePath \ + -verbose=$VERBOSE_LEVEL -appimage -qmake="$qmakePath" + pushd $WORKFOLDER + [ $VERBOSE_LEVEL -ge 1 ] && ldd AppDir/usr/bin/StatusIm + cp -r assets/share/assets AppDir/usr/bin + cp -rf StatusImAppImage/* AppDir/usr/bin + rm -f AppDir/usr/bin/StatusIm.AppImage + popd + $DEPLOYQT \ + "$desktopFilePath" \ + -verbose=$VERBOSE_LEVEL -appimage -qmake="$qmakePath" + pushd $WORKFOLDER + [ $VERBOSE_LEVEL -ge 1 ] && ldd AppDir/usr/bin/StatusIm + rm -rf StatusIm.AppImage + popd + + echo -e "${GREEN}Package ready in ./StatusIm-x86_64.AppImage!${NC}" + echo "" +} + +function bundleMacOS() { + # download prepared package with mac bundle files (it contains qt libraries, icon) + echo "Downloading skeleton of mac bundle..." + + pushd $WORKFOLDER + rm -rf Status.app + # TODO this needs to be fixed: status-react/issues/5378 + [ -f ./Status.app.zip ] || curl -L -o Status.app.zip https://desktop-app-files.ams3.digitaloceanspaces.com/Status.app.zip + echo -e "${GREEN}Downloading done.${NC}" + echo "" + unzip ./Status.app.zip + cp -r assets/share/assets Status.app/Contents/Resources + 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/StatusIm Status.app/Contents/MacOS/Status + cp ../desktop/reportApp/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 + ln -sf ../Resources/qt-reportApp.conf Status.app/Contents/MacOS/qt.conf + install_name_tool -add_rpath "@executable_path/../Frameworks" \ + -delete_rpath "$(joinExistingPath "$QT_PATH" 'clang_64/lib')" \ + 'Status.app/Contents/MacOS/reportApp' + cp -f ../deployment/macos/Info.plist Status.app/Contents + cp -f ../deployment/macos/status-icon.icns Status.app/Contents/Resources + $DEPLOYQT Status.app -verbose=$VERBOSE_LEVEL \ + -qmldir="$STATUSREACTPATH/node_modules/react-native/ReactQt/runtime/src/qml/" + rm -f Status.app.zip + popd + + echo -e "${GREEN}Package ready in $WORKFOLDER/Status.app!${NC}" + echo "" +} + +function bundle() { + if is_macos; then + bundleMacOS + else + bundleLinux + fi +} + +init + +if [ -z "$@" ]; then + buildClojureScript + compile + bundle +else + "$@" +fi diff --git a/scripts/create-desktop-mac-bundle.sh b/scripts/create-desktop-mac-bundle.sh deleted file mode 100755 index 32504c8627..0000000000 --- a/scripts/create-desktop-mac-bundle.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' -SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -STATUSREACTPATH="$SCRIPTPATH/.." -WORKFOLDER="$SCRIPTPATH/../mac_bundle" -MACDEPLOYQT="" - -#if no arguments passed, inform user about possible ones (one for making script interactive, one for path to macdeployqt) - -if [ $# -eq 0 ] - then - echo -e "${RED}You need to specify path to macdeployqt binary as an argument${NC}" - echo "Example: scripts/create-desktop-mac-bundle.sh /usr/bin/macdeployqt" - exit 1 - else - MACDEPLOYQT=$1 -fi - -# check if gdrive installed -command -v gdrive >/dev/null 2>&1 || { echo -e "${RED}gdrive tool need to be installed. (brew install gdrive). Aborting.${NC}" >&2; exit 1; } - - -# inform user that define should be changed in "desktop/main.cpp" -echo "" -echo -e "${YELLOW}In desktop/main.cpp file please uncomment #define BULID_FOR_BUNDLE line.${NC}" -read -p "When ready, plese press enter to continue" -echo "" - - -# create directory for all work related to bundling -mkdir -p $WORKFOLDER -echo -e "${GREEN}Work folder created: $WORKFOLDER${NC}" -echo "" - -# from index.desktop.js create javascript bundle and resources folder -echo "Generating StatusIm.bundle and assets folder..." -react-native bundle --entry-file index.desktop.js --bundle-output $WORKFOLDER/StatusIm.jsbundle --dev false --platform desktop --assets-dest $WORKFOLDER/assets -echo -e "${GREEN}Generating done.${NC}" -echo "" - -# show path to javascript bundle and line that should be added to package.json -echo -e "${YELLOW}Please add the following line to package.json:${NC}" -echo "\"desktopJSBundlePath\": \"$WORKFOLDER/StatusIm.jsbundle\"" -echo "" -read -p "When ready, plese press enter to continue" -echo "" - - -# build desktop app -echo "Building StatusIm desktop..." -react-native build-desktop -echo -e "${GREEN}Building done.${NC}" -echo "" - - -# download prepared package with mac bundle files (it contains qt libraries, icon) -echo "Downloading skeleton of mac bundle..." -echo -e "${YELLOW}First time gdrive can ask you for permissions to google drive${NC}" -gdrive download --path $WORKFOLDER 1fJbW9FzGGPvYkuJcSH5mCAcGdnyUeDSY -echo -e "${GREEN}Downloading done.${NC}" -echo "" - - -# Unpacking downloaded archive -echo "Unpacking bundle skeleton" -unzip $WORKFOLDER/StatusIm.app.zip -d $WORKFOLDER -chmod +x $WORKFOLDER/StatusIm.app/Contents/MacOs/ubuntu-server -echo -e "${GREEN}Unzipping done.${NC}" -echo "" - - -# copy binary and resources to mac bundle -echo "Copying resources and binary..." -cp -r $WORKFOLDER/assets/share/assets $WORKFOLDER/StatusIm.app/Contents/MacOs -cp $STATUSREACTPATH/desktop/bin/StatusIm $WORKFOLDER/StatusIm.app/Contents/MacOs -echo -e "${GREEN}Copying done.${NC}" -echo "" - - -# invoke macdeployqt to create StatusIm.dmg -echo "Creating bundle dmg..." -$MACDEPLOYQT $WORKFOLDER/StatusIm.app -verbose=3 -qmldir="$STATUSREACTPATH/node_modules/react-native/ReactQt/application/src/" -qmldir="$STATUSREACTPATH/node_modules/react-native/ReactQt/runtime/src/qml/" -dmg -echo -e "${GREEN}Bundle ready!${NC}" -echo "" diff --git a/scripts/lib/setup/installers.sh b/scripts/lib/setup/installers.sh index 4a600cae6c..370d9193e5 100755 --- a/scripts/lib/setup/installers.sh +++ b/scripts/lib/setup/installers.sh @@ -2,6 +2,14 @@ _localPropertiesPath=./android/local.properties +function downloadUrl() { + if program_exists "aria2c"; then + aria2c --max-connection-per-server=16 --split=16 --dir="$1" -o "$2" "$3" + else + wget --show-progress --output-document="$1/$2" "$3" + fi +} + function install_node() { if nvm_installed; then install_node_via_nvm @@ -331,10 +339,10 @@ function install_android_ndk() { PLATFORM="darwin" fi - wget --output-document=android-ndk.zip https://dl.google.com/android/repository/android-ndk-r10e-$PLATFORM-x86_64.zip && \ + downloadUrl . android-ndk.zip https://dl.google.com/android/repository/android-ndk-r10e-$PLATFORM-x86_64.zip && \ cecho "@cyan[[Extracting Android NDK to $_ndkParentDir.]]" && \ - unzip -q -o android-ndk.zip -d "$_ndkParentDir" && \ - rm -f android-ndk.zip && \ + unzip -q -o ./android-ndk.zip -d "$_ndkParentDir" && \ + rm -f ./android-ndk.zip && \ _ndkTargetDir="$_ndkParentDir/$(ls $_ndkParentDir | head -n 1)" && \ echo "ndk.dir=$_ndkTargetDir" | tee -a $_localPropertiesPath && \ cecho "@blue[[Android NDK installation completed in $_ndkTargetDir.]]" diff --git a/scripts/setup b/scripts/setup index be370b7466..7c591ce532 100755 --- a/scripts/setup +++ b/scripts/setup @@ -39,7 +39,6 @@ install_cocoapods #### echo && setup_header "Installing dependencies..." -dependency_setup make prepare-android -dependency_setup make prepare-ios +dependency_setup make prepare-mobile setup_complete diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index 3f1e8d1a49..94165c1d00 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -1,5 +1,6 @@ (ns status-im.node.core (:require [re-frame.core :as re-frame] + [status-im.constants :as constants] [status-im.fleet.core :as fleet] [status-im.native-module.core :as status] [status-im.utils.config :as config] @@ -109,8 +110,8 @@ (defn get-node-config [db network] (-> (get-in (:networks/networks db) [network :config]) (get-base-node-config) - (assoc :PFSEnabled false) - (assoc :NoDiscovery true) + (assoc :PFSEnabled false + :NoDiscovery true) (add-log-level config/log-level-status-go))) (fx/defn start diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 0772cb2670..43ca630560 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -1,5 +1,6 @@ (ns status-im.utils.config (:require [status-im.react-native.js-dependencies :as rn-dependencies] + [status-im.utils.platform :as platform] [clojure.string :as string])) (def config (js->clj (.-default rn-dependencies/config) :keywordize-keys true)) @@ -17,7 +18,7 @@ ;; TESTFAIRY_ENABLED - indefinite ;; CONFIG FLAGS -(def testfairy-enabled? (enabled? (get-config :TESTFAIRY_ENABLED))) +(def testfairy-enabled? (when-not platform/desktop? (enabled? (get-config :TESTFAIRY_ENABLED)))) (def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1"))) (def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1")))