Skip to content

Commit

Permalink
Merge pull request #8 from jonbartels/windows-builds-2
Browse files Browse the repository at this point in the history
Updated README for Windows. Made the app work in Windows by using cor…
  • Loading branch information
kayyagari authored Aug 1, 2023
2 parents d2b44ae + b0e13ba commit 1b9f90f
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 8 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build-catapault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build on every push and every pull-request
on:
pull_request:
paths-ignore:
- '*.md'
push:
paths-ignore:
- '*.md'
workflow_dispatch:

jobs:
release:
permissions:
contents: write
strategy:
fail-fast: false
max-parallel: 3
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies (ubuntu only)
if: startsWith(matrix.platform, 'ubuntu')
# You can remove libayatana-appindicator3-dev if you don't use the system tray feature.
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev
- name: Rust setup
uses: dtolnay/rust-toolchain@stable

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'

- name: Sync node version and setup cache
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'npm' # Set this to npm, yarn or pnpm.

- name: Install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: npm install # Change this to npm, yarn or pnpm.

- name: Build the app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ github.ref_name }} # This only works if your workflow triggers on new tags.
releaseName: 'App Name v__VERSION__' # tauri-action replaces \_\_VERSION\_\_ with the app version.
releaseBody: 'See the assets to download and install this version.'
releaseDraft: true
prerelease: false

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.platform }}
path: |
src-tauri/target/release/bundle/nsis/*.exe
src-tauri/target/release/bundle/msi/*.msi
src-tauri/target/release/bundle/appimage/*.AppImage
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/rpm/*.rpm
src-tauri/target/release/bundle/dmg/*.dmg
src-tauri/target/release/bundle/macos/*.app
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ These compilation instructions are written for users not familiar with Rust and

You should generally follow the Tauri Getting started guide: https://tauri.app/v1/guides/getting-started/prerequisites

A good reference for how to run builds is the file .github/workflows/build-catapault.yml . If you can replicate the same steps the build pipeline does, then you should have good builds!

### MacOS

1. Open the project in VS Code. Let VS code install the suggested plugins.
Expand All @@ -29,4 +31,15 @@ Should be very similar to MacOS.

### Windows

Please make a PR if you use Windows and know how to compile the app
Please make a PR if you use Windows and know how to compile the app!

___Follow the instructions at___: https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-windows

Follow the openssl instructions at: https://docs.rs/crate/openssl/0.9.24 *EXCEPT* you have to use different commands to set env vars in PowerShell:
```
$env:OPENSSL_DIR='C:\Program Files\OpenSSL-Win64\'
$env:OPENSSL_INCLUDE_DIR='C:\Program Files\OpenSSL-Win64\include'
$env:OPENSSL_LIB_DIR='C:\Program Files\OpenSSL-Win64\lib'
$env:OPENSSL_NO_VENDOR=1
Get-ChildItem Env
```
22 changes: 15 additions & 7 deletions src-tauri/src/webstart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use std::{env, os};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::{Arc, Mutex};
use std::time::{Duration, SystemTime};
use std::time::{SystemTime};

use anyhow::Error;
use openssl::x509::store::X509StoreRef;
use reqwest::blocking::{Client, ClientBuilder};
use reqwest::Url;
use roxmltree::{Document, Node};
use roxmltree::Node;
use rustc_hash::FxHashMap;
use sha2::{Digest, Sha256};

Expand Down Expand Up @@ -71,10 +70,12 @@ impl WebstartFile {

let r = client.get(&webstart).send()?;
let data = r.text()?;
//TODO VERY NOISY, is there a log level lower than debug?
//println!("Got response from MC as: {:?}", data);
let doc = roxmltree::Document::parse(&data)?;

let root = doc.root();
let main_class_node = get_node(&root, "application-desc").expect("application-desc node");
let main_class_node = get_node(&root, "application-desc").expect("Got something from MC that was not an application-desc node in a JNLP XML");
let main_class = main_class_node.attribute("main-class").expect("missing main-class attribute").to_string();
let args = get_client_args(&main_class_node);

Expand Down Expand Up @@ -117,17 +118,22 @@ impl WebstartFile {
let file_name = file_path.file_name().unwrap();
let file_path = file_path.as_os_str();
let file_path = file_path.to_str().unwrap();

//In Windows the CP separator is ';' and literally every other OS is ':'
let classpath_separator = if cfg!(windows) {';'} else {':' };

//println!("{}", file_path);
// MirthConnect's own jars contain some overridden classes
// of the dependent libraries and hence must be loaded first
// https://forums.mirthproject.io/forum/mirth-connect/support/15524-using-com-mirth-connect-client-core-client
//TODO this should probably build the classpath objects as an ordered set, then do a .join(classpath_separator)
if file_name.to_str().unwrap().starts_with("mirth") {
classpath.push_str(file_path);
classpath.push(':');
classpath.push(classpath_separator);
}
else {
classpath_suffix.push_str(file_path);
classpath_suffix.push(':');
classpath_suffix.push(classpath_separator);
}
}

Expand Down Expand Up @@ -180,6 +186,8 @@ impl WebstartFile {
println!("log_file_path {:?}", log_file_path);
let f = File::create(log_file_path)?;
cmd.stdout(Stdio::from(f));
//TODO noisy, should be a debug logger
//println!("Executing with: {:?}", cmd);
cmd.spawn()?;
Ok(())
}
Expand Down Expand Up @@ -292,4 +300,4 @@ mod tests {
let ws = WebstartFile::load("https://localhost:8443").unwrap();
println!("{:?}", ws);
}
}
}

0 comments on commit 1b9f90f

Please sign in to comment.