Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change include path in wgpu.h #424

Closed
wants to merge 1 commit into from
Closed

Conversation

eliemichel
Copy link
Contributor

@eliemichel eliemichel commented Sep 15, 2024

The generated release zips files are organized as follows:

 - include/
   - webgpu/
     - webgpu.h
   - wgpu/
     - wgpu.h
 - lib/
   - ...

However, wgpu.h includes webgpu.h with #include "webgpu.h", which forces to add include/webgpu/ to the include directories, while it feels more idiomatic to only include include/. Other implementations also have webgpu.h in a include/webgpu/ subfolder so I suggest leaving this so, leading to two possible fixes:

  • Option A: Change the include path in wgpu.h (this PR)
  • Option B: Distribute wgpu.h in include/webgpu/ instead of include/wgpu/ (what I had been doing manually in my distributions so far) -> edit: alternative PR for this option: Distribute wgpu.h in include/webgpu #425

@almarklein
Copy link
Collaborator

@rajveermalviya and @Sahnvour thoughts?

I don't really care personally (I made wgpu-py find the files regardless of folder structure 😅).

@rajveermalviya
Copy link
Collaborator

rajveermalviya commented Sep 15, 2024

Thanks for catching this issue, @eliemichel!

Updating the checked-in file directly would cause problems with bindgen, and since this only impacts package builds, the best approach (for now) is to update the Makefile instead:

diff --git a/Makefile b/Makefile
index 6a5546e..ddea760 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,7 @@ package: lib-native lib-native-release
                cp ./dist/wgpu-native-git-tag                 dist/$$ARCHIVEDIR; \
                cp ./ffi/webgpu-headers/webgpu.h              dist/$$ARCHIVEDIR/include/webgpu; \
                cp ./ffi/wgpu.h                               dist/$$ARCHIVEDIR/include/wgpu; \
+               sed -i '' 's/"webgpu.h"/<webgpu\/webgpu.h>/'  dist/$$ARCHIVEDIR/include/wgpu/wgpu.h; \
                if [ $(OS_NAME) = linux ]; then \
                        cp ./$$LIBDIR/libwgpu_native.so           dist/$$ARCHIVEDIR/lib; \
                        cp ./$$LIBDIR/libwgpu_native.a            dist/$$ARCHIVEDIR/lib; \

For reference, the folder structure was updated in #417 and #419, but we missed updating the include path because there’s no testing infrastructure for the built archives at the moment.

@almarklein
Copy link
Collaborator

I know I said I don't care ... but changing the contents of a file in the makefile is rather unexpected and may cause confusion.

What about option B? Keeping webgpu.h and wgpu.h together does feel nice and simple, and wgpu.h basically defines 'extensions' so webgpu, so it kinda makes sense (to me)?

@Sahnvour
Copy link

IMHO option B is simpler and more intuitive, I don't think it causes any trouble to have both headers in the same folder.

@eliemichel
Copy link
Contributor Author

If Option B feels like a better solution, here is an alternative PR (which indeed only affects the Makefile): #425

@almarklein
Copy link
Collaborator

Thanks @eliemichel! Closing in favor of #425

@almarklein almarklein closed this Sep 19, 2024
@eliemichel eliemichel deleted the patch-1 branch September 24, 2024 21:16
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.

4 participants