Skip to content

Commit

Permalink
Include fasmg update option in make.bat
Browse files Browse the repository at this point in the history
Adds an option in make.bat to update fasmg to the latest version. No functional change for asmFish.
  • Loading branch information
CounterPly committed Jul 5, 2018
1 parent 0cb355f commit b260036
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
75 changes: 75 additions & 0 deletions download.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'
' Download and unzip script.
'

URL_BASE = WScript.Arguments(0)
ZIP_FILE = WScript.Arguments(1)
SRC_FILE = WScript.Arguments(2)
DST_FILE = WScript.Arguments(3)
MSG_TEXT = WScript.Arguments(4)

' Globals
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")

' Download a file from HTTP
Sub DownloadHttp(Url, File)
Const BINARY = 1
Const OVERWRITE = 2
Set xHttp = createobject("Microsoft.XMLHTTP")
Set bStrm = createobject("Adodb.Stream")
Call xHttp.Open("GET", Url, False)
' Disable caching for downloads
Call xHttp.SetRequestHeader("If-None-Match", "some-random-string")
Call xHttp.SetRequestHeader("Cache-Control", "no-cache,max-age=0")
Call xHttp.SetRequestHeader("Pragma", "no-cache")
Call xHttp.Send()
If Not xHttp.Status = 200 Then
Call WScript.Echo("Unable to access file - Error " & xHttp.Status)
Call WScript.Quit(1)
End If
With bStrm
.type = BINARY
.open
.write xHttp.responseBody
.savetofile File, OVERWRITE
End With
End Sub

' Unzip a specific file from an archive
Sub Unzip(Archive, File)
Const NOCONFIRMATION = &H10&
Const NOERRORUI = &H400&
Const SIMPLEPROGRESS = &H100&
unzipFlags = NOCONFIRMATION + NOERRORUI + SIMPLEPROGRESS
Set objShell = CreateObject("Shell.Application")
Set objSource = objShell.NameSpace(fso.GetAbsolutePathName(Archive)).Items()
Set objTarget = objShell.NameSpace(fso.GetAbsolutePathName("."))
' Only extract the file we are interested in
For i = 0 To objSource.Count - 1
If objSource.Item(i).Name = File Then
Call objTarget.CopyHere(objSource.Item(i), unzipFlags)
End If
Next
End Sub

' Fetch the file, unzip it and rename it
If Not fso.FileExists(DST_FILE) Then
Call WScript.Echo(vbCrLf & MSG_TEXT & " is being downloaded from: " &_
vbCrLf & URL_BASE & "/" & ZIP_FILE & vbCrLf &_
"Note: This only updates the Windows binary.")
Call DownloadHttp(URL_BASE & "/" & ZIP_FILE, ZIP_FILE)
End If
If Not fso.FileExists(ZIP_FILE) And Not fso.FileExists(DST_FILE) Then
Call WScript.Echo("There was a problem downloading the file.")
Call WScript.Quit(1)
End If
If fso.FileExists(ZIP_FILE) Then
Call Unzip(ZIP_FILE, SRC_FILE)
Call fso.MoveFile(SRC_FILE, DST_FILE)
Call fso.DeleteFile(ZIP_FILE)
End If
If Not fso.FileExists(DST_FILE) Then
Call WScript.Echo("There was a problem unzipping the file.")
Call WScript.Quit(1)
End If
Binary file modified fasmg.exe
Binary file not shown.
28 changes: 18 additions & 10 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ echo 6 - Base
echo 7 - Matefinder
echo.
echo D - Toggle Debug Mode
echo U - Update fasmg.exe
echo Q - Quit
echo.
choice /c:1234567QpbD>NUL
choice /c:1234567QpbDU>NUL

:: Debug = OFF [default]

:: OPTIONS
if errorlevel 12 goto update
if errorlevel 11 goto debug
if errorlevel 10 goto WinBmi2
if errorlevel 9 goto WinPopcnt
if errorlevel 8 goto done
if errorlevel 7 goto matefinder
if errorlevel 6 goto base
if errorlevel 5 goto arm
if errorlevel 4 goto mac
if errorlevel 3 goto linux
if errorlevel 2 goto windows
if errorlevel 1 goto allBinaries
if errorlevel 9 goto WinPopcnt
if errorlevel 8 goto done
if errorlevel 7 goto matefinder
if errorlevel 6 goto base
if errorlevel 5 goto arm
if errorlevel 4 goto mac
if errorlevel 3 goto linux
if errorlevel 2 goto windows
if errorlevel 1 goto allBinaries
echo CHOICE missing
goto done

Expand Down Expand Up @@ -388,4 +390,10 @@ if defined debug (ECHO Debug Mode = ON) else (ECHO Debug Mode = OFF)
if defined debug (SET "debug=") else (SET "debug=%default%")
goto menu

:update
if exist fasmg.exe del fasmg.exe
call cscript /nologo "%~dp0download.vbs" https://flatassembler.net fasmg.zip fasmg.exe fasmg.exe "The latest fasmg assembler"
echo.
goto menu

:END
File renamed without changes.

0 comments on commit b260036

Please sign in to comment.