Skip to content

Commit 3eb8e8c

Browse files
Working static linking
1 parent 503bb0f commit 3eb8e8c

35 files changed

+386
-249
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/filesystem")
2121
# =========================================================================
2222
# Generate yaml files as c
2323
# =========================================================================
24-
# TODO(NOW): Use target instead
25-
if(RUNCPP2_UPDATE_DEFAULT_YAMLS)
24+
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c")
25+
set(EMBEDDED_FILE_SIZE 0)
26+
else()
27+
file(SIZE "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c" EMBEDDED_FILE_SIZE)
28+
endif()
29+
30+
if(RUNCPP2_UPDATE_DEFAULT_YAMLS OR EMBEDDED_FILE_SIZE LESS 1024)
2631
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C")
2732
include("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C/embedFile.cmake")
2833

@@ -54,7 +59,7 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/System2")
5459
add_executable(runcpp2 "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/CompilerInfo.cpp"
5560
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/CompilerProfile.cpp"
5661
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencyInfo.cpp"
57-
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencySearchProperty.cpp"
62+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencyLinkProperty.cpp"
5863
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencySetup.cpp"
5964
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencySource.cpp"
6065
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FlagsOverrideInfo.cpp"

DefaultYAMLs/DefaultCompilerProfiles.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ CompilerProfiles:
7979
# {LinkFlags}, {OutputFile}, {ObjectFile} will be replaced accordingly
8080
OutputPart: "{LinkFlags} -o {OutputFile} {ObjectFile}"
8181

82-
# TODO(NOW): If the thing we want to link is libabc.a (or .so)
83-
# -l either accepts -labc or -l:abc.a
84-
8582
# Syntax for linking each dependency.
86-
# TODO(NOW): Rename to {DependencyFile}
87-
# {DependencyName} will be replaced accordingly
88-
DependenciesPart: "-l:{DependencyName}"
83+
# {DependencyFile} will be replaced accordingly
84+
#DependenciesPart: "-l:{DependencyFile}"
85+
DependenciesPart: "{DependencyFile}"

DefaultYAMLs/DefaultScriptInfo.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ OverrideLinkFlags:
3333
# (Optional) The list of dependencies needed by the script
3434
Dependencies:
3535
# Dependency name
36-
- Name: lib1
36+
- Name: MyLibrary
3737

3838
# Supported platforms of the dependency
3939
Platforms: [Windows, Linux, MacOS]
4040

4141
# The source of getting the dependency
4242
Source:
4343
Type: Git
44-
Value: "https://github.com/USER/REPO.git"
44+
Value: "https://github.com/MyUser/MyLibrary.git"
4545

4646
# Library Type (Static, Object, Shared, Header)
4747
LibraryType: Static
@@ -50,20 +50,22 @@ Dependencies:
5050
IncludePaths:
5151
- "src/include"
5252

53-
# (Optional if Header type) Searchable properties of the dependency
53+
# (Optional if LibraryType is Header) Link properties of the dependency
5454
LinkProperties:
5555
# Properties for searching the library binary for the profile
5656
"g++":
57-
# The library name to be searched for when linking against the script
58-
SearchLibraryNames: ["lib1"]
57+
# The library names to be searched for when linking against the script
58+
SearchLibraryNames: ["MyLibrary"]
5959

60-
# TODO(NOW): Add option to exclude names
60+
# (Optional) The library names to be excluded from being searched
61+
ExcludeLibraryNames: []
6162

6263
# The path (relative to the dependency folder) to be searched for the dependency binaries
6364
SearchDirectories: ["./build"]
6465

65-
# TODO(NOW): Add additional link option?
66-
66+
# (Optional) Additional link options for this dependency
67+
AdditionalLinkOptions:
68+
All: []
6769

6870

6971
# (Optional) List of setup commands for the supported platforms

DefaultYAMLs/ScriptInfoSchema.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,28 @@
153153
"items": { "type":"string" },
154154
"description": "The library name to be searched for when linking against the script"
155155
},
156+
"ExcludeLibraryNames":
157+
{
158+
"type": "array",
159+
"items": { "type":"string" }
160+
},
156161
"SearchDirectories":
157162
{
158163
"type": "array",
159164
"items": { "type":"string" },
160165
"description": "The path to be searched for the dependency. {BuildType} will be replaced accordingly"
166+
},
167+
"AdditionalLinkOptions":
168+
{
169+
"type": "object",
170+
"properties":
171+
{
172+
"^.*$":
173+
{
174+
"type": "array",
175+
"items": { "type":"string" }
176+
}
177+
}
161178
}
162179
},
163180
"required": ["SearchLibraryNames", "SearchDirectories"],

Include/runcpp2/CompilerProfileHelper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace runcpp2
88
{
99
int GetPreferredProfileIndex( const std::string& scriptPath,
10-
const ScriptInfo& scriptInfo,
11-
const std::vector<CompilerProfile>& profiles,
10+
const Data::ScriptInfo& scriptInfo,
11+
const std::vector<Data::CompilerProfile>& profiles,
1212
const std::string& configPreferredProfile);
1313
}
1414

