Skip to content

Commit

Permalink
Create runsample.bat script for Windows (#275)
Browse files Browse the repository at this point in the history
For those of us still using Windows without WSL, B4W...

While I was at it, I've also fixed a few shellcheck warnings in the original runsample script and made it exit upon encountering an empty string.
  • Loading branch information
mataha committed Feb 10, 2021
1 parent 979fcdf commit 0c9fe44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
9 changes: 4 additions & 5 deletions runsample
Expand Up @@ -6,11 +6,10 @@
task=$1
shift 1

if [ ! -d "samples/${task}" ]; then
echo "Unknown sample ${task}"
if [ -z "${task}" ] || [ ! -d "samples/${task}" ]
then
echo "Unknown sample: '${task}'"
exit 1
fi

./gradlew --quiet :samples:${task}:installDist

./samples/${task}/build/install/${task}/bin/${task} "$@"
./gradlew --quiet ":samples:${task}:installDist" && "./samples/${task}/build/install/${task}/bin/${task}" "$@"
24 changes: 24 additions & 0 deletions runsample.bat
@@ -0,0 +1,24 @@
@if "%DEBUG%"=="" @echo off
:: Run one of the samples.
:: The first argument must be the name of the sample task (e.g. echo).
:: Any remaining arguments are forwarded to the sample's argv.

if "%OS%"=="Windows_NT" setlocal EnableDelayedExpansion

set TASK=%~1

set SAMPLE=false
if defined TASK if not "!TASK: =!"=="" if exist "samples\%TASK%\*" set SAMPLE=true

if "%SAMPLE%"=="false" (
echo Unknown sample: '%TASK%'
exit /b 1
)

set ARGS=%*
set ARGS=!ARGS:*%1=!
if "!ARGS:~0,1!"==" " set ARGS=!ARGS:~1!

call gradlew --quiet ":samples:%TASK%:installDist" && call "samples\%TASK%\build\install\%TASK%\bin\%TASK%" %ARGS%

if "%OS%"=="Windows_NT" endlocal

0 comments on commit 0c9fe44

Please sign in to comment.