diff options
author | Muxi Yan <mxyan@google.com> | 2017-02-06 13:40:43 -0800 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-02-06 13:40:43 -0800 |
commit | 7a008c9311c037524b3401c81983e8788d71d679 (patch) | |
tree | 3a619e8be6d0d425a621bcda4f8758e276579f69 /templates | |
parent | 1783bd3c99c51b75402fac2195926c1ffd3b6c72 (diff) | |
parent | d6d2677637fee5d2988dae08cee1b909d822c650 (diff) |
Merge remote-tracking branch 'upstream/master' into automate-objc-version-advancement
Diffstat (limited to 'templates')
-rw-r--r-- | templates/CMakeLists.txt.template | 159 | ||||
-rw-r--r-- | templates/Makefile.template | 3 | ||||
-rw-r--r-- | templates/composer.json.template | 3 | ||||
-rw-r--r-- | templates/gRPC-Core.podspec.template | 13 | ||||
-rw-r--r-- | templates/src/csharp/Grpc.Core.Testing/project.json.template | 41 | ||||
-rwxr-xr-x | templates/src/csharp/build_packages_dotnetcli.bat.template | 1 | ||||
-rwxr-xr-x | templates/src/csharp/build_packages_dotnetcli.sh.template | 1 | ||||
-rw-r--r-- | templates/src/php/composer.json.template | 14 | ||||
-rw-r--r-- | templates/test/core/end2end/end2end_defs.include | 3 | ||||
-rw-r--r-- | templates/tools/run_tests/generated/tests.json.template | 2 |
10 files changed, 207 insertions, 33 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index a326f36fe9..444fb6a2dc 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -59,15 +59,27 @@ 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_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) @@ -100,12 +112,30 @@ 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() + + ## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + if (MSVC) + include(cmake/msvc_static_runtime.cmake) 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 - add_definitions(/wd4464 /wd4623 /wd4668 /wd4701 /wd4702 /wd4777 /wd5027) # needed to compile protobuf add_definitions(/wd4065 /wd4506) # TODO(jtattermusch): revisit C4267 occurrences throughout the code @@ -189,6 +219,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) @@ -223,12 +254,36 @@ endif() 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() @@ -287,9 +342,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)} @@ -300,23 +409,28 @@ % 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 <%def name="cc_library(lib)"> - add_library(${lib.name} + add_library(${lib.name}${' SHARED' if lib.get('dll', None) == 'only' else ''} % for src in lib.src: % if not proto_re.match(src): ${src} @@ -343,13 +457,14 @@ 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>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/gflags/include % if lib.build in ['test', 'private'] and lib.language == 'c++': 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 ) @@ -380,18 +495,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>${CMAKE_CURRENT_BINARY_DIR}</%text>/third_party/gflags/include @@ -399,6 +530,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: @@ -420,13 +554,6 @@ endif() </%def> - if (gRPC_INSTALL) - install(EXPORT gRPCTargets - DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR}</%text> - NAMESPACE gRPC:: - ) - endif() - foreach(_config gRPCConfig gRPCConfigVersion) configure_file(tools/cmake/<%text>${_config}</%text>.cmake.in <%text>${_config}</%text>.cmake @ONLY) diff --git a/templates/Makefile.template b/templates/Makefile.template index 6f4db26f2b..10d7861f03 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -135,9 +135,6 @@ ${arg}_${name} = ${args.get(arg)} % endif % endfor - % if args.get('timeout_multiplier', 1) != 1: - DEFINES_${name} += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=${args.timeout_multiplier} - % endif % endfor diff --git a/templates/composer.json.template b/templates/composer.json.template index 3b4d62f24d..f56ecb69d6 100644 --- a/templates/composer.json.template +++ b/templates/composer.json.template @@ -9,8 +9,7 @@ "license": "BSD-3-Clause", "require": { "php": ">=5.5.0", - "ext-grpc": "*", - "google/protobuf": "v3.1.0-alpha-1" + "google/protobuf": "v3.1.0" }, "require-dev": { "google/auth": "v0.9" diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 18dabb9603..5b5e68dc52 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -166,13 +166,22 @@ s.subspec 'Cronet-Implementation' do |ss| ss.header_mappings_dir = '.' + + ss.dependency "#{s.name}/Interface", version + ss.dependency "#{s.name}/Implementation", version + ss.dependency "#{s.name}/Cronet-Interface", version + ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c', - 'src/core/ext/transport/cronet/transport/cronet_transport.c' + 'src/core/ext/transport/cronet/transport/cronet_transport.c', + 'third_party/objective_c/Cronet/bidirectional_stream_c.h' end s.subspec 'Tests' do |ss| ss.header_mappings_dir = '.' + ss.dependency "#{s.name}/Interface", version + ss.dependency "#{s.name}/Implementation", version + ss.source_files = 'test/core/end2end/cq_verifier.{c,h}', 'test/core/end2end/end2end_tests.{c,h}', 'test/core/end2end/end2end_test_utils.c', @@ -182,7 +191,5 @@ 'test/core/util/port.h', 'test/core/util/port_posix.c', 'test/core/util/port_server_client.{c,h}' - - ss.dependency 'CronetFramework' end end 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 12a4ce8f83..ecc516d1c4 100644 --- a/templates/src/php/composer.json.template +++ b/templates/src/php/composer.json.template @@ -1,24 +1,22 @@ %YAML 1.2 --- | { - "name": "grpc/grpc", - "type": "library", - "description": "gRPC library for PHP", - "keywords": ["rpc"], - "homepage": "http://grpc.io", + "name": "grpc/grpc-dev", + "description": "gRPC library for PHP - for Developement use only", "license": "BSD-3-Clause", "version": "${settings.php_version.php_composer()}", "require": { "php": ">=5.5.0", - "ext-grpc": "*", - "google/protobuf": "v3.1.0-alpha-1" + "google/protobuf": "v3.1.0" }, "require-dev": { "google/auth": "v0.9" }, "autoload": { "psr-4": { - "Grpc\\": "lib/Grpc/" + "Grpc\\": "lib/Grpc/", + "": ["tests/interop/", + "tests/generated_code/"] } } } diff --git a/templates/test/core/end2end/end2end_defs.include b/templates/test/core/end2end/end2end_defs.include index b828f84f1c..68b9e69c2f 100644 --- a/templates/test/core/end2end/end2end_defs.include +++ b/templates/test/core/end2end/end2end_defs.include @@ -42,6 +42,8 @@ #include <grpc/support/log.h> +#include "test/core/util/debugger_macros.h" + static bool g_pre_init_called = false; % for test in tests: @@ -52,6 +54,7 @@ extern void ${test}_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; + grpc_summon_debugger_macros(); % for test in tests: ${test}_pre_init(); % endfor diff --git a/templates/tools/run_tests/generated/tests.json.template b/templates/tools/run_tests/generated/tests.json.template index 1e21465dd2..2815dbb9b3 100644 --- a/templates/tools/run_tests/generated/tests.json.template +++ b/templates/tools/run_tests/generated/tests.json.template @@ -11,7 +11,7 @@ "gtest": tgt.gtest, "exclude_configs": tgt.get("exclude_configs", []), "exclude_iomgrs": tgt.get("exclude_iomgrs", []), - "args": [], + "args": tgt.get("args", []), "flaky": tgt.flaky, "cpu_cost": tgt.get("cpu_cost", 1.0)} for tgt in targets |