Skip to content

Commit

Permalink
Update install lua/premake scripts
Browse files Browse the repository at this point in the history
Ensure they're running in the right folder and don't make them clutter the "root" directory but save downloaded files in a "tmp" directory, now the batch scripts can be used by just double clicking them
  • Loading branch information
edo9300 committed Sep 7, 2024
1 parent 607a5fc commit 92d96a0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 20 deletions.
19 changes: 12 additions & 7 deletions scripts/install-lua.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
SETLOCAL

SET LUA_VERSION=5.3.6
SET LUA_ZIP=lua-%LUA_VERSION%.zip
SET LUA_ZIP="tmp\lua-%LUA_VERSION%.zip"

REM ensure the script is always running inside the core's root directory
CD %~dp0..

MKDIR tmp

IF EXIST %LUA_ZIP% DEL /f /q %LUA_ZIP%
IF EXIST %LUA_ZIP% EXIT /B 1
IF EXIST "lua/src" RMDIR /s /q "lua/src"
IF EXIST "lua/src" EXIT /B 1
IF EXIST "lua\src" RMDIR /s /q "lua\src"
IF EXIST "lua\src" EXIT /B 1

CALL "%~DP0cmd/download.bat" ^
https://github.com/lua/lua/archive/refs/tags/v%LUA_VERSION%.zip lua-%LUA_VERSION%.zip
CALL "%~DP0cmd\download.bat" ^
https://github.com/lua/lua/archive/refs/tags/v%LUA_VERSION%.zip %LUA_ZIP%
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

CALL "%~DP0cmd/unzip.bat" lua-%LUA_VERSION%.zip lua
CALL "%~DP0cmd/unzip.bat" %LUA_ZIP% lua
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
REN "lua/lua-%LUA_VERSION%" src
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

SET LUACONF="lua/src/luaconf.h"
SET LUACONF="lua\src\luaconf.h"
>>%LUACONF% ECHO.
>>%LUACONF% ECHO #ifdef LUA_USE_WINDOWS
>>%LUACONF% ECHO #undef LUA_USE_WINDOWS
Expand Down
15 changes: 11 additions & 4 deletions scripts/install-lua.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

set -euxo pipefail

export LUA_VERSION=5.3.6
curl --retry 2 --connect-timeout 30 --location https://github.com/lua/lua/archive/refs/tags/v$LUA_VERSION.tar.gz -o lua-$LUA_VERSION.tar.gz
LUA_VERSION=5.3.6
LUA_ARCHIVE=tmp/lua-$LUA_VERSION.tar.gz
#ensure the script is always running inside the core's root directory
cd "$(dirname "$0")/.."

mkdir -p tmp

rm -rf $LUA_ARCHIVE
curl --retry 2 --connect-timeout 30 --location https://github.com/lua/lua/archive/refs/tags/v$LUA_VERSION.tar.gz -o $LUA_ARCHIVE
rm -rf lua/src
mkdir -p lua/src
tar xf lua-$LUA_VERSION.tar.gz --strip-components=1 -C lua/src
tar xf $LUA_ARCHIVE --strip-components=1 -C lua/src
cd lua
cat <<EOT >> src/luaconf.h
cat <<EOT >> src/luaconf.h
#ifdef LUA_USE_WINDOWS
#undef LUA_USE_WINDOWS
Expand Down
19 changes: 16 additions & 3 deletions scripts/install-premake5.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@
SETLOCAL

SET PREMAKE_VERSION=5.0.0-beta2
SET PREMAKE_EXTRACT_DIR="tmp\premake"
SET PREMAKE_ZIP="tmp\premake-%PREMAKE_VERSION%-windows.zip"

CALL "%~DP0cmd/download.bat" ^
https://github.com/premake/premake-core/releases/download/v%PREMAKE_VERSION%/premake-%PREMAKE_VERSION%-windows.zip premake.zip
REM ensure the script is always running inside the core's root directory
CD %~dp0..

MKDIR tmp

IF EXIST %PREMAKE_EXTRACT_DIR% RMDIR /s /q %PREMAKE_EXTRACT_DIR%
IF EXIST %PREMAKE_EXTRACT_DIR% EXIT /B 1

CALL "%~DP0cmd\download.bat" ^
https://github.com/premake/premake-core/releases/download/v%PREMAKE_VERSION%/premake-%PREMAKE_VERSION%-windows.zip %PREMAKE_ZIP%
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

CALL "%~DP0cmd\unzip.bat" %PREMAKE_ZIP% %PREMAKE_EXTRACT_DIR%
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

CALL "%~DP0cmd/unzip.bat" premake.zip .
COPY /V /Y %PREMAKE_EXTRACT_DIR%\premake5.exe .
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

EXIT /B
30 changes: 24 additions & 6 deletions scripts/install-premake5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@
set -euxo pipefail

TRAVIS_OS_NAME=${1:-$TRAVIS_OS_NAME}
PREMAKE_VERSION=5.0.0-beta2
#ensure the script is always running inside the core's root directory
cd "$(dirname "$0")/.."

mkdir -p tmp

if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-windows.zip
unzip -uo premake-5.0.0-beta2-windows.zip
PREMAKE_ARCHIVE=premake-$PREMAKE_VERSION-windows.zip
fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz
tar xf premake-5.0.0-beta2-linux.tar.gz
PREMAKE_ARCHIVE=premake-$PREMAKE_VERSION-linux.tar.gz
fi
if [[ "$TRAVIS_OS_NAME" == "macosx" ]]; then
curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-macosx.tar.gz
tar xf premake-5.0.0-beta2-macosx.tar.gz
PREMAKE_ARCHIVE=premake-$PREMAKE_VERSION-macosx.tar.gz
fi

PREMAKE_ARCHIVE_LOCATION=tmp/"$PREMAKE_ARCHIVE"

rm -rf $PREMAKE_ARCHIVE_LOCATION
curl --retry 5 --connect-timeout 30 --location --remote-header-name \
https://github.com/premake/premake-core/releases/download/v$PREMAKE_VERSION/$PREMAKE_ARCHIVE -o "$PREMAKE_ARCHIVE_LOCATION"

rm -rf tmp/premake
mkdir tmp/premake
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
unzip -uo "$PREMAKE_ARCHIVE_LOCATION" -d tmp/premake
cp tmp/premake/premake5.exe .
else
tar xf "$PREMAKE_ARCHIVE_LOCATION" -C tmp/premake
cp tmp/premake/premake5 .
fi

0 comments on commit 92d96a0

Please sign in to comment.