You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by jeeyoung kim <je...@gmail.com> on 2011/06/02 20:27:48 UTC

Recommended way to incorporate thrift to the build system.

Hey guys.

I was wondering what is the recommended way to incorporate thrift into to
the build system. Right now, for the build system @ work, we just compile
the *.thrift file, and commit them in the source repository. This works, but
it doesn't feel very comfortable committing automatically generated files.

For other builds @ work, we're using CMake to compile the c++ project. Any
solution that uses make / cmake / some other build system would be
appreciated. thanks.

-Jee

Re: Recommended way to incorporate thrift to the build system.

Posted by jeeyoung kim <je...@gmail.com>.
More update on my side.

I was looking at a CMake module that does very similar thing - mainly, CMake
module that compiles Google Protobuf.

http://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Modules/FindProtobuf.cmake;hb=HEAD

<http://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Modules/FindProtobuf.cmake;hb=HEAD>it
creates a new target, with its own input target (*.proto files) and output
targets (*.cc and *.h files).

I think one the major different (with respect to build system) between
protobuf and thrift is that with protobuf, you can predict what the output
files are going to be for the compiled protobuf files (x.proto generates
x.pb.cc and x.pb.h), but with thrift, you cannot know it unless you read the
actual *.thrift file, because each services generate its own file.

On Thu, Jun 2, 2011 at 11:27 AM, jeeyoung kim <je...@gmail.com> wrote:

> Hey guys.
>
> I was wondering what is the recommended way to incorporate thrift into to
> the build system. Right now, for the build system @ work, we just compile
> the *.thrift file, and commit them in the source repository. This works, but
> it doesn't feel very comfortable committing automatically generated files.
>
> For other builds @ work, we're using CMake to compile the c++ project. Any
> solution that uses make / cmake / some other build system would be
> appreciated. thanks.
>
> -Jee
>

Re: Recommended way to incorporate thrift to the build system.

Posted by Jake Farrell <jf...@apache.org>.
Diwaker
if there is something missing from the thrift documentation then we should add it to the documentation rather than starting a second set of documentation. Fragmenting the guides and how-to docs will not benefit a new user who is just starting out and will only make it harder to keep things up to date. I agree that we are lacking in rich documentation, but i think that with a little effort we can greatly help the project as a whole. Your initial steps at adding missing pieces is great and I would love to incorporate this into the existing thrift wiki. If the wiki is proving to be too hard to maintain and having it checked into the repo would be better (similar to the website) then i'm all for that as well. If you would like to discuss this or any ideas you have on making the documentation better please email me or find me in the #thrift irc channel

Jake



On Jun 3, 2011, at 12:54 PM, Diwaker Gupta wrote:

> Thanks Roberto, that's a good point. We use Maven for Java projects
> and GNU Make for C++ projects with Thrift at work and the integration
> has been relatively easy so far. I'm happy to add examples for CMake
> and other build systems if they're useful.
> 
> Diwaker
> 
> On Fri, Jun 3, 2011 at 2:09 AM, Roberto Aloi
> <ro...@erlang-solutions.com> wrote:
>> This is actually a very good point. Why not to add a complete example to:
>> 
>> https://github.com/diwakergupta/thrift-missing-guide
>> 
>> That would be extremely helpful for most Thrift developer and would avoid re-inventing the wheel for many of them.
>> 
>> Regards,
>> 
>> Roberto Aloi
>> @robertoaloi
>> 
>> ----- "Jake Farrell" <jf...@apache.org> wrote:
>> 
>>> Have you tried using something like this yet? if you need an example
>>> with make let me know
>>> 
>>> Jake
>>> 
>>> 
>>> SET( THRIFT_FILE "something.thrift" )
>>> SET( THRIFT_OUTDIR ${CMAKE_CURRENT_LIST_DIR})
>>> SET(THRIFT_FLAGS "-r --gen-cpp:pure_enums -o
>>> ${CMAKE_CURRENT_LIST_DIR}")
>>> 
>>> FIND_PROGRAM(THIRFT_BIN thrift /bin /usr/bin /usr/local/bin)
>>> IF (THIRFT_BIN)
>>>   SET( THRIFT_COMMAND "${THIRFT_BIN} ${THRIFT_FLAGS} ${THRIFT_FILE}")
>>>   IF(EXISTS THRIFT_FILE)
>>>     MESSAGE("Generating ${THRIFT_COMMAND}")
>>>     execute_process(THRIFT_COMMAND . RESULT_VARIABLE result)
>>>     MESSAGE("Result: ${result}")
>>>     SET_DIRECTORY_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}
>>> ADDITIONAL_MAKE_CLEAN_FILES ${THRIFT_OUTDIR})
>>>   ENDIF(EXISTS THRIFT_FILE)
>>> ELSE(THIRFT_BIN)
>>>     MESSAGE(SEND_ERROR "Cannot find thrift in your path.")
>>> ENDIF(THIRFT_BIN)
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Jun 2, 2011, at 1:27 PM, jeeyoung kim wrote:
>>> 
>>>> Hey guys.
>>>> 
>>>> I was wondering what is the recommended way to incorporate thrift
>>> into to
>>>> the build system. Right now, for the build system @ work, we just
>>> compile
>>>> the *.thrift file, and commit them in the source repository. This
>>> works, but
>>>> it doesn't feel very comfortable committing automatically generated
>>> files.
>>>> 
>>>> For other builds @ work, we're using CMake to compile the c++
>>> project. Any
>>>> solution that uses make / cmake / some other build system would be
>>>> appreciated. thanks.
>>>> 
>>>> -Jee
>> 


