Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ jobs:
toolchain: stable

- uses: Swatinem/rust-cache@v1
with:
key: ${{ secrets.CACHE_VERSION }}

- uses: davidB/rust-cargo-make@v1
with:
Expand All @@ -84,10 +86,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pyproject-toml-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pyproject-toml-
${{ runner.os }}-
key: ${{ runner.os }}-pyproject-toml-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}

- name: Set up python builder
shell: bash
Expand Down Expand Up @@ -140,6 +139,8 @@ jobs:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
key: ${{ secrets.CACHE_VERSION }}

- uses: davidB/rust-cargo-make@v1
with:
Expand All @@ -153,10 +154,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pyproject-toml-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pyproject-toml-
${{ runner.os }}-
key: ${{ runner.os }}-pyproject-toml-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}

- name: Set up python builder
shell: bash
Expand Down Expand Up @@ -253,6 +251,8 @@ jobs:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
key: ${{ secrets.CACHE_VERSION }}

- uses: davidB/rust-cargo-make@v1
with:
Expand All @@ -262,10 +262,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pyproject-toml-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pyproject-toml-
${{ runner.os }}-
key: ${{ runner.os }}-pyproject-toml-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}

- name: Set up python builder
shell: bash
Expand All @@ -287,6 +284,14 @@ jobs:
cargo make create-dist
if: matrix.os != 'windows-2019'

- name: Create ${{ runner.os }} Installers.
shell: bash
run: |
cargo make dist-to-installer
INSTALLER_ARCHIVE=$(find installers/Windows -maxdepth 1 -iname "*.exe")
echo "INSTALLER_ARCHIVE=$INSTALLER_ARCHIVE" >>$GITHUB_ENV
if: matrix.os == 'windows-2019' && github.event_name == 'push' && contains(github.ref, 'refs/tags')

