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

Initial WoA64 and MingW-LLVM support

This commit is contained in:
Samuel Gomes 2023-10-01 08:08:58 +05:30
parent 059a41a86f
commit 49aeccc486
5 changed files with 89 additions and 37 deletions

View file

@ -32199,10 +32199,18 @@ int32 addone(int32 x) { return x + 1; } // for testing purposes only
qbs *func__os() {
qbs *tqbs;
#ifdef QB64_WINDOWS
# ifdef QB64_32
# ifdef QB64_32
# ifdef QB64_ARM
tqbs = qbs_new_txt("[WINDOWS][32BIT][ARM]");
# else
tqbs = qbs_new_txt("[WINDOWS][32BIT]");
# endif
# else
# ifdef QB64_ARM
tqbs = qbs_new_txt("[WINDOWS][64BIT][ARM]");
# else
tqbs = qbs_new_txt("[WINDOWS][64BIT]");
# endif
# endif
#elif defined(QB64_LINUX)
# ifdef QB64_32

View file

@ -20,7 +20,7 @@
# define QB64_WINDOWS
// This supports Windows Vista and up
# define _WIN32_WINNT 0x0600
# define WINVER 0x0600
# define WINVER 0x0600
# define QB64_BACKSLASH_FILESYSTEM
# ifdef _MSC_VER
@ -50,6 +50,9 @@
#if !defined(i386) && !defined(__x86_64__)
# define QB64_NOT_X86
# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
# define QB64_ARM
# endif
#endif
#endif

View file

@ -2,7 +2,7 @@
@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 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
@ -39,41 +39,82 @@ if not exist "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 Check the processor type and then set the ARCH variable to the processor type
rem These values are from https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor#properties
set "ARCH="
wmic cpu get architecture | find "0" > nul && set ARCH=X86
wmic cpu get architecture | find "5" > nul && set ARCH=ARM
wmic cpu get architecture | find "9" > nul && set ARCH=X86
wmic cpu get architecture | find "12" > nul && set ARCH=ARM
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/13.1.0-rt_v11-rev1/i686-13.1.0-release-win32-dwarf-msvcrt-rt_v11-rev1.7z"
) else (
set url="https://github.com/niXman/mingw-builds-binaries/releases/download/13.1.0-rt_v11-rev1/x86_64-13.1.0-release-win32-seh-msvcrt-rt_v11-rev1.7z"
rem Check if this is an alien processor
if "%ARCH%" == "" (
echo Error: Unknown processor type!
goto end
)
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 Check the processor type and then set the BITS variable
wmic os get osarchitecture | find /i "64-bit" > nul && set BITS=64 || set BITS=32
rem Download the MINGW archive
echo Downloading %url%...
curl -L %url% -o temp.7z
echo %ARCH%-%BITS% platform detected.
rem Extract the MINGW binaries
echo Extracting C++ Compiler...
7zr.exe x temp.7z -y
rem Check if "32" was passed as an argument and if so set BITS to 32
if "%~1" == "32" set BITS=32
echo %ARCH%-%BITS% platform selected.
rem Set some critical variables before we move to the actual setup part
rem MINGW_DIR is actually the internal directory name inside the zip / 7z file
rem It needs to be updated whenever the toolchains are updated
if "%ARCH%" == "ARM" (
if %BITS% == 64 (
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20230919/llvm-mingw-20230919-ucrt-aarch64.zip"
set MINGW_DIR=llvm-mingw-20230919-ucrt-aarch64
) else (
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20230919/llvm-mingw-20230919-ucrt-armv7.zip"
set MINGW_DIR=llvm-mingw-20230919-ucrt-armv7
)
set MINGW_TEMP_FILE=temp.zip
) else (
if %BITS% == 64 (
set URL="https://github.com/niXman/mingw-builds-binaries/releases/download/13.1.0-rt_v11-rev1/x86_64-13.1.0-release-win32-seh-msvcrt-rt_v11-rev1.7z"
) else (
set URL="https://github.com/niXman/mingw-builds-binaries/releases/download/13.1.0-rt_v11-rev1/i686-13.1.0-release-win32-dwarf-msvcrt-rt_v11-rev1.7z"
)
set MINGW_DIR=mingw64
set MINGW_TEMP_FILE=temp.7z
)
rem Download MingW files
if exist %MINGW_TEMP_FILE% del %MINGW_TEMP_FILE%
echo Downloading %URL%...
curl -L %URL% -o %MINGW_TEMP_FILE%
rem Extract MingW files
if "%ARCH%" == "ARM" (
rem Use tar to extract the zip file on Windows on ARM. tar is available in Windows since build 17063
rem And this includes all ARM64 Windows versions
echo Extracting C++ Compiler...
tar -xvf %MINGW_TEMP_FILE%
) else (
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 Extract the MINGW binaries
echo Extracting C++ Compiler...
7zr.exe x %MINGW_TEMP_FILE% -y
del 7zr.exe
)
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\
for /f %%a in ('dir %MINGW_DIR% /b') do move /y "%MINGW_DIR%\%%a" internal\c\c_compiler\
rem Cleanup downloaded temporary files
echo Cleaning up...
rd %MINGW%
del 7zr.exe
del temp.7z
rd %MINGW_DIR%
del %MINGW_TEMP_FILE%
rem The End!
:end

View file

@ -27,21 +27,21 @@ cd %~dp0
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 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 Check the processor type and then set the BITS variable
wmic os get osarchitecture | find /i "64-bit" > nul && set BITS=64 || set BITS=32
rem If the OS is 32-bit then proceed to download right away
if %ARCH% == 32 goto setup_mingw
if %BITS% == 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 ARCH=32
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 BITS=32
:setup_mingw
rem Call the MINGW setup script using the ARCH variable
rem Call the MINGW setup script using the BITS variable
pushd .
call setup_mingw.cmd %ARCH%
call setup_mingw.cmd %BITS%
popd
rem Finally check if the C++ compiler is there now
@ -55,14 +55,14 @@ if not exist "internal\c\c_compiler\bin\c++.exe" (
rem Run make clean
echo Cleaning...
internal\c\c_compiler\bin\mingw32-make.exe OS=win clean > NUL 2> NUL
internal\c\c_compiler\bin\mingw32-make.exe OS=win clean > nul 2> nul
rem Now build QB64-PE
echo Building QB64-PE...
internal\c\c_compiler\bin\mingw32-make.exe OS=win BUILD_QB64=y || goto report_error
rem Execute QB64-PE only if there are no parameters
if "%~1"=="" (
if "%~1" == "" (
echo.
echo Launching QB64-PE...
qb64pe.exe

View file

@ -219,7 +219,7 @@ DIM SHARED MacOSX AS LONG
IF INSTR(_OS$, "[MACOSX]") THEN MacOSX = 1
DIM SHARED inline_DATA
IF MacOSX THEN inline_DATA = 1
IF MacOSX OR INSTR(_OS$, "[ARM]") THEN inline_DATA = 1
DIM SHARED BATCHFILE_EXTENSION AS STRING
BATCHFILE_EXTENSION = ".bat"