Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Rev 28 | Rev 30 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 29
Line 2... Line 2...
2
setlocal enableextensions enabledelayedexpansion
2
setlocal enableextensions enabledelayedexpansion
3
 
3
 
-
 
4
rem // what we're building
-
 
5
set PRODUCT_NAME=the LLVM compiler suite
-
 
6
 
4
rem // set the WSL distribution to use
7
rem // the WSL distribution to use
5
set WSL_DISTR=Ubuntu-22.04
8
set WSL_DISTR=Ubuntu-22.04
6
 
9
 
7
rem // name of the QNX SDK root directory
10
rem // name of the QNX SDK root directory
8
set QNXSDK_DIRNAME=qnx800
11
set QNXSDK_DIRNAME=qnx800
9
 
12
 
10
rem // list of Linux tools required by the cross-build script
13
rem // list of Linux tools required by the cross-build script
11
set REQUIRED_TOOLS=wget python3 cmake gcc g++ ninja:ninja-build ccache
14
set REQUIRED_TOOLS=wget python3 cmake gcc g++ ninja:ninja-build ccache
12
 
15
 
13
 
16
 
14
rem // welcome the wary user
17
rem // welcome the wary user
15
echo QNX8 toolchain cross-build script for WSL by Pierre-Marie Baty ^<pm@pmbaty.com^>
18
echo QNX8 toolchain cross-build script for WSL by Pierre-Marie Baty ^<pm@pmbaty.com^>
16
echo.
19
echo.
17
 
20
 
18
rem // make sure we have at least Windows 10
21
rem // make sure we have at least Windows 10
19
for /f "tokens=4 delims=. " %%i in ('ver') do set VERSION=%%i
22
for /f "tokens=4 delims=. " %%i in ('ver') do set VERSION=%%i
20
echo Detected Windows NT kernel version: %VERSION%
23
echo Detected Windows NT kernel version: %VERSION%
21
if %VERSION% LSS 10 (
24
if %VERSION% LSS 10 (
22
        echo Error: you need at least Windows 10 to cross-build LLVM to QNX 8.
25
        echo Error: you need at least Windows 10 to cross-build %PRODUCT_NAME% to QNX 8.
23
        echo Please upgrade your Windows operating system to Windows 10 version 2004 build
26
        echo Please upgrade your Windows operating system to Windows 10 version 2004 build
24
        echo 19041 or a later version.
27
        echo 19041 or a later version.
25
        goto :exit_error
28
        goto :exit_error
26
)
29
)
27
 
30
 
28
rem // if WSL is not installed, do so
31
rem // if WSL is not installed, do so
29
echo|set /p=Checking whether the Windows Subsystem for Linux is installed...
32
echo|set /p=Checking whether the Windows Subsystem for Linux is installed...
30
wsl --list -v > nul 2>&1 || ( echo no & goto :install_wsl )
33
wsl --list -v > nul 2>&1 || ( echo no & goto :install_wsl )
31
echo yes
34
echo yes
Line 80... Line 83...
80
                wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || (
83
                wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || (
81
                        echo Error: the required Linux tool !REQUIRED_TOOL! can't be installed with apt-get.
84
                        echo Error: the required Linux tool !REQUIRED_TOOL! can't be installed with apt-get.
82
                        pause
85
                        pause
83
                        goto :exit_error
86
                        goto :exit_error
84
                )
87
                )
85
        )
88
        )
86
)
89
)
87
 
90
 
88
rem // setup the QNX SDP on the WSL side
91
rem // setup the QNX SDP on the WSL side
89
 
92
 