- name: Pull Git LFS objects
run: git lfs pull
env:
Expand Down Expand Up @@ -316,6 +321,12 @@ jobs:
path: |
${{ env.RELEASE_ARCHIVE }}
release-archive.filename
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-installer
path: |
${{ env.INSTALLER_ARCHIVE }}
if: matrix.os == 'windows-2019' && github.event_name == 'push' && contains(github.ref, 'refs/tags')
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-artifacts-debug
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dist/
console_backend/tests/fileout.json
get-pip.py
.*.sw?
installers/Windows/*.exe
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ exec --fail-on-error xz -T 0 -e -9 "${output_name}.tar"
[tasks.create-dist]
run_task = [{ name = ["build-dist", "purge-dist", "compress-dist"] }]

[tasks.dist-to-installer]

[tasks.dist-to-installer.windows]
script_runner = "@shell"
script = '''
makensis /V4 .\installers\Windows\Installer.nsi
'''

[tasks.qml-format]
dependencies = ["set-qml-files", "set-qml-app"]
script_runner = "@shell"
Expand Down
3 changes: 3 additions & 0 deletions entrypoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ windows = { version = ">=0.24", features = [
"Win32_System_Console",
"Win32_Foundation",
] }

[target.'cfg(target_os = "windows")'.build-dependencies]
winres = "0.1"
13 changes: 12 additions & 1 deletion entrypoint/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
fn main() {
#[cfg(target_os = "windows")]
use winres::WindowsResource;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

fn main() -> Result<()> {
#[cfg(target_os = "linux")]
{
println!("cargo:rustc-link-lib=dylib=crypt");
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN/lib");
}
#[cfg(target_os = "windows")]
{
WindowsResource::new()
.set_icon("../resources/images/icon.ico")
.compile()?;
}
Ok(())
}
132 changes: 132 additions & 0 deletions installers/Windows/Installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
; This file was adapted from:
; https://github.com/mherrmann/fbs/blob/master/fbs/_defaults/src/installer/windows/Installer.nsi
!include MUI2.nsh
!include FileFunc.nsh
!include LogicLib.nsh
!define MUI_ICON "..\..\resources\images\icon.ico"
!define MUI_UNICON "..\..\resources\images\icon.ico"

!searchparse /file "..\..\console_backend\src\version.txt" `` VER_MAJOR `.` VER_MINOR `.` VER_PATCH_UNFILTERED ``
!searchparse /noerrors "${VER_PATCH_UNFILTERED}" `` VER_PATCH `-`
!define VERSION_ORIGINAL "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH_UNFILTERED}"
!define VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}.0"
!define app_name "Swift Navigation Console"
!define app_executable "console.exe"
!define installer_dir "py39-dist"
!define company_name "Swift Navigation"



!define UNINST_KEY \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${app_name}"

VIProductVersion "${VERSION}"
VIAddVersionKey "ProductName" "${app_name}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "ProductVersion" "${VERSION}"
VIAddVersionKey "LegalCopyright" "(C) ${company_name}"
VIAddVersionKey "FileDescription" "${app_name}"

!define MULTIUSER_EXECUTIONLEVEL Standard ; Switch to "Highest" for All Users when available otherwise current user.

!define MULTIUSER_INSTALLMODE_COMMANDLINE
!include MultiUser.nsh

;--------------------------------
;Init

Function .onInit
!insertmacro MULTIUSER_INIT
; Do not use InstallDir at all so we can detect empty $InstDir!
${If} $InstDir == "" ; /D not used
${If} $MultiUser.InstallMode == "AllUsers"
StrCpy $InstDir "$PROGRAMFILES64\${company_name}\${app_name}"
${Else}
StrCpy $InstDir "$LOCALAPPDATA\${company_name}\${app_name}"
${EndIf}
${EndIf}

FunctionEnd

;--------------------------------
;General

Name "${app_name}"
OutFile "${app_name}-${VERSION_ORIGINAL}.exe"

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Pages
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${app_name} version ${VERSION_ORIGINAL}.$\r$\n$\r$\n$\r$\nClick Next to continue."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Run ${app_name}"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchAsNonAdmin"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section
SetOutPath "$InstDir"
Call Uninstall
File /r "..\..\${installer_dir}\*"
WriteRegStr SHCTX "Software\${app_name}" "" $InstDir
WriteUninstaller "$InstDir\uninstall.exe"
CreateShortCut "$DESKTOP\${app_name}.lnk" "$InstDir\${app_executable}"
CreateShortCut "$SMPROGRAMS\${app_name}.lnk" "$InstDir\${app_executable}"
WriteRegStr SHCTX "${UNINST_KEY}" "DisplayName" "${app_name}"
WriteRegStr SHCTX "${UNINST_KEY}" "UninstallString" \
"$\"$InstDir\uninstall.exe$\" /$MultiUser.InstallMode"
WriteRegStr SHCTX "${UNINST_KEY}" "QuietUninstallString" \
"$\"$InstDir\uninstall.exe$\" /$MultiUser.InstallMode /S"
WriteRegStr SHCTX "${UNINST_KEY}" "Publisher" "${company_name}"
WriteRegStr SHCTX "${UNINST_KEY}" "DisplayIcon" "$InstDir\uninstall.exe"
${GetSize} "$InstDir" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD SHCTX "${UNINST_KEY}" "EstimatedSize" "$0"

SectionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"
Call un.Uninstall
SectionEnd

Function LaunchAsNonAdmin
Exec '"$WINDIR\explorer.exe" "$InstDir\${app_executable}"'
FunctionEnd

!macro Uninstall Prefix
Function ${Prefix}Uninstall
RMDir /r "$InstDir"
Delete "$DESKTOP\${app_name}.lnk"
Delete "$SMPROGRAMS\${app_name}.lnk"
DeleteRegKey /ifempty SHCTX "Software\${app_name}"
DeleteRegKey SHCTX "${UNINST_KEY}"
FunctionEnd
!macroend
!insertmacro Uninstall ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both of these macro calls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah when using a call inside of the uninstaller the function/macro must be prefixed by "un." so this allows us to call the same function before installing and when uninstalling.

!insertmacro Uninstall "un."

Function un.onInit
!insertmacro MULTIUSER_UNINIT
FunctionEnd
1 change: 1 addition & 0 deletions resources/console_resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<file>images/fontawesome/file-import.svg</file>
<file>images/fontawesome/exclamation-triangle.svg</file>
<file>images/icon.png</file>
<file>images/icon.ico</file>
<file>TableComponents/SortableColumnHeading.qml</file>
<file>TableComponents/TableCellDelegate.qml</file>
<file>BaseComponents/SmallCheckBox.qml</file>
Expand Down
Binary file added resources/images/icon.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion swiftnav_console/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from PySide2 import QtQml, QtCore

from PySide2.QtGui import QFontDatabase
from PySide2.QtGui import QFontDatabase, QIcon

from PySide2.QtQml import QQmlComponent, qmlRegisterType

Expand Down Expand Up @@ -796,6 +796,7 @@ def main():
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(":/images/icon.ico"))
app.setOrganizationName(ApplicationMetadata.ORGANIZATION_NAME)
app.setOrganizationDomain(ApplicationMetadata.ORGANIZATION_DOMAIN)
app.setApplicationName(ApplicationMetadata.APPLICATION_NAME)
Expand Down