Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// RUN: %target-swift-emit-irgen -I %t/Inputs -enable-experimental-cxx-interop -Xcc -std=c++17 %t/test.swift -module-name Test | %FileCheck %s

// REQUIRES: OS=windows-msvc
// XFAIL: OS=windows-msvc

//--- Inputs/module.modulemap
module MsvcUseVecIt {
Expand Down
5 changes: 3 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ config.gyb = make_path(config.swift_utils, 'gyb.py')
config.rth = make_path(config.swift_utils, 'rth') # Resilience test helper
config.scale_test = make_path(config.swift_utils, 'scale-test')
config.PathSanitizingFileCheck = make_path(config.swift_utils, 'PathSanitizingFileCheck')
config.swift_bin_dir = make_path(config.swift, '..', '..', 'bin')
config.swift_lib_dir = make_path(config.swift, '..', '..', 'lib')
config.round_trip_syntax_test = make_path(config.swift_utils, 'round-trip-syntax-test')
config.refactor_check_compiles = make_path(config.swift_utils, 'refactor-check-compiles.py')
Expand Down Expand Up @@ -2705,8 +2706,8 @@ run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitiz
# we provide we use realpath here. Because PathSanitizingFileCheck only
# understands sanitize patterns with forward slashes, and realpath normalizes
# the slashes, we have to replace them back to forward slashes.
shell_quote(os.path.realpath(swift_obj_root).replace("\\", "/")),
shell_quote(os.path.realpath(config.swift_src_root).replace("\\", "/")),
shell_quote(lit.util.abs_path_preserve_drive(swift_obj_root).replace("\\", "/")),
shell_quote(lit.util.abs_path_preserve_drive(config.swift_src_root).replace("\\", "/")),
shell_quote(config.filecheck),
'--enable-windows-compatibility' if kIsWindows else '')

Expand Down
3 changes: 2 additions & 1 deletion test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import platform
import sys
import lit.util

config.cmake = "@CMAKE_COMMAND@"
config.llvm_src_root = "@LLVM_MAIN_SRC_DIR@"
Expand Down Expand Up @@ -170,6 +171,6 @@ if '@SWIFT_SWIFT_PARSER@' == 'TRUE':

# Let the main config do the real work.
if config.test_exec_root is None:
config.test_exec_root = os.path.dirname(os.path.realpath(__file__))
config.test_exec_root = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
lit_config.load_config(
config, os.path.join(config.swift_src_root, "test", "lit.cfg"))
71 changes: 66 additions & 5 deletions utils/build-windows-toolchain.bat
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ del /f /q "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap"
del /f /q "%VCToolsInstallDir%\include\module.modulemap"
del /f /q "%VCToolsInstallDir%\include\vcruntime.apinotes"

call :FetchWiX || (exit /b)
call :FetchX64Toolchain || (exit /b)
call :CloneDependencies || (exit /b)
call :CloneRepositories || (exit /b)

Expand Down Expand Up @@ -190,6 +192,33 @@ cmake ^
cmake --build "%BuildRoot%\curl" || (exit /b)
cmake --build "%BuildRoot%\curl" --target install || (exit /b)

path %BuildRoot%\toolchains\5.9.0\PFiles64\Swift\runtime-development\usr\bin;%BuildRoot%\toolchains\5.9.0\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin;%Path%

:: Build Swift Syntax
cmake ^
-B "%BuildRoot%\99" ^

-D BUILD_SHARED_LIBS=YES ^
-D CMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^
-D CMAKE_C_COMPILER=cl.exe ^
-D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy" ^
-D CMAKE_CXX_COMPILER=cl ^
-D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy" ^
-D CMAKE_MT=mt ^
-D CMAKE_Swift_COMPILER=%BuildRoot%/toolchains/5.9.0/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe ^
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^
-D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^
-D CMAKE_SHARED_LINKER_FLAGS="/INCREMENTAL:NO" ^
-D CMAKE_Swift_FLAGS_RELEASE="-O" ^
-D CMAKE_Swift_FLAGS_RELWITHDEBINFO="-O" ^

-D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^

-G Ninja ^
-S %SourceRoot%\swift-syntax || (exit /b)
cmake --build %BuildRoot%\99 || (exit /b)
cmake --build %BuildRoot%\99 --target install || (exit /b)

:: Build Toolchain
cmake ^
-B "%BuildRoot%\1" ^
Expand All @@ -207,11 +236,17 @@ cmake ^

-D CMAKE_INSTALL_PREFIX="%InstallRoot%" ^

-D CMAKE_Swift_COMPILER="%BuildRoot%/toolchains/5.9.0/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe" ^
-D CMAKE_Swift_FLAGS="-sdk %BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^

