www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to compile against GitHub fork of Phobos?

reply Q. Schroll <qs.il.paperinik gmail.com> writes:
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.
Mar 06
next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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.
Mar 06
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
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.
Mar 06
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
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".
Mar 06
parent Q. Schroll <qs.il.paperinik gmail.com> writes:
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.
Mar 06
prev sibling parent XavierAP <n3minis-git yahoo.es> writes:
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.
Mar 07