From e2d947ccd6947c9190569fedbb4a90505b5fe9a5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 1 Oct 2018 04:51:42 +0200 Subject: Allow specifying project platform without arch --- src/Conf.cpp | 83 +++++++++++++++++------------------------------------------- 1 file changed, 23 insertions(+), 60 deletions(-) (limited to 'src/Conf.cpp') diff --git a/src/Conf.cpp b/src/Conf.cpp index 2fdef25..c93f830 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -491,16 +491,6 @@ namespace sibs return parseResult; } - - bool containsPlatform(const vector &platforms, Platform platform) - { - for (Platform vecPlatform : platforms) - { - if (vecPlatform == platform || vecPlatform == PLATFORM_ANY) - return true; - } - return false; - } void readSibsConfig(const FileString &projectPath, const FileString &projectConfFilePath, SibsConfig &sibsConfig, FileString &buildPath) { @@ -523,21 +513,6 @@ namespace sibs } } - const char* asString(Platform platform) - { - switch (platform) - { - case PLATFORM_ANY: return "any"; - case PLATFORM_LINUX32: return "linux32"; - case PLATFORM_LINUX64: return "linux64"; - case PLATFORM_WIN32: return "win32"; - case PLATFORM_WIN64: return "win64"; - case PLATFORM_MACOS32: return "macos32"; - case PLATFORM_MACOS64: return "macos64"; - default: return nullptr; - } - } - const char* asString(OptimizationLevel optLevel) { switch(optLevel) @@ -666,6 +641,23 @@ namespace sibs }); } + static string combineSupportedPlatformsAsString() + { + string result; + int i = 0; + int size = PLATFORM_BY_NAME.size(); + for(const auto &it : PLATFORM_BY_NAME) + { + if(i > 0 && i == size - 1) + result += " or "; + else if(i > 0) + result += ", "; + result += it.second; + ++i; + } + return result; + } + void SibsConfig::processObject(StringView name) { currentObject = name; @@ -783,47 +775,16 @@ namespace sibs for (const StringView &platform : value.asList()) { - if (platform.equals("any")) - { - platforms.push_back(PLATFORM_ANY); - } - else if (platform.equals("linux32")) - { - platforms.push_back(PLATFORM_LINUX32); - } - else if (platform.equals("linux64")) - { - platforms.push_back(PLATFORM_LINUX64); - } - else if (platform.equals("win32")) - { - platforms.push_back(PLATFORM_WIN32); - } - else if (platform.equals("win64")) - { - platforms.push_back(PLATFORM_WIN64); - } - else if (platform.equals("macos32")) - { - platforms.push_back(PLATFORM_MACOS32); - } - else if (platform.equals("macos64")) - { - platforms.push_back(PLATFORM_MACOS64); - } - else if (platform.equals("openbsd32")) - { - platforms.push_back(PLATFORM_OPENBSD32); - } - else if (platform.equals("openbsd64")) + Platform platformType = getPlatformByName(platform); + if (platformType != PLATFORM_INVALID) { - platforms.push_back(PLATFORM_OPENBSD64); + platforms.push_back(platformType); } else { string errMsg = "package.platforms contains invalid platform \""; errMsg += string(platform.data, platform.size); - errMsg += "\". Expected platform to be one of: any, linux32, linux64, win32, win64, macos32, macos64, openbsd32 or openbsd64"; + errMsg += "\". Expected platform to be one of: " + combineSupportedPlatformsAsString(); throw ParserException(errMsg); } } @@ -1177,9 +1138,11 @@ namespace sibs validConfig = true; switch(i) { + case CONFIG_GENERIC_STATIC_DEBUG_PLATFORM: case CONFIG_STATIC_DEBUG_PLATFORM: parsePlatformConfigStaticDebug(fieldName, fieldValue); break; + case CONFIG_GENERIC_STATIC_RELEASE_PLATFORM: case CONFIG_STATIC_RELEASE_PLATFORM: parsePlatformConfigStaticRelease(fieldName, fieldValue); break; -- cgit v1.2.3