Skip to content

Commit

Permalink
Use stremio-runtime.exe in place of node.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
core1024 committed Jan 5, 2021
1 parent aebccee commit 8c32040
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 7 deletions.
14 changes: 8 additions & 6 deletions appveyor.yml
Expand Up @@ -25,6 +25,12 @@ install:
- ps: del "$env:OPENSSL_INSTALLER"
- set OPENSSL_BIN_PATH=C:\OpenSSL-Win32\bin

# Install Resource Hacker
- ps: $env:RH_INSTALLER = "reshacker_setup.exe"
- ps: Start-FileDownload "http://www.angusj.com/resourcehacker/$env:RH_INSTALLER"
- ps: Start-Process "$env:RH_INSTALLER" -ArgumentList "/silent /verysilent /sp- /suppressmsgboxes /dir=C:\RH" -Wait
- ps: del "$env:RH_INSTALLER"

# Temp debugging
- ps: $env:DLL_DIR = "windows"
- echo DLL_DIR %DLL_DIR%
Expand All @@ -47,7 +53,6 @@ install:
- set VSCDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
- set NSISDIR=C:\Program Files (x86)\NSIS
- set PATH=%PATH%;%QTDIR%\bin;%VSCDIR%\bin;%NSISDIR%
- ps: $env:NODE_BIN_PATH=(Get-Command node.exe | Split-Path)

# Install NsProcess NSIS Plugin
- move windows\NsProcess\Include\nsProcess.nsh "%NSISDIR%\Include"
Expand All @@ -67,8 +72,6 @@ build: off
test_script:
- ps: $env:UPLOAD_PATH = If ($env:TAG) { $env:TAG } else { If ($env:APPVEYOR_REPO_TAG_NAME) { $env:APPVEYOR_REPO_TAG_NAME } else { $env:APPVEYOR_REPO_BRANCH } }
- ps: $env:TAG = If (!$env:TAG) { "master" } else { $env:TAG }
# Install packages
- yarn install

- ps: $env:package_version = git grep -hoP '^\s*VERSION\s*=\s*\K.*$' HEAD -- stremio.pro
# Pull pre-built resources from S3; those were generated by the travis build for "stremio"
Expand All @@ -83,7 +86,6 @@ test_script:
- if exist shell/deps/qBreakpad ( cd shell/deps/qBreakpad/handler && qmake && nmake && cd ../../../.. )
- qmake .
- nmake
#- node .\node_modules\gulp\bin\gulp gulp-deploy

- mkdir dist-win
# copy-windows-mpv
Expand All @@ -94,8 +96,8 @@ test_script:
- copy "%OPENSSL_BIN_PATH%\libeay32.dll" dist-win
# copy-windows-ffmpeg
- copy "%FFMPEG_BIN_PATH%\ffmpeg.exe" dist-win
# copy-windows-node
- copy "%NODE_BIN_PATH%\node.exe" dist-win
# copy-windows-node (stremio-runtime)
- %DLL_DIR%\generate_stremio-runtime.cmd dist-win
# copy-windows-server
- appveyor DownloadFile https://s3-eu-west-1.amazonaws.com/stremio-artifacts/four/v%package_version%/server.js -FileName dist-win\server.js
# copy-windows-msvc
Expand Down
Binary file added images/stremio_gray.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion main.qml
Expand Up @@ -258,7 +258,7 @@ ApplicationWindow {
}
function launchServer() {
var node_executable = applicationDirPath + "/node"
if (Qt.platform.os === "windows") node_executable = applicationDirPath + "/node.exe"
if (Qt.platform.os === "windows") node_executable = applicationDirPath + "/stremio-runtime.exe"
streamingServer.start(node_executable,
[applicationDirPath +"/server.js"].concat(Qt.application.arguments.slice(1)),
"EngineFS server started at "
Expand Down
72 changes: 72 additions & 0 deletions windows/generate_stremio-runtime.cmd
@@ -0,0 +1,72 @@
@echo off

:: Prepare paths and environment
set "rt_path=%~dpf1"
set rt_exe="%rt_path%\stremio-runtime.exe"

set rh="C:\RH\ResourceHacker.exe"

FOR /f "tokens=* USEBACKQ" %%p IN (`where node.exe`) DO (
set node="%%p"
)

pushd %~dp0
pushd ..\images
set rt_icon="%cd%\stremio_gray.ico"
popd
popd

:: Check if all paths are correct
if not exist %rh% goto :norh
if not exist %node% goto :nonode
if not exist %rt_icon% goto :noico
if not exist "%rt_path%\" goto :nodir

:: Create temp dir
set "res_dir=%TEMP%\srres"
md "%res_dir%"

:: Extract Node.js resources
%rh% -open %node% -save "%res_dir%\resources.rc" -action extract -mask ",,"

:: Replace desired resources
copy /D /Y %rt_icon% "%res_dir%\ICON1_1.ico"

set textFile="%res_dir%\resources.rc"
for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set line=!line:Node.js=Stremio Runtime!
>>"%textFile%" echo !line:node.exe=stremio-runtime.exe!
endlocal
)

:: Compile new resource file
pushd "%res_dir%"
%rh% -open .\resources.rc -save .\stremio-rt.res -action compile
popd

:: Build the stremio-runtime executable
%rh% -open %node% -saveas %rt_exe% -action modify -res "%res_dir%\stremio-rt.res"

:: Cleanup
rd /S /Q "%res_dir%"
exit /b 0

:: Error states

:norh
echo ResourceHacker.exe not found at %rh%
exit /b 1

:nonode
echo Node.exe not found at %node%
exit /b 2

:noico
echo Icon file not found at %rt_icon%
exit /b 3

:nodir
echo Destination directory does not exists at %rt_path%
exit /b 4

0 comments on commit 8c32040

Please sign in to comment.