aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-09-29 15:03:24 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commita5eeb97292ed084d0da3a02d7057d6f72219e6b9 (patch)
treed6ea0e590b4be964bf1967f2eee60006ff1dbb53
parent9f3f366deec411675cc21c2fceaa7ac090d03a4c (diff)
Fix TODO: Move include_dirs & ignore_dirs under config
Merge duplicate parsing code into one function
-rw-r--r--README.md20
-rw-r--r--include/Conf.hpp4
-rw-r--r--project.conf2
-rw-r--r--src/Conf.cpp122
-rw-r--r--src/main.cpp7
5 files changed, 71 insertions, 84 deletions
diff --git a/README.md b/README.md
index 59560d7..d59b322 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ For easiest usage of sibs under windows, add msvc subdirectory to PATH environme
with the only missing software being cmake.
Dependencies that are required to build sibs from source are:
-`libcurl, libarchive, libgit2`
+`libcurl, libarchive, libgit2, curl`
`Ninja (build system)` needs to be installed on the system to be able to build projects. CMake can be required for some projects that uses cmake files to build project instead of sibs.
# IDE support
@@ -45,8 +45,6 @@ type = "library"
version = "0.1.0"
platforms = ["linux32", "linux64", "win32", "win64"]
authors = ["DEC05EBA <0xdec05eba@gmail.com>"]
-include_dirs = ["include"]
-ignore_dirs = ["examples"]
[dependencies]
catch2 = "0.1.0"
@@ -69,6 +67,8 @@ BOOST_COMPILE_STATIC = "1"
BOOST_COMPILE_DYNAMIC = "1"
[config]
+include_dirs = ["include"]
+ignore_dirs = ["examples"]
expose_include_dirs = ["include"]
[config.win32.static.debug]
@@ -93,25 +93,15 @@ args = ["ENTITYX_BUILD_SHARED=1"]
## package
### name
Required
-
### type
Required. Should be one of: "executable", "static", "dynamic", "library"
-
### version
Required. Version string has to be in the format of "xxx.yyy.zzz" where xxx is major, yyy is minor and zzz is patch
-
### platforms
Required. A list of platforms the package supports. Can contain the following values: "any", "linux32", "linux64", "win32", "win64".
If platforms contains "any", then other there is no need to specify other platforms
-
### authors
Optional. A list of authors
-
-### include_dirs
-Optional. A list of directories which should be specified as global include directories when compiling. This means that instead of using relative paths to header files, you can include the directory with headers and then you only have to specify the header name when using #include
-
-### ignore_dirs
-Optional. A list of directories to ignore. This means that if the ignored directory contains source files, then they wont be included in the build
## dependencies
Optional. A list of dependencies which are specified in name-value pairs where the name is the name of the dependency, which should match the dependency name under the packages name specified in its project.conf file.
Currently, the value is the version and has to be an exact match for the package version, which is specified in the dependencies project.conf file.
@@ -135,6 +125,10 @@ Works like \[define], but these definitions are only used when building static p
## define.dynamic
Works like \[define], but these definitions are only used when building dynamic project. If a definition with the same exists in \[define], then it's overwritten
## config
+### include_dirs
+Optional. A list of directories which should be specified as global include directories when compiling. This means that instead of using relative paths to header files, you can include the directory with headers and then you only have to specify the header name when using #include
+### ignore_dirs
+Optional. A list of directories to ignore. This means that if the ignored directory contains source files, then they wont be included in the build
### expose_include_dirs
Optional. A list of directories which contains (header) files which should be exposed to dependencies as directories to include globally. This means that dependencies can include (header) files from the dependency without specifying path to the dependency
## config.*
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 35dab86..709d285 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -431,8 +431,8 @@ namespace sibs
private:
void parseCLang(const StringView &fieldName, const ConfigValue &fieldValue);
void parseCppLang(const StringView &fieldName, const ConfigValue &fieldValue);
- void parsePlatformConfigs(const StringView &fieldName, const ConfigValue &fieldValue);
- void parsePlatformConfig(const StringView &fieldName, const ConfigValue &fieldValue);
+ void parsePlatformBuildTypeConfigs(const StringView &fieldName, const ConfigValue &fieldValue);
+ std::string parsePlatformConfigStatic(const StringView &fieldName, const ConfigValue &fieldValue);
void parsePlatformConfigStaticDebug(const StringView &fieldName, const ConfigValue &fieldValue);
void parsePlatformConfigStaticRelease(const StringView &fieldName, const ConfigValue &fieldValue);
void parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, FileString &cmakeDir, FileString &cmakeArgs);
diff --git a/project.conf b/project.conf
index 968c8af..6bf8884 100644
--- a/project.conf
+++ b/project.conf
@@ -4,6 +4,8 @@ type = "executable"
version = "0.1.5"
authors = ["DEC05EBA <0xdec05eba@gmail.com>"]
platforms = ["linux32", "linux64", "win64"]
+
+[config]
ignore_dirs = ["cmake", "cmake-build-debug", "build", "distribute", "examples", "msvc", "cmake_msvc"]
[dependencies]
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 40ff018..8dc4e7c 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -766,6 +766,7 @@ namespace sibs
{
includeDirs.emplace_back(string(includeDir.data, includeDir.size));
}
+ fprintf(stderr, "Warning: package.include_dirs is deprecated, please move include_dirs under config\n");
}
else
throw ParserException("Expected package.include_dirs to be a list, was a single value");
@@ -828,6 +829,7 @@ namespace sibs
ignoreDirFull += string(ignoreDir.data, ignoreDir.size);
ignoreDirs.emplace_back(ignoreDirFull);
}
+ fprintf(stderr, "Warning: package.ignore_dirs is deprecated, please move ignore_dirs under config\n");
}
else
throw ParserException("Expected package.ignore_dirs to be a list, was a single value");
@@ -837,9 +839,10 @@ namespace sibs
}
else if(currentObject.size >= 6 && strncmp(currentObject.data, "config", 6) == 0)
{
- if(currentObject.size == 6) // [config]
+ bool platformConfig = currentObject.equals(CONFIGS[CONFIG_SYSTEM_PLATFORM]);
+ if(currentObject.size == 6 || platformConfig) // [config]
{
- if (name.equals("expose_include_dirs"))
+ if(name.equals("expose_include_dirs"))
{
if (value.isList())
{
@@ -856,13 +859,39 @@ namespace sibs
throw ParserException(errMsg);
}
}
+ else if(name.equals("include_dirs"))
+ {
+ if(value.isList())
+ {
+ for(const StringView &includeDir : value.asList())
+ {
+ includeDirs.emplace_back(string(includeDir.data, includeDir.size));
+ }
+ }
+ else
+ throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".include_dirs to be a list, was a single value");
+ }
+ else if(name.equals("ignore_dirs"))
+ {
+ if (value.isList())
+ {
+ string projectPathUtf8 = toUtf8(projectPath);
+ for (const StringView &ignoreDir : value.asList())
+ {
+ string ignoreDirFull = projectPathUtf8;
+ ignoreDirFull += "/";
+ ignoreDirFull += string(ignoreDir.data, ignoreDir.size);
+ ignoreDirs.emplace_back(move(ignoreDirFull));
+ }
+ }
+ else
+ throw ParserException("Expected " + string(currentObject.data, currentObject.size) + ".ignore_dirs to be a list, was a single value");
+ }
else
failInvalidFieldUnderObject(name);
}
- else // [config.*]
- {
- parsePlatformConfigs(name, value);
- }
+ else
+ parsePlatformBuildTypeConfigs(name, value);
}
else if(currentObject.equals("dependencies"))
{
@@ -1119,66 +1148,48 @@ namespace sibs
failInvalidFieldUnderObject(fieldName);
}
- void SibsConfig::parsePlatformConfigs(const StringView &fieldName, const ConfigValue &fieldValue)
+ void SibsConfig::parsePlatformBuildTypeConfigs(const StringView &fieldName, const ConfigValue &fieldValue)
{
+ bool validConfig = false;
for(int i = 0; i < NUM_CONFIGS; ++i)
{
const StringView &config = CONFIGS[i];
if(currentObject.equals(config))
{
+ validConfig = true;
switch(i)
{
- case CONFIG_SYSTEM_PLATFORM:
- return parsePlatformConfig(fieldName, fieldValue);
case CONFIG_STATIC_DEBUG_PLATFORM:
- return parsePlatformConfigStaticDebug(fieldName, fieldValue);
+ parsePlatformConfigStaticDebug(fieldName, fieldValue);
+ break;
case CONFIG_STATIC_RELEASE_PLATFORM:
- return parsePlatformConfigStaticRelease(fieldName, fieldValue);
+ parsePlatformConfigStaticRelease(fieldName, fieldValue);
+ break;
default:
- return;
+ break;
}
}
}
- string errMsg = "Invalid config object \"";
- errMsg += string(currentObject.data, currentObject.size);
- errMsg += "\"";
- throw ParserException(errMsg);
- }
-
- void SibsConfig::parsePlatformConfig(const StringView &fieldName, const ConfigValue &fieldValue)
- {
- if (fieldName.equals("expose_include_dirs"))
+ if(!validConfig)
{
- if (fieldValue.isList())
- {
- for (const StringView &includeDir : fieldValue.asList())
- {
- exposeIncludeDirs.emplace_back(string(includeDir.data, includeDir.size));
- }
- }
- else
- {
- string errMsg = "Expected ";
- errMsg += string(currentObject.data, currentObject.size);
- errMsg += " to be a list, was a single value";
- throw ParserException(errMsg);
- }
+ string errMsg = "Invalid config object \"";
+ errMsg += string(currentObject.data, currentObject.size);
+ errMsg += "\"";
+ throw ParserException(errMsg);
}
- else
- failInvalidFieldUnderObject(fieldName);
}
-
- void SibsConfig::parsePlatformConfigStaticDebug(const StringView &fieldName, const ConfigValue &fieldValue)
+
+ string SibsConfig::parsePlatformConfigStatic(const StringView &fieldName, const ConfigValue &fieldValue)
{
if (fieldName.equals("lib"))
{
if (fieldValue.isSingle())
{
- string debugStaticLibPath = toUtf8(projectPath);
- debugStaticLibPath += "/";
- debugStaticLibPath += string(fieldValue.asSingle().data, fieldValue.asSingle().size);
- getLibFiles(debugStaticLibPath, debugStaticLibs);
+ string staticLibPath = toUtf8(projectPath);
+ staticLibPath += "/";
+ staticLibPath += string(fieldValue.asSingle().data, fieldValue.asSingle().size);
+ return staticLibPath;
}
else
{
@@ -1192,27 +1203,14 @@ namespace sibs
failInvalidFieldUnderObject(fieldName);
}
+ void SibsConfig::parsePlatformConfigStaticDebug(const StringView &fieldName, const ConfigValue &fieldValue)
+ {
+ getLibFiles(parsePlatformConfigStatic(fieldName, fieldValue), debugStaticLibs);
+ }
+
void SibsConfig::parsePlatformConfigStaticRelease(const StringView &fieldName, const ConfigValue &fieldValue)
{
- if (fieldName.equals("lib"))
- {
- if (fieldValue.isSingle())
- {
- string releaseStaticLibPath = toUtf8(projectPath);
- releaseStaticLibPath += "/";
- releaseStaticLibPath += string(fieldValue.asSingle().data, fieldValue.asSingle().size);
- getLibFiles(releaseStaticLibPath, releaseStaticLibs);
- }
- else
- {
- string errMsg = "Expected ";
- errMsg += string(currentObject.data, currentObject.size);
- errMsg += " to be a single value, was a list";
- throw ParserException(errMsg);
- }
- }
- else
- failInvalidFieldUnderObject(fieldName);
+ getLibFiles(parsePlatformConfigStatic(fieldName, fieldValue), releaseStaticLibs);
}
void SibsConfig::parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, FileString &cmakeDir, FileString &cmakeArgs)
diff --git a/src/main.cpp b/src/main.cpp
index 334f972..a5f7562 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,10 +29,6 @@ using namespace std::chrono;
// TODO: Remove install.sh when sibs supports installation of packages (so it can install itself)
-// TODO: Move package include_dirs and ignore_dirs under config in project.conf.
-// Package object should only contain metadata for the package, which is used for finding dependencies
-// and when building a list of installed packages / available packages.
-
// TODO: Allow different platforms to have different dependencies.
// This can be done by specifying dependencies under [dependencies.platform] instead of [dependencies],
// for example for win32: [dependencies.win32]
@@ -46,9 +42,6 @@ using namespace std::chrono;
// Might need to make it possible to define variables if a dependency exists (or doesn't exist) because the code might have
// preprocessor like: USE_LIBSODIUM or NO_LIBSODIUM.
-// TODO: When building a sibs project, add a hardlink in ~/.cache/sibs/lib to it. This allows us to have dependency to a project that we can modify
-// without having to commit & push to remote
-
// TODO: Check compiler flags generated by cmake and visual studio in debug and release mode and use the same ones when building sibs project.
// There are certain compiler flags we do not currently have, for example _ITERATOR_DEBUG_LEVEL in debug mode which enables runtime checks.
// You should be able to specify runtime checks as an option to `sibs build` and project specific config in .conf file.