Skip to content

Commit

Permalink
Merge pull request #275 from msupply-foundation/162-windows-installer…
Browse files Browse the repository at this point in the history
…-setup

162 windows installer setup
  • Loading branch information
jmbrunskill authored Dec 6, 2023
2 parents 82338cb + 7cbda8a commit 4d5709f
Show file tree
Hide file tree
Showing 12 changed files with 4,526 additions and 16 deletions.
10 changes: 10 additions & 0 deletions backend/Cargo.lock

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

4 changes: 3 additions & 1 deletion backend/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ license = "AFFERO GPL-3.0"
version = "0.1.0"
edition = "2018"
default-run = "notify_server"
build = "src/set_icon.rs"

[lib]
path = "src/lib.rs"
Expand Down Expand Up @@ -61,4 +62,5 @@ sanitize-filename = "0.4"

[dev-dependencies]


[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
Binary file added backend/server/notify.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions backend/server/src/set_icon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[cfg(windows)]
extern crate winres;

#[cfg(windows)]
fn main() {
let mut res = winres::WindowsResource::new();
res.set_icon("notify.ico");
// The winres crate compiles the icon into a Windows resource file and directs cargo to link it into the output binary
res.compile().unwrap();
}

// Keep the unix build happy
#[cfg(unix)]
fn main() {}
17 changes: 17 additions & 0 deletions build/notify_license_and_warranty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
License

Notify software (including it's documentation produced by mSupply Foundation) is protected by copyright and licensed with the GNU Affero General Public License v3.0.
A copy of the license is available at https://github.com/msupply-foundation/notify/blob/main/LICENSE

mSupply Foundation grants you license to use notify software according to the stated licensing agreement and your installation and/or continued use of notify confirms your agreement.

The user guide, including material on the mSupply web site may not, in whole or in part, be copied, reproduced, translated or reduced to any machine readable form without prior consent in writing from mSupply Foundation.


Warranty

No warranty is given on product software, the user guide and other training materials. Even though mSupply Foundation has tested the software and documentation and reviewed their contents, mSupply Foundation and its distributors and dealers make no warranties, either expressed or implied, with respect to their fitness for a particular purpose. The program and the user guides are distributed solely on an "as is" basis. The entire risk as to their quality and performance is with the you.

Should either the software or the manuals or both prove defective, you, and not mSupply Foundation or its distributors or dealers, assume the entire cost of all necessary servicing, repair, or correction.

mSupply Foundation and its distributors and dealers will not be liable for direct, indirect, incidental, or consequential damages resulting from any defect in the software or user guide, even if they have been advised of the possibility of such damage.
21 changes: 21 additions & 0 deletions build/windows/adjustSUFs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require('fs');
const files = fs.readdirSync('.');

files.forEach((fileName) => {
if (fileName.endsWith('.suf')) {
const sufFileName = `${fileName}`;
const fileContent = fs.readFileSync(sufFileName, 'utf8');
fs.writeFileSync(fileName, replaceVersion(adjustOutputFolder(fileContent)));
}
});

function replaceVersion(fileContent) {
return fileContent.replace(/replace with version/g, process.env.versionTag);
}

function adjustOutputFolder(fileContent) {
return fileContent.replace(
/<OutputFolder>.*<\/OutputFolder>/g,
`<OutputFolder>${process.env.installersOutputFolder}</OutputFolder>`
);
}
19 changes: 19 additions & 0 deletions build/windows/installers-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@ECHO ##### Removing installers folder #####
@rmdir "installers" /s /q

@ECHO ##### Update SUF files #####
copy /y notify\notify\notify_service.suf notify\notify_service.suf

@ECHO ##### Adjusting SUFS #####
SET installerWorkspace=%cd%\notify
SET SUFlocation=%installerWorkspace%\notify
FOR /F "delims=*" %%i in ('more notify\notify\version.txt') do SET versionTag=%%i
@ECHO "current tag = %versionTag%"
SET installersOutputFolder=%cd%\installers

@cd notify
node "%SUFlocation%\adjustSUFs.js"
@cd ..

@ECHO ##### Creating installers #####
start "" /wait "C:\Program Files (x86)\Setup Factory 9\SUFDesign.exe" /BUILD /LOG:installers\setup-factory.log "%installerWorkspace%\notify_service.suf"
19 changes: 19 additions & 0 deletions build/windows/notify-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@ECHO ##### Removing previous builds #####
@rmdir "notify" /s /q

@ECHO ##### Starting notify builds #####
mkdir "notify"
xcopy "notify\configuration" "notify\configuration" /e /h /c /i

copy "backend\server\notify.ico" "build\notify.ico"
xcopy "build\*.*" "notify" /c
xcopy "build\windows\*.*" "notify" /c
copy "version.txt" "notify\version.txt"

@ECHO ##### Prepare notify frontend #####
start /b /wait build\windows\notify-prepare.bat
@if %errorlevel% neq 0 exit /b %errorlevel%

ECHO ##### Building notify app #####
cd backend && cargo build --release --bin notify_service && copy "target\release\notify_service.exe" "..\notify\notify_service.exe"
if %errorlevel% neq 0 exit /b %errorlevel%
8 changes: 8 additions & 0 deletions build/windows/notify-prepare.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
IF NOT EXIST version.txt (
@ECHO ##### No version.txt found, defaulting to package version #####
node -p "require('./frontend/package.json').version" > version.txt
)
set /p APP_BUILD_VERSION=<version.txt
@ECHO %APP_BUILD_VERSION%
cd frontend && yarn install --force --frozen-lockfile && yarn build-windows
if %errorlevel% neq 0 exit /b %errorlevel%
Loading

0 comments on commit 4d5709f

Please sign in to comment.