aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-03-29 01:37:10 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commitf9666347840e519f6248c71688b57227bca4f454 (patch)
tree91362ea567f8e8817b2d84b4dae6be603d80f703 /src
parentc6e8fe8125f8900f3019716aa1cfbf18ff8264bd (diff)
Add 'lib' config, for including external libraries without pkg-config
Diffstat (limited to 'src')
-rw-r--r--src/Conf.cpp15
-rw-r--r--src/GlobalLib.cpp8
-rw-r--r--src/main.cpp8
3 files changed, 31 insertions, 0 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 27071a3..dc9c406 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -1081,6 +1081,18 @@ namespace sibs
else
throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".error_on_warning to be a single value, was a list");
}
+ else if(name.equals("libs"))
+ {
+ if(value.isList())
+ {
+ for(const StringView &lib : value.asList())
+ {
+ libs.emplace_back(string(lib.data, lib.size));
+ }
+ }
+ else
+ throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".libs to be a list, was a single value");
+ }
else
failInvalidFieldUnderObject(name);
}
@@ -1321,6 +1333,9 @@ namespace sibs
string SibsConfig::parsePlatformConfigStatic(const StringView &fieldName, const ConfigValue &fieldValue)
{
// TODO: Verify the library is actually a static library
+ // TODO: Remove this and use "libs" config instead and support wildcard, then "libs"
+ // can be used to specify directories as well.. or just do if the path is a directory then
+ // use the files in the directory (recursively)
if (fieldName.equals("lib"))
{
if (fieldValue.isSingle())
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index 1a795bf..586ec2d 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -249,6 +249,14 @@ namespace sibs
break;
}
}
+
+ for(const std::string &lib : sibsConfig.getLibs())
+ {
+ string staticLibCmd = "\"";
+ staticLibCmd += lib;
+ staticLibCmd += "\"";
+ staticLinkerFlagCallbackFunc(staticLibCmd);
+ }
if(sibsConfig.shouldUseCmake())
{
diff --git a/src/main.cpp b/src/main.cpp
index af43892..47da4bb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -421,6 +421,14 @@ static int buildProject(const FileString &projectPath, const FileString &project
}
}
+ for(const std::string &lib : sibsConfig.getLibs())
+ {
+ string staticLibCmd = "\"";
+ staticLibCmd += lib;
+ staticLibCmd += "\"";
+ ninja.addDependency(staticLibCmd);
+ }
+
if(sibsConfig.shouldBuildTests() && sibsConfig.getTestPath().empty() && !sibsConfig.zigTestAllFiles && sibsConfig.zigTestFiles.empty())
{
printf("Project is missing tests subdirectory. No tests to build\n");