@@ -565,7 +565,8 @@ bool Chapter2_BuildConfig()
565565
566566 DELAYED_OUTPUT (" " );
567567 DELAYED_OUTPUT (" A common build config is to specify other source files." );
568- DELAYED_OUTPUT (" This can be done by adding the paths to the `OtherFilesToBeCompiled` field." );
568+ DELAYED_OUTPUT (" This can be done by adding the paths to the `SourceFiles` field." );
569+ DELAYED_OUTPUT (" The script file is implicitly added to this field so you don't need to specify it." );
569570 DELAYED_OUTPUT (" Let me add a second C++ file (\" tutorial/Hello.cpp\" )." );
570571 DELAYED_OUTPUT (" Press enter to continue..." );
571572 GetInput (true );
@@ -596,33 +597,7 @@ void CallHello();
596597 WriteFile (" tutorial/Hello.hpp" , fileContent);
597598 }
598599
599- DELAYED_OUTPUT (" Turns out I still need to edit tutorial/main.cpp to call the function." );
600- DELAYED_OUTPUT (" Let me do that now." );
601- DELAYED_OUTPUT (" Press enter to continue..." );
602- GetInput (true );
603-
604- {
605- std::string fileContent = ReadFile (" tutorial/main.cpp" );
606- if (fileContent.empty ())
607- {
608- ssLOG_ERROR (" Failed to read tutorial/main.cpp" );
609- return false ;
610- }
611-
612- size_t returnPos = fileContent.find (" return 0;" );
613- if (returnPos == std::string::npos)
614- {
615- ssLOG_ERROR (" Failed to find return 0; in tutorial/main.cpp" );
616- return false ;
617- }
618- fileContent.replace (returnPos,
619- std::string (" return 0;" ).size (),
620- " CallHello();\n return 0;" );
621-
622- WriteFile (" tutorial/main.cpp" , std::string (" #include \" Hello.hpp\"\n " ) + fileContent);
623- }
624-
625- DELAYED_OUTPUT (" Now let me add the second C++ file to `OtherFilesToBeCompiled` in the YAML file." );
600+ DELAYED_OUTPUT (" Now let me add the second C++ file to `SourceFiles` in the tutorial/main.yaml file." );
626601 DELAYED_OUTPUT (" Press enter to continue..." );
627602 GetInput (true );
628603
@@ -631,15 +606,15 @@ void CallHello();
631606 DefaultPlatform:
632607 DefaultProfile: ["WORLD=42"]
633608
634- OtherFilesToBeCompiled :
609+ SourceFiles :
635610 DefaultPlatform:
636611 DefaultProfile: ["./Hello.cpp"]
637612)" ;
638613
639614 WriteFile (" tutorial/main.yaml" , yamlContent);
640615 }
641616
642- DELAYED_OUTPUT (" The path to the other file is always **relative to the script file** ." );
617+ DELAYED_OUTPUT (" The paths to the files are always __relative to the script file__ ." );
643618 DELAYED_OUTPUT (" You can also add include paths for the script to the `IncludePaths` field" );
644619 DELAYED_OUTPUT (" Although unnecessary in this case, let me add \" ./\" to the include paths." );
645620 DELAYED_OUTPUT (" Press enter to continue..." );
@@ -650,7 +625,7 @@ void CallHello();
650625 DefaultPlatform:
651626 DefaultProfile: ["WORLD=42"]
652627
653- OtherFilesToBeCompiled :
628+ SourceFiles :
654629 DefaultPlatform:
655630 DefaultProfile: ["./Hello.cpp"]
656631
@@ -662,23 +637,49 @@ void CallHello();
662637 WriteFile (" tutorial/main.yaml" , yamlContent);
663638 }
664639
640+ DELAYED_OUTPUT (" Turns out, I still need to edit tutorial/main.cpp to call the function." );
641+ DELAYED_OUTPUT (" Let me do that now." );
642+ DELAYED_OUTPUT (" Press enter to continue..." );
643+ GetInput (true );
644+
645+ {
646+ std::string fileContent = ReadFile (" tutorial/main.cpp" );
647+ if (fileContent.empty ())
648+ {
649+ ssLOG_ERROR (" Failed to read tutorial/main.cpp" );
650+ return false ;
651+ }
652+
653+ size_t returnPos = fileContent.find (" return 0;" );
654+ if (returnPos == std::string::npos)
655+ {
656+ ssLOG_ERROR (" Failed to find return 0; in tutorial/main.cpp" );
657+ return false ;
658+ }
659+ fileContent.replace (returnPos,
660+ std::string (" return 0;" ).size (),
661+ " CallHello();\n return 0;" );
662+
663+ WriteFile (" tutorial/main.cpp" , std::string (" #include \" Hello.hpp\"\n " ) + fileContent);
664+ }
665+
665666 DELAYED_OUTPUT (" Let's run the script again." );
666667 if (!RunCommandWithPrompt (" cd tutorial && " + runcpp2ExecutablePath + " main.cpp" ))
667668 return false ;
668669
669670 DELAYED_OUTPUT (" You should see the output `Hello from another C++ file`." );
670671 DELAYED_OUTPUT (" " );
671672
672- DELAYED_OUTPUT ( " If you **only ** have a setting that applies to all platforms and profiles like "
673+ DELAYED_OUTPUT ( " If you **ONLY ** have a setting that applies to all platforms and profiles like "
673674 " what we have," );
674675 DELAYED_OUTPUT (" you can specify the settings directly." );
675- DELAYED_OUTPUT (" Let me update the YAML file and show you what I mean." );
676+ DELAYED_OUTPUT (" Let me update the tutorial/main.yaml file and show you what I mean." );
676677 DELAYED_OUTPUT (" Press enter to continue..." );
677678 GetInput (true );
678679
679680 {
680681 const std::string yamlContent = R"( Defines: ["WORLD=42"]
681- OtherFilesToBeCompiled : ["./Hello.cpp"]
682+ SourceFiles : ["./Hello.cpp"]
682683IncludePaths: ["./"]
683684)" ;
684685 WriteFile (" tutorial/main.yaml" , yamlContent);
@@ -700,7 +701,7 @@ IncludePaths: ["./"]
700701
701702 {
702703 const std::string yamlContent = R"( Defines: ["WORLD=42"]
703- OtherFilesToBeCompiled : ["./Hello.cpp"]
704+ SourceFiles : ["./Hello.cpp"]
704705IncludePaths: ["./"]
705706
706707OverrideCompileFlags:
@@ -735,7 +736,7 @@ IncludePaths: ["./"]
735736
736737 {
737738 const std::string yamlContent = R"( Defines: ["WORLD=42"]
738- OtherFilesToBeCompiled : ["./Hello.cpp"]
739+ SourceFiles : ["./Hello.cpp"]
739740IncludePaths: ["./"]
740741)" ;
741742 WriteFile (" tutorial/main.yaml" , yamlContent);
@@ -798,7 +799,7 @@ bool Chapter3_ExternalDependencies()
798799 DELAYED_OUTPUT (" Press enter to continue..." );
799800 GetInput (true );
800801
801- DELAYED_OUTPUT (" A dependency must contain a \" Source\" to determine where it is." );
802+ DELAYED_OUTPUT (" A dependency must contain a \" Source\" to determine where it is from ." );
802803 DELAYED_OUTPUT (" In this case, it is coming from a \" Git\" repository." );
803804 DELAYED_OUTPUT ( " If you have a git submodule, you can point it to a local directory with "
804805 " \" Local\" instead of \" Git\" " );
@@ -807,7 +808,7 @@ bool Chapter3_ExternalDependencies()
807808
808809 DELAYED_OUTPUT ( " Next, you have \" LibraryType\" which tells runcpp2 what type of dependency "
809810 " this is. Other options include \" Static\" , \" Object\" and \" Shared\" " );
810- DELAYED_OUTPUT (" That's pretty much it for a header only library. Let's run it shell we?" );
811+ DELAYED_OUTPUT (" That's pretty much it for a header only library. Let's run it shall we?" );
811812 if (!RunCommandWithPrompt (" cd tutorial && " + runcpp2ExecutablePath + " Logging.cpp" ))
812813 return false ;
813814
@@ -997,7 +998,7 @@ bool Chapter3_ExternalDependencies()
997998 return false ;
998999 }
9991000
1000- DELAYED_OUTPUT (" I have extracted the SDL2 dependency block to a standalone YAML file." );
1001+ DELAYED_OUTPUT (" I have extracted the SDL2 dependency block to tutorial/SDL2.yaml file." );
10011002 DELAYED_OUTPUT (" Press enter to continue..." );
10021003 GetInput (true );
10031004
0 commit comments