Skip to content

build: migrate to CMake based build of swift-format #70814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "CMark Version: ${_CMARK_VERSION}")
elseif(SWIFT_INCLUDE_TOOLS)
find_package(cmark-gfm CONFIG REQUIRED)
find_package(cmark-gfm REQUIRED)
endif()
message(STATUS "")

Expand Down
1 change: 0 additions & 1 deletion cmake/caches/Windows-aarch64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set(LLVM_ENABLE_PROJECTS
CACHE STRING "")

set(LLVM_EXTERNAL_PROJECTS
cmark
swift
CACHE STRING "")

Expand Down
1 change: 0 additions & 1 deletion cmake/caches/Windows-x86_64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set(LLVM_ENABLE_PROJECTS
CACHE STRING "")

set(LLVM_EXTERNAL_PROJECTS
cmark
swift
CACHE STRING "")

Expand Down
3 changes: 2 additions & 1 deletion stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,8 @@ function(_compile_swift_files
if (NOT SWIFTFILE_IS_MAIN)
add_custom_command_target(
module_dependency_target
COMMAND "${CMAKE_COMMAND}" -E make_directory ${dirs_to_create}
COMMAND
"${CMAKE_COMMAND}" -E make_directory ${dirs_to_create}
COMMAND
"${CMAKE_COMMAND}" "-E" "remove" "-f" ${module_outputs}
COMMAND
Expand Down
68 changes: 46 additions & 22 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,11 @@ function Build-CMark($Arch) {
Build-CMakeProject `
-Src $SourceCache\cmark `
-Bin "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13" `
-InstallTo "$LibraryRoot\cmark-0.29.0.gfm.13\usr" `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
BUILD_SHARED_LIBS = "YES";
BUILD_TESTING = "NO";
CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP = "YES";
}
Expand Down Expand Up @@ -913,8 +913,7 @@ function Build-Compilers() {

Isolate-EnvVars {
if ($TestClang -or $TestLLD -or $TestLLDB -or $TestLLVM -or $TestSwift) {
$LibdispatchBinDir = "$BinaryCache\1\tools\swift\libdispatch-windows-$($Arch.LLVMName)-prefix\bin"
$env:Path = "$LibdispatchBinDir;$BinaryCache\1\bin;$env:Path;$VSInstallRoot\DIA SDK\bin\$($HostArch.VSName);$UnixToolsBinDir"
$env:Path = "$($HostArch.BinaryCache)\cmark-gfm-0.29.0.gfm.13\src;$BinaryCache\1\tools\swift\libdispatch-windows-$($Arch.LLVMName)-prefix\bin;$BinaryCache\1\bin;$env:Path;$VSInstallRoot\DIA SDK\bin\$($HostArch.VSName);$UnixToolsBinDir"
$Targets = @()
$TestingDefines = @{
SWIFT_BUILD_DYNAMIC_SDK_OVERLAY = "YES";
Expand Down Expand Up @@ -1159,18 +1158,19 @@ function Build-Runtime($Arch) {
$LLVMBinaryCache = Get-ProjectBinaryCache $Arch 0

Isolate-EnvVars {
$env:Path = "$(Get-PinnedToolchainRuntime);${env:Path}"
$env:Path = "$($HostArch.BinaryCache)\cmark-gfm-0.29.0.gfm.13\src;$(Get-PinnedToolchainRuntime);${env:Path}"

Build-CMakeProject `
-Src $SourceCache\swift `
-Bin (Get-ProjectBinaryCache $Arch 1) `
-InstallTo "$($Arch.SDKInstallRoot)\usr" `
-Arch $Arch `
-CacheScript $SourceCache\swift\cmake\caches\Runtime-Windows-$($Arch.LLVMName).cmake `
-UseBuiltCompilers C,CXX `
-UseBuiltCompilers C,CXX,Swift `
-BuildTargets default `
-Defines @{
CMAKE_Swift_COMPILER_TARGET = $Arch.LLVMTarget;
CMAKE_Swift_COMPILER_WORKS = "YES";
LLVM_DIR = "$LLVMBinaryCache\lib\cmake\llvm";
SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES";
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES";
Expand Down Expand Up @@ -1606,10 +1606,45 @@ function Build-PackageManager($Arch) {
}
}

function Build-Markdown($Arch) {
Build-CMakeProject `
-Src $SourceCache\swift-markdown `
-Bin $BinaryCache\13 `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
-UseBuiltCompilers Swift `
-SwiftSDK $SDKInstallRoot `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
ArgumentParser_DIR = "$BinaryCache\6\cmake\modules";
"cmark-gfm_DIR" = "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13";
}
}

function Build-Format($Arch) {
Build-CMakeProject `
-Src $SourceCache\swift-format `
-Bin $BinaryCache\14 `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
-UseMSVCCompilers C `
-UseBuiltCompilers Swift `
-SwiftSDK $SDKInstallRoot `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "YES";
ArgumentParser_DIR = "$BinaryCache\6\cmake\modules";
SwiftSyntax_DIR = "$BinaryCache\1\cmake\modules";
"cmark-gfm_DIR" = "$($Arch.BinaryCache)\cmark-gfm-0.29.0.gfm.13";
SwiftMarkdown_DIR = "$BinaryCache\13\cmake\modules";
}
}

function Build-IndexStoreDB($Arch) {
Build-CMakeProject `
-Src $SourceCache\indexstore-db `
-Bin $BinaryCache\13 `
-Bin $BinaryCache\15 `
-Arch $Arch `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK $SDKInstallRoot `
Expand All @@ -1624,7 +1659,7 @@ function Build-IndexStoreDB($Arch) {
function Build-SourceKitLSP($Arch) {
Build-CMakeProject `
-Src $SourceCache\sourcekit-lsp `
-Bin $BinaryCache\14 `
-Bin $BinaryCache\16 `
-InstallTo "$($Arch.ToolchainInstallRoot)\usr" `
-Arch $Arch `
-UseBuiltCompilers C,Swift `
Expand All @@ -1639,7 +1674,7 @@ function Build-SourceKitLSP($Arch) {
SwiftCrypto_DIR = "$BinaryCache\8\cmake\modules";
SwiftCollections_DIR = "$BinaryCache\9\cmake\modules";
SwiftPM_DIR = "$BinaryCache\12\cmake\modules";
IndexStoreDB_DIR = "$BinaryCache\13\cmake\modules";
IndexStoreDB_DIR = "$BinaryCache\15\cmake\modules";
}
}

Expand Down Expand Up @@ -1675,18 +1710,6 @@ function Build-Inspect() {
}
}

function Build-Format() {
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-format

Isolate-EnvVars {
$env:SWIFTCI_USE_LOCAL_DEPS=1
Build-SPMProject `
-Src $SourceCache\swift-format `
-Bin $OutDir `
-Arch $HostArch
}
}

function Build-DocC() {
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-docc

Expand Down Expand Up @@ -1813,6 +1836,8 @@ if (-not $SkipBuild) {
Invoke-BuildStep Build-ASN1 $HostArch
Invoke-BuildStep Build-Certificates $HostArch
Invoke-BuildStep Build-PackageManager $HostArch
Invoke-BuildStep Build-Markdown $HostArch
Invoke-BuildStep Build-Format $HostArch
Invoke-BuildStep Build-IndexStoreDB $HostArch
Invoke-BuildStep Build-SourceKitLSP $HostArch
}
Expand All @@ -1821,7 +1846,6 @@ Install-HostToolchain

if (-not $SkipBuild) {
Invoke-BuildStep Build-Inspect $HostArch
Invoke-BuildStep Build-Format $HostArch
Invoke-BuildStep Build-DocC $HostArch
}

Expand Down