From 324140c2e9b4b10bc4b19dc30043a60ed051ed26 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Jan 2016 08:54:01 -0800 Subject: [PATCH 1/2] support static linkage for dependencies --- build.yaml | 3 ++- templates/Makefile.template | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build.yaml b/build.yaml index e513f0daf77..740e751af32 100644 --- a/build.yaml +++ b/build.yaml @@ -797,8 +797,9 @@ libs: src: - src/csharp/ext/grpc_csharp_ext.c deps: - - gpr - grpc + - gpr + deps_linkage: static dll: only vs_config_type: DynamicLibrary vs_packages: diff --git a/templates/Makefile.template b/templates/Makefile.template index ba5a80659c0..43ce6c5794a 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -1645,11 +1645,18 @@ if lib.language == 'c++': lib_deps += ' $(PROTOBUF_DEP)' mingw_lib_deps += ' $(PROTOBUF_DEP)' - for dep in lib.get('deps', []): - libs = libs + ' -l' + dep - lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)' - mingw_libs = mingw_libs + ' -l' + dep + '-imp' - mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)' + if lib.get('deps_linkage', None) == 'static': + for dep in lib.get('deps', []): + lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a' + common = common + ' ' + lib_archive + lib_deps = lib_deps + ' ' + lib_archive + 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)' + mingw_libs = mingw_libs + ' -l' + dep + '-imp' + mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)' security = lib.get('secure', 'check') if security == True: From 0f582a21982dbaa17a3e1873f8f4096c00386704 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Jan 2016 08:54:50 -0800 Subject: [PATCH 2/2] regenerate makefile --- BUILD | 2 +- Makefile | 10 +++++----- vsprojects/grpc_csharp_ext.sln | 2 +- .../vcxproj/grpc_csharp_ext/grpc_csharp_ext.vcxproj | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/BUILD b/BUILD index 2b386fb814c..56b5c12148d 100644 --- a/BUILD +++ b/BUILD @@ -969,8 +969,8 @@ cc_library( ".", ], deps = [ - ":gpr", ":grpc", + ":gpr", ], ) diff --git a/Makefile b/Makefile index 18363ec31ef..a62f95a3163 100644 --- a/Makefile +++ b/Makefile @@ -3694,18 +3694,18 @@ endif ifeq ($(SYSTEM),MINGW32) -$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/gpr.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/grpc.$(SHARED_EXT) $(OPENSSL_DEP) +$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) -lgpr-imp -lgrpc-imp + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) else -$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgpr.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc.$(SHARED_EXT) $(OPENSSL_DEP) +$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP) $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) -lgpr -lgrpc + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) -lgpr -lgrpc + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so.0 $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so endif diff --git a/vsprojects/grpc_csharp_ext.sln b/vsprojects/grpc_csharp_ext.sln index 1c824963f21..11d2204ba58 100644 --- a/vsprojects/grpc_csharp_ext.sln +++ b/vsprojects/grpc_csharp_ext.sln @@ -29,8 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_csharp_ext", "vcxproj\ lib = "True" EndProjectSection ProjectSection(ProjectDependencies) = postProject - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject Global diff --git a/vsprojects/vcxproj/grpc_csharp_ext/grpc_csharp_ext.vcxproj b/vsprojects/vcxproj/grpc_csharp_ext/grpc_csharp_ext.vcxproj index aa37d1dbead..fca7b725f2d 100644 --- a/vsprojects/vcxproj/grpc_csharp_ext/grpc_csharp_ext.vcxproj +++ b/vsprojects/vcxproj/grpc_csharp_ext/grpc_csharp_ext.vcxproj @@ -160,12 +160,12 @@ - - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} +