Browse Source

finalized build layout

c6burns 6 years ago
parent
commit
103c49a065

+ 2 - 2
Directory.Build.props

@@ -29,8 +29,8 @@
     </PropertyGroup>
     </PropertyGroup>
 
 
     <PropertyGroup>
     <PropertyGroup>
-        <PluginDir>$(SlnDir)PluginOutput</PluginDir>
-        <PluginArchDir>x86_64\</PluginArchDir>
+        <PluginDir>$(SlnDir)build_cmake_enet\</PluginDir>
+        <PluginArchDir></PluginArchDir>
         <PluginBaseName>enet</PluginBaseName>
         <PluginBaseName>enet</PluginBaseName>
         
         
         <PluginPrefix Condition="'$(OSPlatformLinux)' == 'true'">lib</PluginPrefix>
         <PluginPrefix Condition="'$(OSPlatformLinux)' == 'true'">lib</PluginPrefix>

+ 69 - 56
ENet-CSharp.sln

@@ -1,56 +1,69 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
-MinimumVisualStudioVersion = 15.0.26124.0
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MSBuild", "MSBuild", "{3F0B29E5-FF51-4A21-871E-8F70E34C7CBF}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMake", "MSBuild\CMake\CMake.csproj", "{C47E0036-4655-4448-8F29-FEBE850E5A08}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{62667EDC-E795-4351-80C6-324911DB7B69}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENet-CSharp", "Source\Managed\ENet-CSharp.csproj", "{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Debug|x64 = Debug|x64
-		Debug|x86 = Debug|x86
-		Release|Any CPU = Release|Any CPU
-		Release|x64 = Release|x64
-		Release|x86 = Release|x86
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|x64.ActiveCfg = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|x64.Build.0 = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Debug|x86.Build.0 = Debug|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|Any CPU.Build.0 = Release|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|x64.ActiveCfg = Release|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|x64.Build.0 = Release|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|x86.ActiveCfg = Release|Any CPU
-		{C47E0036-4655-4448-8F29-FEBE850E5A08}.Release|x86.Build.0 = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|x64.ActiveCfg = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|x64.Build.0 = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Debug|x86.Build.0 = Debug|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|Any CPU.Build.0 = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|x64.ActiveCfg = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|x64.Build.0 = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|x86.ActiveCfg = Release|Any CPU
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4}.Release|x86.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(NestedProjects) = preSolution
-		{C47E0036-4655-4448-8F29-FEBE850E5A08} = {3F0B29E5-FF51-4A21-871E-8F70E34C7CBF}
-		{3DCD3704-5D77-4CDF-A287-4E8FC5CD33B4} = {62667EDC-E795-4351-80C6-324911DB7B69}
-	EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26124.0
+MinimumVisualStudioVersion = 15.0.26124.0
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MSBuild", "MSBuild", "{3C9CA6C8-3AAB-4D16-BF28-E66AA81F9854}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMake", "MSBuild\CMake\CMake.csproj", "{CB21753B-56F0-46D2-8495-40CC8F5915A7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENet-CSharp", "MSBuild\ENetCSharp\ENetCSharp.csproj", "{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENetTests", "MSBuild\ENetTests\ENetTests.csproj", "{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|x64.Build.0 = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Debug|x86.Build.0 = Debug|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|x64.ActiveCfg = Release|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|x64.Build.0 = Release|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|x86.ActiveCfg = Release|Any CPU
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7}.Release|x86.Build.0 = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|x64.Build.0 = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Debug|x86.Build.0 = Debug|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|x64.ActiveCfg = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|x64.Build.0 = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|x86.ActiveCfg = Release|Any CPU
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF}.Release|x86.Build.0 = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|x64.Build.0 = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Debug|x86.Build.0 = Debug|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|x64.ActiveCfg = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|x64.Build.0 = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|x86.ActiveCfg = Release|Any CPU
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E}.Release|x86.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{CB21753B-56F0-46D2-8495-40CC8F5915A7} = {3C9CA6C8-3AAB-4D16-BF28-E66AA81F9854}
+		{311EBFD0-E0DE-439E-9AE3-CBE210E1A9EF} = {3C9CA6C8-3AAB-4D16-BF28-E66AA81F9854}
+		{E25F1A0A-7FCB-4CA2-9CFF-AAE6DD28EB0E} = {3C9CA6C8-3AAB-4D16-BF28-E66AA81F9854}
+	EndGlobalSection
+EndGlobal

