diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-01 04:51:42 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | e2d947ccd6947c9190569fedbb4a90505b5fe9a5 (patch) | |
tree | 943167a2aae91af3164e5cd80a96b08826952d23 | |
parent | 63cedcab19474cae0a4b1322600355ddc23d56d0 (diff) |
Allow specifying project platform without arch
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | include/Conf.hpp | 110 | ||||
-rw-r--r-- | include/Package.hpp | 3 | ||||
-rw-r--r-- | include/Platform.hpp | 53 | ||||
-rw-r--r-- | src/Conf.cpp | 83 | ||||
-rw-r--r-- | src/GlobalLib.cpp | 15 | ||||
-rw-r--r-- | src/Package.cpp | 23 | ||||
-rw-r--r-- | src/Platform.cpp | 44 | ||||
-rw-r--r-- | src/main.cpp | 4 |
10 files changed, 208 insertions, 138 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a7cd470..1070620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ set(SOURCE_FILES src/CmakeModule.cpp src/Package.cpp src/GitRepository.cpp + src/Platform.cpp depends/libninja/src/Ninja.cpp) @@ -15,9 +15,9 @@ To compile under windows you can use vcpkg to install dependencies and then gene List of packages can be found at https://gitlab.com/DEC05EBA/sibs_packages/raw/master/packages.json ### Supported platforms -|Linux|Windows|MacOS |OpenBSD|... | -|-----|-------|-----------|-----------|---| -|✓ |✓ |✓ |✓|TBD* | +|Linux|Windows|MacOS |OpenBSD |... | +|-----|-------|-----------|-----------|-----------| +|✓ |✓ |✓ |✓ |TBD* | \* Sibs is intended to work on as many platforms as possible, you can help by porting sibs to another platform. Should only be minor changes if the platform is unix-like. @@ -46,7 +46,7 @@ If your project contains a sub directory called "tests" then that directory will name = "packageName" type = "library" version = "0.1.0" -platforms = ["linux32", "linux64", "win32", "win64", "macos32", "macos64", "openbsd32", "openbsd64"] +platforms = ["linux", "linux32", "linux64", "win", "win32", "win64", "macos32", "macos64", "bsd", "openbsd", "openbsd32", "openbsd64"] authors = ["DEC05EBA <0xdec05eba@gmail.com>"] [dependencies] @@ -101,7 +101,7 @@ 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", "macos32", "macos64", "openbsd32", "openbsd64". +Required. A list of platforms the package supports. Can contain the following values: "any", "linux", "linux32", "linux64", "win", "win32", "win64", "macos32", "macos64", "bsd", "openbsd", "openbsd32", "openbsd64". If platforms contains "any", then other there is no need to specify other platforms ### authors Optional. A list of authors diff --git a/include/Conf.hpp b/include/Conf.hpp index 8fa3475..d492e99 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -7,6 +7,7 @@ #include "utils.hpp" #include "Dependency.hpp" #include "Package.hpp" +#include "Platform.hpp" #include <vector> #include <unordered_map> #include <cassert> @@ -108,23 +109,6 @@ namespace sibs GCC, MSVC }; - - enum Platform - { - PLATFORM_ANY, - - PLATFORM_LINUX32, - PLATFORM_LINUX64, - - PLATFORM_WIN32, - PLATFORM_WIN64, - - PLATFORM_MACOS32, - PLATFORM_MACOS64, - - PLATFORM_OPENBSD32, - PLATFORM_OPENBSD64 - }; enum class CVersion { @@ -155,6 +139,26 @@ namespace sibs }; const StringView CONFIGS[] = { + "config.win", + "config.win.static.debug", + "config.win.static.release", + + "config.linux", + "config.linux.static.debug", + "config.linux.static.release", + + "config.macos", + "config.macos.static.debug", + "config.macos.static.release", + + "config.bsd", + "config.bsd.static.debug", + "config.bsd.static.release", + + "config.openbsd", + "config.openbsd.static.debug", + "config.openbsd.static.release", + "config.win32", "config.win32.static.debug", "config.win32.static.release", @@ -188,75 +192,95 @@ namespace sibs "config.openbsd64.static.release" }; const int NUM_CONFIGS = 12; + const int CONFIGS_GENERIC_OFFSET = 15; #if OS_TYPE == OS_TYPE_WINDOWS #ifdef SIBS_ENV_32BIT const Platform SYSTEM_PLATFORM = PLATFORM_WIN32; #define SYSTEM_PLATFORM_NAME "win32" - #define CONFIG_SYSTEM_PLATFORM 0 - #define CONFIG_STATIC_DEBUG_PLATFORM 1 - #define CONFIG_STATIC_RELEASE_PLATFORM 2 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 0 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 1 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 2 #else const Platform SYSTEM_PLATFORM = PLATFORM_WIN64; #define SYSTEM_PLATFORM_NAME "win64" - #define CONFIG_SYSTEM_PLATFORM 3 - #define CONFIG_STATIC_DEBUG_PLATFORM 4 - #define CONFIG_STATIC_RELEASE_PLATFORM 5 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 3 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 4 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 5 #endif #define CONFIG_STATIC_LIB_FILE_EXTENSION L"lib" #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION L"dll" + + #define SYSTEM_GENERIC_PLATFORM_NAME "win" + #define CONFIG_GENERIC_SYSTEM_PLATFORM 0 + #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 1 + #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 2 #elif OS_TYPE == OS_TYPE_LINUX #ifdef SIBS_ENV_32BIT const Platform SYSTEM_PLATFORM = PLATFORM_LINUX32; #define SYSTEM_PLATFORM_NAME "linux32" - #define CONFIG_SYSTEM_PLATFORM 6 - #define CONFIG_STATIC_DEBUG_PLATFORM 7 - #define CONFIG_STATIC_RELEASE_PLATFORM 8 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 6 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 7 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 8 #else const Platform SYSTEM_PLATFORM = PLATFORM_LINUX64; #define SYSTEM_PLATFORM_NAME "linux64" - #define CONFIG_SYSTEM_PLATFORM 9 - #define CONFIG_STATIC_DEBUG_PLATFORM 10 - #define CONFIG_STATIC_RELEASE_PLATFORM 11 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 9 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 10 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 11 #endif #define CONFIG_STATIC_LIB_FILE_EXTENSION "a" #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "so" + + #define SYSTEM_GENERIC_PLATFORM_NAME "linux" + #define CONFIG_GENERIC_SYSTEM_PLATFORM 3 + #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 4 + #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 5 #elif OS_TYPE == OS_TYPE_APPLE #ifdef SIBS_ENV_32BIT const Platform SYSTEM_PLATFORM = PLATFORM_MACOS32; #define SYSTEM_PLATFORM_NAME "macos32" - #define CONFIG_SYSTEM_PLATFORM 12 - #define CONFIG_STATIC_DEBUG_PLATFORM 13 - #define CONFIG_STATIC_RELEASE_PLATFORM 14 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 12 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 13 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 14 #else const Platform SYSTEM_PLATFORM = PLATFORM_MACOS64; #define SYSTEM_PLATFORM_NAME "macos64" - #define CONFIG_SYSTEM_PLATFORM 15 - #define CONFIG_STATIC_DEBUG_PLATFORM 16 - #define CONFIG_STATIC_RELEASE_PLATFORM 17 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 15 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 16 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 17 #endif #define CONFIG_STATIC_LIB_FILE_EXTENSION "a" #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "dylib" + + #define SYSTEM_GENERIC_PLATFORM_NAME "macos" + #define CONFIG_GENERIC_SYSTEM_PLATFORM 6 + #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 7 + #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 8 #elif OS_TYPE == OS_TYPE_OPENBSD #ifdef SIBS_ENV_32BIT const Platform SYSTEM_PLATFORM = PLATFORM_OPENBSD32; #define SYSTEM_PLATFORM_NAME "openbsd32" - #define CONFIG_SYSTEM_PLATFORM 18 - #define CONFIG_STATIC_DEBUG_PLATFORM 19 - #define CONFIG_STATIC_RELEASE_PLATFORM 20 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 18 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 19 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 20 #else const Platform SYSTEM_PLATFORM = PLATFORM_OPENBSD64; #define SYSTEM_PLATFORM_NAME "openbsd64" - #define CONFIG_SYSTEM_PLATFORM 21 - #define CONFIG_STATIC_DEBUG_PLATFORM 22 - #define CONFIG_STATIC_RELEASE_PLATFORM 23 + #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 21 + #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 22 + #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 23 #endif #define CONFIG_STATIC_LIB_FILE_EXTENSION "a" #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "so" + + // TODO: Also add "bsd" platform + #define SYSTEM_GENERIC_PLATFORM_NAME "openbsd" + #define CONFIG_GENERIC_SYSTEM_PLATFORM 9 + #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 10 + #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 11 #endif - bool containsPlatform(const std::vector<Platform> &platforms, Platform platform); - const char* asString(Platform platform); const char* asString(OptimizationLevel optLevel); bool directoryToIgnore(const FileString &dir, const std::vector<std::string> &ignoreDirList); bool isProjectNameValid(const std::string &projectName); diff --git a/include/Package.hpp b/include/Package.hpp index 131e87f..dbae5f2 100644 --- a/include/Package.hpp +++ b/include/Package.hpp @@ -2,6 +2,7 @@ #define SIBS_PACKAGE_HPP #include "../external/rapidjson/document.h" +#include "Platform.hpp" #include "Result.hpp" #include <string> #include <vector> @@ -48,7 +49,7 @@ namespace sibs * TODO: If we fail to fetch package from first url, try other other ones in the list (or if the first url is too slow / takes too long to respond). * TODO: Add version matching with wildcard etc. If we specify "1.2.*", then it should get the latest version that matches; etc... */ - static Result<std::string> getPackageUrl(const char *packageName, const char *packageVersion, const char *platform); + static Result<std::string> getPackageUrl(const char *packageName, const char *packageVersion, Platform platform); }; } diff --git a/include/Platform.hpp b/include/Platform.hpp new file mode 100644 index 0000000..995d307 --- /dev/null +++ b/include/Platform.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "types.hpp" +#include "StringView.hpp" +#include <vector> + +namespace sibs +{ + enum Platform : u32 + { + PLATFORM_INVALID = 0x00000000, + + PLATFORM_ANY = 0xFFFFFFFF, + + PLATFORM_LINUX = 1 << 1, + PLATFORM_LINUX32 = 1 << 2 | PLATFORM_LINUX, + PLATFORM_LINUX64 = 1 << 3 | PLATFORM_LINUX, + + PLATFORM_WIN = 1 << 4, + PLATFORM_WIN32 = 1 << 5 | PLATFORM_WIN, + PLATFORM_WIN64 = 1 << 6 | PLATFORM_WIN, + + PLATFORM_MACOS = 1 << 7, + PLATFORM_MACOS32 = 1 << 8 | PLATFORM_MACOS, + PLATFORM_MACOS64 = 1 << 9 | PLATFORM_MACOS, + + PLATFORM_BSD = 1 << 10, + PLATFORM_OPENBSD = 1 << 11 | PLATFORM_BSD, + PLATFORM_OPENBSD32 = 1 << 12 | PLATFORM_OPENBSD, + PLATFORM_OPENBSD64 = 1 << 13 | PLATFORM_OPENBSD + }; + + const StringViewMap<Platform> PLATFORM_BY_NAME = { + { "any", PLATFORM_ANY }, + { "linux", PLATFORM_LINUX }, + { "linux32", PLATFORM_LINUX32 }, + { "linux64", PLATFORM_LINUX64 }, + { "win", PLATFORM_WIN }, + { "win32", PLATFORM_WIN32 }, + { "win64", PLATFORM_WIN64 }, + { "macos", PLATFORM_MACOS }, + { "macos32", PLATFORM_MACOS32 }, + { "macos64", PLATFORM_MACOS64 }, + { "bsd", PLATFORM_BSD }, + { "openbsd", PLATFORM_OPENBSD }, + { "openbsd32", PLATFORM_OPENBSD32 }, + { "openbsd64", PLATFORM_OPENBSD64 } + }; + + bool containsPlatform(const std::vector<Platform> &platforms, Platform platform); + const char* asString(Platform platform); + Platform getPlatformByName(StringView name); +}
\ No newline at end of file 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<Platform> &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; diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp index 9921c1b..916ba3e 100644 --- a/src/GlobalLib.cpp +++ b/src/GlobalLib.cpp @@ -205,9 +205,6 @@ namespace sibs if (result.isErr()) return result; - if(sibsConfig.getPackageName().empty()) - return Result<bool>::Err("project.conf is missing required field package.name"); - if(sibsConfig.getPackageType() == PackageType::EXECUTABLE) { string errMsg = "The dependency "; @@ -215,16 +212,6 @@ namespace sibs errMsg += " is an executable. Only libraries can be dependencies"; return Result<bool>::Err(errMsg); } - - if (!containsPlatform(sibsConfig.getPlatforms(), SYSTEM_PLATFORM)) - { - string errMsg = "The dependency "; - errMsg += dependencyName; - errMsg += " does not support your platform ("; - errMsg += asString(SYSTEM_PLATFORM); - errMsg += ")"; - return Result<bool>::Err(errMsg); - } FileString buildPath = packageDir + TINYDIR_STRING("/sibs-build/"); switch (sibsConfig.getOptimizationLevel()) @@ -272,7 +259,7 @@ namespace sibs Result<bool> GlobalLib::downloadDependency(PackageListDependency *dependency) { - Result<string> packageUrlResult = Package::getPackageUrl(dependency->name.c_str(), dependency->version.c_str(), SYSTEM_PLATFORM_NAME); + Result<string> packageUrlResult = Package::getPackageUrl(dependency->name.c_str(), dependency->version.c_str(), SYSTEM_PLATFORM); if(!packageUrlResult) return Result<bool>::Err(packageUrlResult); diff --git a/src/Package.cpp b/src/Package.cpp index 9ba26cd..6773265 100644 --- a/src/Package.cpp +++ b/src/Package.cpp @@ -13,19 +13,18 @@ static Document *packageList = nullptr; namespace sibs { - // TODO: Use containsPlatform in Conf.hpp instead? dont need a vector of string when we can use vector of enum - bool containsPlatform(const vector<string> &supportedPlatforms, const char *platform) + static vector<Platform> getPlatformsByNames(const vector<string> &platformNames) { - for(const string &supportedPlatform : supportedPlatforms) + vector<Platform> result; + result.reserve(platformNames.size()); + for(const string &platformName : platformNames) { - if(strcmp(supportedPlatform.c_str(), platform) == 0 || strcmp(supportedPlatform.c_str(), "any") == 0) - return true; + result.push_back(getPlatformByName(StringView(platformName.data(), platformName.size()))); } - - return false; + return result; } - - Result<PackageMetadata> getPackageMetadata(Value::ConstObject jsonObj) + + static Result<PackageMetadata> getPackageMetadata(Value::ConstObject jsonObj) { const auto &description = jsonObj.FindMember("description"); if(description == jsonObj.MemberEnd() || !description->value.IsString()) return Result<PackageMetadata>::Err("Expected description to be a string"); @@ -63,7 +62,7 @@ namespace sibs return Result<PackageMetadata>::Ok(packageMetadata); } - Result<string> getPackageUrl(const PackageMetadata &packageMetadata, const char *packageName, const char *packageVersion, const char *platform) + static Result<string> getPackageUrl(const PackageMetadata &packageMetadata, const char *packageName, const char *packageVersion, Platform platform) { if(strcmp(packageMetadata.version.c_str(), packageVersion) != 0) { @@ -75,7 +74,7 @@ namespace sibs return Result<string>::Err(errMsg); } - if(!containsPlatform(packageMetadata.platforms, platform)) + if(!containsPlatform(getPlatformsByNames(packageMetadata.platforms), platform)) { string errMsg = "Package \""; errMsg += packageName; @@ -121,7 +120,7 @@ namespace sibs return Result<Document*>::Ok(packageList); } - Result<string> Package::getPackageUrl(const char *packageName, const char *packageVersion, const char *platform) + Result<string> Package::getPackageUrl(const char *packageName, const char *packageVersion, Platform platform) { Result<Document*> packageList = Package::getPackageList("https://gitlab.com/DEC05EBA/sibs_packages/raw/master/packages.json"); if(!packageList) diff --git a/src/Platform.cpp b/src/Platform.cpp new file mode 100644 index 0000000..44f42db --- /dev/null +++ b/src/Platform.cpp @@ -0,0 +1,44 @@ +#include "../include/Platform.hpp" + +namespace sibs +{ + bool containsPlatform(const std::vector<Platform> &platforms, Platform platform) + { + for (Platform vecPlatform : platforms) + { + if(platform & vecPlatform) + return true; + } + return false; + } + + const char* asString(Platform platform) + { + switch (platform) + { + case PLATFORM_ANY: return "any"; + case PLATFORM_LINUX: return "linux"; + case PLATFORM_LINUX32: return "linux32"; + case PLATFORM_LINUX64: return "linux64"; + case PLATFORM_WIN: return "win"; + case PLATFORM_WIN32: return "win32"; + case PLATFORM_WIN64: return "win64"; + case PLATFORM_MACOS: return "macos"; + case PLATFORM_MACOS32: return "macos32"; + case PLATFORM_MACOS64: return "macos64"; + case PLATFORM_BSD: return "bsd"; + case PLATFORM_OPENBSD: return "openbsd"; + case PLATFORM_OPENBSD32: return "openbsd32"; + case PLATFORM_OPENBSD64: return "openbsd64"; + default: return nullptr; + } + } + + Platform getPlatformByName(StringView name) + { + auto it = PLATFORM_BY_NAME.find(name); + if(it != PLATFORM_BY_NAME.end()) + return it->second; + return PLATFORM_INVALID; + } +}
\ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 110c178..6a330ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -653,9 +653,7 @@ static Result<bool> newProjectCreateConf(const string &projectName, const string projectConfStr += "name = \"" + projectName + "\"\n"; projectConfStr += "type = \"" + projectType + "\"\n"; projectConfStr += "version = \"0.1.0\"\n"; - projectConfStr += "platforms = [\""; - projectConfStr += asString(SYSTEM_PLATFORM); - projectConfStr += "\"]\n\n"; + projectConfStr += "platforms = [\"any\"]\n\n"; projectConfStr += "[dependencies]\n"; FileString projectConfPath = projectPath; |