Re: Recommended way to incorporate thrift to the build system.

Posted by Diwaker Gupta <di...@maginatics.com>.
Thanks Roberto, that's a good point. We use Maven for Java projects
and GNU Make for C++ projects with Thrift at work and the integration
has been relatively easy so far. I'm happy to add examples for CMake
and other build systems if they're useful.

Diwaker

On Fri, Jun 3, 2011 at 2:09 AM, Roberto Aloi
<ro...@erlang-solutions.com> wrote:
> This is actually a very good point. Why not to add a complete example to:
>
> https://github.com/diwakergupta/thrift-missing-guide
>
> That would be extremely helpful for most Thrift developer and would avoid re-inventing the wheel for many of them.
>
> Regards,
>
> Roberto Aloi
> @robertoaloi
>
> ----- "Jake Farrell" <jf...@apache.org> wrote:
>
>> Have you tried using something like this yet? if you need an example
>> with make let me know
>>
>> Jake
>>
>>
>> SET( THRIFT_FILE "something.thrift" )
>> SET( THRIFT_OUTDIR ${CMAKE_CURRENT_LIST_DIR})
>> SET(THRIFT_FLAGS "-r --gen-cpp:pure_enums -o
>> ${CMAKE_CURRENT_LIST_DIR}")
>>
>> FIND_PROGRAM(THIRFT_BIN thrift /bin /usr/bin /usr/local/bin)
>> IF (THIRFT_BIN)
>>   SET( THRIFT_COMMAND "${THIRFT_BIN} ${THRIFT_FLAGS} ${THRIFT_FILE}")
>>   IF(EXISTS THRIFT_FILE)
>>     MESSAGE("Generating ${THRIFT_COMMAND}")
>>     execute_process(THRIFT_COMMAND . RESULT_VARIABLE result)
>>     MESSAGE("Result: ${result}")
>>     SET_DIRECTORY_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}
>> ADDITIONAL_MAKE_CLEAN_FILES ${THRIFT_OUTDIR})
>>   ENDIF(EXISTS THRIFT_FILE)
>> ELSE(THIRFT_BIN)
>>     MESSAGE(SEND_ERROR "Cannot find thrift in your path.")
>> ENDIF(THIRFT_BIN)
>>
>>
>>
>>
>>
>> On Jun 2, 2011, at 1:27 PM, jeeyoung kim wrote:
>>
>> > Hey guys.
>> >
>> > I was wondering what is the recommended way to incorporate thrift
>> into to
>> > the build system. Right now, for the build system @ work, we just
>> compile
>> > the *.thrift file, and commit them in the source repository. This
>> works, but
>> > it doesn't feel very comfortable committing automatically generated
>> files.
>> >
>> > For other builds @ work, we're using CMake to compile the c++
>> project. Any
>> > solution that uses make / cmake / some other build system would be
>> > appreciated. thanks.
>> >
>> > -Jee
>

Re: Recommended way to incorporate thrift to the build system.

