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. --- src/CmakeModule.cpp | 3 ++- src/GlobalLib.cpp | 8 ++++++-- src/main.cpp | 4 ---- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') 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