Include/runcpp2/CompilingLinking.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
namespace runcpp2
99
{
1010
bool CompileAndLinkScript( const std::string& scriptPath,
11-
const ScriptInfo& scriptInfo,
12-
const CompilerProfile& profile,
13-
const std::vector<std::string>& copiedDependenciesBinariesNames);
11+
const Data::ScriptInfo& scriptInfo,
12+
const Data::CompilerProfile& profile,
13+
const std::vector<std::string>& copiedDependenciesBinariesPaths);
1414
}
1515

1616
#endif

Include/runcpp2/ConfigParsing.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include <vector>
88
namespace runcpp2
99
{
10-
bool ReadUserConfig(std::vector<CompilerProfile>& outProfiles,
10+
bool ReadUserConfig(std::vector<Data::CompilerProfile>& outProfiles,
1111
std::string& outPreferredProfile);
1212

1313
bool ParseScriptInfo( const std::string& scriptInfo,
14-
ScriptInfo& outScriptInfo);
14+
Data::ScriptInfo& outScriptInfo);
1515
}
1616

1717
#endif

Include/runcpp2/Data/CompilerInfo.hpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,28 @@
77

88
namespace runcpp2
99
{
10-
class CompilerInfo
10+
namespace Data
1111
{
12-
public:
13-
std::string Executable;
14-
std::string DefaultCompileFlags;
15-
16-
struct Args
17-
{
18-
std::string CompilePart;
19-
std::string IncludePart;
20-
std::string InputPart;
21-
std::string OutputPart;
22-
};
23-
24-
Args CompileArgs;
25-
26-
bool ParseYAML_Node(YAML::Node& profileNode);
27-
std::string ToString(std::string indentation) const;
28-
};
12+
class CompilerInfo
13+
{
14+
public:
15+
std::string Executable;
16+
std::string DefaultCompileFlags;
17+
18+
struct Args
19+
{
20+
std::string CompilePart;
21+
std::string IncludePart;
22+
std::string InputPart;
23+
std::string OutputPart;
24+
};
25+
26+
Args CompileArgs;
27+
28+
bool ParseYAML_Node(YAML::Node& profileNode);
29+
std::string ToString(std::string indentation) const;
30+
};
31+
}
2932
}
3033

3134
#endif

Include/runcpp2/Data/CompilerProfile.hpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@
1111

1212
namespace runcpp2
1313
{
14-
class CompilerProfile
14+
namespace Data
1515
{
16-
public:
17-
std::string Name;
18-
std::unordered_set<std::string> FileExtensions;
19-
std::unordered_set<std::string> Languages;
20-
std::vector<std::string> SetupSteps;
21-
std::unordered_map<std::string, std::string> ObjectFileExtensions;
22-
std::unordered_map<std::string, std::vector<std::string>> SharedLibraryExtensions;
23-
std::unordered_map<std::string, std::vector<std::string>> StaticLibraryExtensions;
24-
std::unordered_map<std::string, std::vector<std::string>> DebugSymbolFileExtensions;
25-
26-
CompilerInfo Compiler;
27-
LinkerInfo Linker;
28-
29-
bool ParseYAML_Node(YAML::Node& profileNode);
30-
std::string ToString(std::string indentation) const;
31-
};
16+
class CompilerProfile
17+
{
18+
public:
19+
std::string Name;
20+
std::unordered_set<std::string> FileExtensions;
21+
std::unordered_set<std::string> Languages;
22+
std::vector<std::string> SetupSteps;
23+
std::unordered_map<std::string, std::string> ObjectFileExtensions;
24+
std::unordered_map<std::string, std::vector<std::string>> SharedLibraryExtensions;
25+
std::unordered_map<std::string, std::vector<std::string>> StaticLibraryExtensions;
26+
std::unordered_map<std::string, std::vector<std::string>> DebugSymbolFileExtensions;
27+
28+
CompilerInfo Compiler;
29+
LinkerInfo Linker;
30+
31+
bool ParseYAML_Node(YAML::Node& profileNode);
32+
std::string ToString(std::string indentation) const;
33+
};
34+
}
3235
}
3336

3437
#endif

Include/runcpp2/Data/DependencyInfo.hpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@
1212

1313
namespace runcpp2
1414
{
15-
class DependencyInfo
15+
namespace Data
1616
{
17-
public:
18-
std::string Name;
19-
std::unordered_set<PlatformName> Platforms;
20-
DependencySource Source;
21-
DependencyLibraryType LibraryType;
22-
std::vector<std::string> IncludePaths;
23-
std::vector<std::string> AbsoluteIncludePaths;
24-
std::unordered_map<ProfileName, DependencyLinkProperty> LinkProperties;
25-
std::unordered_map<PlatformName, DependencySetup> Setup;
26-
27-
bool ParseYAML_Node(YAML::Node& node);
28-
std::string ToString(std::string indentation) const;
29-
};
17+
class DependencyInfo
18+
{
19+
public:
20+
std::string Name;
21+
std::unordered_set<PlatformName> Platforms;
22+
DependencySource Source;
23+
DependencyLibraryType LibraryType;
24+
std::vector<std::string> IncludePaths;
25+
std::vector<std::string> AbsoluteIncludePaths;
26+
std::unordered_map<ProfileName, DependencyLinkProperty> LinkProperties;
27+
std::unordered_map<PlatformName, DependencySetup> Setup;
28+
29+
bool ParseYAML_Node(YAML::Node& node);
30+
std::string ToString(std::string indentation) const;
31+
};
32+
}
3033
}
3134

3235
#endif

0 commit comments

Comments
 (0)