You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@quickstep.apache.org by cramja <gi...@git.apache.org> on 2017/04/06 20:50:30 UTC

[GitHub] incubator-quickstep pull request #228: Refactored out proto GenerateCPP func...

GitHub user cramja opened a pull request:

    https://github.com/apache/incubator-quickstep/pull/228

    Refactored out proto GenerateCPP function

    Refactored out the GenProto methods from the main cmakelist. This cuts down on clutter and is something I ran into when making the single-node-server.
    
    I also added some comments in the new cmake file.
    
    @zuyu could you review?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cramja/incubator-quickstep refactor-cmake-fn

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-quickstep/pull/228.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #228
    
----
commit aac91b43751b134e66544d6ba7b0ddc28538a453
Author: cramja <ma...@gmail.com>
Date:   2017-04-06T20:40:43Z

    Refactored out proto GenerateCPP function

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by cramja <gi...@git.apache.org>.
Github user cramja commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    What is an EOL? I thought what you were saying was to add a `\n` but is that not it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by cramja <gi...@git.apache.org>.
Github user cramja commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    D'oh I think what I read was `EOF` and was thinking, wtf, do I add a EOF?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep pull request #228: Refactored out proto GenerateCPP func...

Posted by zuyu <gi...@git.apache.org>.
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/228#discussion_r110269580
  
    --- Diff: cmake/QsProtobufGenerateCpp.cmake ---
    @@ -0,0 +1,80 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you under the Apache License, Version 2.0 (the
    +# "License"); you may not use this file except in compliance
    +# with the License.  You may obtain a copy of the License at
    +#
    +#   http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing,
    +# software distributed under the License is distributed on an
    +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +# KIND, either express or implied.  See the License for the
    +# specific language governing permissions and limitations
    +# under the License.
    +
    +# This function is partially based on a similar one from FindProtobuf.cmake,
    +# but it adds the ability to scan .proto files for imports and automatically
    +# set the proper dependencies.
    +#
    +#  QS_PROTOBUF_GENERATE_CPP(SRCS HDRS [PROTOFILES ...])
    +#
    +# - Example
    +#
    +# include(QsProtobufGenerateCpp)  NOTE: already included in /CMakeLists.txt
    +# QsProtobufGenerateCpp(storage_AggregationOperationState_proto_srcs
    +#                       storage_AggregationOperationState_proto_hdrs
    +#                       AggregationOperationState.proto)
    +# Requires CMake 2.6+
    +function(QS_PROTOBUF_GENERATE_CPP SRCS HDRS)
    +    if(NOT ARGN)
    --- End diff --
    
    Please reduce to two whitespace indentations.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by zuyu <gi...@git.apache.org>.
Github user zuyu commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    Pressing `<Enter>` adds `\n`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by zuyu <gi...@git.apache.org>.
Github user zuyu commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    LGTM!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep pull request #228: Refactored out proto GenerateCPP func...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-quickstep/pull/228


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by zuyu <gi...@git.apache.org>.
Github user zuyu commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    You've already added the `EOL`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep issue #228: Refactored out proto GenerateCPP function

Posted by cramja <gi...@git.apache.org>.
Github user cramja commented on the issue:

    https://github.com/apache/incubator-quickstep/pull/228
  
    @zuyu updated. I tried adding a new line but it doesn't seem to be added on github. Does it really matter? If not, I'll merge


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-quickstep pull request #228: Refactored out proto GenerateCPP func...

Posted by zuyu <gi...@git.apache.org>.
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/228#discussion_r110269621
  
    --- Diff: cmake/QsProtobufGenerateCpp.cmake ---
    @@ -0,0 +1,80 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you under the Apache License, Version 2.0 (the
    +# "License"); you may not use this file except in compliance
    +# with the License.  You may obtain a copy of the License at
    +#
    +#   http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing,
    +# software distributed under the License is distributed on an
    +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +# KIND, either express or implied.  See the License for the
    +# specific language governing permissions and limitations
    +# under the License.
    +
    +# This function is partially based on a similar one from FindProtobuf.cmake,
    +# but it adds the ability to scan .proto files for imports and automatically
    +# set the proper dependencies.
    +#
    +#  QS_PROTOBUF_GENERATE_CPP(SRCS HDRS [PROTOFILES ...])
    +#
    +# - Example
    +#
    +# include(QsProtobufGenerateCpp)  NOTE: already included in /CMakeLists.txt
    +# QsProtobufGenerateCpp(storage_AggregationOperationState_proto_srcs
    +#                       storage_AggregationOperationState_proto_hdrs
    +#                       AggregationOperationState.proto)
    +# Requires CMake 2.6+
    +function(QS_PROTOBUF_GENERATE_CPP SRCS HDRS)
    +    if(NOT ARGN)
    +        message(SEND_ERROR "Error: QS_PROTOBUF_GENERATE_CPP() called without any proto files")
    +        return()
    +    endif()
    +
    +    set(${SRCS})
    +    set(${HDRS})
    +    foreach(FIL ${ARGN})
    +        get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
    +        get_filename_component(FIL_WE ${FIL} NAME_WE)
    +
    +        # Scan for other protos imported in the .proto file.
    +        set(PROTO_IMPORT_TARGETS)
    +        file(STRINGS ${ABS_FIL} PROTO_SRC)
    +        foreach(PROTO_SRC_LINE ${PROTO_SRC})
    +            string(REGEX MATCH "import \"(.*)[.]proto\"" TMPMATCH ${PROTO_SRC_LINE})
    +            if (CMAKE_MATCH_1)
    +                string(REPLACE "/" "_" IMPORTED_PROTO_FLAT "${CMAKE_BINARY_DIR}/${CMAKE_MATCH_1}")
    +                string(REPLACE ":" "_" IMPORTED_PROTO_FLAT ${IMPORTED_PROTO_FLAT})
    +                list(APPEND PROTO_IMPORT_TARGETS "protoc_${IMPORTED_PROTO_FLAT}")
    +            endif()
    +        endforeach()
    +
    +        list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
    +        list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
    +
    +        # Note that this adds dependencies for the .proto file itself, as well as
    +        # for any proto imports and the protobuf library if we have to build it
    +        # ourselves.
    +        add_custom_command(
    +                OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
    +                "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
    +                COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
    +                ARGS --cpp_out  ${CMAKE_BINARY_DIR} -I${PROJECT_SOURCE_DIR} ${ABS_FIL}
    +                DEPENDS ${ABS_FIL} ${PROTO_IMPORT_TARGETS} ${PROTOBUF_GLOBAL_DEPS}
    +                COMMENT "Running C++ protocol buffer compiler on ${FIL}"
    +                VERBATIM)
    +
    +        # Make a custom global target so that we have something that protos in
    +        # other directories can depend on for imports.
    +        string(REPLACE "/" "_" PROTOC_TARGET_NAME "protoc_${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}")
    +        string(REPLACE ":" "_" PROTOC_TARGET_NAME ${PROTOC_TARGET_NAME})
    +        add_custom_target(${PROTOC_TARGET_NAME} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
    +    endforeach()
    +
    +    set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
    +    set(${SRCS} ${${SRCS}} PARENT_SCOPE)
    +    set(${HDRS} ${${HDRS}} PARENT_SCOPE)
    +endfunction()
    --- End diff --
    
    Please add `EOL`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---