aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-01 04:51:42 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commite2d947ccd6947c9190569fedbb4a90505b5fe9a5 (patch)
tree943167a2aae91af3164e5cd80a96b08826952d23 /include
parent63cedcab19474cae0a4b1322600355ddc23d56d0 (diff)
Allow specifying project platform without arch
Diffstat (limited to 'include')
-rw-r--r--include/Conf.hpp110
-rw-r--r--include/Package.hpp3
-rw-r--r--include/Platform.hpp53
3 files changed, 122 insertions, 44 deletions
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