Posted by Roberto Aloi <ro...@erlang-solutions.com>.
This is actually a very good point. Why not to add a complete example to:

https://github.com/diwakergupta/thrift-missing-guide

That would be extremely helpful for most Thrift developer and would avoid re-inventing the wheel for many of them.

Regards,

Roberto Aloi
@robertoaloi

----- "Jake Farrell" <jf...@apache.org> wrote:

> Have you tried using something like this yet? if you need an example
> with make let me know
> 
> Jake
>  
> 
> SET( THRIFT_FILE "something.thrift" )
> SET( THRIFT_OUTDIR ${CMAKE_CURRENT_LIST_DIR})
> SET(THRIFT_FLAGS "-r --gen-cpp:pure_enums -o
> ${CMAKE_CURRENT_LIST_DIR}")
> 
> FIND_PROGRAM(THIRFT_BIN thrift /bin /usr/bin /usr/local/bin)
> IF (THIRFT_BIN)
>   SET( THRIFT_COMMAND "${THIRFT_BIN} ${THRIFT_FLAGS} ${THRIFT_FILE}")
>   IF(EXISTS THRIFT_FILE)
>     MESSAGE("Generating ${THRIFT_COMMAND}")
>     execute_process(THRIFT_COMMAND . RESULT_VARIABLE result)
>     MESSAGE("Result: ${result}")
>     SET_DIRECTORY_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}
> ADDITIONAL_MAKE_CLEAN_FILES ${THRIFT_OUTDIR}) 
>   ENDIF(EXISTS THRIFT_FILE)
> ELSE(THIRFT_BIN)
>     MESSAGE(SEND_ERROR "Cannot find thrift in your path.")
> ENDIF(THIRFT_BIN)
> 
> 
> 
> 
> 
> On Jun 2, 2011, at 1:27 PM, jeeyoung kim wrote:
> 
> > Hey guys.
> > 
> > I was wondering what is the recommended way to incorporate thrift
> into to
> > the build system. Right now, for the build system @ work, we just
> compile
> > the *.thrift file, and commit them in the source repository. This
> works, but
> > it doesn't feel very comfortable committing automatically generated
> files.
> > 
> > For other builds @ work, we're using CMake to compile the c++
> project. Any
> > solution that uses make / cmake / some other build system would be
> > appreciated. thanks.
> > 
> > -Jee

Re: Recommended way to incorporate thrift to the build system.

Posted by Jake Farrell <jf...@apache.org>.
Have you tried using something like this yet? if you need an example with make let me know

Jake
 

SET( THRIFT_FILE "something.thrift" )
SET( THRIFT_OUTDIR ${CMAKE_CURRENT_LIST_DIR})
SET(THRIFT_FLAGS "-r --gen-cpp:pure_enums -o ${CMAKE_CURRENT_LIST_DIR}")

FIND_PROGRAM(THIRFT_BIN thrift /bin /usr/bin /usr/local/bin)
IF (THIRFT_BIN)
  SET( THRIFT_COMMAND "${THIRFT_BIN} ${THRIFT_FLAGS} ${THRIFT_FILE}")
  IF(EXISTS THRIFT_FILE)
    MESSAGE("Generating ${THRIFT_COMMAND}")
    execute_process(THRIFT_COMMAND . RESULT_VARIABLE result)
    MESSAGE("Result: ${result}")
    SET_DIRECTORY_PROPERTIES(${CMAKE_CURRENT_LIST_DIR} ADDITIONAL_MAKE_CLEAN_FILES ${THRIFT_OUTDIR}) 
  ENDIF(EXISTS THRIFT_FILE)
ELSE(THIRFT_BIN)
    MESSAGE(SEND_ERROR "Cannot find thrift in your path.")
ENDIF(THIRFT_BIN)





On Jun 2, 2011, at 1:27 PM, jeeyoung kim wrote:

> Hey guys.
> 
> I was wondering what is the recommended way to incorporate thrift into to
> the build system. Right now, for the build system @ work, we just compile
> the *.thrift file, and commit them in the source repository. This works, but
> it doesn't feel very comfortable committing automatically generated files.
> 
> For other builds @ work, we're using CMake to compile the c++ project. Any
> solution that uses make / cmake / some other build system would be
> appreciated. thanks.
> 
> -Jee