@@ -38,6 +38,7 @@ Defines: ["ssLOG_USE_SOURCE=1"]
3838#include < chrono>
3939
4040std::string runcpp2ExecutablePath = " " ;
41+ std::string downloadBranch = " heads/master" ;
4142bool integrationTest = false ;
4243
4344#define DELAYED_OUTPUT (str ) \
@@ -325,12 +326,9 @@ int main(int, char**)
325326 " See https://neko-box-coder.github.io/runcpp2/latest/guides/"
326327 " building_project_sources/ for more details.\n " );
327328
328- // TODO: Remove this when the cache bug is fixed
329- DELAYED_OUTPUT (" `--rebuild` is just resetting the build cache" );
330-
331329 DELAYED_OUTPUT (" Let's try it" );
332330 if (!RunCommandWithPrompt ( runcpp2ExecutablePath +
333- " --build --output ./tutorial --executable --rebuild "
331+ " --build --output ./tutorial --executable "
334332 " tutorial/main.cpp" ))
335333 {
336334 return false ;
@@ -782,15 +780,15 @@ bool Chapter3_ExternalDependencies()
782780 #ifdef _WIN32
783781 if (!RunCommandWithPrompt ( " powershell -Command \" "
784782 " Invoke-WebRequest https://github.com/Neko-Box-Coder/runcpp2/raw/"
785- " refs/heads/master /Examples/Logging.cpp "
783+ " refs/" + downloadBranch + " /Examples/Logging.cpp "
786784 " -OutFile tutorial/Logging.cpp\" " , true , false ))
787785 {
788786 return false ;
789787 }
790788 #else
791789 if (!RunCommandWithPrompt ( " curl -L -o tutorial/Logging.cpp "
792- " https://github.com/Neko-Box-Coder/runcpp2/raw/refs/heads/ "
793- " master /Examples/Logging.cpp" ))
790+ " https://github.com/Neko-Box-Coder/runcpp2/raw/refs/" +
791+ downloadBranch + " /Examples/Logging.cpp" ))
794792 {
795793 return false ;
796794 }
@@ -818,16 +816,16 @@ bool Chapter3_ExternalDependencies()
818816 #ifdef _WIN32
819817 if (!RunCommandWithPrompt ( " powershell -Command \" "
820818 " Invoke-WebRequest https://github.com/Neko-Box-Coder/runcpp2/raw/"
821- " refs/heads/master /Examples/SDLWindow.cpp "
819+ " refs/" + downloadBranch + " /Examples/SDLWindow.cpp "
822820 " -OutFile tutorial/SDLWindow.cpp\" " , true , false ))
823821 {
824822 return false ;
825823 }
826824
827825 #else
828826 if (!RunCommandWithPrompt ( " curl -L -o tutorial/SDLWindow.cpp "
829- " https://github.com/Neko-Box-Coder/runcpp2/raw/refs/heads/ "
830- " master /Examples/SDLWindow.cpp" ))
827+ " https://github.com/Neko-Box-Coder/runcpp2/raw/refs/" +
828+ downloadBranch + " /Examples/SDLWindow.cpp" ))
831829 {
832830 return false ;
833831 }
@@ -1080,6 +1078,56 @@ int main(int argc, char* argv[])
10801078
10811079 runcpp2ExecutablePath = exePath.string () + " -l -c " + configPath.string ();
10821080 }
1081+
1082+ // Get runcpp2 version
1083+ {
1084+ System2CommandInfo commandInfo = {0 };
1085+ commandInfo.RedirectOutput = true ;
1086+ SYSTEM2_RESULT result = System2CppRun (runcpp2ExecutablePath + " --version" , commandInfo);
1087+ #define CHECK_RESULT () \
1088+ if (result != SYSTEM2_RESULT_SUCCESS) \
1089+ { \
1090+ ssLOG_ERROR (" Failed to get version" ); \
1091+ ssLOG_ERROR (" SYSTEM2_RESULT: " << result); \
1092+ return 1 ; \
1093+ }
1094+
1095+ CHECK_RESULT ();
1096+
1097+ std::string versionOutput;
1098+ result = System2CppReadFromOutput (commandInfo, versionOutput);
1099+ CHECK_RESULT ();
1100+
1101+ int returnCode = 0 ;
1102+ result = System2CppGetCommandReturnValueSync (commandInfo, returnCode, false );
1103+ CHECK_RESULT ();
1104+
1105+ if (returnCode != 0 )
1106+ {
1107+ ssLOG_ERROR (" Failed to get version with return code: " << returnCode);
1108+ return 1 ;
1109+ }
1110+
1111+ #undef CHECK_RESULT
1112+
1113+ {
1114+ size_t newlinePos = versionOutput.find (" \r " );
1115+ if (newlinePos == std::string::npos)
1116+ newlinePos = versionOutput.find (" \n " );
1117+ if (newlinePos != std::string::npos)
1118+ versionOutput = versionOutput.substr (0 , newlinePos);
1119+ }
1120+
1121+ size_t versionStartPos = versionOutput.rfind (" " );
1122+ if (versionStartPos == std::string::npos || ++versionStartPos >= versionOutput.size ())
1123+ {
1124+ ssLOG_ERROR (" Failed to extract runcpp2 version" );
1125+ return 1 ;
1126+ }
1127+
1128+ downloadBranch = " tags/" + versionOutput.substr (versionStartPos);
1129+
1130+ }
10831131
10841132 DELAYED_OUTPUT (" The whole tutorial is about 15 minutes long." );
10851133
@@ -1127,7 +1175,7 @@ int main(int argc, char* argv[])
11271175
11281176 DELAYED_OUTPUT (" This concludes the tutorial." );
11291177 DELAYED_OUTPUT (" Feel free to check out the documentation for more details." );
1130- DELAYED_OUTPUT (" https://neko-box-coder.github.io/runcpp2/latest /guides/basic_concepts/" );
1178+ DELAYED_OUTPUT ( " https://neko-box-coder.github.io/runcpp2/master /guides/basic_concepts/" );
11311179 DELAYED_OUTPUT (" " );
11321180 DELAYED_OUTPUT (" As well as the examples in the repository." );
11331181 DELAYED_OUTPUT (" https://github.com/Neko-Box-Coder/runcpp2/tree/master/Examples" );
0 commit comments