Thread overview
How to compile against GitHub fork of Phobos?
Mar 07, 2017
Q. Schroll
Mar 07, 2017
Adam D. Ruppe
Mar 07, 2017
Q. Schroll
Mar 07, 2017
ketmar
Mar 07, 2017
Q. Schroll
Mar 07, 2017
XavierAP
March 07, 2017
I have a fork of the standard-library in the folder "phobos". In version 2.072.1 of the compiler, I could use code like

    void main()
    {
        import phobos.std.format;
        /* code for checking my changes to format */
    }

compiled with

  $ dmd -I"phobos" test_format.d

in the parent folder of phobos. It worked fine.

I've updated the compiler today and get an error message:

    module std.typecons from file phobos\std\typecons.d must be imported with 'import std.typecons;'

But if I do so, it imports the one from the standard library attached to the compiler. Is it a regression? Should the old version have rejected my code? I don't see any possibility to test specific changes in modules of my fork.

I've just read https://wiki.dlang.org/Starting_as_a_Contributor#Building_D, but it didn't help me out.
March 07, 2017
On Tuesday, 7 March 2017 at 01:14:28 UTC, Q. Schroll wrote:
> I have a fork of the standard-library in the folder "phobos". In version 2.072.1 of the compiler, I could use code like
>
>     void main()
>     {
>         import phobos.std.format;

That should never have worked unless you changed the module declaration in the format file too...

> But if I do so, it imports the one from the standard library attached to the compiler. Is it a regression? Should the old version have rejected my code? I don't see any possibility to test specific changes in modules of my fork.

You pass your modified file to the compiler:

dmd yourfile.d format.d

The format.d there can be a copy of the one from phobos (or a fork or whatever) and since you passed it explicitly on the command line, it takes precedence over the one in the library.

You still import it as std.format. You can do that with as many modules as you like.
March 07, 2017
On Tuesday, 7 March 2017 at 01:45:48 UTC, Adam D. Ruppe wrote:
> You pass your modified file to the compiler:
>
> dmd yourfile.d format.d
>
> The format.d there can be a copy of the one from phobos (or a fork or whatever) and since you passed it explicitly on the command line, it takes precedence over the one in the library.
>
> You still import it as std.format. You can do that with as many modules as you like.

I just tried it out.

   dmd myfile.d phobos/std/format.d

worked fine, but interestingly,

   rdmd myfile.d phobos/std/format.d

did not. The latter definitely takes format from the library. I have no idea why.
March 07, 2017
Q. Schroll wrote:

> On Tuesday, 7 March 2017 at 01:45:48 UTC, Adam D. Ruppe wrote:
>> You pass your modified file to the compiler:
>>
>> dmd yourfile.d format.d
>>
>> The format.d there can be a copy of the one from phobos (or a fork or whatever) and since you passed it explicitly on the command line, it takes precedence over the one in the library.
>>
>> You still import it as std.format. You can do that with as many modules as you like.
>
> I just tried it out.
>
> dmd myfile.d phobos/std/format.d
>
> worked fine, but interestingly,
>
> rdmd myfile.d phobos/std/format.d
>
> did not. The latter definitely takes format from the library. I have no idea why.

rdmd doesn't work like dmd. here, it just passing "phobos/std/format.d" as command line argument to "myfile.d".
March 07, 2017
On Tuesday, 7 March 2017 at 02:30:21 UTC, ketmar wrote:
> Q. Schroll wrote:
>
>> On Tuesday, 7 March 2017 at 01:45:48 UTC, Adam D. Ruppe wrote:
>>> You pass your modified file to the compiler:
>>>
>>> dmd yourfile.d format.d
>>>
>>> The format.d there can be a copy of the one from phobos (or a fork or whatever) and since you passed it explicitly on the command line, it takes precedence over the one in the library.
>>>
>>> You still import it as std.format. You can do that with as many modules as you like.
>>
>> I just tried it out.
>>
>> dmd myfile.d phobos/std/format.d
>>
>> worked fine, but interestingly,
>>
>> rdmd myfile.d phobos/std/format.d
>>
>> did not. The latter definitely takes format from the library. I have no idea why.
>
> rdmd doesn't work like dmd. here, it just passing "phobos/std/format.d" as command line argument to "myfile.d".

You're right. I should've known that. By bad ...

Thanks for your replies. They were very helpful.
March 07, 2017
On Tuesday, 7 March 2017 at 01:14:28 UTC, Q. Schroll wrote:
> I have a fork of the standard-library in the folder "phobos".

DMD looking for the built-in phobos is specified in the configuration file (sc.ini on Windows, dmd.conf on Linux), not hardcoded. You may want to remove it from there. When you specify -I on top of this, I guess the compiler looks in both places in some order.

You could also clone your modified Phobos to the directory built into the DMD distribution. But maybe you want to have both. You may also keep and use two DMD bin folders, with different configuration files. There are many possibilities for you to configure what you want.

Also yes with your configuration I think you should remove the preceding "phobos." from imports, since you're already telling the compiler to look inside the phobos folder.