FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

version(DigitalMars)?

 
Post new topic   Reply to topic     Forum Index -> Build
View previous topic :: View next topic  
Author Message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Thu Apr 14, 2005 8:33 pm    Post subject: version(DigitalMars)? Reply with quote

What should build do with version(DigitalMars)? Right now, it's executing the "else" part, but I don't know how much of a good idea it is (or executing the other part), but it caused me a problem when it passed to DMD an import file that wasn't supposed to be there, and of course DMD complained later.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Fri Apr 15, 2005 2:05 am    Post subject: Re: version(DigitalMars)? Reply with quote

Carlos wrote:
What should build do with version(DigitalMars)? Right now, it's executing the "else" part, but I don't know how much of a good idea it is (or executing the other part), but it caused me a problem when it passed to DMD an import file that wasn't supposed to be there, and of course DMD complained later.

I'm sorry but I don't understand the problem that you have. Can you give me a code example? Are you using a D compiler that is not from Digital Mars? If so, what is the import file that shouldn't have been sent to DMD since you are not using DMD? I'm confused.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Fri Apr 15, 2005 7:46 am    Post subject: Reply with quote

Yeah, I thought it was vague.
I have a piece of code that imports std.c.windows.windows, but gdc on cygwin doesn't like that (static assert because version=Windows is not set). So I had to rely on the core32 library but only for gdc. So I have this:

Code:

version(DigitalMars)
   import std.c.windows.windows;
else
   import win32.windows;


So build is passing to DMD "win32\windows.obj" as a command line argument when it shouldn't. That's the problem I'm having.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sat Apr 16, 2005 7:16 am    Post subject: Reply with quote

Carlos wrote:
Yeah, I thought it was vague.
I have a piece of code that imports std.c.windows.windows, but gdc on cygwin doesn't like that (static assert because version=Windows is not set). So I had to rely on the core32 library but only for gdc. So I have this:

Code:

version(DigitalMars)
   import std.c.windows.windows;
else
   import win32.windows;


So build is passing to DMD "win32\windows.obj" as a command line argument when it shouldn't. That's the problem I'm having.

I'm still not 100? sure of what you see as a problem. Here's what I've got so far ...

You are running with gdc and thus 'DigitalMars' is not defined.
Build is using the 'import win32.windows' line in our code and not using the 'import std.c.windows.windows' line, and this is to be expected.
Build is placing 'win32\windows.obj' on the gdc command line.

What I don't understand is why you think this is wrong. Your code is saying it needs the module "win32.windows" so thus Build puts it on the command line.

What do you think should be happening instead?
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sat Apr 16, 2005 9:18 pm    Post subject: Reply with quote

Well, no, that wasn't the case. I was running build for dmd, and since it doesn't have version=DigitalMars set, it used "win32.windows", when it shouldn't've. At that point, dmd complained because it didn't find the file.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Apr 16, 2005 10:03 pm    Post subject: Reply with quote

Carlos wrote:
I was running build for dmd, and since it doesn't have version=DigitalMars set, it used "win32.windows", when it shouldn't've.
I think I understand now. Basically, you'd like build to automatically have the DigitalMars version set when you're using DMD. Is that it?

(I wonder if there is at least a way you could set the version manually.)
Back to top
View user's profile Send private message AIM Address
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sun Apr 17, 2005 12:53 am    Post subject: Reply with quote

jcc7 wrote:
Carlos wrote:
I was running build for dmd, and since it doesn't have version=DigitalMars set, it used "win32.windows", when it shouldn't've.
I think I understand now. Basically, you'd like build to automatically have the DigitalMars version set when you're using DMD. Is that it?

(I wonder if there is at least a way you could set the version manually.)

Okay, now I'm really confused!!!! Shocked

'dmd' stands for 'Digital Mars D' doesn't it? It's the compiler that is made by the DigitalMars organisation right? My copy of dmd.exe program does have the version 'DigitalMars' set. What version of dmd are you using? If you are using something called dmd and that is not supplied by Digital Mars, then it shouldn't have the version (DigitalMars) set because its not from DigitalMars!

However, if you actually need the foreign dmd to have it set, then set it on the command line ...

build -version=DigitalMars etc etc etc...

