Compare commits

..

No commits in common. "main" and "steve/test" have entirely different histories.

46 changed files with 254 additions and 322 deletions

View File

@ -17,11 +17,12 @@ let package = Package(
products: [
.library(name: "WinAppSDK", type: .dynamic, targets: ["WinAppSDK"]),
.library(name: "CWinAppSDK", targets: ["CWinAppSDK"]),
.library(name: "WinAppSDKExt", targets: ["WinAppSDKExt"])
],
dependencies: [
.package(url: "https://git.aparoksha.dev/winui-swift/swift-cwinrt", branch: "main"),
.package(url: "https://git.aparoksha.dev/winui-swift/swift-uwp", branch: "main"),
.package(url: "https://git.aparoksha.dev/winui-swift/swift-windowsfoundation", branch: "main"),
.package(url: "https://github.com/thebrowsercompany/swift-cwinrt", branch: "main"),
.package(url: "https://github.com/thebrowsercompany/swift-uwp", branch: "main"),
.package(url: "https://github.com/thebrowsercompany/swift-windowsfoundation", branch: "main"),
],
targets: [
.target(
@ -40,10 +41,17 @@ let package = Package(
],
linkerSettings: linkerSettings
),
.testTarget(
name: "WinAppSDKTests",
.target(
name: "WinAppSDKExt",
dependencies: [
"WinAppSDK",
"CWinAppSDK"
]
),
.testTarget(
name: "WinAppSDKExtTests",
dependencies: [
"WinAppSDKExt",
]
)
]

View File

@ -1,9 +1,10 @@
# swift-windowsappsdk
This is based on [thebrowsercompany/swift-windowsappsdk](https://github.com/thebrowsercompany/swift-windowsappsdk).
Swift Language Bindings for the Windows App SDK APIs
These APIs are intendened to be used in conjuction with the following projects:
- [swift-winui](https://github.com/thebrowsercompany/swift-winui)
- [swift-win2d](https://github.com/thebrowsercompany/swift-win2d)
## APIs
These projections contains a subset of APIs for the Windows App SDK, minus those of WinUI (`Microsoft.UI.Xaml`). See official documentation for more information on these components:
@ -16,18 +17,12 @@ These projections contains a subset of APIs for the Windows App SDK, minus those
2. Windows App SDK: `1.5-preview1`
## Project Configuration
The bindings are generated from WinMD files, found in NuGet packages on Nuget.org. There are two key files which drive this:
1. projections.json - this specifies the project/package and which apis to include in the projection
2. generate-bindings.ps1 - this file reads `projections.json` and generates the appropriate bindings.
The bindings are generated from WinMD files, found in NuGet packages on Nuget.org. There are three key files which drive this:
1. packages.config - this specifies the packages and their versions
2. projections.json - this specifies the project/package and which apis to include in the projection
3. generate-bindings.ps1 - this file reads both `packages.config` and `projections.json` and generates the appropriate bindings.
## Known Issues and Limitations
- Only x64 architecture is supported right now
- The developer experience for consuming WinRT APIs from Swift is a work in progress. Due to current limitations, not all APIs can be generated as this causes export limit issues.
- The APIs listed in projections.json are required for the other `swift-*` projects to build. Modify a projections.json in any one of those projects could require an update here.
## Using Windows App SDK
In order to use the Windows App SDK, you need to download the Windows App SDK from here: https://aka.ms/windowsappsdk/1.5/1.5.240205001-preview1/windowsappruntimeinstall-x64.exe

View File

@ -192,28 +192,17 @@ STDAPI MddAddPackageDependency(
STDAPI_(void) MddRemovePackageDependency(
_In_ MDD_PACKAGEDEPENDENCY_CONTEXT packageDependencyContext) noexcept;
/// Return the package full name to which the
/// PackageDependency has been resolved. Does not add the
/// Return the package full name that would be used if the
/// PackageDependency were to be resolved. Does not add the
/// package to the process graph.
///
/// @param packageFullName allocated via HeapAlloc; use HeapFree to deallocate.
/// If the package dependency cannot be resolved the function
/// succeeds but packageFullName is nullptr.
/// @note An unknown packageDependencyId returns S_OK and packageFullName=null.
STDAPI MddGetResolvedPackageFullNameForPackageDependency(
_In_ PCWSTR packageDependencyId,
_Outptr_result_maybenull_ PWSTR* packageFullName) noexcept;
/// Return the package full name to which the
/// PackageDependency has been resolved. Does not add the
/// package to the process graph.
///
/// @param packageFullName allocated via HeapAlloc; use HeapFree to deallocate.
/// @note An unknown packageDependencyId returns HRESULT_FROM_WIN32(ERROR_NOT_FOUND).
STDAPI MddGetResolvedPackageFullNameForPackageDependency2(
_In_ PCWSTR packageDependencyId,
_Outptr_result_maybenull_ PWSTR* packageFullName) noexcept;
/// Return the package dependency for the context.
///
/// @param packageDependencyId allocated via HeapAlloc; use HeapFree to deallocate.

View File

@ -7,23 +7,23 @@
// Release information
#define WINDOWSAPPSDK_RELEASE_MAJOR 1
#define WINDOWSAPPSDK_RELEASE_MINOR 5
#define WINDOWSAPPSDK_RELEASE_PATCH 1
#define WINDOWSAPPSDK_RELEASE_PATCH 0
#define WINDOWSAPPSDK_RELEASE_MAJORMINOR 0x00010005
#define WINDOWSAPPSDK_RELEASE_CHANNEL "stable"
#define WINDOWSAPPSDK_RELEASE_CHANNEL_W L"stable"
#define WINDOWSAPPSDK_RELEASE_CHANNEL "preview"
#define WINDOWSAPPSDK_RELEASE_CHANNEL_W L"preview"
#define WINDOWSAPPSDK_RELEASE_VERSION_TAG ""
#define WINDOWSAPPSDK_RELEASE_VERSION_TAG_W L""
#define WINDOWSAPPSDK_RELEASE_VERSION_TAG "preview1"
#define WINDOWSAPPSDK_RELEASE_VERSION_TAG_W L"preview1"
#define WINDOWSAPPSDK_RELEASE_VERSION_SHORTTAG ""
#define WINDOWSAPPSDK_RELEASE_VERSION_SHORTTAG_W L""
#define WINDOWSAPPSDK_RELEASE_VERSION_SHORTTAG "p1"
#define WINDOWSAPPSDK_RELEASE_VERSION_SHORTTAG_W L"p1"
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_TAG ""
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_TAG_W L""
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_TAG "-preview1"
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_TAG_W L"-preview1"
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_SHORTTAG ""
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_SHORTTAG_W L""
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_SHORTTAG "-p1"
#define WINDOWSAPPSDK_RELEASE_FORMATTED_VERSION_SHORTTAG_W L"-p1"
// Runtime information
#define WINDOWSAPPSDK_RUNTIME_IDENTITY_PUBLISHER "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
@ -31,26 +31,26 @@
#define WINDOWSAPPSDK_RUNTIME_IDENTITY_PUBLISHERID "8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_IDENTITY_PUBLISHERID_W L"8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_VERSION_MAJOR 5001u
#define WINDOWSAPPSDK_RUNTIME_VERSION_MINOR 159u
#define WINDOWSAPPSDK_RUNTIME_VERSION_BUILD 55u
#define WINDOWSAPPSDK_RUNTIME_VERSION_MAJOR 5000u
#define WINDOWSAPPSDK_RUNTIME_VERSION_MINOR 35u
#define WINDOWSAPPSDK_RUNTIME_VERSION_BUILD 2034u
#define WINDOWSAPPSDK_RUNTIME_VERSION_REVISION 0u
#define WINDOWSAPPSDK_RUNTIME_VERSION_UINT64 0x1389009F00370000u
#define WINDOWSAPPSDK_RUNTIME_VERSION_DOTQUADSTRING "5001.159.55.0"
#define WINDOWSAPPSDK_RUNTIME_VERSION_DOTQUADSTRING_W L"5001.159.55.0"
#define WINDOWSAPPSDK_RUNTIME_VERSION_UINT64 0x1388002307F20000u
#define WINDOWSAPPSDK_RUNTIME_VERSION_DOTQUADSTRING "5000.35.2034.0"
#define WINDOWSAPPSDK_RUNTIME_VERSION_DOTQUADSTRING_W L"5000.35.2034.0"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_FRAMEWORK_PACKAGEFAMILYNAME "Microsoft.WindowsAppRuntime.1.5_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_FRAMEWORK_PACKAGEFAMILYNAME_W L"Microsoft.WindowsAppRuntime.1.5_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_MAIN_PACKAGEFAMILYNAME "MicrosoftCorporationII.WinAppRuntime.Main.1.5_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_MAIN_PACKAGEFAMILYNAME_W L"MicrosoftCorporationII.WinAppRuntime.Main.1.5_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_SINGLETON_PACKAGEFAMILYNAME "MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_SINGLETON_PACKAGEFAMILYNAME_W L"MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X86_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x8_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X86_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x8_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X64_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x6_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X64_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x6_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_ARM64_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-a6_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_ARM64_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-a6_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_FRAMEWORK_PACKAGEFAMILYNAME "Microsoft.WindowsAppRuntime.1.5-preview1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_FRAMEWORK_PACKAGEFAMILYNAME_W L"Microsoft.WindowsAppRuntime.1.5-preview1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_MAIN_PACKAGEFAMILYNAME "MicrosoftCorporationII.WinAppRuntime.Main.1.5-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_MAIN_PACKAGEFAMILYNAME_W L"MicrosoftCorporationII.WinAppRuntime.Main.1.5-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_SINGLETON_PACKAGEFAMILYNAME "MicrosoftCorporationII.WinAppRuntime.Singleton-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_SINGLETON_PACKAGEFAMILYNAME_W L"MicrosoftCorporationII.WinAppRuntime.Singleton-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X86_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x8-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X86_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x8-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X64_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x6-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_X64_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x6-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_ARM64_PACKAGEFAMILYNAME "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-a6-p1_8wekyb3d8bbwe"
#define WINDOWSAPPSDK_RUNTIME_PACKAGE_DDLM_ARM64_PACKAGEFAMILYNAME_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-a6-p1_8wekyb3d8bbwe"
#ifdef RC_INVOKED
// Only first 31 characters are significant for ResourceCompiler macro names (anything beyond that's silently ignored)
@ -65,23 +65,23 @@
// Release information
#define WAS_RELEASE_MAJOR 1
#define WAS_RELEASE_MINOR 5
#define WAS_RELEASE_PATCH 1
#define WAS_RELEASE_PATCH 0
#define WAS_RELEASE_MAJORMINOR 0x00010005
#define WAS_RELEASE_CHANNEL "stable"
#define WAS_RELEASE_CHANNEL_W L"stable"
#define WAS_RELEASE_CHANNEL "preview"
#define WAS_RELEASE_CHANNEL_W L"preview"
#define WAS_RELEASE_VERSION_TAG ""
#define WAS_RELEASE_VERSION_TAG_W L""
#define WAS_RELEASE_VERSION_TAG "preview1"
#define WAS_RELEASE_VERSION_TAG_W L"preview1"
#define WAS_RELEASE_VERSION_STAG ""
#define WAS_RELEASE_VERSION_STAG_W L""
#define WAS_RELEASE_VERSION_STAG "p1"
#define WAS_RELEASE_VERSION_STAG_W L"p1"
#define WAS_RELEASE_FMT_VERSION_TAG ""
#define WAS_RELEASE_FMT_VERSION_TAG_W L""
#define WAS_RELEASE_FMT_VERSION_TAG "-preview1"
#define WAS_RELEASE_FMT_VERSION_TAG_W L"-preview1"
#define WAS_RELEASE_FMT_VERSION_STAG ""
#define WAS_RELEASE_FMT_VERSION_STAG_W L""
#define WAS_RELEASE_FMT_VERSION_STAG "-p1"
#define WAS_RELEASE_FMT_VERSION_STAG_W L"-p1"
// Runtime information
#define WASR_IDENTITY_PUBLISHER "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
@ -89,26 +89,26 @@
#define WASR_IDENTITY_PUBLISHERID "8wekyb3d8bbwe"
#define WASR_IDENTITY_PUBLISHERID_W L"8wekyb3d8bbwe"
#define WASR_VERSION_MAJOR 5001
#define WASR_VERSION_MINOR 159
#define WASR_VERSION_BUILD 55
#define WASR_VERSION_MAJOR 5000
#define WASR_VERSION_MINOR 35
#define WASR_VERSION_BUILD 2034
#define WASR_VERSION_REVISION 0
#define WASR_VERSION_UINT64 0x1389009F00370000
#define WASR_VERSION_DOTQUADSTRING "5001.159.55.0"
#define WASR_VERSION_DOTQUADSTRING_W L"5001.159.55.0"
#define WASR_VERSION_UINT64 0x1388002307F20000
#define WASR_VERSION_DOTQUADSTRING "5000.35.2034.0"
#define WASR_VERSION_DOTQUADSTRING_W L"5000.35.2034.0"
#define WASR_PKG_FRAMEWORK_FAMILY "Microsoft.WindowsAppRuntime.1.5_8wekyb3d8bbwe"
#define WASR_PKG_FRAMEWORK_FAMILY_W L"Microsoft.WindowsAppRuntime.1.5_8wekyb3d8bbwe"
#define WASR_PKG_MAIN_FAMILY "MicrosoftCorporationII.WinAppRuntime.Main.1.5_8wekyb3d8bbwe"
#define WASR_PKG_MAIN_FAMILY_W L"MicrosoftCorporationII.WinAppRuntime.Main.1.5_8wekyb3d8bbwe"
#define WASR_PKG_SINGLETON_FAMILY "MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe"
#define WASR_PKG_SINGLETON_FAMILY_W L"MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X86_FAMILY "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x8_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X86_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x8_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X64_FAMILY "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x6_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X64_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x6_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_ARM64_FAMILY "Microsoft.WinAppRuntime.DDLM.5001.159.55.0-a6_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_ARM64_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-a6_8wekyb3d8bbwe"
#define WASR_PKG_FRAMEWORK_FAMILY "Microsoft.WindowsAppRuntime.1.5-preview1_8wekyb3d8bbwe"
#define WASR_PKG_FRAMEWORK_FAMILY_W L"Microsoft.WindowsAppRuntime.1.5-preview1_8wekyb3d8bbwe"
#define WASR_PKG_MAIN_FAMILY "MicrosoftCorporationII.WinAppRuntime.Main.1.5-p1_8wekyb3d8bbwe"
#define WASR_PKG_MAIN_FAMILY_W L"MicrosoftCorporationII.WinAppRuntime.Main.1.5-p1_8wekyb3d8bbwe"
#define WASR_PKG_SINGLETON_FAMILY "MicrosoftCorporationII.WinAppRuntime.Singleton-p1_8wekyb3d8bbwe"
#define WASR_PKG_SINGLETON_FAMILY_W L"MicrosoftCorporationII.WinAppRuntime.Singleton-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X86_FAMILY "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x8-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X86_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x8-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X64_FAMILY "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x6-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_X64_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x6-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_ARM64_FAMILY "Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-a6-p1_8wekyb3d8bbwe"
#define WASR_PKG_DDLM_ARM64_FAMILY_W L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-a6-p1_8wekyb3d8bbwe"
#endif
#ifdef __cplusplus
@ -125,25 +125,25 @@ namespace Microsoft::WindowsAppSDK
constexpr uint16_t Minor = 5;
/// The patch version of the Windows App SDK release.
constexpr uint16_t Patch = 1;
constexpr uint16_t Patch = 0;
/// The major and minor version of the Windows App SDK release, encoded as a uint32_t (0xMMMMNNNN where M=major, N=minor).
constexpr uint32_t MajorMinor = 0x00010005;
/// The Windows App SDK release's channel; for example, "preview", or empty string for stable.
constexpr PCWSTR Channel = L"stable";
constexpr PCWSTR Channel = L"preview";
/// The Windows App SDK release's version tag; for example, "preview2", or empty string for stable.
constexpr PCWSTR VersionTag = L"";
constexpr PCWSTR VersionTag = L"preview1";
/// The Windows App SDK release's short-form version tag; for example, "p2", or empty string for stable.
constexpr PCWSTR VersionShortTag = L"";
constexpr PCWSTR VersionShortTag = L"p1";
/// The Windows App SDK release's version tag, formatted for concatenation when constructing identifiers; for example, "-preview2", or empty string for stable.
constexpr PCWSTR FormattedVersionTag = L"";
constexpr PCWSTR FormattedVersionTag = L"-preview1";
/// The Windows App SDK release's short-form version tag, formatted for concatenation when constructing identifiers; for example, "-p2", or empty string for stable.
constexpr PCWSTR FormattedVersionShortTag = L"";
constexpr PCWSTR FormattedVersionShortTag = L"-p1";
}
/// Build-time constants for the Windows App SDK runtime
@ -161,22 +161,22 @@ namespace Microsoft::WindowsAppSDK
namespace Version
{
/// The major version of the Windows App SDK runtime; for example, 1000.
constexpr uint16_t Major = 5001;
constexpr uint16_t Major = 5000;
/// The minor version of the Windows App SDK runtime; for example, 446.
constexpr uint16_t Minor = 159;
constexpr uint16_t Minor = 35;
/// The build version of the Windows App SDK runtime; for example, 804.
constexpr uint16_t Build = 55;
constexpr uint16_t Build = 2034;
/// The revision version of the Windows App SDK runtime; for example, 0.
constexpr uint16_t Revision = 0;
/// The version of the Windows App SDK runtime, as a uint64l for example, 0x03E801BE03240000.
constexpr uint64_t UInt64 = 0x1389009F00370000;
constexpr uint64_t UInt64 = 0x1388002307F20000;
/// The version of the Windows App SDK runtime, as a string (const wchar_t*); for example, "1000.446.804.0".
constexpr PCWSTR DotQuadString = L"5001.159.55.0";
constexpr PCWSTR DotQuadString = L"5000.35.2034.0";
}
namespace Packages
@ -184,34 +184,34 @@ namespace Microsoft::WindowsAppSDK
namespace Framework
{
/// The Windows App SDK runtime's Framework package's family name.
constexpr PCWSTR PackageFamilyName = L"Microsoft.WindowsAppRuntime.1.5_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"Microsoft.WindowsAppRuntime.1.5-preview1_8wekyb3d8bbwe";
}
namespace Main
{
/// The Windows App SDK runtime's Main package's family name.
constexpr PCWSTR PackageFamilyName = L"MicrosoftCorporationII.WinAppRuntime.Main.1.5_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"MicrosoftCorporationII.WinAppRuntime.Main.1.5-p1_8wekyb3d8bbwe";
}
namespace Singleton
{
/// The Windows App SDK runtime's Singleton package's family name.
constexpr PCWSTR PackageFamilyName = L"MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"MicrosoftCorporationII.WinAppRuntime.Singleton-p1_8wekyb3d8bbwe";
}
namespace DDLM
{
namespace X86
{
/// The Windows App SDK runtime's Dynamic Dependency Lifetime Manager (DDLM) package's family name, for x86.
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x8_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x8-p1_8wekyb3d8bbwe";
}
namespace X64
{
/// The Windows App SDK runtime's Dynamic Dependency Lifetime Manager (DDLM) package's family name, for x64.
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-x6_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-x6-p1_8wekyb3d8bbwe";
}
namespace Arm64
{
/// The Windows App SDK runtime's Dynamic Dependency Lifetime Manager (DDLM) package's family name, for arm64.
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5001.159.55.0-a6_8wekyb3d8bbwe";
constexpr PCWSTR PackageFamilyName = L"Microsoft.WinAppRuntime.DDLM.5000.35.2034.0-a6-p1_8wekyb3d8bbwe";
}
}
}

View File

@ -141,7 +141,6 @@
/*
*
* Typedef of Windows.Graphics.DirectX.DirectXAlphaMode
@ -434,7 +433,6 @@ ABI_NAMESPACE_END
/*
*
* Typedef of Windows.Graphics.DirectX.DirectXAlphaMode

View File

@ -8,25 +8,10 @@ public enum ThreadingModel {
case multi
}
/// WindowsAppRuntimeInitializer is used to properly initialize the Windows App SDK runtime, along with the Windows Runtime.
/// The runtime is initalized for the lifetime of the object, and is deinitialized when the object is deallocated.
/// Example usage:
/// ```
/// public static func main() {
/// do {
/// try withExtendedLifetime(WindowsAppRuntimeInitializer()) {
/// initialization code here
/// }
/// }
/// catch {
/// fatalError("Failed to initialize WindowsAppRuntimeInitializer: \(error)")
/// }
/// }
/// ```
public class WindowsAppRuntimeInitializer {
// TODO: Figure out how to properly link against delayimp.lib so that we can delay load the bootstrap dll.
private typealias pfnMddBootstrapInitialize2 = @convention(c) (UInt32, PCWSTR?, PACKAGE_VERSION, MddBootstrapInitializeOptions) -> HRESULT
private typealias pfnMddBootstrapShutdown = @convention(c) () -> Void
private typealias pfnMddBootstrapShutdown = @convention(c) () -> HRESULT
private let bootsrapperDll = LoadLibraryA("swift-windowsappsdk_CWinAppSDK.resources\\Microsoft.WindowsAppRuntime.Bootstrap.dll")
private lazy var Initialize: pfnMddBootstrapInitialize2 = {

View File

@ -1,4 +1,4 @@
import WinAppSDK
import WinAppSDKExt
import XCTest
public class InitiailzerTests: XCTestCase {

View File

@ -1,16 +1,3 @@
function Get-SwiftWinRTVersion {
$Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json
return $Projections."swift-winrt"
}
function Get-PackageString {
param(
$Package
)
if ($Package) {
return " <package id=""$($Package.Id)"" version=""$($Package.Version)"" />`n"
}
}
function Restore-Nuget {
param(
[string]$PackagesDir
@ -20,68 +7,35 @@ function Restore-Nuget {
Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $NugetDownloadPath
}
$Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json
$SwiftWinRTVersion = Get-SwiftWinRTVersion
$PackagesConfigContent = "<?xml version=""1.0"" encoding=""utf-8""?>`n"
$PackagesConfigContent += "<packages>`n"
$PackagesConfigContent += " <package id=""TheBrowserCompany.SwiftWinRT"" version=""$SwiftWinRTVersion"" />`n"
if ($Projections.Package) {
$PackagesConfigContent += Get-PackageString -Package $Projections.Package
}
& $NugetDownloadPath restore .\packages.config -PackagesDirectory $PackagesDir
}
$Projections.Packages | ForEach-Object {
$PackagesConfigContent += Get-PackageString -Package $_
}
$Projections.Dependencies | ForEach-Object {
$PackagesConfigContent += Get-PackageString -Package $_
}
$PackagesConfigContent += "</packages>"
if (-not (Test-Path "$PSScriptRoot\.packages")) {
New-Item -ItemType Directory -Path "$PSScriptRoot\.packages" | Out-Null
}
$PackagesConfigPath = Join-Path $PSScriptRoot ".packages\packages.config"
$PackagesConfigContent | Out-File -FilePath $PackagesConfigPath -Encoding ascii
function Get-NugetPackageVersion() {
param(
[string]$Package
)
& $NugetDownloadPath restore $PackagesConfigPath -PackagesDirectory $PackagesDir | Out-Null
if ($LASTEXITCODE -ne 0) {
exit 1
}
return (Select-XML -Path $PSScriptRoot\packages.config -XPath "/packages/package[@id='$Package']/@version").Node.Value
}
function Get-WinMDInputs() {
param(
$Package
[string]$Package
)
$Id = $Package.Id
$Version = $Package.Version
return Get-ChildItem -Path $PackagesDir\$Id.$Version\ -Filter *.winmd -Recurse
}
function Copy-Project {
param(
[string]$OutputLocation,
[string]$ProjectName
)
if ($ProjectName) {
$ProjectGeneratedDir = if ($ProjectName -eq "CWinRT") { "$ProjectName" } else { "$ProjectName\Generated" }
$ProjectDir = Join-Path $PSScriptRoot "Sources\$ProjectGeneratedDir"
if (Test-Path $ProjectDir) {
Remove-Item -Path $ProjectDir -Recurse -Force
}
Copy-Item -Path $OutputLocation\Sources\$ProjectName -Destination $ProjectDir -Recurse -Force
$Version = Get-NugetPackageVersion -Package $Package
return Get-ChildItem -Path $PackagesDir\$Package.$Version\ -Filter *.winmd -Recurse
$Winmds = $winmds | ForEach-Object {
$RspParams += "-input $($_.FullName)`n"
}
}
function Invoke-SwiftWinRT() {
param(
[string]$PackagesDir
)
$Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json
$SwiftWinRTVersion = Get-SwiftWinRTVersion
$SwiftWinRTVersion = Get-NugetPackageVersion -Package "TheBrowserCompany.SwiftWinRT"
# write generated bindings to a temp directory since swiftwinrt will generate all dependencies and the CWinRT
$OutputLocation = Join-Path $PSScriptRoot ".generated"
if (Test-Path $OutputLocation) {
@ -91,6 +45,19 @@ function Invoke-SwiftWinRT() {
$RspParams = "-output $OutputLocation`n"
# read projections.json and for each "include" write to -include param. for each "exclude" write to -exclude param
$Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json
$ProjectName = $Projections.Project
if (-not $ProjectName) {
Write-Host "projections.json must contain a 'Project' property" -ForegroundColor Red
return
}
$Package = $Projections.Package
if (-not $ProjectName) {
Write-Host "projections.json must contain a 'Package' property" -ForegroundColor Red
return
}
$Projections.Include | ForEach-Object {
$RspParams += "-include $_`n"
}
@ -98,40 +65,30 @@ function Invoke-SwiftWinRT() {
$RspParams += "-exclude $_`n"
}
if ($Projections.Package) {
Get-WinMDInputs -Package $Package | ForEach-Object {
$RspParams += "-input $($_.FullName)`n"
}
}
$Projections.Packages | ForEach-Object {
Get-WinMDInputs -Package $Package | ForEach-Object {
$RspParams += "-input $($_.FullName)`n"
}
}
$Projections.Dependencies | ForEach-Object {
Get-WinMDInputs -Package $Package | ForEach-Object {
$RspParams += "-input $($_.FullName)`n"
Get-WinMDInputs -Package $_ | ForEach-Object {
$RspParams += "-reference $($_.FullName)`n"
}
}
# write rsp params to file
$RspFile = Join-Path $PSScriptRoot "swift-winrt.rsp"
$RspParams | Out-File -FilePath $RspFile -Encoding ascii
$RspParams | Out-File -FilePath $RspFile
& $PackagesDir\TheBrowserCompany.SwiftWinRT.$SwiftWinRTVersion\bin\swiftwinrt.exe "@$RspFile"
# check error code
if ($LASTEXITCODE -ne 0) {
Write-Host "swiftwinrt failed with error code $LASTEXITCODE" -ForegroundColor Red
exit 1
}
$Projections.Projects | ForEach-Object {
Copy-Project -OutputLocation $OutputLocation -ProjectName $_
}
if ($Projections.Project) {
Copy-Project -OutputLocation $OutputLocation -ProjectName $Projections.Project
return
}
# swift-winrt will generate all dependencies so copy all "UWP" sources from the generated dir to the UWP project
$ProjectDir = Join-Path $PSScriptRoot "Sources\$ProjectName"
Remove-Item -Path $ProjectDir -Recurse -Force
Copy-Item -Path $OutputLocation\Sources\$ProjectName -Filter *.swift -Destination $ProjectDir -Recurse -Force
}
function Copy-PackageAssets {
@ -141,8 +98,8 @@ function Copy-PackageAssets {
$Arch = "x64"
$Projections = Get-Content -Path $PSScriptRoot\projections.json | ConvertFrom-Json
$Package = $Projections.Package.Id
$PackageVersion = $Projections.Package.Version
$Package = $Projections.Package
$PackageVersion = Get-NugetPackageVersion -Package $Package
$ProjectName = $Projections.Project
$ProjectDir = Join-Path $PSScriptRoot "Sources\C$ProjectName\nuget"
@ -188,4 +145,7 @@ $PackagesDir = Join-Path $PSScriptRoot ".packages"
Restore-Nuget -PackagesDir $PackagesDir
Invoke-SwiftWinRT -PackagesDir $PackagesDir
Copy-PackageAssets -PackagesDir $PackagesDir
Write-Host "SwiftWinRT bindings generated successfully!" -ForegroundColor Green
if ($LASTEXITCODE -eq 0) {
Write-Host "SwiftWinRT bindings generated successfully!" -ForegroundColor Green
}

View File

@ -1,12 +1,9 @@
{
"swift-winrt": "0.5.0",
"package": {
"id": "Microsoft.WindowsAppSDK",
"version": "1.5.240607001"
},
"package": "Microsoft.WindowsAppSDK",
"version": "1.5.240205001-preview1",
"project": "WinAppSDK",
"dependencies": [
{ "id": "Microsoft.Windows.SDK.Contracts", "version": "10.0.18362.2005" }
"Microsoft.Windows.SDK.Contracts"
],
"include": [
"Microsoft.UI.Composition",