aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-02-02 12:42:54 -0800
committerGravatar Yuchen Zeng <zyc@google.com>2017-02-02 12:42:54 -0800
commit1492f6c6fbef0036b9c9dd58311998a196bdb83a (patch)
treef3bb887cfb8836d023f538f33b1eb7f0c885951e /templates
parent86d2115553bb0eaf0f02c78c9f1d7696c42f424c (diff)
parent26623b3d77ae78e66f66b996593acf57a7cf1197 (diff)
Merge remote-tracking branch 'upstream/master' into cares_bazel_rule
Diffstat (limited to 'templates')
-rw-r--r--templates/CMakeLists.txt.template144
-rw-r--r--templates/src/csharp/Grpc.Core.Testing/project.json.template41
-rwxr-xr-xtemplates/src/csharp/build_packages_dotnetcli.bat.template1
-rwxr-xr-xtemplates/src/csharp/build_packages_dotnetcli.sh.template1
-rw-r--r--templates/src/php/composer.json.template6
5 files changed, 183 insertions, 10 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 7fe536468e..c755e9ae80 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -59,16 +59,28 @@
deps.append("${_gRPC_PROTOBUF_PROTOC_LIBRARIES}")
if target_dict.get('secure', False):
deps.append("${_gRPC_SSL_LIBRARIES}")
- if target_dict['name'] in ['grpc++', 'grpc++_unsecure', 'grpc++_codegen_lib']:
+ if target_dict.language == 'c++':
deps.append("${_gRPC_PROTOBUF_LIBRARIES}")
- elif target_dict['name'] in ['grpc']:
+ if target_dict['name'] in ['grpc']:
deps.append("${_gRPC_ZLIB_LIBRARIES}")
deps.append("${_gRPC_CARES_LIBRARIES}")
+ deps.append("${_gRPC_ALLTARGETS_LIBRARIES}")
for d in target_dict.get('deps', []):
deps.append(d)
if target_dict.build == 'test' and target_dict.language == 'c++':
deps.append("${_gRPC_GFLAGS_LIBRARIES}")
return deps
+
+ def get_platforms_condition_begin(platforms):
+ if all(platform in platforms for platform in ['linux', 'mac', 'posix', 'windows']):
+ return ''
+ cond = ' OR '.join(['_gRPC_PLATFORM_%s' % platform.upper() for platform in platforms])
+ return 'if(%s)\n' % cond
+
+ def get_platforms_condition_end(platforms):
+ if not get_platforms_condition_begin(platforms):
+ return ''
+ return 'endif()\n'
%>
cmake_minimum_required(VERSION 2.8)
@@ -104,8 +116,24 @@
set(gRPC_GFLAGS_PROVIDER "module" CACHE STRING "Provider of gflags library")
set_property(CACHE gRPC_GFLAGS_PROVIDER PROPERTY STRINGS "module" "package")
+ set(gRPC_BENCHMARK_PROVIDER "module" CACHE STRING "Provider of benchmark library")
+ set_property(CACHE gRPC_BENCHMARK_PROVIDER PROPERTY STRINGS "module" "package")
+
set(gRPC_USE_PROTO_LITE OFF CACHE BOOL "Use the protobuf-lite library")
+ if(UNIX)
+ if(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Linux")
+ set(_gRPC_PLATFORM_LINUX ON)
+ elseif(<%text>${CMAKE_SYSTEM_NAME}</%text> MATCHES "Darwin")
+ set(_gRPC_PLATFORM_MAC ON)
+ else()
+ set(_gRPC_PLATFORM_POSIX ON)
+ endif()
+ endif()
+ if(WIN32)
+ set(_gRPC_PLATFORM_WINDOWS ON)
+ endif()
+
if (MSVC)
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
# needed to compile boringssl
@@ -214,6 +242,7 @@
set(BORINGSSL_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/boringssl)
endif()
if(EXISTS "<%text>${BORINGSSL_ROOT_DIR}</%text>/CMakeLists.txt")
+ set(OPENSSL_NO_ASM ON) # make boringssl buildable with Visual Studio
add_subdirectory(<%text>${BORINGSSL_ROOT_DIR}</%text> third_party/boringssl)
if(TARGET ssl)
set(_gRPC_SSL_LIBRARIES ssl)
@@ -249,11 +278,35 @@
set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags)\nendif()")
endif()
+ if("<%text>${gRPC_BENCHMARK_PROVIDER}</%text>" STREQUAL "module")
+ if(NOT BENCHMARK_ROOT_DIR)
+ set(BENCHMARK_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/benchmark)
+ endif()
+ if(EXISTS "<%text>${BENCHMARK_ROOT_DIR}</%text>/CMakeLists.txt")
+ add_subdirectory(<%text>${BENCHMARK_ROOT_DIR}</%text> third_party/benchmark)
+ if(TARGET benchmark)
+ set(_gRPC_BENCHMARK_LIBRARIES benchmark)
+ endif()
+ else()
+ message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
+ endif()
+ elseif("<%text>${gRPC_BENCHMARK_PROVIDER}</%text>" STREQUAL "package")
+ find_package(benchmark)
+ if(TARGET benchmark::benchmark)
+ set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark)
+ endif()
+ set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark)\nendif()")
+ endif()
+
if(NOT MSVC)
- set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c11")
+ set(CMAKE_C_FLAGS "<%text>${CMAKE_C_FLAGS}</%text> -std=c99")
set(CMAKE_CXX_FLAGS "<%text>${CMAKE_CXX_FLAGS}</%text> -std=c++11")
endif()
+ if(UNIX)
+ set(_gRPC_ALLTARGETS_LIBRARIES dl rt m pthread)
+ endif()
+
if(WIN32 AND MSVC)
set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32)
endif()
@@ -312,9 +365,63 @@
endforeach()
endfunction()
+ add_custom_target(plugins
+ DEPENDS
+ % for tgt in targets:
+ % if tgt.build == 'protoc':
+ ${tgt.name}
+ % endif
+ % endfor
+ )
+
+ add_custom_target(tools_c
+ DEPENDS
+ % for tgt in targets:
+ % if tgt.build == 'tool' and not tgt.language == 'c++':
+ ${tgt.name}
+ % endif
+ % endfor
+ )
+
+ add_custom_target(tools_cxx
+ DEPENDS
+ % for tgt in targets:
+ % if tgt.build == 'tool' and tgt.language == 'c++':
+ ${tgt.name}
+ % endif
+ % endfor
+ )
+
+ add_custom_target(tools
+ DEPENDS tools_c tools_cxx)
+
+ if (gRPC_BUILD_TESTS)
+ add_custom_target(buildtests_c)
+ % for tgt in targets:
+ % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
+ ${get_platforms_condition_begin(tgt.platforms)}\
+ add_dependencies(buildtests_c ${tgt.name})
+ ${get_platforms_condition_end(tgt.platforms)}\
+ % endif
+ % endfor
+
+ add_custom_target(buildtests_cxx)
+ % for tgt in targets:
+ % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
+ ${get_platforms_condition_begin(tgt.platforms)}\
+ add_dependencies(buildtests_cxx ${tgt.name})
+ ${get_platforms_condition_end(tgt.platforms)}\
+ % endif
+ % endfor
+
+ add_custom_target(buildtests
+ DEPENDS buildtests_c buildtests_cxx)
+ endif (gRPC_BUILD_TESTS)
+
% for lib in libs:
- % if lib.build in ["all", "protoc", "tool", "test", "private"] and lib.language in ['c', 'c++']:
+ % if lib.build in ["all", "protoc", "tool", "test", "private"] and not lib.boringssl:
% if not lib.get('build_system', []) or 'cmake' in lib.get('build_system', []):
+ % if not lib.name in ['benchmark', 'z']: # we build these using CMake instead
% if lib.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
${cc_library(lib)}
@@ -325,17 +432,22 @@
% endif
% endif
% endif
+ % endif
% endfor
% for tgt in targets:
- % if tgt.build in ["all", "protoc", "tool", "test", "private"] and tgt.language in ['c', 'c++']:
+ % if tgt.build in ["all", "protoc", "tool", "test", "private"] and not tgt.boringssl:
% if tgt.build in ["test", "private"]:
if (gRPC_BUILD_TESTS)
+ ${get_platforms_condition_begin(tgt.platforms)}\
${cc_binary(tgt)}
+ ${get_platforms_condition_end(tgt.platforms)}\
endif (gRPC_BUILD_TESTS)
% else:
+ ${get_platforms_condition_begin(tgt.platforms)}\
${cc_binary(tgt)}
${cc_install(tgt)}
+ ${get_platforms_condition_end(tgt.platforms)}\
% endif
% endif
% endfor
@@ -368,6 +480,7 @@
PRIVATE <%text>${BORINGSSL_ROOT_DIR}</%text>/include
PRIVATE <%text>${PROTOBUF_ROOT_DIR}</%text>/src
PRIVATE <%text>${ZLIB_INCLUDE_DIR}</%text>
+ PRIVATE <%text>${BENCHMARK}</%text>/include
PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/zlib
PRIVATE <%text>${CARES_INCLUDE_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/c-ares
@@ -376,7 +489,7 @@
PRIVATE third_party/googletest/include
PRIVATE third_party/googletest
% endif
- % if any(proto_re.match(src) for src in lib.src):
+ % if lib.language == 'c++':
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
@@ -407,18 +520,34 @@
<%def name="cc_binary(tgt)">
add_executable(${tgt.name}
% for src in tgt.src:
+ % if not proto_re.match(src):
${src}
+ % else:
+ ${proto_replace_ext(src, '.pb.cc')}
+ ${proto_replace_ext(src, '.grpc.pb.cc')}
+ ${proto_replace_ext(src, '.pb.h')}
+ ${proto_replace_ext(src, '.grpc.pb.h')}
+ % endif
% endfor
% if tgt.build == 'test' and tgt.language == 'c++':
third_party/googletest/src/gtest-all.cc
% endif
)
+ % for src in tgt.src:
+ % if proto_re.match(src):
+ protobuf_generate_grpc_cpp(
+ ${src}
+ )
+ % endif
+ % endfor
+
target_include_directories(${tgt.name}
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/include
PRIVATE <%text>${BORINGSSL_ROOT_DIR}</%text>/include
PRIVATE <%text>${PROTOBUF_ROOT_DIR}</%text>/src
+ PRIVATE <%text>${BENCHMARK_ROOT_DIR}</%text>/include
PRIVATE <%text>${ZLIB_ROOT_DIR}</%text>
PRIVATE <%text>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/zlib
PRIVATE <%text>${CARES_ROOT_DIR}</%text>
@@ -428,6 +557,9 @@
PRIVATE third_party/googletest/include
PRIVATE third_party/googletest
% endif
+ % if tgt.language == 'c++':
+ PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
+ % endif
)
% if len(get_deps(tgt)) > 0:
diff --git a/templates/src/csharp/Grpc.Core.Testing/project.json.template b/templates/src/csharp/Grpc.Core.Testing/project.json.template
new file mode 100644
index 0000000000..7aff991145
--- /dev/null
+++ b/templates/src/csharp/Grpc.Core.Testing/project.json.template
@@ -0,0 +1,41 @@
+%YAML 1.2
+--- |
+ {
+ "version": "${settings.csharp_version}",
+ "title": "gRPC C# Core Testing",
+ "authors": [ "Google Inc." ],
+ "copyright": "Copyright 2017, Google Inc.",
+ "packOptions": {
+ "summary": "Testing support for gRPC C#",
+ "description": "Useful when testing code that uses gRPC.",
+ "owners": [ "grpc-packages" ],
+ "licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE",
+ "projectUrl": "https://github.com/grpc/grpc",
+ "requireLicenseAcceptance": false,
+ "tags": [ "gRPC test testing" ]
+ },
+ "buildOptions": {
+ "define": [ "SIGNED" ],
+ "keyFile": "../keys/Grpc.snk",
+ "xmlDoc": true,
+ "compile": {
+ "includeFiles": [ "../Grpc.Core/Version.cs" ]
+ }
+ },
+ "dependencies": {
+ "Grpc.Core": "${settings.csharp_version}"
+ },
+ "frameworks": {
+ "net45": {
+ "frameworkAssemblies": {
+ "System.Runtime": "",
+ "System.IO": ""
+ }
+ },
+ "netstandard1.5": {
+ "dependencies": {
+ "NETStandard.Library": "1.6.0"
+ }
+ }
+ }
+ }
diff --git a/templates/src/csharp/build_packages_dotnetcli.bat.template b/templates/src/csharp/build_packages_dotnetcli.bat.template
index 562b7704ab..2f91d485ec 100755
--- a/templates/src/csharp/build_packages_dotnetcli.bat.template
+++ b/templates/src/csharp/build_packages_dotnetcli.bat.template
@@ -61,6 +61,7 @@
%%DOTNET% restore . || goto :error
%%DOTNET% pack --configuration Release Grpc.Core\project.json --output ..\..\artifacts || goto :error
+ %%DOTNET% pack --configuration Release Grpc.Core.Testing\project.json --output ..\..\artifacts || goto :error
%%DOTNET% pack --configuration Release Grpc.Auth\project.json --output ..\..\artifacts || goto :error
%%DOTNET% pack --configuration Release Grpc.HealthCheck\project.json --output ..\..\artifacts || goto :error
%%DOTNET% pack --configuration Release Grpc.Reflection\project.json --output ..\..\artifacts || goto :error
diff --git a/templates/src/csharp/build_packages_dotnetcli.sh.template b/templates/src/csharp/build_packages_dotnetcli.sh.template
index 91c6fb6928..c5364377b9 100755
--- a/templates/src/csharp/build_packages_dotnetcli.sh.template
+++ b/templates/src/csharp/build_packages_dotnetcli.sh.template
@@ -63,6 +63,7 @@
dotnet restore .
dotnet pack --configuration Release Grpc.Core/project.json --output ../../artifacts
+ dotnet pack --configuration Release Grpc.Core.Testing/project.json --output ../../artifacts
dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifacts
dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts
dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts
diff --git a/templates/src/php/composer.json.template b/templates/src/php/composer.json.template
index 5223efd23f..08710d3e71 100644
--- a/templates/src/php/composer.json.template
+++ b/templates/src/php/composer.json.template
@@ -15,10 +15,8 @@
"autoload": {
"psr-4": {
"Grpc\\": "lib/Grpc/",
- "Grpc\\Testing\\": "tests/interop/Grpc/Testing/",
- "GPBMetadata\\Src\\Proto\\Grpc\\Testing\\": "tests/interop/GPBMetadata/Src/Proto/Grpc/Testing/",
- "Math\\": "tests/generated_code/Math/",
- "GPBMetadata\\": "tests/generated_code/GPBMetadata/"
+ "": ["tests/interop/",
+ "tests/generated_code/"]
}
}
}