-D LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc ^

-D PACKAGE_VENDOR="swift.org" ^
-D CLANG_VENDOR="swift.org" ^
-D CLANG_VENDOR_UTI="org.swift" ^
-D LLDB_PYTHON_EXE_RELATIVE_PATH=python.exe ^
-D LLDB_PYTHON_EXT_SUFFIX=.pyd ^
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages ^
-D LLVM_APPEND_VC_REV=NO ^
-D LLVM_VERSION_SUFFIX="" ^

Expand All @@ -226,9 +261,11 @@ cmake ^
-D LLVM_EXTERNAL_CMARK_SOURCE_DIR="%SourceRoot%\cmark" ^
-D PYTHON_HOME=%PYTHON_HOME% ^
-D PYTHON_EXECUTABLE=%PYTHON_HOME%\python.exe ^
-D SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR="%BuildRoot%\99" ^
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE="%SourceRoot%\swift-corelibs-libdispatch" ^
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="%SourceRoot%\swift-syntax" ^
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=%SourceRoot%\swift-experimental-string-processing ^
-D SWIFT_PATH_TO_SWIFT_SDK="%BuildRoot%/toolchains/5.9.0/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk" ^

-G Ninja ^
-S llvm-project\llvm || (exit /b)
Expand Down Expand Up @@ -744,25 +781,25 @@ python -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'D
:: TODO(compnerd) match the XCTest installation name
python -c "import plistlib; print(str(plistlib.dumps({ 'DefaultProperties': { 'XCTEST_VERSION': 'development' } }), encoding='utf-8'))" > %PlatformRoot%\Info.plist

IF NOT "%SKIP_PACKAGING%"=="1" call :PackageToolchain
IF NOT "%SKIP_PACKAGING%"=="1" call :PackageToolchain || (exit /b)

:: TODO(compnerd) test LLVM

SET SKIP_TEST=0
FOR %%T IN (%SKIP_TESTS%) DO (IF /I %%T==swift SET SKIP_TEST=1)
IF "%SKIP_TEST%"=="0" call :TestSwift
IF "%SKIP_TEST%"=="0" call :TestSwift || (exit /b)

SET SKIP_TEST=0
FOR %%T IN (%SKIP_TESTS%) DO (IF /I %%T==dispatch SET SKIP_TEST=1)
IF "%SKIP_TEST%"=="0" call :TestDispatch
IF "%SKIP_TEST%"=="0" call :TestDispatch || (exit /b)

SET SKIP_TEST=0
FOR %%T IN (%SKIP_TESTS%) DO (IF /I %%T==foundation SET SKIP_TEST=1)
IF "%SKIP_TEST%"=="0" call :TestFoundation
IF "%SKIP_TEST%"=="0" call :TestFoundation || (exit /b)

SET SKIP_TEST=0
FOR %%T IN (%SKIP_TESTS%) DO (IF /I %%T==xctest SET SKIP_TEST=1)
IF "%SKIP_TEST%"=="0" call :TestXCTest
IF "%SKIP_TEST%"=="0" call :TestXCTest || (exit /b)

:: Clean up the module cache
rd /s /q %LocalAppData%\clang\ModuleCache
Expand Down Expand Up @@ -815,6 +852,30 @@ git clone --quiet --no-tags --depth 1 --branch curl-7_77_0 https://github.com/cu
goto :eof
endlocal

:FetchWiX
setlocal enableextensions enabledelayedexpansion

curl.exe -sL https://www.nuget.org/api/v2/package/wix/4.0.1 -o wix-4.0.1.zip
md WiX-4.0.1 || exit (/b)
cd WiX-4.0.1 || exit (/b)
tar -xf ../wix-4.0.1.zip || exit (/b)

goto :eof
endlocal

:FetchX64Toolchain
setlocal enableextensions enabledelayedexpansion

curl.exe -k -sOL "https://download.swift.org/swift-5.9-release/windows10/swift-5.9-RELEASE/swift-5.9-RELEASE-windows10.exe" || (exit /b)
"WiX-4.0.1\tools\net6.0\any\wix.exe" burn extract swift-5.9-RELEASE-windows10.exe -o %BuildRoot%\toolchains || (exit /b)
msiexec.exe /qn /a "%BuildRoot%\toolchains\a0" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
msiexec.exe /qn /a "%BuildRoot%\toolchains\a1" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
msiexec.exe /qn /a "%BuildRoot%\toolchains\a2" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)
msiexec.exe /qn /a "%BuildRoot%\toolchains\a3" TARGETDIR="%BuildRoot%\toolchains\5.9.0\" || (exit /b)

goto :eof
endlocal

:TestSwift
setlocal enableextensions enabledelayedexpansion

Expand Down