This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 638ffbc  Fix netstd test lib build on non windows hosts Client: netstd 
Patch: Thomas Bruggink & Jens Geyer
638ffbc is described below

commit 638ffbc5e6e4a74746ee7099f4365d85a6e1c52f
Author: Thomas <[email protected]>
AuthorDate: Fri Mar 26 22:06:05 2021 +0900

    Fix netstd test lib build on non windows hosts
    Client: netstd
    Patch: Thomas Bruggink & Jens Geyer
    
    This closes #2361
---
 .../Thrift.PublicInterfaces.Compile.Tests.csproj   | 57 ++++++++++++++--------
 1 file changed, 38 insertions(+), 19 deletions(-)

diff --git 
a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
 
b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
index 759c42f..103f315 100644
--- 
a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
+++ 
b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj
@@ -19,8 +19,10 @@
   -->
 
   <PropertyGroup>
+    <ThriftVersion>0.15.0</ThriftVersion>
+    <ThriftVersionOutput>Thrift version $(ThriftVersion)</ThriftVersionOutput>
     <TargetFramework>net5.0</TargetFramework>
-    <Version>0.15.0.0</Version>
+    <Version>$(ThriftVersion).0</Version>
     <AssemblyName>Thrift.PublicInterfaces.Compile.Tests</AssemblyName>
     <PackageId>Thrift.PublicInterfaces.Compile.Tests</PackageId>
     
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -38,27 +40,44 @@
   </ItemGroup>
 
   <Target Name="PreBuild" 
BeforeTargets="_GenerateRestoreProjectSpec;Restore;Compile">
+    <!-- Check on the path -->
     <Exec Condition="'$(OS)' == 'Windows_NT'" Command="where thrift" 
ConsoleToMSBuild="true">
       <Output TaskParameter="ConsoleOutput" PropertyName="PathToThrift" />
     </Exec>
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./CassandraTest.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./CassandraTest.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./CassandraTest.thrift" />
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./optional_required_default.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./optional_required_default.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./optional_required_default.thrift" />
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./../../../../test/ThriftTest.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./../../../../test/ThriftTest.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./../../../../test/ThriftTest.thrift" />
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./../../../../contrib/fb303/if/fb303.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./../../../../contrib/fb303/if/fb303.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./../../../../contrib/fb303/if/fb303.thrift" />
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./Thrift5253.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./Thrift5253.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./Thrift5253.thrift" />
-    <Exec Condition="Exists('$(PathToThrift)')" Command="$(PathToThrift) -gen 
netstd:wcf,union,serial -r ./Thrift5320.thrift" />
-    <Exec Condition="Exists('thrift')" Command="thrift -gen 
netstd:wcf,union,serial -r ./Thrift5320.thrift" />
-    <Exec Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Command="$(ProjectDir)/../../../../compiler/cpp/thrift -gen 
netstd:wcf,union,serial -r ./Thrift5320.thrift" />
+    <Exec Condition="'$(OS)' != 'Windows_NT'" Command="which thrift || true" 
ConsoleToMSBuild="true">
+      <Output TaskParameter="ConsoleOutput" PropertyName="PathToThrift" />
+    </Exec>
+    <!-- Check in the current directory -->
+    <CreateProperty Condition="Exists('thrift')" Value="thrift">
+      <Output TaskParameter="Value" PropertyName="PathToThrift" />
+    </CreateProperty>
+    <!-- Check for the root projects output -->
+    <CreateProperty 
Condition="Exists('$(ProjectDir)/../../../../compiler/cpp/thrift')" 
Value="$(ProjectDir)/../../../../compiler/cpp/thrift">
+      <Output TaskParameter="Value" PropertyName="PathToThrift" />
+    </CreateProperty>
+    <Error 
+      Condition="!Exists('$(PathToThrift)')"
+      Text="Thrift executable could not be found."
+    />
+    <!-- Make sure the thrift version found is the same as the projects 
version -->
+    <Exec Command="$(PathToThrift) -version" ConsoleToMSBuild="true">
+      <Output TaskParameter="ConsoleOutput" PropertyName="ThriftBinaryVersion" 
/>
+    </Exec>
+    <Error 
+      
Condition="$('$(ThriftBinaryVersion)'::StartsWith('$(ThriftVersionOutput)')) == 
true"
+      Text="Thrift version returned: '$(ThriftBinaryVersion)' is not equal to 
the projects version '$(ThriftVersionOutput)'."
+    />
+    <Message
+      Importance="high"
+      Text="Generating tests with thrift binary: '$(PathToThrift)'"
+    />
+    <!-- Generate the thrift test files -->
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./CassandraTest.thrift" />
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./optional_required_default.thrift" />
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./../../../../test/ThriftTest.thrift" />
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./../../../../contrib/fb303/if/fb303.thrift" />
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./Thrift5253.thrift" />
+    <Exec Command="$(PathToThrift) -gen netstd:wcf,union,serial -r 
./Thrift5320.thrift" />
   </Target>
 
 </Project>

Reply via email to