+ 1 - 0
MSBuild/CMake/CMake.Build.targets

@@ -33,6 +33,7 @@
     <Target Name="CMakeConfigTarget" BeforeTargets="Build;VSTest">
     <Target Name="CMakeConfigTarget" BeforeTargets="Build;VSTest">
         <Message Text="CMake -- configuring $(CMakeBuildType) $(Platform): $(CMakeProjName)" Importance="high" />
         <Message Text="CMake -- configuring $(CMakeBuildType) $(Platform): $(CMakeProjName)" Importance="high" />
         <MakeDir Directories="$(CMakeBinaryDir)" />
         <MakeDir Directories="$(CMakeBinaryDir)" />
+        <Message Text="cmake $(CMakeGenerator) $(CMakeConfigBuildType) $(CMakeOpts) $(CMakeSourceDir)" Importance="high" />
         <Exec Command="cmake $(CMakeGenerator) $(CMakeConfigBuildType) $(CMakeOpts) $(CMakeSourceDir)" WorkingDirectory="$(CMakeBinaryDir)" StandardOutputImportance="low" StandardErrorImportance="high" />
         <Exec Command="cmake $(CMakeGenerator) $(CMakeConfigBuildType) $(CMakeOpts) $(CMakeSourceDir)" WorkingDirectory="$(CMakeBinaryDir)" StandardOutputImportance="low" StandardErrorImportance="high" />
         <OnError ExecuteTargets="CMakeBuildFailed" />
         <OnError ExecuteTargets="CMakeBuildFailed" />
     </Target>
     </Target>

+ 1 - 6
MSBuild/CMake/CMake.Copy.targets

@@ -5,12 +5,7 @@
             <PluginFullPath>$(PluginDir)$(PluginArchDir)$(PluginPrefix)$(PluginBaseName).$(PluginExt)</PluginFullPath>
             <PluginFullPath>$(PluginDir)$(PluginArchDir)$(PluginPrefix)$(PluginBaseName).$(PluginExt)</PluginFullPath>
         </PropertyGroup>
         </PropertyGroup>
 
 
-        <ItemGroup>
-          <Content Condition="Exists('$(PluginFullPath)')" Include="$(PluginFullPath)">
-            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-          </Content>
-        </ItemGroup>
-        <!--<Copy SourceFiles="$(PluginFullPath)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" />-->
+        <Copy SourceFiles="$(PluginFullPath)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" />
     </Target>
     </Target>
 
 
 </Project>
 </Project>

+ 1 - 2
MSBuild/CMake/CMake.csproj

@@ -1,11 +1,10 @@
 <Project Sdk="Microsoft.NET.Sdk">
 <Project Sdk="Microsoft.NET.Sdk">
 
 
     <PropertyGroup>
     <PropertyGroup>
-        <TargetFramework>netcoreapp2.1</TargetFramework>
+        <TargetFramework>netcoreapp2.2</TargetFramework>
         <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
         <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
         <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
         <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
         <EnableDefaultItems>false</EnableDefaultItems>
         <EnableDefaultItems>false</EnableDefaultItems>
-        <BuildInParallel Condition="'$(BuildInParallel)' == ''">false</BuildInParallel>
     </PropertyGroup>
     </PropertyGroup>
 
 
     <Import Project="$(CsDir)Common\BannerTask.targets" Condition="'$(BuildingInsideVisualStudio)' != 'true'" />
     <Import Project="$(CsDir)Common\BannerTask.targets" Condition="'$(BuildingInsideVisualStudio)' != 'true'" />

+ 30 - 0
MSBuild/ENetCSharp/ENetCSharp.csproj

@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
+    <Optimize>false</Optimize>
+    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)'=='Release'">
+    <Optimize>true</Optimize>
+    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Compile Include="$(SlnDir)Source\Managed\*.cs" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="$(CsDir)CMake\CMake.csproj">
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
+    </ProjectReference>
+  </ItemGroup>
+
+  <Import Project="$(CsDir)CMake\CMake.Copy.targets" />
+
+</Project>

