Skip to content

Commit

Permalink
Move InteropTests under Generator (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Sep 22, 2024
1 parent d7c39ba commit a1481f3
Show file tree
Hide file tree
Showing 121 changed files with 48 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ jobs:
run: swift test --verbose --skip-build

- name: Build WinRTComponent
working-directory: InteropTests
working-directory: Generator/InteropTests
shell: pwsh
run: |
& .\Build-WinRTComponentProjection.ps1 -SwiftWinRT "$Env:GITHUB_WORKSPACE\Generator\.build\debug\SwiftWinRT.exe"
- name: Build InteropTests
working-directory: InteropTests
working-directory: Generator/InteropTests
shell: pwsh
run: swift build --verbose --build-tests

- name: Run InteropTests
working-directory: InteropTests
working-directory: Generator/InteropTests
shell: pwsh
run: swift test --verbose --skip-build

Expand Down
22 changes: 1 addition & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,4 @@ cmake_minimum_required(VERSION 3.21.0)
project(SwiftWinRT LANGUAGES C Swift)

add_subdirectory(Support)

# InteropTests depends on SwiftWinRT.exe, so build it now
message(STATUS "Configuring Generator subproject...")
execute_process(
COMMAND ${CMAKE_COMMAND}
-S "${CMAKE_CURRENT_SOURCE_DIR}/Generator"
-B "${CMAKE_CURRENT_BINARY_DIR}/Generator"
-G "${CMAKE_GENERATOR}"
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
-D "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
-D "CMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}"
COMMAND_ERROR_IS_FATAL ANY)

message(STATUS "Building Generator subproject...")
execute_process(
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/Generator"
COMMAND_ERROR_IS_FATAL ANY)
set(SWIFTWINRT_EXE "${CMAKE_CURRENT_BINARY_DIR}/Generator/Sources/SwiftWinRT/SwiftWinRT.exe")

# Now build InteropTests, which depends on SWIFTWINRT_EXE
add_subdirectory(InteropTests)
add_subdirectory(Generator)
37 changes: 33 additions & 4 deletions Generator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
cmake_minimum_required(VERSION 3.21.0)
# This directory can be built in two modes: standalone or as a subdirectory.
message(STATUS "CMAKE_PROJECT_NAME: ${CMAKE_PROJECT_NAME}")
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# Standalone mode. Only build the code generator.
# We can't build InteropTests in this mode because it depends on SwiftWinRT.exe
cmake_minimum_required(VERSION 3.21.0)

project(SwiftWinRT LANGUAGES C Swift)
project(SwiftWinRT LANGUAGES C Swift)

add_subdirectory(Dependencies)
add_subdirectory(Sources)
add_subdirectory(Dependencies)
add_subdirectory(Sources)
else()
# Subdirectory mode. Build both the code generator and InteropTests.
# Recursively invoke this build in standalone mode so that the code generator is built first,
# and can be used when building InteropTests.
message(STATUS "Configuring Generator as subproject...")
execute_process(
COMMAND ${CMAKE_COMMAND}
-S "${CMAKE_CURRENT_SOURCE_DIR}"
-B "${CMAKE_CURRENT_BINARY_DIR}"
-G "${CMAKE_GENERATOR}"
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
-D "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
-D "CMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}"
COMMAND_ERROR_IS_FATAL ANY)

message(STATUS "Building Generator as subproject...")
execute_process(
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND_ERROR_IS_FATAL ANY)

# Now build InteropTests, which depends on SWIFTWINRT_EXE
set(SWIFTWINRT_EXE "${CMAKE_CURRENT_BINARY_DIR}/Sources/SwiftWinRT/SwiftWinRT.exe")
add_subdirectory(InteropTests)
endif()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"-Xlinker",
"-debug:dwarf"
],
"cwd": "d:\\swift-winrt\\InteropTests",
"disableTaskQueue": true,
"problemMatcher": [
"$swiftc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ErrorActionPreference = "Stop"
if (-not $SwiftWinRT) {
Write-Host -ForegroundColor Cyan "Building SwiftWinRT.exe with SPM..."
$SwiftConfiguration = "debug"
$GeneratorProjectDir = "$PSScriptRoot\..\Generator"
$GeneratorProjectDir = "$PSScriptRoot\.."
& swift.exe build `
--package-path $GeneratorProjectDir `
--configuration $SwiftConfiguration `
Expand All @@ -40,7 +40,7 @@ Write-Host -ForegroundColor Cyan "Generating Swift projection for WinRT componen
-D "WINRTCOMPONENT_WINMD=$WinRTComponentBinDir\WinRTComponent.winmd" `
-D "PROJECTION_JSON=$PSScriptRoot\projection.json" `
-D "PROJECTION_DIR=$PSScriptRoot\Generated" `
-D "SPM_SUPPORT_PACKAGE_DIR=$PSScriptRoot\.." `
-D "SPM_SUPPORT_PACKAGE_DIR=$PSScriptRoot\..\.." `
-P "$PSScriptRoot\GenerateProjection.cmake"

Write-Host -ForegroundColor Cyan "Copying the WinRT component dll next to the test..."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.21.0)
# Support using this directory as a standalone project or as a subdirectory.
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
cmake_minimum_required(VERSION 3.21.0)

if(NOT DEFINED CMAKE_PROJECT_NAME)
project(InteropTests LANGUAGES C Swift)
endif()

Expand All @@ -9,6 +10,8 @@ if (NOT DEFINED SWIFTWINRT_EXE)
endif()
cmake_path(ABSOLUTE_PATH SWIFTWINRT_EXE NORMALIZE OUTPUT_VARIABLE SWIFTWINRT_EXE)

set(REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")

# Generating projection sources will depend on WinRTComponent.winmd, so build it now
include(WinRTComponent/GenerateWinMD.cmake)
set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd")
Expand All @@ -24,7 +27,7 @@ generate_projection(
WINRTCOMPONENT_WINMD "${WINRTCOMPONENT_WINMD}"
PROJECTION_JSON "${CMAKE_CURRENT_SOURCE_DIR}/projection.json"
PROJECTION_DIR "${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources"
SPM_SUPPORT_PACKAGE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
SPM_SUPPORT_PACKAGE_DIR "${REPO_ROOT}")

# Define WinRTComponent build (requires the cl.exe compiler)
include(ExternalProject)
Expand All @@ -41,7 +44,7 @@ ExternalProject_Add(WinRTComponent

# Build the support module if not already the case (by root CMakeLists.txt)
if(NOT TARGET WindowsRuntime)
add_subdirectory(../Support "${CMAKE_CURRENT_BINARY_DIR}/Support")
add_subdirectory("${REPO_ROOT}/Support/Sources" "${CMAKE_CURRENT_BINARY_DIR}/Support")
endif()

# Build the Swift projection
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import PackageDescription
let package = Package(
name: "InteropTests",
dependencies: [
.package(path: ".."), // Support package
.package(name: "Support", path: "../.."),
.package(path: "Generated"),
],
targets: [
.testTarget(
name: "Tests",
dependencies: [
.product(name: "WindowsRuntime", package: "swift-winrt"),
.product(name: "WindowsRuntime", package: "Support"),
.product(name: "UWP", package: "Generated"),
.product(name: "WinRTComponent", package: "Generated"),
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions InteropTests/.vscode/settings.json

This file was deleted.

0 comments on commit a1481f3

Please sign in to comment.