Skip to content

Package dawn artifacts/required files into xcframework for easier integration#13

Draft
SoylentGraham wants to merge 21 commits intohenrybetts:mainfrom
NewChromantics:AddDylibDependency
Draft

Package dawn artifacts/required files into xcframework for easier integration#13
SoylentGraham wants to merge 21 commits intohenrybetts:mainfrom
NewChromantics:AddDylibDependency

Conversation

@SoylentGraham
Copy link
Copy Markdown

@SoylentGraham SoylentGraham commented Nov 5, 2024

Improvement

These changes to the package setup mean the dylib, dawn headers, and dawn.json are all bundled into an .xcframework which SPM consumes quite nicely.

  • Now we don't need any files added to the sytem in /usr/local etc
    • dylib & dawn headers in xcframework
    • pkgconfig replaced with publicHeadersPath and webgpu.h to generate the webgpu symbols (eg WGPUBool)
  • This can later move so the xcframework can come from an URL (ie. github workflow -> release, and automate creation from dawn's own code)
  • This now automatically includes the dylib into any product of a project that requires it (currently the setup fails as the dylib isn't bundled with any projects)
  • WebGPU C->Swift symbols now come via publicHeadersPath in CWebGPU and require webgpu.h (and ONLY this header)

User Instructions

  • Build dawn as before, but copy
    • libwebgpu_dawn.dylib
    • dawn's include/
    • dawn's dawn.json
  • Into Sources/DawnNative/ and then run cd Soruces/DawnNaive && ./CreateXCFramework.sh
  • This will generate a Sources/DawnNative/webgpu_dawn.xcframework
  • The Swift package then gets all it's dependencies from the xcframework when building

Todo

  • Make a seperate repos for xcframework generation
  • Update readme

@SoylentGraham SoylentGraham marked this pull request as draft November 5, 2024 18:30
@SoylentGraham
Copy link
Copy Markdown
Author

SoylentGraham commented Nov 6, 2024

Currently xcode fails to Archive (for app store) any projects - not sure if this is related to my changes or not

dyld[38443]: Library not loaded: @rpath/ArgumentParser_39B7DAEE4DD359BE_PackageProduct.framework/Versions/A/ArgumentParser_39B7DAEE4DD359BE_PackageProduct
  Referenced from: <BA83F552-06A5-33D1-B7AB-3C2508F3A7D9> /Volumes/Sandisk/Xcode_DerivedData/HenryBettsWebGpuDemo-doptxfxqkfjmwzefxxqpaktwloon/Build/Intermediates.noindex/ArchiveIntermediates/HenryBettsWebGpuDemo/IntermediateBuildFilesPath/UninstalledProducts/macosx/generate-webgpu
  Reason: tried: '/usr/lib/swift/ArgumentParser_39B7DAEE4DD359BE_PackageProduct.framework/Versions/A/ArgumentParser_39B7DAEE4DD359BE_PackageProduct' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/ArgumentParser_39B7DAEE4DD359BE_PackageProduct.framework/Versions/A/ArgumentParser_39B7DAEE4DD359BE_PackageProduct' (no such file), '/usr/lib/swift/ArgumentParser_39B7DAEE4DD359BE_PackageProduct.framework/Versions/A/ArgumentParser_39B7DAEE4DD359BE_PackageProduct' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/ArgumentParser_39B7DAEE4DD359BE_PackageProduct.framework/Versions/A/ArgumentParser_39B7DAEE4DD359BE_PackageProduct' (no such file)
/Volumes/Sandisk/Xcode_DerivedData/HenryBettsWebGpuDemo-doptxfxqkfjmwzefxxqpaktwloon/Build/Intermediates.noindex/ArchiveIntermediates/HenryBettsWebGpuDemo/IntermediateBuildFilesPath/swift-webgpu.build/Release/WebGPU.build/Script-16908758398532019134.sh: line 20: 38443 Abort trap: 6           /usr/bin/sandbox-exec -p "(version 1)

edit: same error when building release

@SoylentGraham
Copy link
Copy Markdown
Author

To get the right artifacts, after building via ninja (as per current instructions), I cannot find the correct artifacts...
only when doing sudo ninja install can I find the .dylib and the correct includes.

todo:

  • Find where this dylib is (does install do a final link??) and dont require /usr/lib install
  • find out which are the correct includes to be used with this script

@SoylentGraham
Copy link
Copy Markdown
Author

SoylentGraham commented Nov 12, 2024

Current setup is building a hardcoded path to /Volumes/Code/dawn/out/Release/src/dawn/platform/libdawn_platform.dylib in libwebgpu_dawn.framework/webgpu_dawn so clearing out dawn artifacts (or using on another system) fails

Need to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant