Archived

This forum has been archived. Please start a new discussion on GitHub.

Generating code from slice includes?

I'm trying to put some common logic into a central .ice file that gets "included" by some of my server definitions. The problem is that there's some tedium involved because I have to run slice2cpp on each of the included files as well as on my main slice file that includes them.

For example, if I define some kind of common structure:

struct Datum {
double data;
string unit;
};

That I want to use between various servers:

..

include <datum.ice>

module Something {
interface SomeServer {
} ...
};

...

include <datum.ice>

module Something2 {
interface SomeOtherServer {
};
};

Is there a way to tell "slice2cpp" to go ahead and run itself on any files that were "include"d in a slice definition file? The problem is that as I may be utilizing a bunch of different "datum.ice" like files for common structures between different servers and in my project files where I tell it which ice files to build it gets tedius to have to specify every single include dependency manually, particularly if some of them have includes, and some of their includes have includes, etc.

Thanks,
Caleb

Comments

  • You could of course compile all slice sources at once with something like this:

    $ slice2cpp *.ice
  • matthew
    matthew NL, Canada
    There is no way to do what you want. For that matter I'm not sure what you actually want to do. Each .ice file generates a .cpp and a .h file, so each one of these needs to be compiled also.
  • > There is no way to do what you want. For that matter I'm not sure what you actually want to do. Each .ice file generates a .cpp and a .h file, so each one of these needs to be compiled also.

    Righto. My projects basically use the .ice files and run slice2cpp on them on a fresh compile and automatically add the generated .cpp and .h files as dependencies. This way, instead of manually creating makefiles I can just create a list of the .ice files I am using for the project and my generator script does the rest.

    But obviously this fails unless I also include all of the .ice dependencies in my definition file.

    Anyway, I can work around it, but I was hoping there might be an easier way. Thanks for the comments.
  • matthew
    matthew NL, Canada
    Why don't you use the --depend option of the slice2cpp compiler to automatically generate the dependencies?