Skip to content

Add build support for CXX consumers #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

jieyu
Copy link
Member

@jieyu jieyu commented Aug 4, 2017

This patch chain adds the support for CXX consumers. It uses cmake as the configuration tooling. Currently, it only generates the headers and a static library.

@jieyu jieyu mentioned this pull request Aug 4, 2017
CMakeLists.txt Outdated
cmake_minimum_required(VERSION 3.3)

set(PACKAGE_NAME "csi")
set(PACKAGE_VERSION "0.0.1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the version be "0.1.0"?

CMakeLists.txt Outdated
COMMENT "Generating protobuf file from the spec"
)

add_library(${PACKAGE_NAME} ${CSI_CXX_PROTO_SOURCES})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the protobuf and grpc headers are in non-standard paths, the compilation of this library will fail. Let's add the following lines after Line 52:

find_path(PROTOBUF_INCLUDE_DIR google/protobuf/message.h)
find_path(GRPC_INCLUDE_DIR grpc++/grpc++.h)

and the following after this line:

target_include_directories(
  ${PACKAGE_NAME}
  PUBLIC ${PROTOBUF_INCLUDE_DIR}
  PUBLIC ${GRPC_INCLUDE_DIR}
)

Copy link
Contributor

@chhsia0 chhsia0 Aug 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use the headers in non-standard paths, we can then add -DCMAKE_INCLUDE_PATH="<protobuf_path>;<grpc_path>;..." when running cmake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, let's not do this but ask the user to set up CMAKE_CXX_FLAGS instead.

CMakeLists.txt Outdated

set(CMAKE_CXX_STANDARD 11)

find_program(PROTOBUF_COMPILER NAMES protoc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAMES not required here. Ditto below.

@@ -228,6 +228,9 @@ There are three sets of RPCs:
* **Node Service**: The Node Plugin MUST implement this sets of RPCs.

```protobuf
syntax = "proto3";
Copy link
Contributor

@chhsia0 chhsia0 Aug 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines will make the original make command fail due to Lines 124 & 138 in csi.mk. We probably want to either: 1. remove this and re-generate them in CMake; or 2. fix csi.mk; or 3. deprecate csi.mk and change the CI test.

CMakeLists.txt Outdated

set(CMAKE_CXX_STANDARD 11)

find_program(PROTOBUF_COMPILER NAMES protoc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about doing find_program only if PROTOBUF_COMPILER is not set? Then the user can set up it directly instead of setting up CMAKE_PROGRAM_PATH. Ditto below.


```bash
$ CSI_SPEC_FILE=spec.md make csi.proto
$ mkdir build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the point of including golang build support here is to encourage people to reuse these bits then ... we've failed. this is too much to ask of golang devs. a typical golang devs workflow is go get github.com/org/project/package.

this all feels too complex for what the original CI scripts were attempting to do: validate that the protos in the spec actually compiled to something. I somewhat regret accepting a PR that complicated the process. This PR adds additional prerequisites and process .. things that I don't think are actually appropriate for this repo.

I guess I could be convinced otherwise, but as of this moment I don't see the justification for making this repo more complex.

@jdef jdef mentioned this pull request Aug 10, 2017
set(PROTOBUF_COMPILER ${PROTOBUF_COMPILER_PATH})
endif ()

if (NOT GRPC_CXX_PLUGIN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (NOT GRPC_CXX_PLUGIN_PATH)

Also, do we want to document these variables in the README file?

set(GRPC_CXX_PLUGIN ${GRPC_CXX_PLUGIN_PATH})
endif ()

if (NOT GRPC_GO_PLUGIN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (NOT GRPC_GO_PLUGIN_PATH)


if (NOT GRPC_CXX_PLUGIN)
find_program(GRPC_CXX_PLUGIN grpc_cpp_plugin)
else()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow the same style and put a space between else and (). Ditto below.

@akutz
Copy link
Contributor

akutz commented Aug 11, 2017

This will need to be rebased onto the PR #74 regarding bindings. I concur re: documenting the vars in the readme. See what I did for the old csi.mk file. However, please use the lib/cxx/README.md file for this (again, please see PR #74).

@jieyu
Copy link
Member Author

jieyu commented Aug 15, 2017

Close this for now. I'll resend a PR later that rebase onto the current master.

@jieyu jieyu closed this Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants