From f1a80658b08c8b489772052b5569cb1d3086db08 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Nov 2018 04:29:04 +0100 Subject: Store dependencies in different directories depending on target platform This fixed conflicts in cache filepath when building 32-bit and 64-bit project on the same machine or when doing cross compilation. --- backend/ninja/Ninja.cpp | 3 ++- include/GlobalLib.hpp | 2 +- project.conf | 8 ++++---- src/CmakeModule.cpp | 3 ++- src/GlobalLib.cpp | 8 ++++++-- src/main.cpp | 4 ---- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 71e9c08..526fccb 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -325,7 +325,8 @@ namespace backend if (!globalLibDirResult) return Result::Err(globalLibDirResult); FileString globalLibDir = globalLibDirResult.unwrap(); - globalLibDir += TINYDIR_STRING("/.cache/sibs/lib"); + globalLibDir += TINYDIR_STRING("/.cache/sibs/lib/"); + globalLibDir += toFileString(asString(config.platform)); Result createGlobalLibDirResult = createDirectoryRecursive(globalLibDir.c_str()); if(createGlobalLibDirResult.isErr()) return createGlobalLibDirResult; diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp index 6a6c72a..b6ac60c 100644 --- a/include/GlobalLib.hpp +++ b/include/GlobalLib.hpp @@ -24,7 +24,7 @@ namespace sibs static Result getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, const std::string &name, const PackageVersionRange &versionRange, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback); static Result getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, GitDependency *gitDependency, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback); static Result downloadDependency(PackageListDependency *dependency, Platform platform); - static Result downloadDependency(GitDependency *dependency); + static Result downloadDependency(GitDependency *dependency, Platform platform); private: static Result getLibsLinkerFlagsCommon(const SibsConfig &parentConfig, const FileString &packageDir, const std::string &dependencyName, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback); }; diff --git a/project.conf b/project.conf index 5d4e5cb..ae1d2b0 100644 --- a/project.conf +++ b/project.conf @@ -1,7 +1,7 @@ [package] name = "sibs" type = "executable" -version = "0.2.0" +version = "0.3.0" authors = ["DEC05EBA <0xdec05eba@gmail.com>"] platforms = ["any"] @@ -9,6 +9,6 @@ platforms = ["any"] ignore_dirs = ["cmake", "cmake-build-debug", "build", "distribute", "examples", "msvc", "cmake_msvc"] [dependencies] -libcurl = "7" -libarchive = "3" -libgit2 = "0.24.0" \ No newline at end of file +libcurl = ">=7" +libarchive = ">=3" +libgit2 = ">=0.24.0" diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp index 91c572d..a573e85 100644 --- a/src/CmakeModule.cpp +++ b/src/CmakeModule.cpp @@ -23,7 +23,8 @@ namespace sibs if (!globalLibDirResult) return Result::Err(globalLibDirResult); FileString globalLibDir = globalLibDirResult.unwrap(); - globalLibDir += TINYDIR_STRING("/.cache/sibs/lib"); + globalLibDir += TINYDIR_STRING("/.cache/sibs/lib/"); + globalLibDir += toFileString(asString(config.platform)); Result createGlobalLibDirResult = createDirectoryRecursive(globalLibDir.c_str()); if(createGlobalLibDirResult.isErr()) return createGlobalLibDirResult; diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp index 7f9d949..5c0e16d 100644 --- a/src/GlobalLib.cpp +++ b/src/GlobalLib.cpp @@ -102,7 +102,7 @@ namespace sibs // TODO: If return error is invalid url, then the message should be converted to // invalid package name/version. A check should be done if it is the name or version // that is invalid. - Result downloadDependencyResult = GlobalLib::downloadDependency(gitDependency); + Result downloadDependencyResult = GlobalLib::downloadDependency(gitDependency, parentConfig.platform); if(!downloadDependencyResult) return downloadDependencyResult; @@ -276,6 +276,8 @@ namespace sibs return Result::Err(libPathResult); FileString libPath = libPathResult.unwrap(); libPath += TINYDIR_STRING("/.cache/sibs/lib/"); + libPath += toFileString(asString(platform)); + libPath += TINYDIR_STRING("/"); libPath += toFileString(dependency->name); libPath += TINYDIR_STRING("/"); libPath += toFileString(package.version.toString()); @@ -308,13 +310,15 @@ namespace sibs return archiveExtractResult; } - Result GlobalLib::downloadDependency(GitDependency *dependency) + Result GlobalLib::downloadDependency(GitDependency *dependency, Platform platform) { Result libPathResult = getHomeDir(); if (!libPathResult) return Result::Err(libPathResult); FileString libPath = libPathResult.unwrap(); libPath += TINYDIR_STRING("/.cache/sibs/lib/"); + libPath += toFileString(asString(platform)); + libPath += TINYDIR_STRING("/"); libPath += toFileString(dependency->name); // We dont care if the directory already exists. Nothing will happen if it does diff --git a/src/main.cpp b/src/main.cpp index ab8cd59..1265d3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,10 +101,6 @@ using namespace std::chrono; // TODO: If dependencies are using a version that is not within our dependency version range then ask the user if they still want to use the dependency (the closest matching dependency). // Currently if dependency version does not match, build will always fail with no option to ignore version mismatch. -// TODO: Move global lib dependencies into different directories depending on the target platform, because one system can be used -// to build packages for the host platfrom and another platform by cross compilation. If cross compilation is used and a dependency is installed that is not compatible with the target platform then the dependency that fits the target platform wont be downloaded -// since the dependency already exists locally (but for a different platform). - #if OS_FAMILY == OS_FAMILY_POSIX #define fout std::cout #define ferr std::cerr -- cgit v1.2.3