From c66f5a3a213efe029e45a52ef5af32e6e1cb7d34 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 30 Dec 2024 07:22:43 -0500 Subject: [PATCH 1/4] Build the WinRTComponent winmd file as a CMake subproject --- InteropTests/CMakeLists.txt | 1 - InteropTests/SPMPrebuild.ps1 | 2 +- InteropTests/WinRTComponent/CMakeLists.txt | 23 +++--- .../WinRTComponent/GenerateWinMD.cmake | 52 -------------- .../WinRTComponent/IDL/WinRTComponent.idl | 33 --------- .../WinRTComponent/{IDL => WinMD}/Arrays.idl | 0 .../{IDL => WinMD}/ByteBuffers.idl | 0 .../WinRTComponent/WinMD/CMakeLists.txt | 70 +++++++++++++++++++ .../{IDL => WinMD}/ClassInheritance.idl | 0 .../{ => WinMD}/Clear-PEDateTimeStamp.ps1 | 0 .../{IDL => WinMD}/Collections.idl | 0 .../{IDL => WinMD}/DateTimes.idl | 0 .../{IDL => WinMD}/Deprecation.idl | 0 .../{IDL => WinMD}/DestructionCallback.idl | 0 .../{IDL => WinMD}/DocumentationComments.idl | 0 .../WinRTComponent/{IDL => WinMD}/Enums.idl | 0 .../WinRTComponent/{IDL => WinMD}/Errors.idl | 0 .../WinRTComponent/{IDL => WinMD}/Events.idl | 0 .../ForCustomActivationFactoryResolution.idl | 0 .../IExposeObservableVector.idl | 0 .../IMultiGenericInstantiation.idl | 0 .../{IDL => WinMD}/IMultiOutParams.idl | 0 .../{IDL => WinMD}/InspectableBoxing.idl | 0 .../{IDL => WinMD}/Int32Wrapper.idl | 0 .../{IDL => WinMD}/InterfaceCasting.idl | 0 .../{IDL => WinMD}/ManualAsyncOperation.idl | 0 .../{IDL => WinMD}/MinimalTypes.idl | 0 .../{IDL => WinMD}/NullValues.idl | 0 .../WinRTComponent/{IDL => WinMD}/Numbers.idl | 0 .../{IDL => WinMD}/ObjectReferencer.idl | 0 .../{IDL => WinMD}/OutputArgument.idl | 0 .../{IDL => WinMD}/OverloadedSum.idl | 0 .../{IDL => WinMD}/ReferenceBoxing.idl | 0 .../{IDL => WinMD}/ReturnArgument.idl | 0 .../{IDL => WinMD}/ShadowingConstructors.idl | 0 .../WinRTComponent/{IDL => WinMD}/Strings.idl | 0 .../WinRTComponent/{IDL => WinMD}/Structs.idl | 0 .../{IDL => WinMD}/SwiftAttributes.idl | 0 .../{IDL => WinMD}/WeakReferencer.idl | 0 .../{ => WinMD}/WinRTComponent.xml | 0 40 files changed, 83 insertions(+), 98 deletions(-) delete mode 100644 InteropTests/WinRTComponent/GenerateWinMD.cmake delete mode 100644 InteropTests/WinRTComponent/IDL/WinRTComponent.idl rename InteropTests/WinRTComponent/{IDL => WinMD}/Arrays.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ByteBuffers.idl (100%) create mode 100644 InteropTests/WinRTComponent/WinMD/CMakeLists.txt rename InteropTests/WinRTComponent/{IDL => WinMD}/ClassInheritance.idl (100%) rename InteropTests/WinRTComponent/{ => WinMD}/Clear-PEDateTimeStamp.ps1 (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Collections.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/DateTimes.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Deprecation.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/DestructionCallback.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/DocumentationComments.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Enums.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Errors.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Events.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ForCustomActivationFactoryResolution.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/IExposeObservableVector.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/IMultiGenericInstantiation.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/IMultiOutParams.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/InspectableBoxing.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Int32Wrapper.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/InterfaceCasting.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ManualAsyncOperation.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/MinimalTypes.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/NullValues.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Numbers.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ObjectReferencer.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/OutputArgument.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/OverloadedSum.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ReferenceBoxing.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ReturnArgument.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/ShadowingConstructors.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Strings.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/Structs.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/SwiftAttributes.idl (100%) rename InteropTests/WinRTComponent/{IDL => WinMD}/WeakReferencer.idl (100%) rename InteropTests/WinRTComponent/{ => WinMD}/WinRTComponent.xml (100%) diff --git a/InteropTests/CMakeLists.txt b/InteropTests/CMakeLists.txt index aa1c248f..000ab356 100644 --- a/InteropTests/CMakeLists.txt +++ b/InteropTests/CMakeLists.txt @@ -1,7 +1,6 @@ # 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(InteropTests LANGUAGES C Swift) endif() diff --git a/InteropTests/SPMPrebuild.ps1 b/InteropTests/SPMPrebuild.ps1 index 24e9c3ec..ce42dd22 100644 --- a/InteropTests/SPMPrebuild.ps1 +++ b/InteropTests/SPMPrebuild.ps1 @@ -53,7 +53,7 @@ switch ($SwiftBug72724) { default {} } & cmake.exe --preset $CMakePreset @Defines -& cmake.exe --build --preset $CMakePreset --target WinRTComponent +& cmake.exe --build --preset $CMakePreset --target WinRTComponentDll $WinRTComponentBinDir = "$(Get-Location)\build\$CMakePreset\Dll" Pop-Location diff --git a/InteropTests/WinRTComponent/CMakeLists.txt b/InteropTests/WinRTComponent/CMakeLists.txt index df746fab..b29dccdc 100644 --- a/InteropTests/WinRTComponent/CMakeLists.txt +++ b/InteropTests/WinRTComponent/CMakeLists.txt @@ -14,19 +14,19 @@ if(NOT DEFINED PROJECTION_DIR) endif() # 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}") - -# Copy the documentation xml file next to it +message(STATUS "Building WinRTComponent.winmd as a subproject...") +execute_process( + COMMAND ${CMAKE_COMMAND} + -S "${CMAKE_CURRENT_SOURCE_DIR}/WinMD" + -B "${CMAKE_CURRENT_BINARY_DIR}/WinMD" + -G "${CMAKE_GENERATOR}" + COMMAND_ERROR_IS_FATAL ANY) execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" - "${CMAKE_CURRENT_BINARY_DIR}/" + COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/WinMD" COMMAND_ERROR_IS_FATAL ANY) +set(WINRTCOMPONENT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinMD/WinRTComponent.winmd") + # Generate Swift projection message(STATUS "Generating Swift projection for WinRTComponent...") include(GenerateProjection.cmake) @@ -38,10 +38,11 @@ generate_projection( # Define the dll build (requires cl.exe) include(ExternalProject) -ExternalProject_Add(WinRTComponent +ExternalProject_Add(WinRTComponentDll SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Dll" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Dll" CMAKE_ARGS + -D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" -D "WINRTCOMPONENT_WINMD=${WINRTCOMPONENT_WINMD}" -D "CMAKE_CXX_COMPILER=cl.exe" -D "CMAKE_CXX_FLAGS=/std:c++latest /W4 /EHsc" diff --git a/InteropTests/WinRTComponent/GenerateWinMD.cmake b/InteropTests/WinRTComponent/GenerateWinMD.cmake deleted file mode 100644 index 62b83d65..00000000 --- a/InteropTests/WinRTComponent/GenerateWinMD.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Generates the WinRTComponent.winmd file from the WinRTComponent.idl file. -function(generate_winrtcomponent_winmd) - cmake_parse_arguments("ARG" "" "IDL;WINMD" "" ${ARGN}) - if("${ARG_IDL}" STREQUAL "") - message(FATAL_ERROR "IDL argument is required") - endif() - - if("${ARG_WINMD}" STREQUAL "") - message(FATAL_ERROR "WINMD argument is required") - endif() - - cmake_path(CONVERT "$ENV{WindowsSdkDir}References\\$ENV{WindowsSDKVersion}" TO_CMAKE_PATH_LIST WINSDK_REFERENCES_DIR NORMALIZE) - - # Find the reference assemblies we're interested in, assuming there is a single version of each - file(GLOB FOUNDATIONCONTRACT_WINMD "${WINSDK_REFERENCES_DIR}/Windows.Foundation.FoundationContract/*/Windows.Foundation.FoundationContract.winmd") - if("${FOUNDATIONCONTRACT_WINMD}" STREQUAL "" OR "${FOUNDATIONCONTRACT_WINMD}" MATCHES ";") - message(FATAL_ERROR "Zero or multiple Windows.Foundation.FoundationContract assemblies found under ${WINSDK_REFERENCES_DIR}") - endif() - - file(GLOB UNIVERSALAPICONTRACT_WINMD "${WINSDK_REFERENCES_DIR}/Windows.Foundation.UniversalApiContract/*/Windows.Foundation.UniversalApiContract.winmd") - if("${UNIVERSALAPICONTRACT_WINMD}" STREQUAL "" OR "${UNIVERSALAPICONTRACT_WINMD}" MATCHES ";") - message(FATAL_ERROR "Zero or multiple Windows.Foundation.UniversalApiContract assemblies found under ${WINSDK_REFERENCES_DIR}") - endif() - - message(STATUS "Generating WinRTComponent.winmd...") - set(MIDLRT_EXE_NATIVE "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\midlrt.exe") - cmake_path(GET FOUNDATIONCONTRACT_WINMD PARENT_PATH FOUNDATIONCONTRACT_DIR) - cmake_path(CONVERT "${FOUNDATIONCONTRACT_DIR}" TO_NATIVE_PATH_LIST METADATA_DIR_NATIVE) - cmake_path(CONVERT "${FOUNDATIONCONTRACT_WINMD}" TO_NATIVE_PATH_LIST FOUNDATIONCONTRACT_WINMD_NATIVE) - cmake_path(CONVERT "${UNIVERSALAPICONTRACT_WINMD}" TO_NATIVE_PATH_LIST UNIVERSALAPICONTRACT_WINMD_NATIVE) - cmake_path(CONVERT "${ARG_WINMD}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_WINMD_NATIVE) - string(REPLACE ".winmd" ".h" WINRTCOMPONENT_H_NATIVE "${WINRTCOMPONENT_WINMD_NATIVE}") - cmake_path(CONVERT "${ARG_IDL}" TO_NATIVE_PATH_LIST WINRTCOMPONENT_IDL_NATIVE) - execute_process( - COMMAND "${MIDLRT_EXE_NATIVE}" - /W1 /nologo /nomidl - /metadata_dir "${METADATA_DIR_NATIVE}" - /reference "${FOUNDATIONCONTRACT_WINMD_NATIVE}" - /reference "${UNIVERSALAPICONTRACT_WINMD_NATIVE}" - /winmd "${WINRTCOMPONENT_WINMD_NATIVE}.timestamped" - /header "${WINRTCOMPONENT_H_NATIVE}" - "${WINRTCOMPONENT_IDL_NATIVE}" - COMMAND_ERROR_IS_FATAL ANY) - - # Remove the timestamp from the generated WinRTComponent.winmd file for cachability - # TODO: We also need to zero the random "mvid" (module version id) field of the module metadata table :/ - execute_process( - COMMAND powershell.exe -File "${CMAKE_CURRENT_SOURCE_DIR}/Clear-PEDateTimeStamp.ps1" - -In "${WINRTCOMPONENT_WINMD_NATIVE}.timestamped" - -Out "${WINRTCOMPONENT_WINMD_NATIVE}" - COMMAND_ERROR_IS_FATAL ANY) -endfunction() \ No newline at end of file diff --git a/InteropTests/WinRTComponent/IDL/WinRTComponent.idl b/InteropTests/WinRTComponent/IDL/WinRTComponent.idl deleted file mode 100644 index 00826230..00000000 --- a/InteropTests/WinRTComponent/IDL/WinRTComponent.idl +++ /dev/null @@ -1,33 +0,0 @@ -// Includes all .idl files so we can call midlrt only once and avoid slow mdmerge steps. -#include "Arrays.idl" -#include "ByteBuffers.idl" -#include "ClassInheritance.idl" -#include "Collections.idl" -#include "DateTimes.idl" -#include "Deprecation.idl" -#include "DestructionCallback.idl" -#include "DocumentationComments.idl" -#include "Enums.idl" -#include "Errors.idl" -#include "Events.idl" -#include "ForCustomActivationFactoryResolution.idl" -#include "InspectableBoxing.idl" -#include "Int32Wrapper.idl" -#include "InterfaceCasting.idl" -#include "IExposeObservableVector.idl" -#include "IMultiGenericInstantiation.idl" -#include "IMultiOutParams.idl" -#include "ManualAsyncOperation.idl" -#include "MinimalTypes.idl" -#include "NullValues.idl" -#include "Numbers.idl" -#include "ObjectReferencer.idl" -#include "OutputArgument.idl" -#include "OverloadedSum.idl" -#include "ReferenceBoxing.idl" -#include "ReturnArgument.idl" -#include "ShadowingConstructors.idl" -#include "Strings.idl" -#include "Structs.idl" -#include "SwiftAttributes.idl" -#include "WeakReferencer.idl" \ No newline at end of file diff --git a/InteropTests/WinRTComponent/IDL/Arrays.idl b/InteropTests/WinRTComponent/WinMD/Arrays.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Arrays.idl rename to InteropTests/WinRTComponent/WinMD/Arrays.idl diff --git a/InteropTests/WinRTComponent/IDL/ByteBuffers.idl b/InteropTests/WinRTComponent/WinMD/ByteBuffers.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ByteBuffers.idl rename to InteropTests/WinRTComponent/WinMD/ByteBuffers.idl diff --git a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt new file mode 100644 index 00000000..350d7e3a --- /dev/null +++ b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt @@ -0,0 +1,70 @@ +# 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(WinMD LANGUAGES NONE) +endif() + +# Locate files we need from the Windows SDK +if("$ENV{VSCMD_ARG_HOST_ARCH}" STREQUAL "" OR "$ENV{WindowsSdkDir}" STREQUAL "" OR "$ENV{WindowsSDKVersion}" STREQUAL "") + message(FATAL_ERROR "CMake should be called within a VS developer command prompt.") +endif() + +cmake_path(CONVERT "$ENV{WindowsSdkDir}References\\$ENV{WindowsSDKVersion}" TO_CMAKE_PATH_LIST WINSDK_REFERENCES_DIR NORMALIZE) + +file(GLOB FOUNDATIONCONTRACT_WINMD "${WINSDK_REFERENCES_DIR}/Windows.Foundation.FoundationContract/*/Windows.Foundation.FoundationContract.winmd") +if("${FOUNDATIONCONTRACT_WINMD}" STREQUAL "" OR "${FOUNDATIONCONTRACT_WINMD}" MATCHES ";") + message(FATAL_ERROR "Zero or multiple Windows.Foundation.FoundationContract assemblies found under ${WINSDK_REFERENCES_DIR}") +endif() +cmake_path(GET FOUNDATIONCONTRACT_WINMD PARENT_PATH FOUNDATIONCONTRACT_DIR) + +file(GLOB UNIVERSALAPICONTRACT_WINMD "${WINSDK_REFERENCES_DIR}/Windows.Foundation.UniversalApiContract/*/Windows.Foundation.UniversalApiContract.winmd") +if("${UNIVERSALAPICONTRACT_WINMD}" STREQUAL "" OR "${UNIVERSALAPICONTRACT_WINMD}" MATCHES ";") + message(FATAL_ERROR "Zero or multiple Windows.Foundation.UniversalApiContract assemblies found under ${WINSDK_REFERENCES_DIR}") +endif() + +cmake_path(CONVERT "$ENV{WindowsSdkVerBinPath}$ENV{VSCMD_ARG_HOST_ARCH}\\midlrt.exe" TO_CMAKE_PATH_LIST MIDLRT_EXE NORMALIZE) + +# Generate a single idl source file that includes all idl files in the directory. +set(IDL_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.idl") +file(GLOB IDL_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.idl") +set(IDL_SOURCE_CODE "") +foreach(IDL_SOURCE_FILE IN LISTS IDL_SOURCE_FILES) + set(IDL_SOURCE_CODE "${IDL_SOURCE_CODE}#include \"${IDL_SOURCE_FILE}\"\n") +endforeach() +file(WRITE "${IDL_SOURCE}" "${IDL_SOURCE_CODE}") + +set(OUTPUT_WINMD "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.winmd") +set(OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.h") +set(OUTPUT_XMLDOCS "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.xml") + +# Generate the WinMD +add_custom_command( + OUTPUT "${OUTPUT_WINMD}.timestamped" "${OUTPUT_HEADER}" + DEPENDS ${IDL_SOURCES} ${FOUNDATIONCONTRACT_WINMD} ${UNIVERSALAPICONTRACT_WINMD} + COMMAND "$" + /W1 /nologo /nomidl + /metadata_dir "$" + /reference "$" + /reference "$" + /winmd "$.timestamped" + /header "$" + "$") + +# Remove the timestamp from the generated WinRTComponent.winmd file for cachability +# TODO: We also need to zero the random "mvid" (module version id) field of the module metadata table :/ +add_custom_command( + OUTPUT "${OUTPUT_WINMD}" + DEPENDS "${OUTPUT_WINMD}.timestamped" + COMMAND powershell.exe -File "${CMAKE_CURRENT_SOURCE_DIR}/Clear-PEDateTimeStamp.ps1" + -In "$.timestamped" + -Out "$") + +add_custom_command( + OUTPUT "${OUTPUT_XMLDOCS}" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" + "${CMAKE_CURRENT_BINARY_DIR}/") + +add_custom_target(WinRTComponentWinMD ALL + DEPENDS "${OUTPUT_WINMD}" "${OUTPUT_HEADER}" "${OUTPUT_XMLDOCS}") diff --git a/InteropTests/WinRTComponent/IDL/ClassInheritance.idl b/InteropTests/WinRTComponent/WinMD/ClassInheritance.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ClassInheritance.idl rename to InteropTests/WinRTComponent/WinMD/ClassInheritance.idl diff --git a/InteropTests/WinRTComponent/Clear-PEDateTimeStamp.ps1 b/InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 similarity index 100% rename from InteropTests/WinRTComponent/Clear-PEDateTimeStamp.ps1 rename to InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 diff --git a/InteropTests/WinRTComponent/IDL/Collections.idl b/InteropTests/WinRTComponent/WinMD/Collections.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Collections.idl rename to InteropTests/WinRTComponent/WinMD/Collections.idl diff --git a/InteropTests/WinRTComponent/IDL/DateTimes.idl b/InteropTests/WinRTComponent/WinMD/DateTimes.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/DateTimes.idl rename to InteropTests/WinRTComponent/WinMD/DateTimes.idl diff --git a/InteropTests/WinRTComponent/IDL/Deprecation.idl b/InteropTests/WinRTComponent/WinMD/Deprecation.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Deprecation.idl rename to InteropTests/WinRTComponent/WinMD/Deprecation.idl diff --git a/InteropTests/WinRTComponent/IDL/DestructionCallback.idl b/InteropTests/WinRTComponent/WinMD/DestructionCallback.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/DestructionCallback.idl rename to InteropTests/WinRTComponent/WinMD/DestructionCallback.idl diff --git a/InteropTests/WinRTComponent/IDL/DocumentationComments.idl b/InteropTests/WinRTComponent/WinMD/DocumentationComments.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/DocumentationComments.idl rename to InteropTests/WinRTComponent/WinMD/DocumentationComments.idl diff --git a/InteropTests/WinRTComponent/IDL/Enums.idl b/InteropTests/WinRTComponent/WinMD/Enums.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Enums.idl rename to InteropTests/WinRTComponent/WinMD/Enums.idl diff --git a/InteropTests/WinRTComponent/IDL/Errors.idl b/InteropTests/WinRTComponent/WinMD/Errors.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Errors.idl rename to InteropTests/WinRTComponent/WinMD/Errors.idl diff --git a/InteropTests/WinRTComponent/IDL/Events.idl b/InteropTests/WinRTComponent/WinMD/Events.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Events.idl rename to InteropTests/WinRTComponent/WinMD/Events.idl diff --git a/InteropTests/WinRTComponent/IDL/ForCustomActivationFactoryResolution.idl b/InteropTests/WinRTComponent/WinMD/ForCustomActivationFactoryResolution.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ForCustomActivationFactoryResolution.idl rename to InteropTests/WinRTComponent/WinMD/ForCustomActivationFactoryResolution.idl diff --git a/InteropTests/WinRTComponent/IDL/IExposeObservableVector.idl b/InteropTests/WinRTComponent/WinMD/IExposeObservableVector.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/IExposeObservableVector.idl rename to InteropTests/WinRTComponent/WinMD/IExposeObservableVector.idl diff --git a/InteropTests/WinRTComponent/IDL/IMultiGenericInstantiation.idl b/InteropTests/WinRTComponent/WinMD/IMultiGenericInstantiation.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/IMultiGenericInstantiation.idl rename to InteropTests/WinRTComponent/WinMD/IMultiGenericInstantiation.idl diff --git a/InteropTests/WinRTComponent/IDL/IMultiOutParams.idl b/InteropTests/WinRTComponent/WinMD/IMultiOutParams.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/IMultiOutParams.idl rename to InteropTests/WinRTComponent/WinMD/IMultiOutParams.idl diff --git a/InteropTests/WinRTComponent/IDL/InspectableBoxing.idl b/InteropTests/WinRTComponent/WinMD/InspectableBoxing.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/InspectableBoxing.idl rename to InteropTests/WinRTComponent/WinMD/InspectableBoxing.idl diff --git a/InteropTests/WinRTComponent/IDL/Int32Wrapper.idl b/InteropTests/WinRTComponent/WinMD/Int32Wrapper.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Int32Wrapper.idl rename to InteropTests/WinRTComponent/WinMD/Int32Wrapper.idl diff --git a/InteropTests/WinRTComponent/IDL/InterfaceCasting.idl b/InteropTests/WinRTComponent/WinMD/InterfaceCasting.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/InterfaceCasting.idl rename to InteropTests/WinRTComponent/WinMD/InterfaceCasting.idl diff --git a/InteropTests/WinRTComponent/IDL/ManualAsyncOperation.idl b/InteropTests/WinRTComponent/WinMD/ManualAsyncOperation.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ManualAsyncOperation.idl rename to InteropTests/WinRTComponent/WinMD/ManualAsyncOperation.idl diff --git a/InteropTests/WinRTComponent/IDL/MinimalTypes.idl b/InteropTests/WinRTComponent/WinMD/MinimalTypes.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/MinimalTypes.idl rename to InteropTests/WinRTComponent/WinMD/MinimalTypes.idl diff --git a/InteropTests/WinRTComponent/IDL/NullValues.idl b/InteropTests/WinRTComponent/WinMD/NullValues.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/NullValues.idl rename to InteropTests/WinRTComponent/WinMD/NullValues.idl diff --git a/InteropTests/WinRTComponent/IDL/Numbers.idl b/InteropTests/WinRTComponent/WinMD/Numbers.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Numbers.idl rename to InteropTests/WinRTComponent/WinMD/Numbers.idl diff --git a/InteropTests/WinRTComponent/IDL/ObjectReferencer.idl b/InteropTests/WinRTComponent/WinMD/ObjectReferencer.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ObjectReferencer.idl rename to InteropTests/WinRTComponent/WinMD/ObjectReferencer.idl diff --git a/InteropTests/WinRTComponent/IDL/OutputArgument.idl b/InteropTests/WinRTComponent/WinMD/OutputArgument.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/OutputArgument.idl rename to InteropTests/WinRTComponent/WinMD/OutputArgument.idl diff --git a/InteropTests/WinRTComponent/IDL/OverloadedSum.idl b/InteropTests/WinRTComponent/WinMD/OverloadedSum.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/OverloadedSum.idl rename to InteropTests/WinRTComponent/WinMD/OverloadedSum.idl diff --git a/InteropTests/WinRTComponent/IDL/ReferenceBoxing.idl b/InteropTests/WinRTComponent/WinMD/ReferenceBoxing.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ReferenceBoxing.idl rename to InteropTests/WinRTComponent/WinMD/ReferenceBoxing.idl diff --git a/InteropTests/WinRTComponent/IDL/ReturnArgument.idl b/InteropTests/WinRTComponent/WinMD/ReturnArgument.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ReturnArgument.idl rename to InteropTests/WinRTComponent/WinMD/ReturnArgument.idl diff --git a/InteropTests/WinRTComponent/IDL/ShadowingConstructors.idl b/InteropTests/WinRTComponent/WinMD/ShadowingConstructors.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/ShadowingConstructors.idl rename to InteropTests/WinRTComponent/WinMD/ShadowingConstructors.idl diff --git a/InteropTests/WinRTComponent/IDL/Strings.idl b/InteropTests/WinRTComponent/WinMD/Strings.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Strings.idl rename to InteropTests/WinRTComponent/WinMD/Strings.idl diff --git a/InteropTests/WinRTComponent/IDL/Structs.idl b/InteropTests/WinRTComponent/WinMD/Structs.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/Structs.idl rename to InteropTests/WinRTComponent/WinMD/Structs.idl diff --git a/InteropTests/WinRTComponent/IDL/SwiftAttributes.idl b/InteropTests/WinRTComponent/WinMD/SwiftAttributes.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/SwiftAttributes.idl rename to InteropTests/WinRTComponent/WinMD/SwiftAttributes.idl diff --git a/InteropTests/WinRTComponent/IDL/WeakReferencer.idl b/InteropTests/WinRTComponent/WinMD/WeakReferencer.idl similarity index 100% rename from InteropTests/WinRTComponent/IDL/WeakReferencer.idl rename to InteropTests/WinRTComponent/WinMD/WeakReferencer.idl diff --git a/InteropTests/WinRTComponent/WinRTComponent.xml b/InteropTests/WinRTComponent/WinMD/WinRTComponent.xml similarity index 100% rename from InteropTests/WinRTComponent/WinRTComponent.xml rename to InteropTests/WinRTComponent/WinMD/WinRTComponent.xml From b4f2932b504763a4b5dbbb0d0d01fb4a58e63fbb Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 30 Dec 2024 07:28:14 -0500 Subject: [PATCH 2/4] Remove timestamp clearing --- .../WinRTComponent/WinMD/CMakeLists.txt | 11 +---------- .../WinMD/Clear-PEDateTimeStamp.ps1 | 19 ------------------- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 diff --git a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt index 350d7e3a..808f4f55 100644 --- a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt +++ b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt @@ -39,7 +39,7 @@ set(OUTPUT_XMLDOCS "${CMAKE_CURRENT_BINARY_DIR}/WinRTComponent.xml") # Generate the WinMD add_custom_command( - OUTPUT "${OUTPUT_WINMD}.timestamped" "${OUTPUT_HEADER}" + OUTPUT "${OUTPUT_WINMD}" "${OUTPUT_HEADER}" DEPENDS ${IDL_SOURCES} ${FOUNDATIONCONTRACT_WINMD} ${UNIVERSALAPICONTRACT_WINMD} COMMAND "$" /W1 /nologo /nomidl @@ -50,15 +50,6 @@ add_custom_command( /header "$" "$") -# Remove the timestamp from the generated WinRTComponent.winmd file for cachability -# TODO: We also need to zero the random "mvid" (module version id) field of the module metadata table :/ -add_custom_command( - OUTPUT "${OUTPUT_WINMD}" - DEPENDS "${OUTPUT_WINMD}.timestamped" - COMMAND powershell.exe -File "${CMAKE_CURRENT_SOURCE_DIR}/Clear-PEDateTimeStamp.ps1" - -In "$.timestamped" - -Out "$") - add_custom_command( OUTPUT "${OUTPUT_XMLDOCS}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" diff --git a/InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 b/InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 deleted file mode 100644 index db1fa071..00000000 --- a/InteropTests/WinRTComponent/WinMD/Clear-PEDateTimeStamp.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -[CmdletBinding(PositionalBinding=$false)] -param( - [Parameter(Mandatory=$true)] - [string] $In, - [Parameter(Mandatory=$true)] - [string] $Out -) - -$ErrorActionPreference = "Stop" - -$PEBytes = [IO.File]::ReadAllBytes($In) -$MSDosSignature = [BitConverter]::ToUInt16($PEBytes, 0x0) -if ($MSDosSignature -ne 0x5A4D) { throw "Invalid MS-DOS signature" } # "MZ", little endian -$PEHeaderOffset = [BitConverter]::ToInt32($PEBytes, 0x3C) -$PESignature = [BitConverter]::ToInt32($PEBytes, $PEHeaderOffset) -if ($PESignature -ne 0x4550) { throw "Invalid PE signature" } # "PE\0\0", little endian -$PETimeDateStampOffset = $PEHeaderOffset + 0x8 -[Array]::Clear($PEBytes, $PETimeDateStampOffset, 0x4) -[IO.File]::WriteAllBytes($Out, $PEBytes) \ No newline at end of file From 57e927131fd64b2014f6ef733af6beca63f21360 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 30 Dec 2024 07:38:56 -0500 Subject: [PATCH 3/4] Fix winmd output name --- InteropTests/WinRTComponent/WinMD/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt index 808f4f55..4f93bff3 100644 --- a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt +++ b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt @@ -46,7 +46,7 @@ add_custom_command( /metadata_dir "$" /reference "$" /reference "$" - /winmd "$.timestamped" + /winmd "$" /header "$" "$") From d400f3ead0269a3c85be3d0df7b586db6247e0e3 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Mon, 30 Dec 2024 07:39:38 -0500 Subject: [PATCH 4/4] Tweak docgen command --- InteropTests/WinRTComponent/WinMD/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt index 4f93bff3..f975796c 100644 --- a/InteropTests/WinRTComponent/WinMD/CMakeLists.txt +++ b/InteropTests/WinRTComponent/WinMD/CMakeLists.txt @@ -55,7 +55,7 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/WinRTComponent.xml" - "${CMAKE_CURRENT_BINARY_DIR}/") + "${OUTPUT_XMLDOCS}") add_custom_target(WinRTComponentWinMD ALL DEPENDS "${OUTPUT_WINMD}" "${OUTPUT_HEADER}" "${OUTPUT_XMLDOCS}")