Skip to content

Commit 1a85505

Browse files
Renaming OtherFilesToBeCompiled to SourceFiles for yaml
1 parent 898d5a6 commit 1a85505

File tree

7 files changed

+61
-15
lines changed

7 files changed

+61
-15
lines changed

DefaultYAMLs/DefaultScriptInfo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ OverrideLinkFlags:
6464
Append: ""
6565

6666
# (Optional) Other source files (relative to script file path) to be compiled.
67-
OtherFilesToBeCompiled:
67+
SourceFiles:
6868
# Target Platform
6969
DefaultPlatform:
7070
# Target Profile

Examples/InteractiveTutorial.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
@@ -678,7 +679,7 @@ void CallHello();
678679

679680
{
680681
const std::string yamlContent = R"(Defines: ["WORLD=42"]
681-
OtherFilesToBeCompiled: ["./Hello.cpp"]
682+
SourceFiles: ["./Hello.cpp"]
682683
IncludePaths: ["./"]
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"]
704705
IncludePaths: ["./"]
705706
706707
OverrideCompileFlags:
@@ -735,7 +736,7 @@ IncludePaths: ["./"]
735736

736737
{
737738
const std::string yamlContent = R"(Defines: ["WORLD=42"]
738-
OtherFilesToBeCompiled: ["./Hello.cpp"]
739+
SourceFiles: ["./Hello.cpp"]
739740
IncludePaths: ["./"]
740741
)";
741742
WriteFile("tutorial/main.yaml", yamlContent);

Src/Tests/Data/ScriptInfoTest.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ int main(int argc, char** argv)
99

1010
ssTEST_INIT_TEST_GROUP();
1111

12+
ssTEST_PARSE_ARGS(argc, argv);
13+
1214
ssTEST("ScriptInfo Should Parse Valid YAML")
1315
{
1416
ssTEST_OUTPUT_SETUP
@@ -274,6 +276,41 @@ int main(int argc, char** argv)
274276
scriptInfo.Equals(parsedOutput));
275277
};
276278

279+
ssTEST("ScriptInfo Should Parse SourceFiles as OtherFilesToBeCompiled")
280+
{
281+
ssTEST_OUTPUT_SETUP
282+
(
283+
//NOTE: This is just a test YAML for validating parsing, don't use it for actual config
284+
const char* yamlStr = R"(
285+
SourceFiles:
286+
Windows:
287+
MSVC:
288+
- src/extra.cpp
289+
- src/debug.cpp
290+
)";
291+
292+
ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(yamlStr));
293+
ryml::ConstNodeRef root = tree.rootref();
294+
runcpp2::Data::ScriptInfo scriptInfo;
295+
);
296+
297+
ssTEST_OUTPUT_EXECUTION
298+
(
299+
bool parseResult = scriptInfo.ParseYAML_Node(root);
300+
);
301+
302+
ssTEST_OUTPUT_ASSERT("ParseYAML_Node should succeed", parseResult);
303+
304+
//Verify SourceFiles
305+
ssTEST_OUTPUT_SETUP
306+
(
307+
const std::vector<ghc::filesystem::path>& msvcCompileFiles =
308+
scriptInfo.OtherFilesToBeCompiled.at("Windows").Paths.at("MSVC");
309+
);
310+
ssTEST_OUTPUT_ASSERT("MSVC files count", msvcCompileFiles.size() == 2);
311+
ssTEST_OUTPUT_ASSERT("MSVC first file", msvcCompileFiles.at(0) == "src/extra.cpp");
312+
};
313+
277314
ssTEST("ScriptInfo Should Parse Fields Without Platform And Profile As Default")
278315
{
279316
ssTEST_OUTPUT_SETUP

Src/runcpp2/Data/ScriptInfo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ bool runcpp2::Data::ScriptInfo::ParseYAML_Node(ryml::ConstNodeRef node)
118118
return false;
119119
}
120120

