aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Conf.hpp139
-rw-r--r--include/Platform.hpp17
-rw-r--r--include/StringView.hpp7
3 files changed, 20 insertions, 143 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp
index bae0153..a60bc36 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -138,181 +138,47 @@ namespace sibs
Language language;
std::string filepath;
};
-
- 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.haiku",
- "config.haiku.static.debug",
- "config.haiku.static.release",
-
- "config.win32",
- "config.win32.static.debug",
- "config.win32.static.release",
-
- "config.win64",
- "config.win64.static.debug",
- "config.win64.static.release",
-
- "config.linux32",
- "config.linux32.static.debug",
- "config.linux32.static.release",
-
- "config.linux64",
- "config.linux64.static.debug",
- "config.linux64.static.release",
-
- "config.macos32",
- "config.macos32.static.debug",
- "config.macos32.static.release"
-
- "config.macos64",
- "config.macos64.static.debug",
- "config.macos64.static.release",
-
- "config.openbsd32",
- "config.openbsd32.static.debug",
- "config.openbsd32.static.release",
-
- "config.openbsd64",
- "config.openbsd64.static.debug",
- "config.openbsd64.static.release",
-
- "config.haiku32",
- "config.haiku32.static.debug",
- "config.haiku32.static.release",
-
- "config.haiku64",
- "config.haiku64.static.debug",
- "config.haiku64.static.release"
- };
- const int NUM_CONFIGS = 3 * 16;
- const int CONFIGS_GENERIC_OFFSET = 3 * 6;
#if OS_TYPE == OS_TYPE_WINDOWS
#ifdef SIBS_ENV_32BIT
const Platform SYSTEM_PLATFORM = PLATFORM_WIN32;
- #define SYSTEM_PLATFORM_NAME L"win32"
- #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 L"win64"
- #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 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 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 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 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 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 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 12
- #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 13
- #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 14
#elif OS_TYPE == OS_TYPE_HAIKU
#ifdef SIBS_ENV_32BIT
const Platform SYSTEM_PLATFORM = PLATFORM_HAIKU32;
- #define SYSTEM_PLATFORM_NAME "haiku32"
- #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 24
- #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 25
- #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 26
#else
const Platform SYSTEM_PLATFORM = PLATFORM_HAIKU64;
- #define SYSTEM_PLATFORM_NAME "haiku64"
- #define CONFIG_SYSTEM_PLATFORM CONFIGS_GENERIC_OFFSET + 27
- #define CONFIG_STATIC_DEBUG_PLATFORM CONFIGS_GENERIC_OFFSET + 28
- #define CONFIG_STATIC_RELEASE_PLATFORM CONFIGS_GENERIC_OFFSET + 29
#endif
#define CONFIG_STATIC_LIB_FILE_EXTENSION "a"
#define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "so"
-
- #define SYSTEM_GENERIC_PLATFORM_NAME "haiku"
- #define CONFIG_GENERIC_SYSTEM_PLATFORM 15
- #define CONFIG_GENERIC_STATIC_DEBUG_PLATFORM 16
- #define CONFIG_GENERIC_STATIC_RELEASE_PLATFORM 17
#endif
const char* asString(OptimizationLevel optLevel);
@@ -365,13 +231,11 @@ namespace sibs
virtual const std::string& getPackageName() const
{
- assert(finishedProcessing);
return packageName;
}
virtual PackageType getPackageType() const
{
- assert(finishedProcessing);
return packageType;
}
@@ -543,6 +407,7 @@ namespace sibs
protected:
virtual void processObject(StringView name) override;
virtual void processField(StringView name, const ConfigValue &value) override;
+ void parseConfig(const StringView &name, const ConfigValue &value);
void parseDependencies(const StringView &name, const ConfigValue &value);
virtual void finished() override;
void failInvalidFieldUnderObject(const StringView &fieldName) const;
@@ -550,7 +415,7 @@ namespace sibs
private:
void parseCLang(const StringView &fieldName, const ConfigValue &fieldValue);
void parseCppLang(const StringView &fieldName, const ConfigValue &fieldValue);
- void parsePlatformBuildTypeConfigs(const StringView &fieldName, const ConfigValue &fieldValue);
+ void parsePlatformConfig(const StringView &fieldName, const ConfigValue &fieldValue);
std::string parsePlatformConfigStatic(const StringView &fieldName, const ConfigValue &fieldValue);
void parsePlatformConfigStaticDebug(const StringView &fieldName, const ConfigValue &fieldValue);
void parsePlatformConfigStaticRelease(const StringView &fieldName, const ConfigValue &fieldValue);
diff --git a/include/Platform.hpp b/include/Platform.hpp
index ffe7038..3ae3d24 100644
--- a/include/Platform.hpp
+++ b/include/Platform.hpp
@@ -29,9 +29,9 @@ namespace sibs
PLATFORM_OPENBSD32 = 1 << 12 | PLATFORM_OPENBSD,
PLATFORM_OPENBSD64 = 1 << 13 | PLATFORM_OPENBSD,
- PLATFORM_HAIKU = 1 << 20,
- PLATFORM_HAIKU32 = 1 << 21 | PLATFORM_HAIKU,
- PLATFORM_HAIKU64 = 1 << 22 | PLATFORM_HAIKU
+ PLATFORM_HAIKU = 1 << 20,
+ PLATFORM_HAIKU32 = 1 << 21 | PLATFORM_HAIKU,
+ PLATFORM_HAIKU64 = 1 << 22 | PLATFORM_HAIKU
};
const StringViewMap<Platform> PLATFORM_BY_NAME = {
@@ -49,13 +49,18 @@ namespace sibs
{ "openbsd", PLATFORM_OPENBSD },
{ "openbsd32", PLATFORM_OPENBSD32 },
{ "openbsd64", PLATFORM_OPENBSD64 },
- { "haiku", PLATFORM_HAIKU },
- { "haiku32", PLATFORM_HAIKU32 },
- { "haiku64", PLATFORM_HAIKU64 },
+ { "haiku", PLATFORM_HAIKU },
+ { "haiku32", PLATFORM_HAIKU32 },
+ { "haiku64", PLATFORM_HAIKU64 },
};
bool containsPlatform(const std::vector<Platform> &platforms, Platform platform);
const char* asString(Platform platform);
Platform getPlatformByName(StringView name);
+ // Return true if both platforms are of same type, for example if platform @a is either win, win32, win64 and @b is either win, win32, win64
bool isSamePlatformFamily(Platform a, Platform b);
+ // Returns true if platform @base is a base platform for platform @platform, for example if @platform is win64 and @base is either win64 or win, then this function return true.
+ // If for example @platform is win64 and @base is win32, then this function returns false.
+ bool isBaseForPlatform(Platform base, Platform platform);
+ Platform getPlatformGenericType(Platform platform);
}
diff --git a/include/StringView.hpp b/include/StringView.hpp
index adfa237..4d87d8a 100644
--- a/include/StringView.hpp
+++ b/include/StringView.hpp
@@ -7,6 +7,7 @@
#include "env.hpp"
#include <cstring>
#include <unordered_map>
+#include <cassert>
namespace sibs
{
@@ -47,6 +48,12 @@ namespace sibs
return XXH32(data, size, 0xdec05eba);
#endif
}
+
+ char operator [] (size_t index) const
+ {
+ assert(index < size);
+ return data[index];
+ }
const char *data;
usize size;