Go Back   ZeroC Forums > Patches

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 08-25-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
slice2freeze correct header with --output-dir option

Hi,

Here is a patch to 2.1.0 to fix the locations of slice output header files in the source generated by slice2freeze. The 2.1.0 code ignores the --output-dir option when inserting #include directives into its output. This patch corrects this oversight.

This fix assumes that if you use the --output-dir option for slice2freeze, you will use the same option for slice2cpp. This may not be the best assumption, but I believe it's better than what is currently done. This has been tested a little on gcc/Solaris, but it's portable code, so it should work elsewhere.

This patch should also work on version 2.1.2, but this hasn't been tested.

Cheers,

-- Andrew Bell
andrew.bell.ia@gmail.com
Attached Files
File Type: txt patch.txt (2.0 KB, 255 views)
Reply With Quote
  #2 (permalink)  
Old 11-28-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
Not in 3.0 - Another Solution?

Hi,

This patch didn't make it into 3.0. Did you code another solution? I didn't see anything obvious with a really quick look at the source. Do you have another recommendation for working around the problem?

Thanks,
Reply With Quote
  #3 (permalink)  
Old 11-28-2005
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,772
What exactly is the problem? --output-dir is not supposed to modify the #include statements. --include-dir is used for this purpose.
Reply With Quote
  #4 (permalink)  
Old 11-28-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
More Info

When you generate an index, you get two files, a .cpp and a .h. When you specify --include-dir, the specified directory is inserted in the #include statement in the .cpp so that the corresponding .h can be located.

The problem is that also included in the slice2freeze generated header file is a reference to a generated header that is built separately by slice2cpp. If you are using --output-dir when you run slice2cpp and slice2freeze, it puts all of the generated files in the location specified by output-dir, but there are header references to files generated by slice2freeze that don't respect this option. Instead, it uses the directory where the slice file was located. This isn't where the generated files are -- things won't build.

Here is an example. Put an ice file in a directory other than the one in which you are building. Run slice2freeze and slice2cpp on the file in the other directory with the --output-dir option set to ".". Take a look at the header file generated by slice2freeze and you will see that it tries to include files from the location of the ice file, rather than the location of the ouput directory, ".".

Hope this doesn't confuse too much

Thanks,
Reply With Quote
  #5 (permalink)  
Old 11-28-2005
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Hi Andrew,

The proper way to control the directories in a generated #include statement is to use -I options. For example, if I run the following command

$ slice2freeze ... MyMap slice/Ice/Identity.ice

then the generated file MyMap.h contains

#include <slice/Ice/Identity.h>

Essentially, the pathname of the Slice file is transferred directly to the #include statement.

However, if I use this command instead

$ slice2freeze ... -Islice MyMap slice/Ice/Identity.ice

then the generated file contains

#include <Ice/Identity.h>

The translator removes the include path "slice" from the generated #include statement. You must then use the proper compiler options that allow the preprocessor to find Ice/Identity.h.

Take care,
- Mark
Reply With Quote
  #6 (permalink)  
Old 11-28-2005
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
As a clarification, the C++ translators (slice2cpp and slice2freeze) assume that the Slice files and the generated include files have the same directory structure (e.g., slice/Ice/Identity.ice and include/Ice/Identity.h). You control the contents of the #include statements that the translators emit using -I options, and you use equivalent -I options for the C++ compiler. The --output-dir option is simply a convenience for relocating the generated files, but has no affect on the pathnames of #include statements.

- Mark
Reply With Quote
  #7 (permalink)  
Old 11-29-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
I think that this assumption about layout is unfortunate.

I believe that what you say about --output-dir not modifying the #include directives is incorrect. If you say:

slice2freeze --output-dir .. [junk omitted] foo_index foo.ice

The file foo_index.cpp, which is put in the directory one level above the current working directory, includes the line:

#include <../foo_index.h>

The ".." in the above construct comes from the --output-dir option, not from the --include-dir option. But this option has NO effect on the include directive for the slice2cpp-generated file in foo_index.h. The patch I offered treats the stuff in the header file the same as the stuff in the .cpp with respect to the --output-dir argument. The assumption is that if you are using --output-dir for slice2freeze, you are also using it for slice2cpp. Perhaps this isn't a good assumption, but I didn't see any way to deal with it without another option.

I'm really confused here. Is there a way to have a slice file in some other arbitrary directory and put all the generated code into the current working directory?

Thanks as always,
Reply With Quote
  #8 (permalink)  
Old 11-29-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
Bad Patch

Hi,

Just found that this patch doesn't work it you are using the --include-dir option. I'm not sure how the two (include-dir and output-dir) should interact, if at all.

I still wonder how to handle the case of the ice file being in some arbitrary directory and have output go to the current directory.

Last edited by acbell : 11-29-2005 at 12:13 PM.
Reply With Quote
  #9 (permalink)  
Old 11-29-2005
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Quote:
Originally Posted by acbell
I think that this assumption about layout is unfortunate.
The behavior of the translators is driven by our own needs in the Ice source tree, and we try to make them flexible enough to suit the needs of Ice developers.

Quote:
I believe that what you say about --output-dir not modifying the #include directives is incorrect. If you say:

slice2freeze --output-dir .. [junk omitted] foo_index foo.ice

The file foo_index.cpp, which is put in the directory one level above the current working directory, includes the line:

#include <../foo_index.h>
You're right. What I described is the intended behavior, but clearly slice2freeze is not behaving as we intended. We'll investigate this further.

Quote:
I'm really confused here. Is there a way to have a slice file in some other arbitrary directory and put all the generated code into the current working directory?
The translators generate files into the current working directory by default, so there is no need to use the --output-dir option if that's where you want the files to go. For example:

$ slice2freeze -I/path/to/slice ... MyMap /path/to/slice/Types.ice

This generates MyMap.h and MyMap.cpp in the current working directory. Because I specified the -I option, MyMap.h contains

#include <Types.h>

And since I did not use --output-dir, MyMap.cpp contains

#include <MyMap.h>

Is that what you are trying to achieve?

Take care,
- Mark
Reply With Quote
  #10 (permalink)  
Old 11-29-2005
acbell acbell is offline
Registered User
 
Name: Andrew Bell
Organization: Iowa State University
Project: National Resources Inventory
 
Join Date: Jan 2005
Location: Ames, IA, USA
Posts: 89
Thanks

Thanks for this. I guess that when I saw the --output-dir changing the include path, I ran with it. What I wasn't aware of was that -I would influence the creation of the include paths. This isn't what is in the documentation (at least in 2.1.2 docs section 4.18). This should be stressed somewhere, and some small note should be placed in the help for the preprocessors (slice2freeze -?). This explanation is super-helpful:

slice2cpp & --include-dir

Thanks, and sorry for the hassle.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Patch #8 for Ice 3.1.0: support for paths with spaces in -I option benoit Patches 2 01-05-2007 04:50 AM
about slice2freeze Yunqiao Yin Comments 0 11-01-2005 08:25 PM
Link error when adding MFC header in dll project emoly Help Center 7 09-12-2005 07:49 AM
my option about AMD rc_hz Help Center 18 06-03-2005 03:23 AM


All times are GMT -4. The time now is 04:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.