diff options
author | 2016-11-08 08:45:18 -0800 | |
---|---|---|
committer | 2016-11-08 08:45:18 -0800 | |
commit | a7a956fe16e85b15363ce720d1d9c08bf09c69b8 (patch) | |
tree | f4a8397ee740506247335b0077cd54444ca9510e /templates | |
parent | b65e234f7af6df1625ccd4dec386e0fa2f573eb7 (diff) | |
parent | b065b31c257a9562114433d880ce19985bc3a0a3 (diff) |
Merge github.com:grpc/grpc into fuzzit
Diffstat (limited to 'templates')
-rw-r--r-- | templates/CMakeLists.txt.template | 2 | ||||
-rw-r--r-- | templates/Makefile.template | 135 | ||||
-rw-r--r-- | templates/src/cpp/common/version_cc.cc.template | 43 |
3 files changed, 137 insertions, 43 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 2b6c0b1a36..c3c636c6af 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -60,7 +60,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") - set(PACKAGE_VERSION "${settings.core_version}") + set(PACKAGE_VERSION "${settings.cpp_version}") set(PACKAGE_STRING "<%text>${PACKAGE_NAME} ${PACKAGE_VERSION}</%text>") set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}</%text>") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/templates/Makefile.template b/templates/Makefile.template index 3b76ded95d..109de33c31 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -62,6 +62,12 @@ return warning[3:] else: return 'no-' + warning + + lang_to_var = { + 'c': 'CORE', + 'c++': 'CPP', + 'csharp': 'CSHARP' + } %> @@ -311,7 +317,9 @@ Q = @ endif - VERSION = ${settings.core_version} + CORE_VERSION = ${settings.core_version} + CPP_VERSION = ${settings.cpp_version} + CSHARP_VERSION = ${settings.csharp_version} CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -344,31 +352,69 @@ CACHE_MK += HAS_PKG_CONFIG = true, endif - PC_TEMPLATE = prefix=$(prefix),\ + CORE_PC_TEMPLATE = prefix=$(prefix),\ + exec_prefix=${'\$${prefix}'},\ + includedir=${'\$${prefix}'}/include,\ + libdir=${'\$${exec_prefix}'}/lib,\ + ,\ + Name: $(PC_NAME),\ + Description: $(PC_DESCRIPTION),\ + Version: $(CORE_VERSION),\ + Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ + Requires.private: $(PC_REQUIRES_PRIVATE),\ + Libs: -L${'\$${libdir}'} $(PC_LIB),\ + Libs.private: $(PC_LIBS_PRIVATE) + + CPP_PC_TEMPLATE = prefix=$(prefix),\ + exec_prefix=${'\$${prefix}'},\ + includedir=${'\$${prefix}'}/include,\ + libdir=${'\$${exec_prefix}'}/lib,\ + ,\ + Name: $(PC_NAME),\ + Description: $(PC_DESCRIPTION),\ + Version: $(CPP_VERSION),\ + Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ + Requires.private: $(PC_REQUIRES_PRIVATE),\ + Libs: -L${'\$${libdir}'} $(PC_LIB),\ + Libs.private: $(PC_LIBS_PRIVATE) + + CSHARP_PC_TEMPLATE = prefix=$(prefix),\ exec_prefix=${'\$${prefix}'},\ includedir=${'\$${prefix}'}/include,\ libdir=${'\$${exec_prefix}'}/lib,\ ,\ Name: $(PC_NAME),\ Description: $(PC_DESCRIPTION),\ - Version: $(VERSION),\ + Version: $(CSHARP_VERSION),\ Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ Requires.private: $(PC_REQUIRES_PRIVATE),\ Libs: -L${'\$${libdir}'} $(PC_LIB),\ Libs.private: $(PC_LIBS_PRIVATE) ifeq ($(SYSTEM),MINGW32) - SHARED_EXT = dll + SHARED_EXT_CORE = dll + SHARED_EXT_CPP = dll + SHARED_EXT_CSHARP = dll SHARED_PREFIX = - SHARED_VERSION = -${settings.core_version.major} + SHARED_VERSION_CORE = -${settings.core_version.major} + SHARED_VERSION_CPP = -${settings.cpp_version.major} + SHARED_VERSION_CSHARP = -${settings.csharp_version.major} else ifeq ($(SYSTEM),Darwin) - SHARED_EXT = dylib + SHARED_EXT_CORE = dylib + SHARED_EXT_CPP = dylib + SHARED_EXT_CSHARP = dylib SHARED_PREFIX = lib - SHARED_VERSION = + SHARED_VERSION_CORE = + SHARED_VERSION_CPP = + SHARED_VERSION_CSHARP = else - SHARED_EXT = so.$(VERSION) + SHARED_EXT_CORE = so.$(CORE_VERSION) + SHARED_EXT_CPP = so.$(CPP_VERSION) + SHARED_EXT_CSHARP = so.$(CSHARP_VERSION) SHARED_PREFIX = lib - SHARED_VERSION = + SHARED_VERSION_CORE = + SHARED_VERSION_CPP = + SHARED_VERSION_CSHARP = endif ifeq ($(wildcard .git),) @@ -603,7 +649,7 @@ PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE) PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE) PC_LIB = -lgrpc - GRPC_PC_FILE := $(PC_TEMPLATE) + GRPC_PC_FILE := $(CORE_PC_TEMPLATE) # grpc_unsecure .pc file PC_NAME = gRPC unsecure @@ -612,7 +658,7 @@ PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) PC_LIB = -lgrpc - GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE) + GRPC_UNSECURE_PC_FILE := $(CORE_PC_TEMPLATE) PROTOBUF_PKG_CONFIG = false @@ -680,7 +726,7 @@ PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX) PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX) PC_LIB = -lgrpc++ - GRPCXX_PC_FILE := $(PC_TEMPLATE) + GRPCXX_PC_FILE := $(CPP_PC_TEMPLATE) # grpc++_unsecure .pc file PC_NAME = gRPC++ unsecure @@ -689,7 +735,7 @@ PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX) PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX) PC_LIB = -lgrpc++ - GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE) + GRPCXX_UNSECURE_PC_FILE := $(CPP_PC_TEMPLATE) ifeq ($(MAKECMDGOALS),clean) NO_DEPS = true @@ -855,7 +901,7 @@ % for lib in libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\ + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)\ % endif % endif % endfor @@ -864,7 +910,7 @@ % for lib in libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c++': - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\ + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)\ % endif % endif % endfor @@ -874,7 +920,7 @@ % for lib in libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'csharp': - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\ + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)\ % endif % endif % endfor @@ -1076,8 +1122,8 @@ % if lib.language == "c": % if lib.build == "all": % if not lib.get('external_deps', None): - $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) + $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" + $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) % endif % endif % endif @@ -1091,8 +1137,8 @@ % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "c++": % if lib.build == "all": - $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) + $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" + $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) % endif % endif % endif @@ -1105,8 +1151,8 @@ % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "csharp": % if lib.build == "all": - $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" - $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) + $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)" + $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) % endif % endif % endif @@ -1245,14 +1291,14 @@ % if lib.language == lang_filter: % if lib.build == "all": % if not lib.get('external_deps', None): - $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)" + $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]})" $(Q) $(INSTALL) -d $(prefix)/lib - $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) + $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT_${lang_to_var[lib.language]}) ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major} - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so + $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major} + $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/lib${lib.name}.so endif % endif % endif @@ -1364,7 +1410,7 @@ $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error % if lib.build == "all": - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): openssl_dep_error % endif else @@ -1377,7 +1423,7 @@ $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error % if lib.build == "all": - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): protobuf_dep_error % endif else @@ -1394,7 +1440,7 @@ $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error % if lib.build == "all": - $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error + $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): protobuf_dep_error % endif else @@ -1440,12 +1486,12 @@ else: ld = '$(LD)' - out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION)' - out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION)' + out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' + out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)' - libs = '' + link_libs = '' lib_deps = ' $(ZLIB_DEP)' mingw_libs = '' mingw_lib_deps = ' $(ZLIB_DEP)' @@ -1460,10 +1506,15 @@ mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive else: for dep in lib.get('deps', []): - libs = libs + ' -l' + dep - lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)' + dep_lib = None + for dl in libs: + if dl.name == dep: + dep_lib = dl + assert dep_lib, 'lib %s not found (in %s)' % (dep, lib.name) + link_libs = link_libs + ' -l' + dep + lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')' mingw_libs = mingw_libs + ' -l' + dep + '-imp' - mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)' + mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')' security = lib.get('secure', 'check') if security == True: @@ -1492,20 +1543,20 @@ % if lib.build == "all": ifeq ($(SYSTEM),MINGW32) - ${out_mingbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} + ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared ${lib.name}.def -Wl,--output-def=${out_mingbase}.def -Wl,--out-implib=${out_libbase}-dll.a -o ${out_mingbase}.$(SHARED_EXT) ${common}${mingw_libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared ${lib.name}.def -Wl,--output-def=${out_mingbase}.def -Wl,--out-implib=${out_libbase}-dll.a -o ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${mingw_libs} else - ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} + ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT_${lang_to_var[lib.language]}) -dynamiclib -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} else - $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so.${settings.core_version.major} - $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} + $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} + $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so endif endif % endif diff --git a/templates/src/cpp/common/version_cc.cc.template b/templates/src/cpp/common/version_cc.cc.template new file mode 100644 index 0000000000..d14e974f56 --- /dev/null +++ b/templates/src/cpp/common/version_cc.cc.template @@ -0,0 +1,43 @@ +%YAML 1.2 +--- | + /* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + /* This file is autogenerated from: + templates/src/core/surface/version.c.template */ + + #include <grpc++/grpc++.h> + + namespace grpc { + grpc::string Version() { return "${settings.cpp_version}"; } + } |