Skip to content

Add support for ImportC by turning them to .di on the fly#798

Open
bangbangsheshotmedown wants to merge 6 commits intodlang-community:masterfrom
bangbangsheshotmedown:importc
Open

Add support for ImportC by turning them to .di on the fly#798
bangbangsheshotmedown wants to merge 6 commits intodlang-community:masterfrom
bangbangsheshotmedown:importc

Conversation

@bangbangsheshotmedown
Copy link
Copy Markdown

Works like a charm:

image

There is also -X, wich generates a json, i wonder if that can be used for templates/mixins, i'll experiment for an other PR

@github-actions
Copy link
Copy Markdown

Thanks for your Pull Request and making D better!

This comment will automatically be updated to summarize some statistics in a few minutes.

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

The joy of not having to generate bindings to get completion anymore

image

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

I forgot to say, this needs a patch for DMD, because -Hf never prints to output, i'll send a PR

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

bangbangsheshotmedown commented Feb 28, 2026

I forgot, they banned me from the repo, @WebFreak001 can you submit the patch for me please?

PR: Generate .di to stdout if name is "-"

This matches the behavior of -X=-
This is needed for #798

$ git diff compiler/src/dmd/main.d                                                                                                                                                   
diff --git a/compiler/src/dmd/main.d b/compiler/src/dmd/main.d
index 9a04c16b9f..4458e623b5 100644
--- a/compiler/src/dmd/main.d
+++ b/compiler/src/dmd/main.d
@@ -582,7 +582,12 @@ private int tryMain(const(char)[][] argv, out Param params)
 
             buf.reset();         // reuse the buffer
             genhdrfile(m, params.dihdr.fullOutput, buf);
-            if (!writeFile(m.loc, m.hdrfile.toString(), buf[]))
+
+            if (params.dihdr.name == "-") {
+                size_t n = fwrite(buf[].ptr, 1, buf.length, stdout);
+                assert(n == buf.length);
+            }
+            else if (!writeFile(m.loc, m.hdrfile.toString(), buf[]))
                 fatal();
         }
     }

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

Now also completes import paths:
image

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

A PR for it got merged: dlang/dmd#22662

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