Added generation of string dictionary.txt for stress test to CMake
authorkhizmax <libcds.dev@gmail.com>
Thu, 2 Jun 2016 20:06:31 +0000 (23:06 +0300)
committerkhizmax <libcds.dev@gmail.com>
Thu, 2 Jun 2016 20:06:31 +0000 (23:06 +0300)
projects/Win/vc14/stress-framework.vcxproj
test/stress/CMakeLists.txt
test/stress/data/split.pl

index 0d255bc77ff24ae51bdf930fd79099b7b3e0f370..000823a98090a497cdd6984fb4bd4cdc3946796b 100644 (file)
   </ItemGroup>\r
   <ItemGroup>\r
     <CustomBuild Include="..\..\..\test\stress\data\text.txt">\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
-      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl  &amp;&amp; copy %(RootDir)%(Directory)\dictionary.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cd %(RootDir)%(Directory) &amp;&amp; perl -X split.pl text.txt $(TargetDir)\dictionary.txt</Command>\r
       <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Build text dictionary</Message>\r
       <Message Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">Build text dictionary</Message>\r
       <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Build text dictionary</Message>\r
index 6b576d46b512f9cbf92b69d01fcb16600f439a21..8801787c3dccc9336fedace1f73c91c166fa099b 100644 (file)
@@ -8,6 +8,13 @@ set(CDSSTRESS_FRAMEWORK_SOURCES
     framework/stress_test.cpp
 )
 
+add_custom_command(
+    OUTPUT ${EXECUTABLE_OUTPUT_PATH}/dictionary.txt
+    MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/test/stress/data/text.txt
+    COMMAND perl -X ${PROJECT_SOURCE_DIR}/test/stress/data/split.pl ${PROJECT_SOURCE_DIR}/test/stress/data/text.txt ${EXECUTABLE_OUTPUT_PATH}/dictionary.txt
+)
+set_property(SOURCE framework/stress_test.cpp APPEND PROPERTY OBJECT_DEPENDS ${EXECUTABLE_OUTPUT_PATH}/dictionary.txt)
+
 add_library(${CDSSTRESS_FRAMEWORK_LIBRARY} OBJECT ${CDSSTRESS_FRAMEWORK_SOURCES}) 
 
 include_directories(
index 3d0f4c7568d5f83cdc7daf675ee7358ecd9e5923..29887d927a7380596b32d50a3b132e575b81592f 100644 (file)
@@ -2,7 +2,10 @@
 \r
 my %words ;\r
 \r
-open( my $f, "text.txt" ) ;\r
+my $input_file = shift;\r
+my $output_file = shift;\r
+\r
+open( my $f, $input_file ) or die "Cannot open input file $input_file";\r
 binmode $f ;\r
 \r
 my $text = ''  ;\r
@@ -26,14 +29,14 @@ for (my $j = 1; $j < 30; ++$j ) {
        }\r
 }\r
 \r
-open (my $dst, ">dictionary.txt") ;\r
+open (my $dst, ">$output_file") or die "Cannot open output file $output_file";\r
 binmode $dst ;\r
 \r
 my $nCount = 0 ;\r
 $nCount++ foreach (keys %words) ;\r
 print $dst $nCount, "\n" ;\r
 \r
-print "Generate test dictionary...\n" ;\r
+print "Generate test dictionary $output_file ...\n" ;\r
 print $dst $_, "\n" foreach (keys %words)      ;\r
 \r
 close $dst  ;\r