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

2017-04-06 Thread asfgit
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


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

2017-04-06 Thread zuyu
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


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

2017-04-06 Thread zuyu
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


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

2017-04-06 Thread cramja
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 
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---