Merge pull request #568 from cypherstack/windows

Windows desktop
This commit is contained in:
Diego Salazar 2023-06-02 10:42:30 -06:00 committed by GitHub
commit 0e9f465cc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 217 additions and 89 deletions

@ -1 +1 @@
Subproject commit 594ab89bc665a15a810ba7476ed2ad255fa8b5ac
Subproject commit 01bad9471c4b41392cd2aa98f5655dc14dedc997

@ -1 +1 @@
Subproject commit b3fac32f57d7ef97da8641463d1a852f41660f9b
Subproject commit 9188e8fa925d1dee5a91d984a92a962027d7a3d3

View file

@ -4,42 +4,37 @@ Here you will find instructions on how to install the necessary tools for buildi
## Prerequisites
- The only OS supported for building is Ubuntu 20.04. Advanced users may also be able to build on other Debian-based distributions like Linux Mint.
- The only OS supported for building Android and Linux desktop is Ubuntu 20.04. Windows build are completed using Ubuntu 20.04 on WSL2. Advanced users may also be able to build on other Debian-based distributions like Linux Mint.
- Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies)
- 100 GB of storage
Install Android Studio following the instructions below before proceeding, then the following prerequisites can be installed with the setup script [`scripts/setup.sh`](./../scripts/setup.sh) or manually as described below:
- Flutter 3.7.12 [(install manually or with git, do not install with snap)](https://docs.flutter.dev/get-started/install)
- Dart SDK Requirement (>=2.19.0, up until <3.0.0) (normally included with a flutter install)
## Linux host
The following instructions are for building and running on a Linux host. Alternatively, see the [Windows](#Windows host) section.
### Android Studio
Android Studio is the recommended IDE for development, not just for launching on Android devices and emulators but also for Linux desktop development.
Follow instructions here [https://developer.android.com/studio/install#linux](https://developer.android.com/studio/install#linux) or install via snap:
Install Android Studio. Follow instructions here [https://developer.android.com/studio/install#linux](https://developer.android.com/studio/install#linux) or install via snap:
```
# setup android studio
sudo apt install -y openjdk-11-jdk
sudo snap install android-studio --classic
```
Use Tools > SDK Manager to install:
- SDK Tools > Android SDK (API 30)
- SDK Tools > NDK
- SDK Tools > Android SDK command line tools
- SDK Tools > CMake
Use `Tools > SDK Manager` to install:
- `SDK Tools > Android SDK (API 30)`
- `SDK Tools > NDK`
- `SDK Tools > Android SDK command line tools`
- `SDK Tools > CMake`
Then in File > Settings > Plugins, install the Flutter plugin and restart the IDE. In File > Settings > Languages & Frameworks > Flutter > Editor, enable auto format on save to match the project's code style. If you have problems with the Dart SDK, make sure to run `flutter` in a terminal to download it (use `source ~/.bashrc` to update your environment variables if you're still using the same terminal from which you ran `setup.sh`)
Then in `File > Settings > Plugins`, install the **Flutter** and **Dart** plugins and restart the IDE. In `File > Settings > Languages & Frameworks > Flutter > Editor`, enable auto format on save to match the project's code style. If you have problems with the Dart SDK, make sure to run `flutter` in a terminal to download it (use `source ~/.bashrc` to update your environment variables if you're still using the same terminal from which you ran `setup.sh`). Run `flutter doctor` to install any missing dependencies and review and agree to any license agreements.
Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation
### Scripted setup
[`scripts/setup.sh`](./../scripts/setup.sh) is provided as a tool to set up installation for building: download the script and run it anywhere. This script should skip the entire [Manual setup](#manual-setup) section below and prepare you for [running](#running). It will set up the stack_wallet repository in `~/projects/stack_wallet` and build it there.
[`scripts/setup.sh`](./../scripts/setup.sh) is provided as a tool to set up installation for building: download the script and run it anywhere. This script should skip the entire [Manual setup](#manual-setup) section below and prepare you for [running](#Running).
### Manual setup
> If you used the `setup.sh` script, skip to [running](#running)
> If you used the `setup.sh` script, skip to [running](#Running)
Install basic dependencies
```
@ -83,7 +78,6 @@ git submodule update --init --recursive
```
Run prebuild script
```
cd scripts
./prebuild.sh
@ -101,26 +95,28 @@ sudo apt-get remove '^libboost.*-dev.*'
```
<!-- TODO: configure compiler to prefer built over system libraries. Should already use them? -->
Building plugins for Android
### Building plugins for Android
> Warning: This will take a long time, please be patient
```
cd scripts/android/
cd scripts/android
./build_all.sh
// when finished go back to the root directory
cd ../..
```
Building plugins for Linux
### Building plugins for Linux
```
cd scripts/linux/
cd scripts/linux
./build_all.sh
// when finished go back to the root directory
cd ../..
```
## Running
### Android
### Building plugins for Windows
```
cd scripts/windows
./deps.sh
./build_all.sh
```
### Running
#### Android
Plug in your android device or use the emulator available via Android Studio and then run the following commands:
```
flutter pub get
@ -129,9 +125,49 @@ flutter run android
Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work
### Linux
#### Linux
Plug in your android device or use the emulator available via Android Studio and then run the following commands:
```
flutter pub get Linux
flutter pub get
flutter run linux
```
## Windows host
### Visual Studio
Visual Studio is required for Windows development with the Flutter SDK. Download it at https://visualstudio.microsoft.com/downloads/ and install the "Desktop development with C++" workload, including all of its default components.
### Building libraries in WSL2
Set up Ubuntu 20.04 in WSL2. Follow the entire Linux host section to get set up and build windows `dll` libraries. Copy the resulting `dll`s to their respective positions on the Windows host:
- `stack_wallet/crypto_plugins/flutter_libepiccash/scripts/windows/build/libepic_cash_wallet.dll`
- `stack_wallet/crypto_plugins/flutter_liblelantus/scripts/windows/build/libmobileliblelantus.dll`
<!-- TODO: script this -->
### Install Flutter on Windows host
Install Flutter 3.7.12 on your Windows host (not in WSL2) by following these instructions: https://docs.flutter.dev/get-started/install/windows or by running `scripts/windows/deps.ps1`. You may still have to add `C:\development\flutter\bin` to PATH before proceeding, even if you ran `deps.ps1`. Run `flutter doctor` in PowerShell to confirm its installation.
### Dependencies
You may need to enable Developer Mode for symlink support,
```
start ms-settings:developers
```
Install NuGet:
```
winget install 9WZDNCRDMDM3 # NuGet, can also use Microsoft.NuGet
```
You may need to install CppWinRT / C++/WinRT SDKs:
```
winget install Microsoft.Windows.CppWinRT
```
Install the Windows SDK: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
### Running
Run the following commands:
```
flutter pub get
flutter run windows
```

View file

@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
// import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
// import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart';
import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
// import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/logger.dart';
@ -105,9 +105,12 @@ class AboutView extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
String firoCommit = FIRO_VERSIONS.getPluginVersion();
String epicCashCommit = EPIC_VERSIONS.getPluginVersion();
String moneroCommit = MONERO_VERSIONS.getPluginVersion();
String firoCommit =
"Unable to fetch version"; //FIRO_VERSIONS.getPluginVersion();
String epicCashCommit =
"Unable to fetch version"; // EPIC_VERSIONS.getPluginVersion();
String moneroCommit =
"Unable to fetch version"; // MONERO_VERSIONS.getPluginVersion();
List<Future> futureFiroList = [
doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit),
isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit),
@ -161,14 +164,14 @@ class AboutView extends ConsumerWidget {
String appName = "";
String build = "";
if (snapshot.connectionState ==
ConnectionState.done &&
snapshot.hasData) {
version = snapshot.data!.version;
build = snapshot.data!.buildNumber;
signature = snapshot.data!.buildSignature;
appName = snapshot.data!.appName;
}
// if (snapshot.connectionState ==
// ConnectionState.done &&
// snapshot.hasData) {
// version = snapshot.data!.version;
// build = snapshot.data!.buildNumber;
// signature = snapshot.data!.buildSignature;
// appName = snapshot.data!.appName;
// }
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,

View file

@ -7,11 +7,11 @@ import 'package:event_bus/event_bus.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
// import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
// import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
// import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:stackwallet/models/isar/models/log.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
@ -292,11 +292,11 @@ class _DebugViewState extends ConsumerState<DebugView> {
packageInfo.buildSignature;
final appName = packageInfo.appName;
String firoCommit =
FIRO_VERSIONS.getPluginVersion();
"Unable to fetch version"; //FIRO_VERSIONS.getPluginVersion();
String epicCashCommit =
EPIC_VERSIONS.getPluginVersion();
"Unable to fetch version"; //EPIC_VERSIONS.getPluginVersion();
String moneroCommit =
MONERO_VERSIONS.getPluginVersion();
"Unable to fetch version"; // MONERO_VERSIONS.getPluginVersion();
DeviceInfoPlugin deviceInfoPlugin =
DeviceInfoPlugin();
final deviceInfo =

View file

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:hive/hive.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/intro_view.dart';
@ -42,7 +43,21 @@ class _ForgotPasswordDesktopViewState
try {
await Hive.close();
if (Platform.isWindows || Platform.isLinux) {
if (Platform.isWindows) {
final xmrDir = Directory("${appRoot.path}/wallets");
if (xmrDir.existsSync()) {
await xmrDir.delete(recursive: true);
}
final epicDir = Directory("${appRoot.path}/epiccash");
if (epicDir.existsSync()) {
await epicDir.delete(recursive: true);
}
await Isar.getInstance("desktopStore")?.close(deleteFromDisk: true);
await (await StackFileSystem.applicationHiveDirectory())
.delete(recursive: true);
} else if (Platform.isLinux) {
await appRoot.delete(recursive: true);
} else {
// macos in ipad mode

View file

@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
// import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS;
// import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart';
import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
// import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/logger.dart';
@ -98,9 +98,12 @@ class DesktopAboutView extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
String firoCommit = FIRO_VERSIONS.getPluginVersion();
String epicCashCommit = EPIC_VERSIONS.getPluginVersion();
String moneroCommit = MONERO_VERSIONS.getPluginVersion();
String firoCommit =
"Unable to fetch version"; // FIRO_VERSIONS.getPluginVersion();
String epicCashCommit =
"Unable to fetch version"; // EPIC_VERSIONS.getPluginVersion();
String moneroCommit =
"Unable to fetch version"; //MONERO_VERSIONS.getPluginVersion();
List<Future> futureFiroList = [
doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit),
isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit),
@ -237,13 +240,13 @@ class DesktopAboutView extends ConsumerWidget {
String signature = "";
String build = "";
if (snapshot.connectionState ==
ConnectionState.done &&
snapshot.hasData) {
version = snapshot.data!.version;
build = snapshot.data!.buildNumber;
signature = snapshot.data!.buildSignature;
}
// if (snapshot.connectionState ==
// ConnectionState.done &&
// snapshot.hasData) {
// version = snapshot.data!.version;
// build = snapshot.data!.buildNumber;
// signature = snapshot.data!.buildSignature;
// }
return Column(
mainAxisAlignment:

View file

@ -11,7 +11,7 @@ description: Stack Wallet
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.7.11+176
version: 1.7.12+177
environment:
sdk: ">=2.17.0 <3.0.0"

View file

@ -18,20 +18,6 @@ echo 'export PATH="$PATH:'${FLUTTER_DIR}'"' >> ~/.bashrc
source ~/.bashrc
flutter doctor
# setup stack_wallet github
cd $PROJECTS
git clone https://github.com/cypherstack/stack_wallet.git
cd stack_wallet
export STACK_WALLET=$(pwd)
git submodule update --init --recursive
# create template lib/external_api_keys.dart file if it doesn't already exist
KEYS="$HOME/projects/stack_wallet/lib/external_api_keys.dart"
if ! test -f "$KEYS"; then
echo 'prebuild.sh: creating template lib/external_api_keys.dart file'
printf 'const kChangeNowApiKey = "";\nconst kSimpleSwapApiKey = "";' > $KEYS
fi
# install stack wallet dependencies
sudo apt-get install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm
@ -46,9 +32,23 @@ source "$HOME/.cargo/env"
cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
# build stack wallet plugins
cd $STACK_WALLET
cd scripts/android
./build_all.sh
cd ../linux
./build_all.sh
# # setup stack_wallet github
# cd $PROJECTS
# git clone https://github.com/cypherstack/stack_wallet.git
# cd stack_wallet
# export STACK_WALLET=$(pwd)
# git submodule update --init --recursive
# # create template lib/external_api_keys.dart file if it doesn't already exist
# KEYS="$HOME/projects/stack_wallet/lib/external_api_keys.dart"
# if ! test -f "$KEYS"; then
# echo 'prebuild.sh: creating template lib/external_api_keys.dart file'
# printf 'const kChangeNowApiKey = "";\nconst kSimpleSwapApiKey = "";' > $KEYS
# fi
# # build stack wallet plugins
# cd $STACK_WALLET
# cd scripts/android
# ./build_all.sh
# cd ../linux
# ./build_all.sh

View file

@ -3,7 +3,7 @@
mkdir -p build
(cd ../../crypto_plugins/flutter_libepiccash/scripts/windows && ./build_all.sh ) &
(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./build_all.sh ) &
(cd ../../crypto_plugins/flutter_libmonero/scripts/windows && ./build_all.sh) &
# (cd ../../crypto_plugins/flutter_libmonero/scripts/windows && ./build_all.sh) &
wait
echo "Done building"

57
scripts/windows/deps.ps1 Normal file
View file

@ -0,0 +1,57 @@
# Create C:\development
New-Item -Path 'C:\development' -ItemType Directory
# Download flutter_windows_3.7.12-stable.zip
Invoke-WebRequest "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.7.12-stable.zip" -OutFile "C:\development\flutter_windows_3.7.12-stable.zip"
# Extract Flutter SDK
Expand-Archive "C:\development\flutter_windows_3.7.12-stable.zip" -DestinationPath "C:\development"
# See https://stackoverflow.com/a/69239861
function Add-Path {
param(
[Parameter(Mandatory, Position=0)]
[string] $LiteralPath,
[ValidateSet('User', 'CurrentUser', 'Machine', 'LocalMachine')]
[string] $Scope
)
Set-StrictMode -Version 1; $ErrorActionPreference = 'Stop'
$isMachineLevel = $Scope -in 'Machine', 'LocalMachine'
if ($isMachineLevel -and -not $($ErrorActionPreference = 'Continue'; net session 2>$null)) { throw "You must run AS ADMIN to update the machine-level Path environment variable." }
$regPath = 'registry::' + ('HKEY_CURRENT_USER\Environment', 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment')[$isMachineLevel]
# Note the use of the .GetValue() method to ensure that the *unexpanded* value is returned.
$currDirs = (Get-Item -LiteralPath $regPath).GetValue('Path', '', 'DoNotExpandEnvironmentNames') -split ';' -ne ''
if ($LiteralPath -in $currDirs) {
Write-Verbose "Already present in the persistent $(('user', 'machine')[$isMachineLevel])-level Path: $LiteralPath"
return
}
$newValue = ($currDirs + $LiteralPath) -join ';'
# Update the registry.
Set-ItemProperty -Type ExpandString -LiteralPath $regPath Path $newValue
# Broadcast WM_SETTINGCHANGE to get the Windows shell to reload the
# updated environment, via a dummy [Environment]::SetEnvironmentVariable() operation.
$dummyName = [guid]::NewGuid().ToString()
[Environment]::SetEnvironmentVariable($dummyName, 'foo', 'User')
[Environment]::SetEnvironmentVariable($dummyName, [NullString]::value, 'User')
# Finally, also update the current session's `$env:Path` definition.
# Note: For simplicity, we always append to the in-process *composite* value,
# even though for a -Scope Machine update this isn't strictly the same.
$env:Path = ($env:Path -replace ';$') + ';' + $LiteralPath
Write-Verbose "`"$LiteralPath`" successfully appended to the persistent $(('user', 'machine')[$isMachineLevel])-level Path and also the current-process value."
}
# Add Flutter SDK to PATH if it's not there already
if ($Env:Path -split ";" -contains 'C:\development\flutter\bin') {
} else {
Add-Path("C:\development\flutter\bin")
}

8
scripts/windows/deps.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/bash
(cd ../../crypto_plugins/flutter_libepiccash/scripts/windows && ./deps.sh ) &
(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./mxedeps.sh ) &
# (cd ../../crypto_plugins/flutter_libmonero/scripts/windows && ./monerodeps.sh && ./mxedeps.sh) &
wait
echo "Done building"

View file

@ -80,6 +80,12 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_libepiccash/scripts/windows/build/libepic_cash_wallet.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_liblelantus/scripts/windows/build/libmobileliblelantus.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"