Skip to content

Commit

Permalink
Create my_download_nasm.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterGabaldon authored Jan 16, 2024
1 parent 972aa19 commit d042ef8
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions my_download_nasm.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
REM ORIGINAL AT https://github.com/ShiftMediaProject/VSNASM/blob/master/install_script.bat

@echo OFF
setlocal

REM Defined cript variables
set NASMDL=http://www.nasm.us/pub/nasm/releasebuilds
set NASMVERSION=2.16.01

REM Store current directory and ensure working directory is the location of current .bat
set CALLDIR=%CD%
set SCRIPTDIR=%~dp0
set SCRIPTDIR=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC

REM Download the latest nasm binary for windows
if exist "%SCRIPTDIR%\nasm_%NASMVERSION%.zip" (
echo Using existing NASM binary...
goto InstallNASM
)
echo Checking for existing NASM in NASMPATH...
%NASMPATH%\nasm.exe -v >nul 2>&1
if ERRORLEVEL 0 (
echo Using existing NASM binary from %NASMPATH%...
goto SkipInstallNASM
)
set NASMDOWNLOAD=%NASMDL%/%NASMVERSION%/win%SYSARCH%/nasm-%NASMVERSION%-win%SYSARCH%.zip
echo Downloading required NASM release binary...
powershell.exe -Command "(New-Object Net.WebClient).DownloadFile('%NASMDOWNLOAD%', '%SCRIPTDIR%\nasm_%NASMVERSION%.zip')" >nul 2>&1
if not exist "%SCRIPTDIR%\nasm_%NASMVERSION%.zip" (
echo Error: Failed to download required NASM binary!
echo The following link could not be resolved "%NASMDOWNLOAD%"
goto Terminate
)

:InstallNASM
powershell.exe -Command Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('"%SCRIPTDIR%\nasm_%NASMVERSION%.zip"', '"%SCRIPTDIR%\TempNASMUnpack"') >nul 2>&1
if not exist "%SCRIPTDIR%\TempNASMUnpack" (
echo Error: Failed to unpack NASM download!
del /F /Q "%SCRIPTDIR%\nasm_.zip" >nul 2>&1
goto Terminate
)

REM copy nasm executable to VC installation folder
echo Installing required NASM release binary...
del /F /Q "%VCINSTALLDIR%\nasm.exe" >nul 2>&1
copy /B /Y /V "%SCRIPTDIR%\TempNASMUnpack\nasm-%NASMVERSION%\nasm.exe" "%VCINSTALLDIR%" >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Error: Failed to install NASM binary!
echo Ensure that this script is run in a shell with the necessary write privileges
rd /S /Q "%SCRIPTDIR%\TempNASMUnpack" >nul 2>&1
goto Terminate
)
rd /S /Q "%SCRIPTDIR%\TempNASMUnpack" >nul 2>&1
:SkipInstallNASM
echo Finished Successfully

0 comments on commit d042ef8

Please sign in to comment.