If you run build with the -V switch, it will show you what versions are actually set for it.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sun Apr 17, 2005 8:29 am    Post subject: Reply with quote

I agree with you both, Justin and Derek. But I have a question regarding your suggestion, Derek: what if some other time I compile for gdc? I'll have to maintain 2 command lines. The idea for build was to just type "build foo.d" and presto, you'd have your program/library ready. I'm sure it's not always that simple as projects get bigger, have more dependencies, etc., but your suggestion is almost as good as not having build (sure, it's an exaggeration). And no, I'm not flaming or anything, I just think it could be better, even if I don't know how.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun Apr 17, 2005 10:51 am    Post subject: Reply with quote

Okay, I'm confused again.

Derek, your program works great. I tried to break it and failed.

Carlos, I still really don't understand what you're trying to do, but you might just need to do it a different way. It sounds like you're trying to use version(DigitalMars) in a way that it wasn't meant to be used. Perhaps you can use a version(GDC) or a version(cygwin) or some other kind of version statement. Or maybe you just need to keep two slightly different versions of batch files to call build. I don't know. I hope one of my suggestions help, but since I'm unclear on the problem the odds are probably against that.
Back to top
View user's profile Send private message AIM Address
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sun Apr 17, 2005 3:29 pm    Post subject: Reply with quote

Carlos wrote:
I agree with you both, Justin and Derek. But I have a question regarding your suggestion, Derek: what if some other time I compile for gdc? I'll have to maintain 2 command lines. The idea for build was to just type "build foo.d" and presto, you'd have your program/library ready. I'm sure it's not always that simple as projects get bigger, have more dependencies, etc., but your suggestion is almost as good as not having build (sure, it's an exaggeration). And no, I'm not flaming or anything, I just think it could be better, even if I don't know how.

Have you read the documentation on Response Files. This is a mechanism to make it easy to have multiple editions from the same source file. It is similar in concept to a make file except that you don't need to put in all the file dependancies. For example, I have two response files for Build itself. One to create a debug edition and another to create a production edition. They look like this ...
Code:

# File: debug.brf
# This creates the 'debugging' edition of Build

build.d  # Starting file.

-info       # Show the version of build

-T{Target}_dbg # This is the target file.
-w          # Ensure warnings are on
-g          # Ensure debug info in placed in object files.
-unittest   # Turn on unit testing
-full       # Ensure everything gets recompiled.

# --Derek Parnell-- March 21, 2005 12:20:23 PM


Code:

# File: full.brf
# This creates a production / distribution edition of the program.

build.d         # Starting file

-info           # Show version of build utility
-release        # Removes runtime tests
-inline         # Allows inlining
-full           # Recompiles all files in the group

-T{Target}_prod # Name of target to build.

# -- Derek Parnell March 20, 2005 09:38:09 PM


And to use them I just type
Code:
build @debug

or
Code:
build @full


You could create two response files, one that had "-version=DigitalMars" and another that didn't. That would save you typing it in all the time. In fact, you can have multiple 'brf' files and mix them with command line options too. So you could make one file and all it contains is the -version switch ...
Code:

# File: dmd.brf
-version=DigitalMars

and then invoke Build thus ...
Code:
build myapp @dmd


By the way, I still don't understand what you are trying to do. If you are using the version(DigitalMars) within your code, then using it with the real dmd and with gdc should work fine. Can you please post a small program which fails to compile using build under dmd and gdc.
You shouldn't force DigitalMars to be set if you are using gdc.

Your original code example was
Code:

version(DigitalMars)
   import std.c.windows.windows;
else
   import win32.windows;

And that is telling the compiler that if you are using the compiler from Digital Mars, then import std.c.windows.windows but if you are not using a compiler from Digital Mars, then import win32.windows. And that is what you report Build as doing. So its doing what you asked it to do. That is why I'm confused. What were you expecting it to do?
If you don't want win32\windows.obj on the command line when compiling under gdc, why do you import it when not using a DigitalMars compiler?
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sun Apr 17, 2005 8:27 pm    Post subject: Reply with quote

DMD obviously ignores "import win32.windows;". See, on cygwin, gdc doesn't set version=Windows (as I said once in the DM ng), so (again) it static asserts on std.c.windows.windows. That's why I used win32.windows, but not for DMD because I didn't need it. As I assume you know, those are just import modules, they don't need to be linked in, so there's no win32\windows.obj, not even for gdc. Build shouldn't be passing that to the compiler. Now, DMD imports std.c.windows.windows and then (wrongly) looks for win32\windows.obj. Bang! Process fails.
I understand Build shouldn't set version=DigitalMars, because build ain't DM, but just ignoring it will cause problems, as I described above. What can be done, I don't know.

You know, maybe I am making a big deal out of it, but it is because build hadn't let me down before, and in that particular case, it did. I apologize for overreacting.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sun Apr 17, 2005 9:06 pm    Post subject: Reply with quote

I'm really sorry I'm so thick, but I still don't understand your problem. Embarassed

Carlos wrote:
DMD obviously ignores "import win32.windows;".

Just to confirm, when you say 'DMD' you are referring to the compiler produced by DigitalMars, right? And not to any other dmd, such as a script running under linux.

If that is the case, then I expect that DMD should ignore the "import win32.windows;". So it looks okay to me so far.

Carlos wrote:
See, on cygwin, gdc doesn't set version=Windows (as I said once in the DM ng), so (again) it static asserts on std.c.windows.windows.

Ok, that is to be expected. I see no problem yet.

Carlos wrote:
That's why I used win32.windows, but not for DMD because I didn't need it.

Still okay. This sounds reasonable. I assume that "win32\windows.d" is a module supplied by gdc. I don't have it as I'm only using DigitalMars products.

Carlos wrote:
As I assume you know, those are just import modules, they don't need to be linked in, so there's no win32\windows.obj, not even for gdc. Build shouldn't be passing that to the compiler.

No I didn't know that win32\windows.d is just some import modules. I don't have a copy of that file. Maybe this is where the problem lies. You see, when using DMD, a module that only contains 'header' stuff and no actual code, still produces a .obj file. Think of it as a pre-compiled header file. And thus, it is quite acceptable to place the .obj file on the command line instead of the source file. DMD handles it quite okay. It just means one less file to recompile.

Maybe gdc doesn't work like that? I really don't have here anyway of telling. What happens when using gdc to compile just win32\windows.d without linking? Is a .obj file produced by gdc?

Carlos wrote:
Now, DMD imports std.c.windows.windows and then (wrongly) looks for win32\windows.obj. Bang! Process fails.

Here is where I'm lost again. Why would DMD be looking for win32\windows.d if it's not on the command line (because of the version(DigitalMars) statement)? The way I see it, because of the version statements you have coded, DMD will only be looking for " std\c\windows\windows.d" and will not be looking for "win32\windows.d". Please use the -V switch and post the verbose output so I can see what is actually happening. I don't understand what you mean by "DMD looks for win32\windows.obj"

Carlos wrote:
I understand Build shouldn't set version=DigitalMars, because build ain't DM, but just ignoring it will cause problems, as I described above. What can be done, I don't know.

Again, I don't understand you. You say "just ignoring it", and does that mean "Build is just ignoring the version(DigitalMars) statement"?

I've asked this before and not quite got an answer but what exactly are you expecting from Build in this situation?

Carlos wrote:
You know, maybe I am making a big deal out of it, but it is because build hadn't let me down before, and in that particular case, it did. I apologize for overreacting.


I honestly want to help, and I'm willing to keep at this to make Build helpful, but I'm not getting enough detailed information from to you yet. Please post some sample code or the output of a -V run.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Mon Apr 18, 2005 2:45 pm    Post subject: Reply with quote

Ok, I have a working (or should I say "not working"?) sample. It was actually easier than I thought:

Code:

module myprog;

version(DigitalMars)
    import std.file;
else
    import mymod;

void main()
{
}


Put that file somewhere, but don't create mymod.d anywhere. That is, don't let build or dmd find it. Then run build: "build myprog". Here's what I get:

Code:

*** build v2.00 (build 700)***
Current Dir 'C:\home\carlos\dev\d\tests\b\bar\'
Compiler installed in c:\devtools\dmd\bin\
Configuration File installed in c:\devtools\dmd\bin\
Active Version: 'X86'
Active Version: 'Win32'
Active Version: 'LittleEndian'
Active Version: 'Windows'
Active Version: 'build'
Active Version: 'D_InlineAsm'
Active Version: 'DigitalMars'
Reading from config: c:\devtools\dmd\bin\sc.ini
 Line 1: [Version]
 Line 2: version=7.51 Build 020
 Line 3:
 Line 4: [Environment]
 Line 5: LIB="c:\devtools\dmd\bin\..\lib";c:\devtools\dm\lib
 use LIB="c:\devtools\dmd\lib\";"c:\devtools\dm\lib\"
 Line 6: DFLAGS="-Ic:\devtools\dmd\bin\..\src\phobos;c:\home\carlos\dev\d;c:\hom
e\carlos\dev\d\mango;c:\home\carlos\dev\d\Apollo"
 added root from config file c:\devtools\dmd\src\phobos\
 added root from config file c:\home\carlos\dev\d\
 added root from config file c:\home\carlos\dev\d\mango\
 added root from config file c:\home\carlos\dev\d\Apollo\
 Line 7: LINKCMD=c:\devtools\dmd\bin\..\..\dm\bin\link.exe
 file->module myprog.d => myprog
Time 2005/04/18 14:59:23 for myprog.d
Time not recorded for myprog.obj
Scanning myprog.d
Module name set to 'myprog'
 module->file std.file => c:\devtools\dmd\src\phobos\std\file.d
 module->file mymod => mymod.d
Ignoring c:\devtools\dmd\src\phobos\std\file.d (package: phobos)
 file->module mymod.d => mymod
Time not recorded for mymod.d
Time not recorded for mymod.obj
Scanning mymod.d
source file[0] mymod.d
source file[1] myprog.d
Newer time: from not recorded to 2005/04/18 14:59:23

Building target 'myprog.exe'
Time not recorded for C:\home\carlos\dev\d\tests\b\bar\myprog.exe (target)
Time 2005/04/18 14:59:23 (most recent)
myprog.d newer than its object file
Compiling with ..........
"-op"
"-Ic:\devtools\dmd\bin\..\src\phobos"
"-Ic:\home\carlos\dev\d"
"-Ic:\home\carlos\dev\d\mango"
"-Ic:\home\carlos\dev\d\Apollo"
"mymod.obj"
"myprog.d"
"myprog.def"
"-ofmyprog.exe"


Running 'c:\devtools\dmd\bin\dmd.exe @myprog.rsp'
c:\devtools\dmd\bin\..\..\dm\bin\link.exe mymod+myprog,myprog.exe,,user32+kernel
32,myprog.def/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

mymod.obj
 Error 2: File Not Found mymod.obj
--- errorlevel 1
Failed. Return code: 1


build args: ...............
 [ 0]: -V

compiler args: ................
 [ 0]: -op
 [ 1]: -Ic:\devtools\dmd\bin\..\src\phobos
 [ 2]: -Ic:\home\carlos\dev\d
 [ 3]: -Ic:\home\carlos\dev\d\mango
 [ 4]: -Ic:\home\carlos\dev\d\Apollo

command line files: ...............
 [ 0]: myprog.d

declared source files: ...............
 [ 0]: mymod.d
 [ 1]: myprog.d

import roots: .................
 [ 0]: c:\devtools\dmd\src\phobos\
 [ 1]: c:\home\carlos\dev\d\
 [ 2]: c:\home\carlos\dev\d\mango\
 [ 3]: c:\home\carlos\dev\d\Apollo\

ignored packages: .................
 [ 0]: phobos


I know what you're gonna say: "it's complaining because such file doesn't exist", but it shouldn't complain because that's why I'm using different versions. Also, build should catch such things (missing files) earlier. But I think the real problem is with how build is handling version.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Mon Apr 18, 2005 4:07 pm    Post subject: Reply with quote

Carlos wrote:
Ok, I have a working (or should I say "not working"?) sample. It was actually easier than I thought:

Thanks. The example helped me understand it now. Yes, there is a bug I need to fix. I'll get on to it today.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Mon Apr 18, 2005 6:22 pm    Post subject: Reply with quote

The problem is that Build is not handling the situation when a simple statement follows the version directive. As a workaround, place the statements inside braces ...

Code:

module myprog;

version(DigitalMars) {
    import std.file;
}
else {
    import mymod;
}

void main()
{
}

_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Build All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group