+ 20 - 0
MSBuild/ENetTests/ENetTests.csproj

@@ -0,0 +1,20 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <IsPackable>false</IsPackable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="nunit" Version="3.11.0" />
+    <PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="$(CsDir)ENetCSharp\ENetCSharp.csproj" />
+  </ItemGroup>
+
+  <Import Project="$(CsDir)CMake\CMake.Copy.targets" />
+  
+</Project>

+ 152 - 0
MSBuild/ENetTests/UnitTests.cs

@@ -0,0 +1,152 @@
+using NUnit.Framework;
+using System;
+using System.Net;
+using System.Diagnostics;
+using ENet;
+
+public class UnitTests
+{
+    enum ClientState
+    {
+        None,
+        Connecting,
+        Connected,
+        SendData,
+        RecvData,
+        Disconnecting,
+        Disconnected,
+    }
+
+    [OneTimeSetUp]
+    public void FixtureSetup()
+    {
+    }
+
+    [OneTimeTearDown]
+    public void FixtureCleanup()
+    {
+    }
+
+    [SetUp]
+    public void TestSetup()
+    {
+    }
+
+    [TearDown]
+    public void TestCleanup()
+    {
+    }
+
+    [Test]
+    public void InitAndUninit()
+    {
+        using (Host host = new Host())
+        {
+        }
+    }
+
+    [Test]
+    public void SendAndRecv()
+    {
+        ushort port = 7777;
+        int maxClients = 1;
+
+        int clientEvents = 0;
+        int clientConnected = 0;
+        int clientDisconnected = 0;
+        int clientTimeout = 0;
+        int clientNone = 0;
+        int clientSendData = 0;
+        int clientRecvData = 0;
+        int serverEvents = 0;
+        int serverConnected = 0;
+        int serverDisconnected = 0;
+        int serverSendData = 0;
+        int serverRecvData = 0;
+        int serverTimeout = 0;
+        int serverNone = 0;
+
+        ClientState clientState = ClientState.None;
+
+        using (Host client = new Host())
+        using (Host server = new Host())
+        {
+            Address address = new Address();
+            address.Port = port;
+            server.Create(address, maxClients);
+
+            address.SetHost("0.0.0.0");
+            client.Create();
+
+            Peer clientPeer;
+            Stopwatch sw = Stopwatch.StartNew();
+            while (sw.ElapsedMilliseconds < 10000)
+            {
+                while (server.Service(15, out Event netEvent) > 0) {
+                    serverEvents++;
+                    switch (netEvent.Type)
+                    {
+                        case EventType.None:
+                            serverNone++;
+                            break;
+                        case EventType.Connect:
+                            serverConnected++;
+                            break;
+                        case EventType.Disconnect:
+                            serverDisconnected++;
+                            break;
+                        case EventType.Timeout:
+                            serverTimeout++;
+                            break;
+                        case EventType.Receive:
+                            serverRecvData++;
+                            netEvent.Packet.Dispose();
+                            break;
+                    }
+                }
+            }
+            server.Flush();
+
+            while (client.Service(15, out Event netEvent) > 0)
+            {
+                clientEvents++;
+                switch (netEvent.Type)
+                {
+                    case EventType.None:
+                        clientNone++;
+                        break;
+                    case EventType.Connect:
+                        clientConnected++;
+                        break;
+                    case EventType.Disconnect:
+                        clientDisconnected++;
+                        break;
+                    case EventType.Timeout:
+                        clientTimeout++;
+                        break;
+                    case EventType.Receive:
+                        clientRecvData++;
+                        netEvent.Packet.Dispose();
+                        break;
+                }
+            }
+            client.Flush();
+
+            if (clientState == ClientState.None)
+            {
+                clientState = ClientState.Connecting;
+                clientPeer = client.Connect(address);
+            }
+            else if (clientState == ClientState.Connected)
+            {
+
+            }
+        }
+
+        Assert.True(clientEvents != 0, "client host never generated an event");
+        Assert.True(serverEvents != 0, "server host never generated an event");
+        Assert.True(clientState != ClientState.None, "client never changed state");
+        Assert.AreEqual(1, clientConnected, "client did not connect to server");
+        Assert.AreEqual(1, serverConnected, "server did not see client connection");
+    }
+}