Skip to content

Commit

Permalink
Fix/windows installer (wasmerio#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmclark authored Feb 14, 2019
1 parent 0c7532b commit 5948fa1
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 8 deletions.
30 changes: 22 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
branches:
except:
- master

version: "{build} ~ {branch}"

os: Visual Studio 2017

# Do not build feature branch with open Pull Requests
skip_branch_with_pr: true

environment:
matrix:
- CHANNEL: stable
Expand All @@ -20,14 +19,29 @@ install:
- rustc -vV
- cargo -vV

artifacts:
- path: target\debug\wasmer.exe
name: wasmer.exe

build_script:
- cargo build --verbose

test_script:
- set RUST_BACKTRACE=1
- cd ./lib/spectests && cargo test -- --test-threads 1 && cd ../..

before_deploy:
- cd installer
- iscc wasmer.iss
- copy /y .\WasmerInstaller.exe ..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
- appveyor PushArtifact WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe

artifacts:
- path: WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
name: WasmerInstaller.exe

deploy:
description: 'WasmerInstaller'
artifact: /.*\.exe/
auth_token:
secure: CaKtncy7S1PWxzDUQ0p2264pe3HwxzDn5VIyRizDaa72/SVfskNcoMjwwRh0ut22
provider: GitHub
on:
branch: master
appveyor_repo_tag: true
71 changes: 71 additions & 0 deletions installer/wasmer.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[Setup]
AppName=Wasmer
AppVersion=1.5
DefaultDirName={pf}\Wasmer
DefaultGroupName=Wasmer
Compression=lzma2
SolidCompression=yes
OutputDir=.\
DisableProgramGroupPage=yes
ChangesEnvironment=yes
OutputBaseFilename=WasmerInstaller

[Files]
Source: "..\target\release\wasmer.exe"; DestDir: "{app}\bin"

[Code]
const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
procedure EnvAddPath(Path: string);
var
Paths: string;
begin
{ Retrieve current path (use empty string if entry not exists) }
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
then Paths := '';
{ Skip if string already found in path }
if Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';') > 0 then exit;
{ App string to the end of the path variable }
Paths := Paths + ';'+ Path +';'
{ Overwrite (or create if missing) path environment variable }
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
then Log(Format('The [%s] added to PATH: [%s]', [Path, Paths]))
else Log(Format('Error while adding the [%s] to PATH: [%s]', [Path, Paths]));
end;
procedure EnvRemovePath(Path: string);
var
Paths: string;
P: Integer;
begin
{ Skip if registry entry not exists }
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
exit;
{ Skip if string not found in path }
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then exit;
{ Update path variable }
Delete(Paths, P - 1, Length(Path) + 1);
{ Overwrite path environment variable }
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
then Log(Format('The [%s] removed from PATH: [%s]', [Path, Paths]))
else Log(Format('Error while removing the [%s] from PATH: [%s]', [Path, Paths]));
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall
then EnvAddPath(ExpandConstant('{app}') +'\bin');
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall
then EnvRemovePath(ExpandConstant('{app}') +'\bin');
end;
5 changes: 5 additions & 0 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ fn main() {
let options = CLIOptions::from_args();
match options {
CLIOptions::Run(options) => run(options),
#[cfg(not(target_os = "windows"))]
CLIOptions::SelfUpdate => update::self_update(),
#[cfg(target_os = "windows")]
CLIOptions::SelfUpdate => {
println!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
}
}
}

0 comments on commit 5948fa1

Please sign in to comment.