Install xdg mimetype definitions for OpenCL C & CUDA C
ClosedPublic

Authored by kossebau on Apr 27 2017, 6:21 PM.

Details

Summary

Installing these mimetypes ourselves to complete the
system mimetype db will help people for now.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Apr 27 2017, 6:21 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptApr 27 2017, 6:21 PM

The non-CUDA stuff should be also added to 5.1.

kossebau added inline comments.Apr 27 2017, 6:35 PM
languages/clang/kdevclang.xml
13

@aaronpuchert, given D5485 this indeed should be "OpenCL C source code", not "OpenCL source code", right?

If so, someone with knowledge should write a patch to fix-up the entry in shared-mime-info, which is without the "C": https://cgit.freedesktop.org/xdg/shared-mime-info/commit/?id=4ab969c398671c519a10a601ad3eeb46f04361de

aaronpuchert added inline comments.Apr 27 2017, 9:58 PM
languages/clang/kdevclang.xml
13

Yes, that is the official name of the language. I'd also argue that the mime type should be text/x-opencl-csrc.

The reason being that there is also OpenCL C++ (since OpenCL 2.1), though that is not yet supported by Clang.

kossebau added inline comments.Apr 28 2017, 12:11 AM
languages/clang/kdevclang.xml
13

@aaronpuchert Could you introduce us KDevelop developers to any people who are active in the OpenCL developer scene and who would have the knowledge and motivation to push for proper mimetype ids now?
There is no shared-mime-info release out yet with the current text/x-opencl-src, so if we are quick we can fix things before they reach more people for a begin.

Just saw in the KDE software world already another mimetype has been in use: text/x-clsrc. as part of the syntax highlight definition for OpenCL:
https://cgit.kde.org/syntax-highlighting.git/tree/data/syntax/opencl.xml#n7

The alias noted here in the mimetype definition, text/x-opencl can seen in even more places.
And someone is using text/x-opencl_c and application/x-opencl_c: https://github.com/rtms/rouge/blob/master/lib/rouge/lexers/opencl_c.rb#L14

So it really needs someone from the active OpenCL scene to tell the IDEs and systems what to use as id. Can you make the difference? :) Any Khronos channels you are on where you could poke people to decide on one, and perhaps even register with IANA?

aaronpuchert added inline comments.Apr 28 2017, 11:27 PM
languages/clang/kdevclang.xml
13

You're right, no one ever took the time to register a MIME type for OpenCL C. Even the file extension .cl doesn't seem to be “official”, at least I can't find any reference to it in the official documents.

I will try to contact Khronos about this and ask them to register with IANA or do it myself, if they don't care. Obviously this is the right way.

nalvarez added inline comments.
languages/clang/kdevclang.xml
13

Note that none of those MIME types can be registered with IANA. Registered types don't have an x-.

aaronpuchert added inline comments.Apr 29 2017, 12:11 AM
languages/clang/kdevclang.xml
13

I'm a bit stunned: not even C or C++ source files are registered with IANA. Why would that be?

After MIME types beginning with x- have been deprecated in RFC 6648, it is recommended in RFC 6838 that such types, if in wide use, should be registered with a standardized type. No one has apparently taken the time to do that.

So for now, we should probably just update shared-mime-info, since registering with IANA requires an RFC.

kossebau added inline comments.Apr 29 2017, 12:35 AM
languages/clang/kdevclang.xml
13

Question is, what should be used for updating shared-mime-info?

And it still would be good to make OpenCL/Khronos people aware of the need to have something to identify/speficify files with OpenCL C/C++ content. And if only they come up with some recommended informal mimetype ids and file extensions :) Anything not made up ourselves would be good.

I tried to catch some people via planet kde, but surely that might not have been the best audience: https://frinring.wordpress.com/2017/04/28/give-us-a-proper-mimetype-name-for-opencl-c-files/

kfunk accepted this revision.May 8 2017, 5:51 PM
This revision is now accepted and ready to land.May 8 2017, 5:51 PM
aaronpuchert edited edge metadata.May 8 2017, 11:52 PM

By the way, I posted the question to Khronos. Their preferred channel seems to be opening an issue on one of their GitHub repositories. So I opened issue #27 at the OpenCL Registry. However, I do not expect an answer. From Khronos' point of view OpenCL source code is just a string in memory. Compiling OpenCL directly from file is not possible. (As far as I know the API.)

I'm not sure there will ever be a standard type. Not even for C there is: while shared-mime-info defines it as text/x-csrc, I get text/x-c when running file -i on a C source file.

This revision was automatically updated to reflect the committed changes.
kossebau added a comment.EditedMay 9 2017, 11:18 AM

By the way, I posted the question to Khronos. Their preferred channel seems to be opening an issue on one of their GitHub repositories. So I opened issue #27 at the OpenCL Registry.

Good!

However, I do not expect an answer. From Khronos' point of view OpenCL source code is just a string in memory. Compiling OpenCL directly from file is not possible. (As far as I know the API.)

Mimetype is not just about files in the filesystem, but also in the clipboard, as attachments to messages, network-transferred blobs etc. Kind of type metadata for any byte streams/blobs :) Having that helps here and there programs to do better guesses what to do with some blob submitted over a generic API (like clipboard), so it's worth pushing for some type

I'm not sure there will ever be a standard type. Not even for C there is: while shared-mime-info defines it as text/x-csrc, I get text/x-c when running file -i on a C source file.

Yes, quite frustrating. Was'nt that the nice thing about standards that there are so many to pick from? ;) shared-mime-info tries to encounter that wildness with unregisterd mimetypes a little by here having that alternative also registered, via <alias type="text/x-c"/>, so some mapping is possible for code using shared-mime-info (which IIRC file yet has to do, they seem to maintain their own db/magic).
((And then mimetype (usage) is also not the best content type tagging system, e.g. does it have little/no help about format versions (just think about application/msword). But it's what we have right now.))