90
rem // The build script initially recursively transferred the contents of $QNX_HOST and $QNX_TARGET to the WSL2 ext4 partition
93
rem // The build script initially recursively transferred the contents of $QNX_HOST and $QNX_TARGET to the WSL2 ext4 partition
91
rem // when necessary using the Plan9 NTFS to ext4 bridge (9p file protocol) implemented by Microsoft to transfer files
94
rem // when necessary using the Plan9 NTFS to ext4 bridge (9p file protocol) implemented by Microsoft to transfer files
92
rem // from Windows to WSL2. The only problem with this is, and Microsoft admits it, that 9p is *catastrophically slow*.
95
rem // from Windows to WSL2. The only problem with this is, and Microsoft admits it, that 9p is *catastrophically slow*.
93
rem // See https://learn.microsoft.com/en-us/windows/wsl/compare-versions - And when Microsoft says "slow", hear "unusable".
96
rem // See https://learn.microsoft.com/en-us/windows/wsl/compare-versions - And when Microsoft says "slow", hear "unusable".
94
rem // To make this faster, here's what I do:
97
rem // To make this faster, here's what I do:
Line 105... Line 108...
105
rem // So test for the presence of the symlinks state file as it's the last file that's created (this ensures a complete copy), then check for the directory mtimes.
108
rem // So test for the presence of the symlinks state file as it's the last file that's created (this ensures a complete copy), then check for the directory mtimes.
106
rem // NOTE: on WSL2, the QNX SDK will always be copied to $HOME, regardless of what xdg-user-dir DESKTOP says.
109
rem // NOTE: on WSL2, the QNX SDK will always be copied to $HOME, regardless of what xdg-user-dir DESKTOP says.
107
echo|set /p=Checking if the %QNXSDK_DIRNAME% directory is present in WSL and up to date...
110
echo|set /p=Checking if the %QNXSDK_DIRNAME% directory is present in WSL and up to date...
108
wsl --distribution %WSL_DISTR% -- test ! -f "${HOME}/%QNXSDK_DIRNAME%/.symlinks-state" -o "../%QNXSDK_DIRNAME%" -nt "${HOME}/%QNXSDK_DIRNAME%" && (
111
wsl --distribution %WSL_DISTR% -- test ! -f "${HOME}/%QNXSDK_DIRNAME%/.symlinks-state" -o "../%QNXSDK_DIRNAME%" -nt "${HOME}/%QNXSDK_DIRNAME%" && (
109
        echo no
112
        echo no
110
 
113
 
111
        rem // copy needed - cleanup and create the directories we'll need in $HOME to accomodate the QNX SDK. We want the Linux host tools, and the QNX target sysroot files
114
        rem // copy needed - cleanup and create the directories we'll need in $HOME to accomodate the QNX SDK. We want the Linux host tools, and the QNX target sysroot files
112
        echo|set /p=Preparing to copy QNX8 SDK files to WSL2 ext4 filesystem...
115
        echo|set /p=Preparing to copy QNX8 SDK files to WSL2 ext4 filesystem...
113
        wsl --distribution %WSL_DISTR% -- rm -rf "${HOME}/%QNXSDK_DIRNAME%"; mkdir -p "${HOME}/%QNXSDK_DIRNAME%/host" "${HOME}/%QNXSDK_DIRNAME%/target" 2>nul
116
        wsl --distribution %WSL_DISTR% -- rm -rf "${HOME}/%QNXSDK_DIRNAME%"; mkdir -p "${HOME}/%QNXSDK_DIRNAME%/host" "${HOME}/%QNXSDK_DIRNAME%/target" 2>nul
114
        echo done
117
        echo done
115
 
118
 
Line 140... Line 143...
140
wsl --distribution %WSL_DISTR% -- ./cross-build.sh || goto :exit_error
143
wsl --distribution %WSL_DISTR% -- ./cross-build.sh || goto :exit_error
141
 
144
 
142
rem // at this point, the story is supposed to have ended well.
145
rem // at this point, the story is supposed to have ended well.
143
rem // Keep calm, and I'll tell you another one tomorrow.
146
rem // Keep calm, and I'll tell you another one tomorrow.
144
echo.
147
echo.
145
echo ^-- on a true Linux desktop a colorful icon would be displayed here, but Windows ruins all the fun. Pah.
148
echo The build ended successfully.
146
goto :exit_success
149
goto :exit_success
147
 
150
 
148
 
151
 
149
:install_wsl
152
:install_wsl
150
        echo Installing the Windows Subsystem for Linux...
153
        echo Installing the Windows Subsystem for Linux...
Line 170... Line 173...
170
pause
173
pause
171
exit /b 1
174
exit /b 1
172
 
175
 
173
:exit_success
176
:exit_success
174
rem // successful exit
177
rem // successful exit
-
 
178
pause
175
exit /b 0
179
exit /b 0