Boost logo

Boost-Build :

Subject: Re: [Boost-build] Preprocessed output
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-03-30 17:07:55


On 3/29/2011 4:08 PM, Steven Watanabe wrote:
> AMDG
>
> On 03/29/2011 12:39 PM, Edward Diener wrote:
>> On 3/29/2011 2:34 PM, Steven Watanabe wrote:
>>> On 03/29/2011 11:10 AM, Edward Diener wrote:
>>>> How do I tell Boost Build to generate preprocessed output, either when
>>>> using the 'compile' rule or using some other rule ?
>>>>
>>>> I tried, for gcc, adding an -E to the command line as a cxxflag but the
>>>> compile rule still attempted to compile the file and no output was
>>>> produced. I need to send preprocessed output to a file without
>>>> compiling
>>>> the preprocessed output.
>>>>
>>>
>>> I don't think there's a way to do this at present.
>>
>> That is unfortunate. I guess I am forced to do it by hand after manually
>> copying the command-line output of the 'compile' rule for a given
>> compiler and altering it as necessary.
>>
>>> It shouldn't be too hard to add, though. There would
>>> need to be a new target type and rules in the toolset
>>> modules to generate it.
>>>
>>> I needed this for my template profiler, but I only
>>> implemented it for msvc and gcc and not in a particularly
>>> reusable way.
>>
>> Right now I only need it for msvc and gcc on Windows also.
>>
>
> I'm probably not going to get to this
> immediately, but if you file a trac
> ticket, so I don't forget, I'll try
> to get it done within a few weeks.

I filed a ticket at https://svn.boost.org/trac/boost/ticket/5390 .

>
>>>
>>> a) Does it need to distinguish between C and C++?
>>> I think so, since we want exactly the same compiler
>>> flags that would be passed to create an object file.
>>
>> That would be ideal, if the preprocessor really works differently
>> depending on whether the compiling mode is for C or C++. I was not aware
>> that it does.
>>
>
> It should mostly be the same. Except for:
> a) Effects of cxxflags vs. cflags.
> b) #ifdef __cplusplus.

You are correct.

>
>>> b) What should the name of the type be? This will
>>> also control the name of the main target rule.
>>
>> preproc
>>
>
> Normally the name of the type is
> the same as the default extension.
> If we use something different, I'd
> personally rather spell out the whole word.

Then make the extension .preproc . In this case I do not think it is an
advantage to have the name of the extension the same as the name of he type.

>
> Actually, we probably want to use
> a single rule for C and C++ and deduce
> which is which from the source. We
> should also propagate that information
> through, so that a preprocessed file
> can be compiled correctly.
>
>>> c) What should the extension be. I know msvc uses .i
>>> by default for preprocessor output. Unless they're
>>> already used by something else, we could make it
>>> .i and .ipp.
>>
>> I think that is fine.
>>
>
> On the other hand, .ipp is used in a few places in
> Boost with a different meaning, so it's probably
> not a good choice. Would it be confusing to use
> .i for everything? Do you know of any other
> common convention?

I vote for .i but the name of the type/rule must be longer and I think
preproc is fine.


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk