Skip to content

Commit e1bdb30

Browse files
Merge pull request #10 from Neko-Box-Coder/MultiSourceFiles
Support multi source files
2 parents dc192a3 + 250291b commit e1bdb30

16 files changed

+724
-407
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ add_executable(runcpp2
8181
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FlagsOverrideInfo.cpp"
8282
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesFlagsOverride.cpp"
8383
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ScriptInfo.cpp"
84+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCompilesFiles.cpp"
8485
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesTypesInfo.cpp"
8586
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp"
8687
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ProfileHelper.cpp"
Lines changed: 117 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,122 @@
1-
# (Optional) Language of the script
2-
Language: "c++"
1+
# NOTE: All the options here are defaulted to empty.
2+
# You can uncomment different sections to set what you want.
33

4-
# Each of the platform dependent settings can be listed under
5-
# - All
6-
# - Windows
7-
# - Linux
8-
# - MacOS
9-
# - Unix
4+
# # (Optional) Language of the script
5+
# Language: "c++"
106

11-
# (Optional) Preferred compiler/linker profiles for the script for each platform
12-
RequiredProfiles:
13-
Windows: ["g++"]
14-
Linux: ["g++"]
15-
MacOS: ["g++"]
7+
# # (Optional) Preferred profiles for the script for each platform.
8+
# # A special profile name "All" can be used to allow any profile.
9+
# # Default profiles are listed in user config file,
10+
# # which can be retreived by running `runcpp2 --show-config-path`
11+
# # Each of the platform dependent settings can be listed under
12+
# # - All
13+
# # - Windows
14+
# # - Linux
15+
# # - MacOS
16+
# # - Unix
17+
# RequiredProfiles:
18+
# Windows: ["g++"]
19+
# Linux: ["g++"]
20+
# MacOS: ["g++"]
1621

17-
# (Optional) Override the default compile flags for each platform
18-
OverrideCompileFlags:
19-
# Target Platform
20-
All:
21-
# Profile with the respective flags to override
22-
"g++":
23-
# (Optional) Flags to be removed from the default compile flags, separated by space
24-
Remove: ""
25-
26-
# (Optional) Additional flags to be appended to the default compile flags, separated by space
27-
Append: ""
22+
# # (Optional) Override the default compile flags for each platform.
23+
# OverrideCompileFlags:
24+
# # Target Platform
25+
# All:
26+
# # Profile with the respective flags to override. ("All" for any profile)
27+
# "g++":
28+
# # (Optional) Flags to be removed from the default compile flags, separated by space
29+
# Remove: ""
30+
#
31+
# # (Optional) Additional flags to be appended to the default compile flags, separated by space
32+
# Append: ""
2833

29-
30-
# (Optional) Override the default link flags for each platform
31-
OverrideLinkFlags:
32-
# Target Platform
33-
All:
34-
# Profile with the respective flags to override
35-
"g++":
36-
# (Optional) Flags to be removed from the default link flags, separated by space
37-
Remove: ""
38-
39-
# (Optional) Additional flags to be appended to the default link flags, separated by space
40-
Append: ""
34+
# # (Optional) Override the default link flags for each platform.
35+
# OverrideLinkFlags:
36+
# # Target Platform
37+
# All:
38+
# # Profile with the respective flags to override ("All" for any profile)
39+
# "g++":
40+
# # (Optional) Flags to be removed from the default link flags, separated by space
41+
# Remove: ""
42+
#
43+
# # (Optional) Additional flags to be appended to the default link flags,
44+
# # separated by space
45+
# Append: ""
4146

42-
# (Optional) The list of dependencies needed by the script
43-
Dependencies:
44-
# Dependency name
45-
- Name: MyLibrary
46-
47-
# Supported platforms of the dependency
48-
Platforms: [Windows, Linux, MacOS]
49-
50-
# The source of getting the dependency (Git, Local)
51-
Source:
52-
Type: Git
53-
Value: "https://github.com/MyUser/MyLibrary.git"
54-
55-
# Library Type (Static, Object, Shared, Header)
56-
LibraryType: Static
57-
58-
# (Optional) Paths to be added to the include paths, relative to the dependency folder
59-
IncludePaths:
60-
- "src/include"
61-
62-
# (Optional if LibraryType is Header) Link properties of the dependency
63-
LinkProperties:
64-
# Properties for searching the library binary for the profile
65-
# You can also use "All" if all compilers use the same values
66-
"g++":
67-
# The library names to be searched for when linking against the script
68-
SearchLibraryNames: ["MyLibrary"]
69-
70-
# (Optional) The library names to be excluded from being searched
71-
ExcludeLibraryNames: []
72-
73-
# The path (relative to the dependency folder) to be searched for the dependency binaries
74-
SearchDirectories: ["./build"]
75-
76-
# (Optional) Additional link options for this dependency for each platform
77-
AdditionalLinkOptions:
78-
All: []
79-
80-
# (Optional) Setup commands are run once when the dependency is populated
81-
Setup:
82-
# Target Platform
83-
All:
84-
# Setup shell commands for the specified profile.
85-
# All commands are run in the dependency folder
86-
# You can also use "All" if all the compilers run the same setup commands
87-
"g++":
88-
- "mkdir build"
89-
90-
91-
# (Optional) Build commands are run every time before the script is being built
92-
Build:
93-
# Target Platform
94-
All:
95-
"g++":
96-
- "cd build && cmake .."
97-
- "cd build && cmake --build ."
98-
99-
# (Optional) Cleanup commands are run when the reset option is present. Normally nothing needs
100-
# to be done since the dependency folder will be removed automatically.
101-
# Cleanup:
102-
# Linux:
103-
# "g++":
104-
# - "sudo apt purge MyLibrary"
47+
# # (Optional) Other source files (relative to script file path) to be compiled.
48+
# OtherFilesToBeCompiled:
49+
# # Target Platform
50+
# All:
51+
# # Target Profile
52+
# All:
53+
# - "./AnotherSourceFile.cpp"
54+
55+
# # (Optional) The list of dependencies needed by the script
56+
# Dependencies:
57+
# # Dependency name
58+
# - Name: MyLibrary
59+
#
60+
# # Supported platforms of the dependency
61+
# Platforms: [Windows, Linux, MacOS]
62+
#
63+
# # The source of getting the dependency (Git, Local)
64+
# Source:
65+
# # Git: Dependency exists in a git server, and needs to be cloned
66+
# # Local: Dependency exists in local filesystem
67+
# Type: Git
68+
#
69+
# # Git URL for Git type, path to a directory for Local type
70+
# Value: "https://github.com/MyUser/MyLibrary.git"
71+
#
72+
# # Library Type (Static, Object, Shared, Header)
73+
# LibraryType: Static
74+
#
75+
# # (Optional) Paths to be added to the include paths, relative to the dependency folder
76+
# IncludePaths:
77+
# - "src/include"
78+
#
79+
# # (Optional if LibraryType is Header) Link properties of the dependency
80+
# LinkProperties:
81+
# # Properties for searching the library binary for the profile
82+
# # You can also use "All" if all compilers use the same values
83+
# "g++":
84+
# # The library names to be searched for when linking against the script
85+
# SearchLibraryNames: ["MyLibrary"]
86+
#
87+
# # (Optional) The library names to be excluded from being searched
88+
# ExcludeLibraryNames: []
89+
#
90+
# # The path (relative to the dependency folder) to be searched for the dependency binaries
91+
# SearchDirectories: ["./build"]
92+
#
93+
# # (Optional) Additional link options for this dependency for each platform
94+
# AdditionalLinkOptions:
95+
# All: []
96+
#
97+
# # (Optional) Setup commands are run once when the dependency is populated
98+
# Setup:
99+
# # Target Platform
100+
# All:
101+
# # Setup shell commands for the specified profile.
102+
# # All commands are run in the dependency folder
103+
# # You can also use "All" if all the compilers run the same setup commands
104+
# "g++":
105+
# - "mkdir build"
106+
#
107+
#
108+
# # (Optional) Build commands are run every time before the script is being built
109+
# Build:
110+
# # Target Platform
111+
# All:
112+
# # Target Profile ("All" for any profile)
113+
# "g++":
114+
# - "cd build && cmake .."
115+
# - "cd build && cmake --build ."
116+
#
117+
# # (Optional) Cleanup commands are run when the reset option is present. Normally nothing needs
118+
# # to be done since the dependency folder will be removed automatically.
119+
# Cleanup:
120+
# Linux:
121+
# "g++":
122+
# - "sudo apt purge MyLibrary"

DefaultYAMLs/DefaultUserConfig.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Profiles:
103103
NameAliases: ["mingw"]
104104

105105
# The file extensions associated with the profile
106-
FileExtensions: [cpp, cc, cxx]
106+
FileExtensions: [.cpp, .cc, .cxx]
107107

108108
# The languages supported by the profile
109109
Languages: ["c++"]
@@ -251,7 +251,7 @@ Profiles:
251251
- Name: "vs2022_v17+"
252252
NameAliases: ["msvc1930+", "msvc"]
253253
Languages: ["c++"]
254-
FileExtensions: [cpp, cc, cxx]
254+
FileExtensions: [.cpp, .cc, .cxx]
255255
FilesTypes: *CommonFilesTypes
256256
Compiler:
257257
PreRun:

Examples/AnotherSourceFileGcc.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
4+
5+
6+
int TestFunc()
7+
{
8+
return 8;
9+
}

Examples/AnotherSourceFileGcc.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int TestFunc();

Examples/test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
RequiredProfiles:
44
Windows: ["msvc"]
55
Unix: ["g++"]
6+
7+
OtherFilesToBeCompiled:
8+
# Target Platform
9+
All:
10+
# Target Profile
11+
"g++":
12+
- "./AnotherSourceFileGcc.cpp"
13+
All:
14+
- "./AnotherSourceFile.cpp"
15+
- "./AnotherSourceFile2.cpp"
16+
617
Dependencies:
718
- Name: ssLogger
819
Platforms: [Windows, Linux, MacOS]
@@ -33,6 +44,8 @@
3344
#define ssLOG_DLL 1
3445
#include "ssLogger/ssLog.hpp"
3546

47+
#include "./AnotherSourceFileGcc.hpp"
48+
3649
#include <iostream>
3750
#include <chrono>
3851

@@ -49,6 +62,8 @@ int main(int argc, char* argv[])
4962
ssLOG_LINE("Header only dependency is working!!!");
5063
#endif
5164

65+
ssLOG_LINE("Multi source file is working: " << TestFunc());
66+
5267
int CheckCounter = 5;
5368
ssLOG_FATAL("Test fatal: " << CheckCounter);
5469
ssLOG_ERROR("Test error: " << CheckCounter);

Include/runcpp2/CompilingLinking.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@
1111
namespace runcpp2
1212
{
1313
bool CompileScriptOnly( const ghc::filesystem::path& buildDir,
14-
const std::string& scriptPath,
14+
const std::vector<ghc::filesystem::path>& sourceFiles,
15+
const std::vector<bool>& sourceHasCache,
1516
const Data::ScriptInfo& scriptInfo,
1617
const std::vector<Data::DependencyInfo*>& availableDependencies,
1718
const Data::Profile& profile,
1819
bool buildExecutable);
1920

21+
//TODO: Convert string paths to filesystem paths
2022
bool CompileAndLinkScript( const ghc::filesystem::path& buildDir,
21-
const std::string& scriptPath,
23+
const std::string& outputName,
24+
const std::vector<ghc::filesystem::path>& sourceFiles,
25+
const std::vector<bool>& sourceHasCache,
2226
const Data::ScriptInfo& scriptInfo,
2327
const std::vector<Data::DependencyInfo*>& availableDependencies,
2428
const Data::Profile& profile,
25-
const std::vector<std::string>& copiedDependenciesBinariesPaths,
29+
const std::vector<std::string>& compiledObjectsPaths,
2630
bool buildExecutable,
2731
const std::string exeExt);
2832
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
2+
#define RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP
3+
4+
#include "runcpp2/Data/ParseCommon.hpp"
5+
#include "ghc/filesystem.hpp"
6+
#include "ryml.hpp"
7+
#include <unordered_map>
8+
9+
namespace runcpp2
10+
{
11+
namespace Data
12+
{
13+
class ProfilesCompilesFiles
14+
{
15+
public:
16+
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> CompilesFiles;
17+
18+
bool ParseYAML_Node(ryml::ConstNodeRef& node);
19+
std::string ToString(std::string indentation) const;
20+
};
21+
}
22+
}
23+
24+
#endif

Include/runcpp2/Data/ScriptInfo.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "runcpp2/Data/DependencyInfo.hpp"
55
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
66
#include "runcpp2/Data/ParseCommon.hpp"
7+
#include "runcpp2/Data/ProfilesCompilesFiles.hpp"
78

89
#include <string>
910
#include <vector>
@@ -22,6 +23,8 @@ namespace runcpp2
2223
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideCompileFlags;
2324
std::unordered_map<PlatformName, ProfilesFlagsOverride> OverrideLinkFlags;
2425

26+
std::unordered_map<PlatformName, ProfilesCompilesFiles> OtherFilesToBeCompiled;
27+
2528
std::vector<DependencyInfo> Dependencies;
2629

2730

@@ -33,4 +36,4 @@ namespace runcpp2
3336
}
3437
}
3538

36-
#endif
39+
#endif

0 commit comments

Comments
 (0)