diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 80eb8403..46ee6a7d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -50,7 +50,7 @@ jobs: working-directory: Generator/InteropTests shell: pwsh run: | - & .\Build-WinRTComponentProjection.ps1 -SwiftWinRT "$Env:GITHUB_WORKSPACE\Generator\.build\debug\SwiftWinRT.exe" + & .\SPMPrebuild.ps1 -SwiftWinRT "$Env:GITHUB_WORKSPACE\Generator\.build\debug\SwiftWinRT.exe" - name: Build InteropTests working-directory: Generator/InteropTests diff --git a/Building.md b/Building.md index 5fe8004b..6adc0fac 100644 --- a/Building.md +++ b/Building.md @@ -38,4 +38,4 @@ Generator> swift build --build-tests Generator> swift test --skip-build ``` -The `/InteropTests` subdirectory requires building `WinRTComponent.winmd` and `WinRTComponent.dll`, which SPM cannot do. A helper script, `Build-WinRTComponentProjection.ps1`, will do that using CMake, after which the package can be built and tested normally. +The `/Generator/InteropTests` subdirectory requires building `WinRTComponent.winmd` and `WinRTComponent.dll`, which SPM cannot do. A helper script, `SPMPrebuild.ps1`, will do that using CMake, after which the package can be built and tested normally. diff --git a/Generator/CMakeLists.txt b/Generator/CMakeLists.txt index c2bc7ecf..5ce2edf3 100644 --- a/Generator/CMakeLists.txt +++ b/Generator/CMakeLists.txt @@ -1,5 +1,4 @@ # 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 diff --git a/Generator/InteropTests/.gitignore b/Generator/InteropTests/.gitignore deleted file mode 100644 index ca5842dc..00000000 --- a/Generator/InteropTests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.vs/ -Generated/ -*.filters \ No newline at end of file diff --git a/Generator/InteropTests/CMakeLists.txt b/Generator/InteropTests/CMakeLists.txt index 145e76b9..1b7a4592 100644 --- a/Generator/InteropTests/CMakeLists.txt +++ b/Generator/InteropTests/CMakeLists.txt @@ -8,47 +8,16 @@ endif() if (NOT DEFINED SWIFTWINRT_EXE) message(FATAL_ERROR "SWIFTWINRT_EXE must be defined") 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") -generate_winrtcomponent_winmd( - IDL "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent/WinRTComponent.idl" - WINMD "${WINRTCOMPONENT_WINMD}") - -# Generate Swift projection -message(STATUS "Generating Swift projection for WinRTComponent...") -include(GenerateProjection.cmake) -generate_projection( - SWIFTWINRT_EXE "${SWIFTWINRT_EXE}" - WINRTCOMPONENT_WINMD "${WINRTCOMPONENT_WINMD}" - PROJECTION_JSON "${CMAKE_CURRENT_SOURCE_DIR}/projection.json" - PROJECTION_DIR "${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources" - SPM_SUPPORT_PACKAGE_DIR "${REPO_ROOT}") - -# Define WinRTComponent build (requires the cl.exe compiler) -include(ExternalProject) -message(STATUS "Building WinRTComponent...") -ExternalProject_Add(WinRTComponent - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent" - CMAKE_ARGS - -D "WINRTCOMPONENT_WINMD=${WINRTCOMPONENT_WINMD}" - -D "CMAKE_CXX_COMPILER=cl.exe" - -D "CMAKE_CXX_FLAGS=/std:c++latest /W4 /EHsc" - INSTALL_COMMAND "" - TEST_COMMAND "") +cmake_path(ABSOLUTE_PATH SWIFTWINRT_EXE NORMALIZE) # Build the support module if not already the case (by root CMakeLists.txt) if(NOT TARGET WindowsRuntime) - add_subdirectory("${REPO_ROOT}/Support/Sources" "${CMAKE_CURRENT_BINARY_DIR}/Support") + execute_process( + COMMAND git.exe -C "${CMAKE_CURRENT_SOURCE_DIR}" rev-parse --path-format=absolute --show-toplevel + OUTPUT_VARIABLE REPO_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) + add_subdirectory("${REPO_ROOT}/Sources" "${CMAKE_CURRENT_BINARY_DIR}/Support") endif() -# Build the Swift projection -# TODO(https://github.com/tristanlabelle/swift-winrt/issues/302): Fix linking issues -# add_subdirectory( -# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources -# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Build) \ No newline at end of file +add_subdirectory(WinRTComponent) diff --git a/Generator/InteropTests/Package.swift b/Generator/InteropTests/Package.swift index bf0b06af..b8633958 100644 --- a/Generator/InteropTests/Package.swift +++ b/Generator/InteropTests/Package.swift @@ -5,22 +5,23 @@ let package = Package( name: "InteropTests", dependencies: [ .package(name: "Support", path: "../.."), - .package(path: "Generated"), + .package(name: "Projection", path: "WinRTComponent/Projection"), ], targets: [ .testTarget( name: "Tests", dependencies: [ .product(name: "WindowsRuntime", package: "Support"), - .product(name: "UWP", package: "Generated"), - .product(name: "WinRTComponent", package: "Generated"), + .product(name: "UWP", package: "Projection"), + .product(name: "WinRTComponent", package: "Projection"), ], path: "Tests", - // Workaround for SPM library support limitations causing "LNK4217: locally defined symbol imported" spew linkerSettings: [ .unsafeFlags([ - "-Xlinker", "-ignore:4217", - "-Xlinker", "/manifestinput:Generated/WinRTComponent.manifest", - "-Xlinker", "/manifest:embed" + // Embed the WinRT component manifest to locate activation factories + "-Xlinker", "/manifestinput:WinRTComponent/Projection/WinRTComponent.manifest", + "-Xlinker", "/manifest:embed", + // Workaround for SPM library support limitations causing "LNK4217: locally defined symbol imported" spew + "-Xlinker", "-ignore:4217" ]) ]) ] ) diff --git a/Generator/InteropTests/Build-WinRTComponentProjection.ps1 b/Generator/InteropTests/SPMPrebuild.ps1 similarity index 70% rename from Generator/InteropTests/Build-WinRTComponentProjection.ps1 rename to Generator/InteropTests/SPMPrebuild.ps1 index 85d862c1..bf028c94 100644 --- a/Generator/InteropTests/Build-WinRTComponentProjection.ps1 +++ b/Generator/InteropTests/SPMPrebuild.ps1 @@ -25,23 +25,17 @@ if (-not $SwiftWinRT) { if ($LASTEXITCODE -ne 0) { throw "Failed to build SwiftWinRT.exe" } $SwiftWinRT = "$GeneratorProjectDir\.build\$SwiftConfiguration\SwiftWinRT.exe" } +else { + $SwiftWinRT = [IO.Path]::GetFullPath($SwiftWinRT) +} Write-Host -ForegroundColor Cyan "Building WinRTComponent.dll & winmd..." -$CMakePreset = "debug" +$CMakePreset = "debug" # Tests are always built in debug mode Push-Location "$PSScriptRoot\WinRTComponent" - & cmake.exe --preset $CMakePreset - & cmake.exe --build --preset $CMakePreset +& cmake.exe --preset $CMakePreset -D "SWIFTWINRT_EXE=$SwiftWinRT" -D "PROJECTION_DIR=$(Get-Location)\Projection" +& cmake.exe --build --preset $CMakePreset --target WinRTComponent +$WinRTComponentBinDir = "$(Get-Location)\build\$CMakePreset\Dll" Pop-Location -$WinRTComponentBinDir = "$PSScriptRoot\WinRTComponent\build\$CMakePreset" - -Write-Host -ForegroundColor Cyan "Generating Swift projection for WinRT component..." -& cmake.exe ` - -D "SWIFTWINRT_EXE=$SwiftWinRT" ` - -D "WINRTCOMPONENT_WINMD=$WinRTComponentBinDir\WinRTComponent.winmd" ` - -D "PROJECTION_JSON=$PSScriptRoot\projection.json" ` - -D "PROJECTION_DIR=$PSScriptRoot\Generated" ` - -D "SPM_SUPPORT_PACKAGE_DIR=$PSScriptRoot\..\.." ` - -P "$PSScriptRoot\GenerateProjection.cmake" Write-Host -ForegroundColor Cyan "Copying the WinRT component dll next to the test..." $SwiftTestPackageDir = $PSScriptRoot diff --git a/Generator/InteropTests/WinRTComponent/CMakeLists.txt b/Generator/InteropTests/WinRTComponent/CMakeLists.txt index 8538018e..b85c7e5f 100644 --- a/Generator/InteropTests/WinRTComponent/CMakeLists.txt +++ b/Generator/InteropTests/WinRTComponent/CMakeLists.txt @@ -1,38 +1,48 @@ -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) + project(WinRTComponent LANGUAGES CXX) +endif() -project(WinRTComponent LANGUAGES CXX) +if (NOT DEFINED SWIFTWINRT_EXE) + message(FATAL_ERROR "SWIFTWINRT_EXE must be defined") +endif() +cmake_path(ABSOLUTE_PATH SWIFTWINRT_EXE NORMALIZE) -# Generate the WinRTComponent.winmd file if not previously done -if("${WINRTCOMPONENT_WINMD}" STREQUAL "") - set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd") - include(GenerateWinMD.cmake) - generate_winrtcomponent_winmd( - IDL "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.idl" - WINMD "${WINRTCOMPONENT_WINMD}") +if(NOT DEFINED PROJECTION_DIR) + set(PROJECTION_DIR "${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources") endif() -# Generate the C++/WinRT boilerplate -message(STATUS "Generating C++/WinRT boilerplate for WinRTComponent...") -set(CPPWINRT_EXE_NATIVE "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\cppwinrt.exe") -cmake_path(CONVERT "${WINRTCOMPONENT_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) -string(REPLACE "\\" "" WINSDK_VERSION "$ENV{WindowsSDKVersion}") -set(CPPWINRT_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/CppWinRT") -cmake_path(CONVERT "${CPPWINRT_GENERATED_DIR}" TO_NATIVE_PATH_LIST CPPWINRT_GENERATED_DIR_NATIVE) -execute_process( - COMMAND "${CPPWINRT_EXE_NATIVE}" - -input "${WINRTCOMPONENT_WINMD_NATIVE}" - -reference "${WINSDK_VERSION}" - -component "${CPPWINRT_GENERATED_DIR_NATIVE}" -overwrite -optimize - -output "${CPPWINRT_GENERATED_DIR_NATIVE}" - COMMAND_ERROR_IS_FATAL ANY) +# Generate the WinRTComponent.winmd file +set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd") +include(GenerateWinMD.cmake) +generate_winrtcomponent_winmd( + IDL "${CMAKE_CURRENT_SOURCE_DIR}/IDL/WinRTComponent.idl" + WINMD "${WINRTCOMPONENT_WINMD}") + +# Generate Swift projection +message(STATUS "Generating Swift projection for WinRTComponent...") +include(GenerateProjection.cmake) +generate_projection( + SWIFTWINRT_EXE "${SWIFTWINRT_EXE}" + WINRTCOMPONENT_WINMD "${WINRTCOMPONENT_WINMD}" + PROJECTION_JSON "${CMAKE_CURRENT_SOURCE_DIR}/projection.json" + PROJECTION_DIR "${PROJECTION_DIR}") + +# Define the dll build (requires cl.exe) +include(ExternalProject) +ExternalProject_Add(WinRTComponent + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Dll" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Dll" + CMAKE_ARGS + -D "WINRTCOMPONENT_WINMD=${WINRTCOMPONENT_WINMD}" + -D "CMAKE_CXX_COMPILER=cl.exe" + -D "CMAKE_CXX_FLAGS=/std:c++latest /W4 /EHsc" + INSTALL_COMMAND "" + TEST_COMMAND "") -# Build WinRTComponent.dll -file(GLOB SOURCES "*.cpp") -add_library(WinRTComponent SHARED - ${SOURCES} - "${CPPWINRT_GENERATED_DIR}/module.g.cpp" # Other .g.cpp files are #included by our .cpp files - WinRTComponent.def) -target_include_directories(WinRTComponent PRIVATE - "${CMAKE_CURRENT_SOURCES_DIR}" - "${CPPWINRT_GENERATED_DIR}") -target_precompile_headers(WinRTComponent PRIVATE pch.h) +# Define the projection build +# TODO(https://github.com/tristanlabelle/swift-winrt/issues/302): Fix linking issues +# add_subdirectory( +# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Sources +# ${CMAKE_CURRENT_BINARY_DIR}/Projection/Build) \ No newline at end of file diff --git a/Generator/InteropTests/WinRTComponent/Arrays.cpp b/Generator/InteropTests/WinRTComponent/Dll/Arrays.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Arrays.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Arrays.cpp diff --git a/Generator/InteropTests/WinRTComponent/Arrays.h b/Generator/InteropTests/WinRTComponent/Dll/Arrays.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Arrays.h rename to Generator/InteropTests/WinRTComponent/Dll/Arrays.h diff --git a/Generator/InteropTests/WinRTComponent/ByteBuffers.cpp b/Generator/InteropTests/WinRTComponent/Dll/ByteBuffers.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ByteBuffers.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ByteBuffers.cpp diff --git a/Generator/InteropTests/WinRTComponent/ByteBuffers.h b/Generator/InteropTests/WinRTComponent/Dll/ByteBuffers.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ByteBuffers.h rename to Generator/InteropTests/WinRTComponent/Dll/ByteBuffers.h diff --git a/Generator/InteropTests/WinRTComponent/Dll/CMakeLists.txt b/Generator/InteropTests/WinRTComponent/Dll/CMakeLists.txt new file mode 100644 index 00000000..7bfb828f --- /dev/null +++ b/Generator/InteropTests/WinRTComponent/Dll/CMakeLists.txt @@ -0,0 +1,33 @@ +if(NOT DEFINED WINRTCOMPONENT_WINMD) + message(FATAL_ERROR "WINRTCOMPONENT_WINMD must be defined") +endif() + +# Generate the C++/WinRT boilerplate +message(STATUS "Generating C++/WinRT boilerplate for WinRTComponent...") +set(CPPWINRT_EXE_NATIVE "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\cppwinrt.exe") +if(NOT EXISTS "${CPPWINRT_EXE_NATIVE}") + message(FATAL_ERROR "Could not find cppwinrt.exe at ${CPPWINRT_EXE_NATIVE}") +endif() + +cmake_path(CONVERT "${WINRTCOMPONENT_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) +string(REPLACE "\\" "" WINSDK_VERSION "$ENV{WindowsSDKVersion}") +set(CPPWINRT_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/CppWinRT") +cmake_path(CONVERT "${CPPWINRT_GENERATED_DIR}" TO_NATIVE_PATH_LIST CPPWINRT_GENERATED_DIR_NATIVE) +execute_process( + COMMAND "${CPPWINRT_EXE_NATIVE}" + -input "${WINRTCOMPONENT_WINMD_NATIVE}" + -reference "${WINSDK_VERSION}" + -component "${CPPWINRT_GENERATED_DIR_NATIVE}" -overwrite -optimize + -output "${CPPWINRT_GENERATED_DIR_NATIVE}" + COMMAND_ERROR_IS_FATAL ANY) + +# Build WinRTComponent.dll +file(GLOB SOURCES "*.cpp") +add_library(WinRTComponent SHARED + ${SOURCES} + "${CPPWINRT_GENERATED_DIR}/module.g.cpp" # Other .g.cpp files are #included by our .cpp files + WinRTComponent.def) +target_include_directories(WinRTComponent PRIVATE + "${CMAKE_CURRENT_SOURCES_DIR}" + "${CPPWINRT_GENERATED_DIR}") +target_precompile_headers(WinRTComponent PRIVATE pch.h) \ No newline at end of file diff --git a/Generator/InteropTests/WinRTComponent/Collections.cpp b/Generator/InteropTests/WinRTComponent/Dll/Collections.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Collections.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Collections.cpp diff --git a/Generator/InteropTests/WinRTComponent/Collections.h b/Generator/InteropTests/WinRTComponent/Dll/Collections.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Collections.h rename to Generator/InteropTests/WinRTComponent/Dll/Collections.h diff --git a/Generator/InteropTests/WinRTComponent/DateTimes.cpp b/Generator/InteropTests/WinRTComponent/Dll/DateTimes.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/DateTimes.cpp rename to Generator/InteropTests/WinRTComponent/Dll/DateTimes.cpp diff --git a/Generator/InteropTests/WinRTComponent/DateTimes.h b/Generator/InteropTests/WinRTComponent/Dll/DateTimes.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/DateTimes.h rename to Generator/InteropTests/WinRTComponent/Dll/DateTimes.h diff --git a/Generator/InteropTests/WinRTComponent/Errors.cpp b/Generator/InteropTests/WinRTComponent/Dll/Errors.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Errors.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Errors.cpp diff --git a/Generator/InteropTests/WinRTComponent/Errors.h b/Generator/InteropTests/WinRTComponent/Dll/Errors.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Errors.h rename to Generator/InteropTests/WinRTComponent/Dll/Errors.h diff --git a/Generator/InteropTests/WinRTComponent/Events.cpp b/Generator/InteropTests/WinRTComponent/Dll/Events.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Events.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Events.cpp diff --git a/Generator/InteropTests/WinRTComponent/Events.h b/Generator/InteropTests/WinRTComponent/Dll/Events.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Events.h rename to Generator/InteropTests/WinRTComponent/Dll/Events.h diff --git a/Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.cpp b/Generator/InteropTests/WinRTComponent/Dll/ForCustomActivationFactoryResolution.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ForCustomActivationFactoryResolution.cpp diff --git a/Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.h b/Generator/InteropTests/WinRTComponent/Dll/ForCustomActivationFactoryResolution.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.h rename to Generator/InteropTests/WinRTComponent/Dll/ForCustomActivationFactoryResolution.h diff --git a/Generator/InteropTests/WinRTComponent/InspectableBoxing.cpp b/Generator/InteropTests/WinRTComponent/Dll/InspectableBoxing.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/InspectableBoxing.cpp rename to Generator/InteropTests/WinRTComponent/Dll/InspectableBoxing.cpp diff --git a/Generator/InteropTests/WinRTComponent/InspectableBoxing.h b/Generator/InteropTests/WinRTComponent/Dll/InspectableBoxing.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/InspectableBoxing.h rename to Generator/InteropTests/WinRTComponent/Dll/InspectableBoxing.h diff --git a/Generator/InteropTests/WinRTComponent/Int32Wrapper.cpp b/Generator/InteropTests/WinRTComponent/Dll/Int32Wrapper.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Int32Wrapper.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Int32Wrapper.cpp diff --git a/Generator/InteropTests/WinRTComponent/Int32Wrapper.h b/Generator/InteropTests/WinRTComponent/Dll/Int32Wrapper.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Int32Wrapper.h rename to Generator/InteropTests/WinRTComponent/Dll/Int32Wrapper.h diff --git a/Generator/InteropTests/WinRTComponent/InterfaceCasting.cpp b/Generator/InteropTests/WinRTComponent/Dll/InterfaceCasting.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/InterfaceCasting.cpp rename to Generator/InteropTests/WinRTComponent/Dll/InterfaceCasting.cpp diff --git a/Generator/InteropTests/WinRTComponent/InterfaceCasting.h b/Generator/InteropTests/WinRTComponent/Dll/InterfaceCasting.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/InterfaceCasting.h rename to Generator/InteropTests/WinRTComponent/Dll/InterfaceCasting.h diff --git a/Generator/InteropTests/WinRTComponent/ManualAsyncOperation.cpp b/Generator/InteropTests/WinRTComponent/Dll/ManualAsyncOperation.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ManualAsyncOperation.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ManualAsyncOperation.cpp diff --git a/Generator/InteropTests/WinRTComponent/ManualAsyncOperation.h b/Generator/InteropTests/WinRTComponent/Dll/ManualAsyncOperation.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ManualAsyncOperation.h rename to Generator/InteropTests/WinRTComponent/Dll/ManualAsyncOperation.h diff --git a/Generator/InteropTests/WinRTComponent/MinimalTypes.cpp b/Generator/InteropTests/WinRTComponent/Dll/MinimalTypes.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalTypes.cpp rename to Generator/InteropTests/WinRTComponent/Dll/MinimalTypes.cpp diff --git a/Generator/InteropTests/WinRTComponent/MinimalTypes.h b/Generator/InteropTests/WinRTComponent/Dll/MinimalTypes.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalTypes.h rename to Generator/InteropTests/WinRTComponent/Dll/MinimalTypes.h diff --git a/Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.cpp b/Generator/InteropTests/WinRTComponent/Dll/MinimalUnsealedClasses.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.cpp rename to Generator/InteropTests/WinRTComponent/Dll/MinimalUnsealedClasses.cpp diff --git a/Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.h b/Generator/InteropTests/WinRTComponent/Dll/MinimalUnsealedClasses.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.h rename to Generator/InteropTests/WinRTComponent/Dll/MinimalUnsealedClasses.h diff --git a/Generator/InteropTests/WinRTComponent/NullValues.cpp b/Generator/InteropTests/WinRTComponent/Dll/NullValues.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/NullValues.cpp rename to Generator/InteropTests/WinRTComponent/Dll/NullValues.cpp diff --git a/Generator/InteropTests/WinRTComponent/NullValues.h b/Generator/InteropTests/WinRTComponent/Dll/NullValues.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/NullValues.h rename to Generator/InteropTests/WinRTComponent/Dll/NullValues.h diff --git a/Generator/InteropTests/WinRTComponent/Numbers.cpp b/Generator/InteropTests/WinRTComponent/Dll/Numbers.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Numbers.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Numbers.cpp diff --git a/Generator/InteropTests/WinRTComponent/Numbers.h b/Generator/InteropTests/WinRTComponent/Dll/Numbers.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Numbers.h rename to Generator/InteropTests/WinRTComponent/Dll/Numbers.h diff --git a/Generator/InteropTests/WinRTComponent/ObjectReferencer.cpp b/Generator/InteropTests/WinRTComponent/Dll/ObjectReferencer.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ObjectReferencer.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ObjectReferencer.cpp diff --git a/Generator/InteropTests/WinRTComponent/ObjectReferencer.h b/Generator/InteropTests/WinRTComponent/Dll/ObjectReferencer.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ObjectReferencer.h rename to Generator/InteropTests/WinRTComponent/Dll/ObjectReferencer.h diff --git a/Generator/InteropTests/WinRTComponent/OutputArgument.cpp b/Generator/InteropTests/WinRTComponent/Dll/OutputArgument.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/OutputArgument.cpp rename to Generator/InteropTests/WinRTComponent/Dll/OutputArgument.cpp diff --git a/Generator/InteropTests/WinRTComponent/OutputArgument.h b/Generator/InteropTests/WinRTComponent/Dll/OutputArgument.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/OutputArgument.h rename to Generator/InteropTests/WinRTComponent/Dll/OutputArgument.h diff --git a/Generator/InteropTests/WinRTComponent/OverloadedSum.cpp b/Generator/InteropTests/WinRTComponent/Dll/OverloadedSum.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/OverloadedSum.cpp rename to Generator/InteropTests/WinRTComponent/Dll/OverloadedSum.cpp diff --git a/Generator/InteropTests/WinRTComponent/OverloadedSum.h b/Generator/InteropTests/WinRTComponent/Dll/OverloadedSum.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/OverloadedSum.h rename to Generator/InteropTests/WinRTComponent/Dll/OverloadedSum.h diff --git a/Generator/InteropTests/WinRTComponent/ReferenceBoxing.cpp b/Generator/InteropTests/WinRTComponent/Dll/ReferenceBoxing.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReferenceBoxing.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ReferenceBoxing.cpp diff --git a/Generator/InteropTests/WinRTComponent/ReferenceBoxing.h b/Generator/InteropTests/WinRTComponent/Dll/ReferenceBoxing.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReferenceBoxing.h rename to Generator/InteropTests/WinRTComponent/Dll/ReferenceBoxing.h diff --git a/Generator/InteropTests/WinRTComponent/ReturnArgument.cpp b/Generator/InteropTests/WinRTComponent/Dll/ReturnArgument.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReturnArgument.cpp rename to Generator/InteropTests/WinRTComponent/Dll/ReturnArgument.cpp diff --git a/Generator/InteropTests/WinRTComponent/ReturnArgument.h b/Generator/InteropTests/WinRTComponent/Dll/ReturnArgument.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReturnArgument.h rename to Generator/InteropTests/WinRTComponent/Dll/ReturnArgument.h diff --git a/Generator/InteropTests/WinRTComponent/Strings.cpp b/Generator/InteropTests/WinRTComponent/Dll/Strings.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Strings.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Strings.cpp diff --git a/Generator/InteropTests/WinRTComponent/Strings.h b/Generator/InteropTests/WinRTComponent/Dll/Strings.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Strings.h rename to Generator/InteropTests/WinRTComponent/Dll/Strings.h diff --git a/Generator/InteropTests/WinRTComponent/Structs.cpp b/Generator/InteropTests/WinRTComponent/Dll/Structs.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/Structs.cpp rename to Generator/InteropTests/WinRTComponent/Dll/Structs.cpp diff --git a/Generator/InteropTests/WinRTComponent/Structs.h b/Generator/InteropTests/WinRTComponent/Dll/Structs.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/Structs.h rename to Generator/InteropTests/WinRTComponent/Dll/Structs.h diff --git a/Generator/InteropTests/WinRTComponent/SwiftAttributes.cpp b/Generator/InteropTests/WinRTComponent/Dll/SwiftAttributes.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/SwiftAttributes.cpp rename to Generator/InteropTests/WinRTComponent/Dll/SwiftAttributes.cpp diff --git a/Generator/InteropTests/WinRTComponent/SwiftAttributes.h b/Generator/InteropTests/WinRTComponent/Dll/SwiftAttributes.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/SwiftAttributes.h rename to Generator/InteropTests/WinRTComponent/Dll/SwiftAttributes.h diff --git a/Generator/InteropTests/WinRTComponent/WeakReferencer.cpp b/Generator/InteropTests/WinRTComponent/Dll/WeakReferencer.cpp similarity index 100% rename from Generator/InteropTests/WinRTComponent/WeakReferencer.cpp rename to Generator/InteropTests/WinRTComponent/Dll/WeakReferencer.cpp diff --git a/Generator/InteropTests/WinRTComponent/WeakReferencer.h b/Generator/InteropTests/WinRTComponent/Dll/WeakReferencer.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/WeakReferencer.h rename to Generator/InteropTests/WinRTComponent/Dll/WeakReferencer.h diff --git a/Generator/InteropTests/WinRTComponent/WinRTComponent.def b/Generator/InteropTests/WinRTComponent/Dll/WinRTComponent.def similarity index 100% rename from Generator/InteropTests/WinRTComponent/WinRTComponent.def rename to Generator/InteropTests/WinRTComponent/Dll/WinRTComponent.def diff --git a/Generator/InteropTests/WinRTComponent/pch.h b/Generator/InteropTests/WinRTComponent/Dll/pch.h similarity index 100% rename from Generator/InteropTests/WinRTComponent/pch.h rename to Generator/InteropTests/WinRTComponent/Dll/pch.h diff --git a/Generator/InteropTests/GenerateProjection.cmake b/Generator/InteropTests/WinRTComponent/GenerateProjection.cmake similarity index 76% rename from Generator/InteropTests/GenerateProjection.cmake rename to Generator/InteropTests/WinRTComponent/GenerateProjection.cmake index ebffc44f..b529f7ef 100644 --- a/Generator/InteropTests/GenerateProjection.cmake +++ b/Generator/InteropTests/WinRTComponent/GenerateProjection.cmake @@ -1,7 +1,7 @@ # Invokes SwiftWinRT to generate a Swift projection for a WinRT component # This file can be called as a CMake script. function(generate_projection) - cmake_parse_arguments("ARG" "" "SWIFTWINRT_EXE;WINRTCOMPONENT_WINMD;PROJECTION_JSON;PROJECTION_DIR;SPM_SUPPORT_PACKAGE_DIR" "" ${ARGN}) + cmake_parse_arguments("ARG" "" "SWIFTWINRT_EXE;WINRTCOMPONENT_WINMD;PROJECTION_JSON;PROJECTION_DIR" "" ${ARGN}) if ("${ARG_SWIFTWINRT_EXE}" STREQUAL "") message(FATAL_ERROR "SWIFTWINRT_EXE argument is required") @@ -19,17 +19,17 @@ function(generate_projection) message(FATAL_ERROR "PROJECTION_DIR argument is required") endif() - if("${ARG_SPM_SUPPORT_PACKAGE_DIR}" STREQUAL "") - message(FATAL_ERROR "SPM_SUPPORT_PACKAGE_DIR argument is required") - endif() - - # SPM won't handle an absolute path with a ".." component. - cmake_path(ABSOLUTE_PATH ARG_SPM_SUPPORT_PACKAGE_DIR NORMALIZE) + # Determine the support package directory + execute_process( + COMMAND git.exe -C "${CMAKE_CURRENT_SOURCE_DIR}" rev-parse --path-format=absolute --show-toplevel + OUTPUT_VARIABLE REPO_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY) cmake_path(CONVERT "${ARG_PROJECTION_JSON}" TO_NATIVE_PATH_LIST PROJECTION_JSON_NATIVE) string(REPLACE "\\" "" WINDOWS_SDK_VERSION "$ENV{WindowsSDKVersion}") # Remove trailing slash cmake_path(CONVERT "${ARG_WINRTCOMPONENT_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) - cmake_path(CONVERT "${ARG_SPM_SUPPORT_PACKAGE_DIR}" TO_NATIVE_PATH_LIST SPM_SUPPORT_PACKAGE_DIR_NATIVE) + cmake_path(CONVERT "${REPO_ROOT}" TO_NATIVE_PATH_LIST SPM_SUPPORT_PACKAGE_DIR_NATIVE) cmake_path(CONVERT "${ARG_PROJECTION_DIR}" TO_NATIVE_PATH_LIST PROJECTION_DIR_NATIVE) execute_process( COMMAND "${ARG_SWIFTWINRT_EXE}" @@ -50,6 +50,5 @@ if(CMAKE_SCRIPT_MODE_FILE AND NOT CMAKE_PARENT_LIST_FILE) SWIFTWINRT_EXE "${SWIFTWINRT_EXE}" WINRTCOMPONENT_WINMD "${WINRTCOMPONENT_WINMD}" PROJECTION_JSON "${PROJECTION_JSON}" - PROJECTION_DIR "${PROJECTION_DIR}" - SPM_SUPPORT_PACKAGE_DIR "${SPM_SUPPORT_PACKAGE_DIR}") + PROJECTION_DIR "${PROJECTION_DIR}") endif() \ No newline at end of file diff --git a/Generator/InteropTests/WinRTComponent/Arrays.idl b/Generator/InteropTests/WinRTComponent/IDL/Arrays.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Arrays.idl rename to Generator/InteropTests/WinRTComponent/IDL/Arrays.idl diff --git a/Generator/InteropTests/WinRTComponent/ByteBuffers.idl b/Generator/InteropTests/WinRTComponent/IDL/ByteBuffers.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ByteBuffers.idl rename to Generator/InteropTests/WinRTComponent/IDL/ByteBuffers.idl diff --git a/Generator/InteropTests/WinRTComponent/Collections.idl b/Generator/InteropTests/WinRTComponent/IDL/Collections.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Collections.idl rename to Generator/InteropTests/WinRTComponent/IDL/Collections.idl diff --git a/Generator/InteropTests/WinRTComponent/DateTimes.idl b/Generator/InteropTests/WinRTComponent/IDL/DateTimes.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/DateTimes.idl rename to Generator/InteropTests/WinRTComponent/IDL/DateTimes.idl diff --git a/Generator/InteropTests/WinRTComponent/Enums.idl b/Generator/InteropTests/WinRTComponent/IDL/Enums.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Enums.idl rename to Generator/InteropTests/WinRTComponent/IDL/Enums.idl diff --git a/Generator/InteropTests/WinRTComponent/Errors.idl b/Generator/InteropTests/WinRTComponent/IDL/Errors.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Errors.idl rename to Generator/InteropTests/WinRTComponent/IDL/Errors.idl diff --git a/Generator/InteropTests/WinRTComponent/Events.idl b/Generator/InteropTests/WinRTComponent/IDL/Events.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Events.idl rename to Generator/InteropTests/WinRTComponent/IDL/Events.idl diff --git a/Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.idl b/Generator/InteropTests/WinRTComponent/IDL/ForCustomActivationFactoryResolution.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ForCustomActivationFactoryResolution.idl rename to Generator/InteropTests/WinRTComponent/IDL/ForCustomActivationFactoryResolution.idl diff --git a/Generator/InteropTests/WinRTComponent/InspectableBoxing.idl b/Generator/InteropTests/WinRTComponent/IDL/InspectableBoxing.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/InspectableBoxing.idl rename to Generator/InteropTests/WinRTComponent/IDL/InspectableBoxing.idl diff --git a/Generator/InteropTests/WinRTComponent/Int32Wrapper.idl b/Generator/InteropTests/WinRTComponent/IDL/Int32Wrapper.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Int32Wrapper.idl rename to Generator/InteropTests/WinRTComponent/IDL/Int32Wrapper.idl diff --git a/Generator/InteropTests/WinRTComponent/InterfaceCasting.idl b/Generator/InteropTests/WinRTComponent/IDL/InterfaceCasting.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/InterfaceCasting.idl rename to Generator/InteropTests/WinRTComponent/IDL/InterfaceCasting.idl diff --git a/Generator/InteropTests/WinRTComponent/ManualAsyncOperation.idl b/Generator/InteropTests/WinRTComponent/IDL/ManualAsyncOperation.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ManualAsyncOperation.idl rename to Generator/InteropTests/WinRTComponent/IDL/ManualAsyncOperation.idl diff --git a/Generator/InteropTests/WinRTComponent/MinimalTypes.idl b/Generator/InteropTests/WinRTComponent/IDL/MinimalTypes.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalTypes.idl rename to Generator/InteropTests/WinRTComponent/IDL/MinimalTypes.idl diff --git a/Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.idl b/Generator/InteropTests/WinRTComponent/IDL/MinimalUnsealedClasses.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/MinimalUnsealedClasses.idl rename to Generator/InteropTests/WinRTComponent/IDL/MinimalUnsealedClasses.idl diff --git a/Generator/InteropTests/WinRTComponent/NullValues.idl b/Generator/InteropTests/WinRTComponent/IDL/NullValues.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/NullValues.idl rename to Generator/InteropTests/WinRTComponent/IDL/NullValues.idl diff --git a/Generator/InteropTests/WinRTComponent/Numbers.idl b/Generator/InteropTests/WinRTComponent/IDL/Numbers.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Numbers.idl rename to Generator/InteropTests/WinRTComponent/IDL/Numbers.idl diff --git a/Generator/InteropTests/WinRTComponent/ObjectReferencer.idl b/Generator/InteropTests/WinRTComponent/IDL/ObjectReferencer.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ObjectReferencer.idl rename to Generator/InteropTests/WinRTComponent/IDL/ObjectReferencer.idl diff --git a/Generator/InteropTests/WinRTComponent/OutputArgument.idl b/Generator/InteropTests/WinRTComponent/IDL/OutputArgument.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/OutputArgument.idl rename to Generator/InteropTests/WinRTComponent/IDL/OutputArgument.idl diff --git a/Generator/InteropTests/WinRTComponent/OverloadedSum.idl b/Generator/InteropTests/WinRTComponent/IDL/OverloadedSum.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/OverloadedSum.idl rename to Generator/InteropTests/WinRTComponent/IDL/OverloadedSum.idl diff --git a/Generator/InteropTests/WinRTComponent/ReferenceBoxing.idl b/Generator/InteropTests/WinRTComponent/IDL/ReferenceBoxing.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReferenceBoxing.idl rename to Generator/InteropTests/WinRTComponent/IDL/ReferenceBoxing.idl diff --git a/Generator/InteropTests/WinRTComponent/ReturnArgument.idl b/Generator/InteropTests/WinRTComponent/IDL/ReturnArgument.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/ReturnArgument.idl rename to Generator/InteropTests/WinRTComponent/IDL/ReturnArgument.idl diff --git a/Generator/InteropTests/WinRTComponent/Strings.idl b/Generator/InteropTests/WinRTComponent/IDL/Strings.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Strings.idl rename to Generator/InteropTests/WinRTComponent/IDL/Strings.idl diff --git a/Generator/InteropTests/WinRTComponent/Structs.idl b/Generator/InteropTests/WinRTComponent/IDL/Structs.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/Structs.idl rename to Generator/InteropTests/WinRTComponent/IDL/Structs.idl diff --git a/Generator/InteropTests/WinRTComponent/SwiftAttributes.idl b/Generator/InteropTests/WinRTComponent/IDL/SwiftAttributes.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/SwiftAttributes.idl rename to Generator/InteropTests/WinRTComponent/IDL/SwiftAttributes.idl diff --git a/Generator/InteropTests/WinRTComponent/SwiftEnum.idl b/Generator/InteropTests/WinRTComponent/IDL/SwiftEnum.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/SwiftEnum.idl rename to Generator/InteropTests/WinRTComponent/IDL/SwiftEnum.idl diff --git a/Generator/InteropTests/WinRTComponent/WeakReferencer.idl b/Generator/InteropTests/WinRTComponent/IDL/WeakReferencer.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/WeakReferencer.idl rename to Generator/InteropTests/WinRTComponent/IDL/WeakReferencer.idl diff --git a/Generator/InteropTests/WinRTComponent/WinRTComponent.idl b/Generator/InteropTests/WinRTComponent/IDL/WinRTComponent.idl similarity index 100% rename from Generator/InteropTests/WinRTComponent/WinRTComponent.idl rename to Generator/InteropTests/WinRTComponent/IDL/WinRTComponent.idl diff --git a/Generator/InteropTests/WinRTComponent/packages.config b/Generator/InteropTests/WinRTComponent/packages.config deleted file mode 100644 index cbf6205e..00000000 --- a/Generator/InteropTests/WinRTComponent/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Generator/InteropTests/projection.json b/Generator/InteropTests/WinRTComponent/projection.json similarity index 100% rename from Generator/InteropTests/projection.json rename to Generator/InteropTests/WinRTComponent/projection.json