121+
if(!ParsePlatformProfileMap<ProfilesProcessPaths>( node,
122+
"SourceFiles",
123+
OtherFilesToBeCompiled,
124+
"SourceFiles"))
125+
{
126+
return false;
127+
}
128+
121129
if(!ParsePlatformProfileMap<ProfilesProcessPaths>( node,
122130
"IncludePaths",
123131
IncludePaths,
@@ -213,7 +221,7 @@ std::string runcpp2::Data::ScriptInfo::ToString(std::string indentation) const
213221

214222
if(!OtherFilesToBeCompiled.empty())
215223
{
216-
out += indentation + "OtherFilesToBeCompiled:\n";
224+
out += indentation + "SourceFiles:\n";
217225
for(auto it = OtherFilesToBeCompiled.begin(); it != OtherFilesToBeCompiled.end(); ++it)
218226
{
219227
out += indentation + " " + it->first + ":\n";

mkdocs/docs/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### Nightly
77
- Add version for default user config and prompt for update
8+
- Rename "OtherFilesToBeCompiled" to "SourceFiles"
89

910
### v0.3.1
1011
- Check last run is shared lib or executable. Reset cache when necessary if different type
@@ -35,7 +36,6 @@
3536

3637
## High Priority
3738

38-
- Rename "OtherFilesToBeCompiled" to "SourceFiles"
3939
- Expose/rename "InternalExecutableShared" and change BuildType to be platform map
4040
- This ties to the warning in `CompilingLinking.cpp:619`
4141
- Update `FileProperties.hpp` to use list of string for prefix and extension

mkdocs/docs/build_settings.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@
121121
Remove: "-flagA -flagB"
122122
Append: "-flagC -flagD"
123123
```
124-
### `OtherFilesToBeCompiled`
124+
### `SourceFiles`
125125
- Type: `Platform Profile Map` with `list` of `string`
126126
- Optional: `true`
127127
- Default: None
128-
- Description: The source files to be compiled for each platform and profile.
128+
- Description: The source files to be compiled for each platform and profile. The script file is added implicitly
129129
??? example
130130
```yaml
131-
OtherFilesToBeCompiled:
131+
SourceFiles:
132132
DefaultPlatform:
133133
DefaultProfile:
134134
- "./AnotherSourceFile.cpp"
@@ -532,7 +532,7 @@ OverrideLinkFlags:
532532
Append: ""
533533

534534
# (Optional) Other source files (relative to script file path) to be compiled.
535-
OtherFilesToBeCompiled:
535+
SourceFiles:
536536
# Target Platform
537537
DefaultPlatform:
538538
# Target Profile

mkdocs/docs/guides/building_project_sources.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Each setting supports two operations:
7272

7373
## Adding Source Files And Include Paths
7474

75-
You can add additional source files and include paths using `OtherFilesToBeCompiled` and `IncludePaths`.
75+
You can add additional source files and include paths using `SourceFiles` and `IncludePaths`.
7676
All paths are relative to the script file's location.
7777

7878
???+ example
@@ -88,7 +88,7 @@ All paths are relative to the script file's location.
8888
```
8989

9090
```yaml title="Build Settings"
91-
OtherFilesToBeCompiled:
91+
SourceFiles:
9292
- "./src/utils.cpp"
9393
- "./src/helper.cpp"
9494
IncludePaths:
@@ -98,7 +98,7 @@ All paths are relative to the script file's location.
9898
!!! note
9999
You can specify different source files for different platforms/profiles, same for IncludePaths:
100100
```yaml
101-
OtherFilesToBeCompiled:
101+
SourceFiles:
102102
Windows:
103103
"msvc":
104104
- "./src/windows_impl.cpp"
@@ -148,7 +148,7 @@ When building a project with a mixture of c and c++ files, the same profile will
148148
Language: "c"
149149
RequiredProfiles:
150150
DefaultPlatform: ["gcc"]
151-
OtherFilesToBeCompiled:
151+
SourceFiles:
152152
- "./math.c"
153153
IncludePaths:
154154
- "../include"

0 commit comments

Comments
 (0)