diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-04-29 12:57:33 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-04-29 12:57:37 +0200 |
commit | 8d3a83a20a57cd505b2f98a542903a3aee0c2b45 (patch) | |
tree | f22a67990a9b9f6f0729c4466124a8c10b2d4228 | |
parent | 34563dda0ccfc34ce62f0bfcfc20f2b0fa48833e (diff) |
Change sibs cache directory to standard one, remove library archive when it has been extracted
-rw-r--r-- | backend/ninja/Ninja.cpp | 2 | ||||
-rw-r--r-- | include/PackageVersion.hpp | 6 | ||||
-rw-r--r-- | src/CmakeModule.cpp | 2 | ||||
-rw-r--r-- | src/GlobalLib.cpp | 11 | ||||
-rw-r--r-- | src/Package.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | tests/src/main.cpp | 2 |
7 files changed, 16 insertions, 13 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 6b013c4..28e4ea1 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -289,7 +289,7 @@ namespace backend if (!globalLibDirResult) return Result<bool>::Err(globalLibDirResult); FileString globalLibDir = globalLibDirResult.unwrap(); - globalLibDir += TINYDIR_STRING("/.sibs/lib"); + globalLibDir += TINYDIR_STRING("/.cache/sibs/lib"); Result<bool> createGlobalLibDirResult = createDirectoryRecursive(globalLibDir.c_str()); if(createGlobalLibDirResult.isErr()) return createGlobalLibDirResult; diff --git a/include/PackageVersion.hpp b/include/PackageVersion.hpp index 99f8342..1d966fd 100644 --- a/include/PackageVersion.hpp +++ b/include/PackageVersion.hpp @@ -8,16 +8,16 @@ namespace sibs /* * Different package version syntax: * ANY: "major.minor.patch" (xxx.xxx.xxx) - * Checks for package in several different places. First pkg-config, then local lib dir (~/.sibs/lib), then git/server. + * Checks for package in several different places. First pkg-config, then local lib dir (~/.cache/sibs/lib), then git/server. * Example: "2.1.002" * GIT: "branch:revision" * Checks for package in any of the configures git servers (default: github). * Example: "master:HEAD" * LATEST: "latest" - * Checks for package in several different places. First git/server then pkg-config then local lib dir (~/.sibs/lib). + * Checks for package in several different places. First git/server then pkg-config then local lib dir (~/.cache/sibs/lib). * * - * GIT and LATEST first check if local lib (~/.sibs/lib) contains latest version by comparing the revision to remote revision. + * GIT and LATEST first check if local lib (~/.cache/sibs/lib) contains latest version by comparing the revision to remote revision. */ class PackageVersion { diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp index 3beb792..99be269 100644 --- a/src/CmakeModule.cpp +++ b/src/CmakeModule.cpp @@ -19,7 +19,7 @@ namespace sibs if (!globalLibDirResult) return Result<bool>::Err(globalLibDirResult); FileString globalLibDir = globalLibDirResult.unwrap(); - globalLibDir += TINYDIR_STRING("/.sibs/lib"); + globalLibDir += TINYDIR_STRING("/.cache/sibs/lib"); Result<bool> createGlobalLibDirResult = createDirectoryRecursive(globalLibDir.c_str()); if(createGlobalLibDirResult.isErr()) return createGlobalLibDirResult; diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp index 8618cfd..c577a4a 100644 --- a/src/GlobalLib.cpp +++ b/src/GlobalLib.cpp @@ -282,13 +282,13 @@ namespace sibs if (!libPathResult) return Result<bool>::Err(libPathResult); FileString libPath = libPathResult.unwrap(); - libPath += TINYDIR_STRING("/.sibs/lib/"); + libPath += TINYDIR_STRING("/.cache/sibs/lib/"); libPath += toFileString(dependency->name); libPath += TINYDIR_STRING("/"); libPath += toFileString(dependency->version); FileString libArchivedFilePath = libPathResult.unwrap(); - libArchivedFilePath += TINYDIR_STRING("/.sibs/archive/"); + libArchivedFilePath += TINYDIR_STRING("/.cache/sibs/archive/"); libArchivedFilePath += toFileString(dependency->name); Result<bool> createArchiveDirResult = createDirectoryRecursive(libArchivedFilePath.c_str()); if(!createArchiveDirResult) @@ -305,7 +305,10 @@ namespace sibs if(!createLibDirResult) return createLibDirResult; - return Archive::extract(libArchivedFilePath.c_str(), libPath.c_str()); + Result<bool> archiveExtractResult = Archive::extract(libArchivedFilePath.c_str(), libPath.c_str()); + // We have extracted the archive, we dont need to cache it. If remove fails, it doesn't really matter, user can remove it himself + remove(libArchivedFilePath.c_str()); + return archiveExtractResult; } Result<bool> GlobalLib::downloadDependency(GitDependency *dependency) @@ -314,7 +317,7 @@ namespace sibs if (!libPathResult) return Result<bool>::Err(libPathResult); FileString libPath = libPathResult.unwrap(); - libPath += TINYDIR_STRING("/.sibs/lib/"); + libPath += TINYDIR_STRING("/.cache/sibs/lib/"); libPath += toFileString(dependency->name); // We dont care if the directory already exists. Nothing will happen if it does diff --git a/src/Package.cpp b/src/Package.cpp index a2aaf52..f87da86 100644 --- a/src/Package.cpp +++ b/src/Package.cpp @@ -87,7 +87,7 @@ namespace sibs } // TODO: Always downloading is fine right now because the package list is small. This should later be modified to use local cache. - // The package file should be stored locally (at ~/.sibs/packages.json) and the version file should also be stored. + // The package file should be stored locally (at ~/.cache/sibs/packages.json) and the version file should also be stored. // First we check if the version is incorrect and if it, we download the new packages.json file. // We should only check if the package list is up to date once every 10 minute or so (make it configurable in a config file?) // to improve build performance and reduce server load. diff --git a/src/main.cpp b/src/main.cpp index 2223b56..441ec2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,7 @@ 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 ~/.sibs/lib to it. This allows us to have dependency to a project that we can modify +// 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. @@ -429,7 +429,7 @@ void newProjectCreateConf(const string &projectName, const string &projectType, projectConfStr += asString(SYSTEM_PLATFORM); projectConfStr += "\"]\n"; projectConfStr += "tests = \"tests\""; - projectConfStr += "\n"; + projectConfStr += "\n\n"; projectConfStr += "[dependencies]\n"; FileString projectConfPath = projectPath; diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 50ecd8b..b3143fb 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -1,2 +1,2 @@ #define CATCH_CONFIG_MAIN -#include "catch2/2.0.1/catch.hpp" +#include <catch.hpp> |