1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-05-12 12:00:13 +00:00

Update .ci/bootstrap.bat to use setup_mingw.cmd

This commit is contained in:
Samuel Gomes 2022-11-14 09:53:58 +05:30
parent 2229b41e34
commit 2cd889f0ec
3 changed files with 105 additions and 67 deletions

View file

@ -1,21 +1,14 @@
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
mkdir internal\c\c_compiler
set MINGW=mingw32.exe
IF "%PLATFORM%"=="x64" set MINGW=mingw64.exe
set url="https://www.qb64phoenix.com/qb64_files/%MINGW%"
echo Downloading %url%...
curl %url% -o %MINGW%
echo Extracting %MINGW% as C++ Compiler
@echo off
%MINGW% -y -o"./internal/c/c_compiler/"
pushd .
IF "%PLATFORM%"=="x64" (
call setup_mingw.cmd 64
) else (
call setup_mingw.cmd 32
)
popd
echo Bootstrapping QB64-PE
internal\c\c_compiler\bin\mingw32-make.exe -j8 OS=win BUILD_QB64=y EXE=.\qb64pe_bootstrap.exe
IF ERRORLEVEL 1 exit /b 1

80
setup_mingw.cmd Normal file
View file

@ -0,0 +1,80 @@
@rem QB64-PE MINGW setup script
@rem
@rem This NT command script downloads and extracts the latest copy of MINGW binaries from:
@rem https://github.com/niXman/mingw-builds-binaries/releases
@rem So, the filenames in 'url' variable should be updated to the latest stable builds when those are available
@rem
@rem Specifying 32 for argument 1 on a 64-bit system will force a 32-bit MINGW setup
@rem
@echo off
rem Enable cmd extensions and exit if not present
setlocal enableextensions
if errorlevel 1 (
echo.
echo Error: Command Prompt extensions not available!
goto end
)
rem Change to the correct drive letter
%~d0
rem Change to the correct path
cd %~dp0
rem Check if the C++ compiler is there and skip downloading if it exists
if exist "internal\c\c_compiler\bin\c++.exe" (
echo.
echo Info: MINGW detected. Skipping setup.
goto end
)
rem Create the c_compiler directory that should contain the MINGW binaries
mkdir internal\c\c_compiler
rem Check if were able to create the directory
if not exist "internal\c\c_compiler\" (
echo.
echo Error: Not able to create 'internal\c\c_compiler\'!
goto end
)
rem Check the processor type and then set the MINGW variable to the correct MINGW arch
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set MINGW=mingw32 || set MINGW=mingw64
rem If the OS is 32-bit then proceed to download right away
rem Else check if 32 was passed as a parameter. If so, download 32-bit MINGW on a 64-bit system
if "%MINGW%"=="mingw64" if "%~1"=="32" set MINGW=mingw32
rem Set the correct file to download based on processor type
if "%MINGW%"=="mingw32" (
set url="https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/i686-12.2.0-release-win32-dwarf-rt_v10-rev1.7z"
) else (
set url="https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z"
)
rem Download 7zr.exe. We'll need this to extract the MINGW archive
echo Downloading 7zr.exe...
curl -L https://www.7-zip.org/a/7zr.exe -o 7zr.exe
rem Download the MINGW archive
echo Downloading %url%...
curl -L %url% -o temp.7z
rem Extract the MINGW binaries
echo Extracting C++ Compiler...
7zr.exe x temp.7z -y
rem Move the binaries to internal\c\c_compiler\
echo Moving C++ compiler...
for /f %%a in ('dir %MINGW% /b') do move /y "%MINGW%\%%a" internal\c\c_compiler\
rem Cleanup downloaded temporary files
echo Cleaning up...
rd %MINGW%
del 7zr.exe
del temp.7z
rem The End!
:end
endlocal

View file

@ -1,16 +1,16 @@
@rem QB64-PE Windows setup script
@rem
@rem This NT command script downloads and extracts the latest copy of MINGW binaries from:
@rem https://github.com/niXman/mingw-builds-binaries/releases
@rem So, the filenames in 'url' variable should be updated to the latest stable builds when those are available
@rem This NT command script calls setup_mingw.cmd which downloads and installs MINGW if required
@rem It then proceeds to build QB64-PE
@rem
@rem Argument 1: If not blank, qb64pe will not be started after compilation
@rem If argument 1 is not blank, then qb64pe will not be started after compilation
@rem
@echo off
rem Enable cmd extensions and exit if not present
setlocal enableextensions
if errorlevel 1 (
echo.
echo Error: Command Prompt extensions not available!
goto report_error
)
@ -24,66 +24,34 @@ rem Change to the correct drive letter
rem Change to the correct path
cd %~dp0
rem Check if the C++ compiler is there and skip downloading if it exists
if exist "internal\c\c_compiler\bin\c++.exe" goto skip_mingw_setup
rem Check if the C++ compiler is there and skip MINGW setup if it exists
if exist "internal\c\c_compiler\bin\c++.exe" goto build_qb64pe
rem Create the c_compiler directory that should contain the MINGW binaries
mkdir internal\c\c_compiler
rem Check if were able to create the directory
if not exist "internal\c\c_compiler\" (
echo Error: Not able to create 'internal\c\c_compiler\'!
goto report_error
)
rem Check the processor type and then set the MINGW variable to the correct MINGW arch
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set MINGW=mingw32 || set MINGW=mingw64
rem Check the processor type and then set the ARCH variable
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=32 || set ARCH=64
rem If the OS is 32-bit then proceed to download right away
if "%MINGW%"=="mingw32" goto set_download_url
if %ARCH% == 32 goto setup_mingw
rem Check if the user wants to use 32-bit MINGW on a 64-bit system. Default to 64-bit after 60 seconds
choice /t 60 /c 12 /d 1 /m "Do you prefer to download MINGW [1] 64-bit (default) or [2] 32-bit"
if %errorlevel% == 2 set MINGW=mingw32
if %errorlevel% == 2 set ARCH=32
:set_download_url
:setup_mingw
rem Set the correct file to download based on processor type
if "%MINGW%"=="mingw32" (
set url="https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/i686-12.2.0-release-win32-dwarf-rt_v10-rev1.7z"
) else (
set url="https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z"
)
rem Download 7zr.exe. We'll need this to extract the MINGW archive
echo Downloading 7zr.exe...
curl -L https://www.7-zip.org/a/7zr.exe -o 7zr.exe
rem Download the MINGW archive
echo Downloading %url%...
curl -L %url% -o temp.7z
rem Extract the MINGW binaries
echo Extracting C++ Compiler...
7zr.exe x temp.7z -y
rem Move the binaries to internal\c\c_compiler\
echo Moving C++ compiler...
for /f %%a in ('dir %MINGW% /b') do move /y "%MINGW%\%%a" internal\c\c_compiler\
rem Cleanup downloaded temporary files
echo Cleaning up...
rd %MINGW%
del 7zr.exe
del temp.7z
rem Call the MINGW setup script using the ARCH variable
pushd .
call setup_mingw.cmd %ARCH%
popd
rem Finally check if the C++ compiler is there now
if not exist "internal\c\c_compiler\bin\c++.exe" (
echo Error: MINGW download / extract failed!
echo.
echo Error: MINGW setup failed!
goto report_error
)
:skip_mingw_setup
:build_qb64pe
rem Run make clean
echo Cleaning...
@ -111,10 +79,7 @@ rem This is only executed if something on top fails
echo.
echo Error compiling QB64-PE.
echo Please review above steps and report to https://github.com/QB64-Phoenix-Edition/QB64pe/issues if you can't get it to work.
endlocal
exit 1
rem The End!
:end
endlocal
exit 0