Skip to content

Commit

Permalink
Merge pull request grpc#8107 from jtattermusch/backport_coreclr_support
Browse files Browse the repository at this point in the history
Backport CoreCLR support to v1.0.x
  • Loading branch information
jtattermusch committed Sep 19, 2016
2 parents 0da0412 + caa965b commit 10c57a0
Show file tree
Hide file tree
Showing 85 changed files with 826 additions and 473 deletions.
70 changes: 0 additions & 70 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,7 @@ server_registered_method_bad_client_test: $(BINDIR)/$(CONFIG)/server_registered_
simple_request_bad_client_test: $(BINDIR)/$(CONFIG)/simple_request_bad_client_test
unknown_frame_bad_client_test: $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test
window_overflow_bad_client_test: $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test
bad_ssl_alpn_server: $(BINDIR)/$(CONFIG)/bad_ssl_alpn_server
bad_ssl_cert_server: $(BINDIR)/$(CONFIG)/bad_ssl_cert_server
bad_ssl_alpn_test: $(BINDIR)/$(CONFIG)/bad_ssl_alpn_test
bad_ssl_cert_test: $(BINDIR)/$(CONFIG)/bad_ssl_cert_test
h2_census_test: $(BINDIR)/$(CONFIG)/h2_census_test
h2_compress_test: $(BINDIR)/$(CONFIG)/h2_compress_test
Expand Down Expand Up @@ -1298,9 +1296,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/simple_request_bad_client_test \
$(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test \
$(BINDIR)/$(CONFIG)/window_overflow_bad_client_test \
$(BINDIR)/$(CONFIG)/bad_ssl_alpn_server \
$(BINDIR)/$(CONFIG)/bad_ssl_cert_server \
$(BINDIR)/$(CONFIG)/bad_ssl_alpn_test \
$(BINDIR)/$(CONFIG)/bad_ssl_cert_test \
$(BINDIR)/$(CONFIG)/h2_census_test \
$(BINDIR)/$(CONFIG)/h2_compress_test \
Expand Down Expand Up @@ -1687,8 +1683,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/unknown_frame_bad_client_test || ( echo test unknown_frame_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing window_overflow_bad_client_test"
$(Q) $(BINDIR)/$(CONFIG)/window_overflow_bad_client_test || ( echo test window_overflow_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing bad_ssl_alpn_test"
$(Q) $(BINDIR)/$(CONFIG)/bad_ssl_alpn_test || ( echo test bad_ssl_alpn_test failed ; exit 1 )
$(E) "[RUN] Testing bad_ssl_cert_test"
$(Q) $(BINDIR)/$(CONFIG)/bad_ssl_cert_test || ( echo test bad_ssl_cert_test failed ; exit 1 )

Expand Down Expand Up @@ -13700,38 +13694,6 @@ ifneq ($(NO_DEPS),true)
endif


BAD_SSL_ALPN_SERVER_SRC = \
test/core/bad_ssl/servers/alpn.c \

BAD_SSL_ALPN_SERVER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_SSL_ALPN_SERVER_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/bad_ssl_alpn_server: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/bad_ssl_alpn_server: $(BAD_SSL_ALPN_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(BAD_SSL_ALPN_SERVER_OBJS) $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_alpn_server

endif

$(OBJDIR)/$(CONFIG)/test/core/bad_ssl/servers/alpn.o: $(LIBDIR)/$(CONFIG)/libbad_ssl_test_server.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_bad_ssl_alpn_server: $(BAD_SSL_ALPN_SERVER_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(BAD_SSL_ALPN_SERVER_OBJS:.o=.dep)
endif
endif


BAD_SSL_CERT_SERVER_SRC = \
test/core/bad_ssl/servers/cert.c \

Expand Down Expand Up @@ -13764,38 +13726,6 @@ endif
endif


BAD_SSL_ALPN_TEST_SRC = \
test/core/bad_ssl/bad_ssl_test.c \

BAD_SSL_ALPN_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BAD_SSL_ALPN_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/bad_ssl_alpn_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/bad_ssl_alpn_test: $(BAD_SSL_ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(BAD_SSL_ALPN_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bad_ssl_alpn_test

endif

$(OBJDIR)/$(CONFIG)/test/core/bad_ssl/bad_ssl_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_bad_ssl_alpn_test: $(BAD_SSL_ALPN_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(BAD_SSL_ALPN_TEST_OBJS:.o=.dep)
endif
endif


BAD_SSL_CERT_TEST_SRC = \
test/core/bad_ssl/bad_ssl_test.c \

Expand Down
18 changes: 15 additions & 3 deletions src/csharp/Grpc.Auth/Grpc.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,26 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Core">
<HintPath>..\packages\Google.Apis.Core.1.15.0\lib\net45\Google.Apis.Core.dll</HintPath>
<HintPath>..\packages\Google.Apis.Core.1.16.0\lib\net45\Google.Apis.Core.dll</HintPath>
</Reference>
<Reference Include="Zlib.Portable">
<HintPath>..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath>
</Reference>
<Reference Include="Google.Apis">
<HintPath>..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.PlatformServices">
<HintPath>..\packages\Google.Apis.1.16.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth">
<HintPath>..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.dll</HintPath>
<HintPath>..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth.PlatformServices">
<HintPath>..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
<HintPath>..\packages\Google.Apis.Auth.1.16.0\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/csharp/Grpc.Auth/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.7.0" targetFramework="net45" />
<package id="Google.Apis.Auth" version="1.15.0" targetFramework="net45" />
<package id="Google.Apis.Core" version="1.15.0" targetFramework="net45" />
<package id="Google.Apis" version="1.16.0" targetFramework="net45" />
<package id="Google.Apis.Auth" version="1.16.0" targetFramework="net45" />
<package id="Google.Apis.Core" version="1.16.0" targetFramework="net45" />
<package id="log4net" version="2.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="Zlib.Portable.Signed" version="1.11.0" targetFramework="net45" />
</packages>
9 changes: 2 additions & 7 deletions src/csharp/Grpc.Auth/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@
},
"dependencies": {
"Grpc.Core": "1.0.1-pre1",
"Google.Apis.Auth": "1.15.0"
"Google.Apis.Auth": "1.16.0"
},
"frameworks": {
"net45": { },
"netstandard1.5": {
"imports": [
"portable-net45"
],
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"System.Threading.Tasks": "4.0.11"
"NETStandard.Library": "1.6.0"
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/csharp/Grpc.Core.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
}
}
},
"runtimes": {
"win7-x64": { },
"debian.8-x64": { },
"osx.10.11-x64": { }
},

"dependencies": {
"Grpc.Core": {
Expand All @@ -66,8 +61,10 @@
"portable-net45"
],
"dependencies": {
"Microsoft.NETCore.App": "1.0.0",
"NETStandard.Library": "1.6.0"
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
},
Expand Down
14 changes: 7 additions & 7 deletions src/csharp/Grpc.Core/GrpcEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,21 @@ public static void Register()
{
if (!hooksRegistered)
{
// TODO(jtattermusch): register shutdownhooks for CoreCLR as well
#if !NETSTANDARD1_5

AppDomain.CurrentDomain.ProcessExit += ShutdownHookHandler;
AppDomain.CurrentDomain.DomainUnload += ShutdownHookHandler;
#if NETSTANDARD1_5
System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += (assemblyLoadContext) => { HandleShutdown(); };
#else
AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => { HandleShutdown(); };
AppDomain.CurrentDomain.DomainUnload += (sender, eventArgs) => { HandleShutdown(); };
#endif
}
hooksRegistered = true;
}
}

/// <summary>
/// Handler for AppDomain.DomainUnload and AppDomain.ProcessExit hooks.
/// Handler for AppDomain.DomainUnload, AppDomain.ProcessExit and AssemblyLoadContext.Unloading hooks.
/// </summary>
private static void ShutdownHookHandler(object sender, EventArgs e)
private static void HandleShutdown()
{
Task.WaitAll(GrpcEnvironment.ShutdownChannelsAsync(), GrpcEnvironment.KillServersAsync());
}
Expand Down
18 changes: 9 additions & 9 deletions src/csharp/Grpc.Core/Internal/NativeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ private static UnmanagedLibrary Load()

// With old-style VS projects, the native libraries get copied using a .targets rule to the build output folder
// alongside the compiled assembly.
// With dotnet cli projects, the native libraries (just the required ones) are similarly copied to the built output folder,
// through the magic of Microsoft.NETCore.Platforms.
// With dotnet cli projects targeting net45 framework, the native libraries (just the required ones)
// are similarly copied to the built output folder, through the magic of Microsoft.NETCore.Platforms.
var classicPath = Path.Combine(assemblyDirectory, GetNativeLibraryFilename());

// DNX-style project.json projects will use Grpc.Core assembly directly in the location where it got restored
// With dotnet cli project targeting netcoreapp1.0, projects will use Grpc.Core assembly directly in the location where it got restored
// by nuget. We locate the native libraries based on known structure of Grpc.Core nuget package.
// When "dotnet publish" is used, the runtimes directory is copied next to the published assemblies.
string runtimesDirectory = string.Format("runtimes/{0}/native", GetPlatformString());
var netCorePublishedAppStylePath = Path.Combine(assemblyDirectory, runtimesDirectory, GetNativeLibraryFilename());
var netCoreAppStylePath = Path.Combine(assemblyDirectory, "../..", runtimesDirectory, GetNativeLibraryFilename());

// TODO: Support .NET Core applications, which act slightly differently. We may be okay if "dotnet publish"
// is used, but "dotnet run" leaves the native libraries in-package, while copying assemblies.
string platform = GetPlatformString();
string relativeDirectory = string.Format("../../runtimes/{0}/native", platform);
var dnxStylePath = Path.Combine(assemblyDirectory, relativeDirectory, GetNativeLibraryFilename());
string[] paths = new[] { classicPath, dnxStylePath };
// Look for all native library in all possible locations in given order.
string[] paths = new[] { classicPath, netCorePublishedAppStylePath, netCoreAppStylePath};
return new UnmanagedLibrary(paths);
}

Expand Down
4 changes: 1 addition & 3 deletions src/csharp/Grpc.Core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
"frameworks": {
"net45": { },
"netstandard1.5": {
"imports": [
"portable-net45"
],
"dependencies": {
"NETStandard.Library": "1.6.0",
"System.Runtime.Loader": "4.0.0",
"System.Threading.Thread": "4.0.0"
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/csharp/Grpc.Examples.MathClient/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
}
}
},
"runtimes": {
"win7-x64": { },
"debian.8-x64": { },
"osx.10.11-x64": { }
},

"dependencies": {
"Grpc.Examples": {
Expand All @@ -56,12 +51,11 @@
"frameworks": {
"net45": { },
"netcoreapp1.0": {
"imports": [
"portable-net45"
],
"dependencies": {
"Microsoft.NETCore.App": "1.0.0",
"NETStandard.Library": "1.6.0"
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/csharp/Grpc.Examples.MathServer/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
}
}
},
"runtimes": {
"win7-x64": { },
"debian.8-x64": { },
"osx.10.11-x64": { }
},

"dependencies": {
"Grpc.Examples": {
Expand All @@ -56,12 +51,11 @@
"frameworks": {
"net45": { },
"netcoreapp1.0": {
"imports": [
"portable-net45"
],
"dependencies": {
"Microsoft.NETCore.App": "1.0.0",
"NETStandard.Library": "1.6.0"
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-beta3\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
Expand All @@ -48,6 +45,9 @@
<Reference Include="nunitlite">
<HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs">
Expand Down
4 changes: 2 additions & 2 deletions src/csharp/Grpc.Examples.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-beta3" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" />
<package id="NUnit" version="3.2.0" targetFramework="net45" />
<package id="NUnitLite" version="3.2.0" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
</packages>
11 changes: 4 additions & 7 deletions src/csharp/Grpc.Examples.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
}
}
},
"runtimes": {
"win7-x64": { },
"debian.8-x64": { },
"osx.10.11-x64": { }
},

"dependencies": {
"Grpc.Examples": {
Expand All @@ -62,8 +57,10 @@
"portable-net45"
],
"dependencies": {
"Microsoft.NETCore.App": "1.0.0",
"NETStandard.Library": "1.6.0"
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
Expand Down
Loading

0 comments on commit 10c57a0

Please sign in to comment.