From 017ec45e94204f977dcd7b04c8035d48f230ded3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 31 Dec 2017 05:24:40 +0100 Subject: Sibs can now build itself on windows Fixed several bugs. The windows implementation IS QUICK AND DIRTY! It links things as static even if you wish to link as dynamic etc..... NEED TO FIX THIS !!! --- include/Conf.hpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++- include/FileUtil.hpp | 1 + include/GlobalLib.hpp | 2 +- include/Linker.hpp | 1 + include/env.hpp | 10 ++++---- 5 files changed, 73 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/Conf.hpp b/include/Conf.hpp index d147fca..2cb387c 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -99,6 +99,46 @@ namespace sibs MSVC }; + enum Platform + { + PLATFORM_ANY, + + PLATFORM_LINUX32, + PLATFORM_LINUX64, + + PLATFORM_WIN32, + PLATFORM_WIN64 + }; + + // TODO: Detect this at runtime? + #if OS_TYPE == OS_TYPE_WINDOWS + #ifdef SIBS_ENV_32BIT + const Platform SYSTEM_PLATFORM = Platform::PLATFORM_WIN32; + const StringView CONFIG_SYSTEM_PLATFORM = "config.win32"; + const StringView CONFIG_STATIC_DEBUG_PLATFORM = "config.win32.static.debug"; + const StringView CONFIG_STATIC_RELEASE_PLATFORM = "config.win32.static.release"; + #else + const Platform SYSTEM_PLATFORM = Platform::PLATFORM_WIN64; + const StringView CONFIG_SYSTEM_PLATFORM = "config.win64"; + const StringView CONFIG_STATIC_DEBUG_PLATFORM = "config.win64.static.debug"; + const StringView CONFIG_STATIC_RELEASE_PLATFORM = "config.win64.static.release"; + #endif + #elif OS_TYPE == OS_TYPE_LINUX + #ifdef SIBS_ENV_32BIT + const Platform SYSTEM_PLATFORM = Platform::PLATFORM_LINUX32; + const StringView CONFIG_SYSTEM_PLATFORM = "config.linux32"; + const StringView CONFIG_STATIC_DEBUG_PLATFORM = "config.linux32.static.debug"; + const StringView CONFIG_STATIC_RELEASE_PLATFORM = "config.linux32.static.release"; + #else + const Platform SYSTEM_PLATFORM = Platform::PLATFORM_LINUX64; + const StringView CONFIG_SYSTEM_PLATFORM = "config.linux64"; + const StringView CONFIG_STATIC_DEBUG_PLATFORM = "config.linux64.static.debug"; + const StringView CONFIG_STATIC_RELEASE_PLATFORM = "config.linux64.static.release"; + #endif + #endif + + bool containsPlatform(const std::vector &platforms, Platform platform); + const char* asString(Platform platform); const char* asString(OptimizationLevel optLevel); class SibsConfig : public ConfigCallback @@ -144,10 +184,30 @@ namespace sibs return includeDirs; } + virtual const std::vector& getGlobalIncludeDirs() const + { + return exposeIncludeDirs; + } + + virtual const std::vector& getPlatforms() const + { + return platforms; + } + virtual OptimizationLevel getOptimizationLevel() const { return optimizationLevel; } + + const std::vector& getDebugStaticLibs() const + { + return debugStaticLibs; + } + + const std::vector& getReleaseStaticLibs() const + { + return releaseStaticLibs; + } void setPackageType(PackageType packageType) { @@ -170,15 +230,19 @@ namespace sibs PackageType packageType; std::vector dependencies; std::vector includeDirs; + std::vector exposeIncludeDirs; + std::vector platforms; std::unordered_map defines; OptimizationLevel optimizationLevel; + std::vector debugStaticLibs; + std::vector releaseStaticLibs; bool finishedProcessing; }; class SibsTestConfig : public SibsConfig { public: - SibsTestConfig(Compiler _compiler, const FileString &_projectPath) : SibsConfig(_compiler, _projectPath) + SibsTestConfig(Compiler _compiler, const FileString &_projectPath, OptimizationLevel _optimizationLevel) : SibsConfig(_compiler, _projectPath, _optimizationLevel) { packageName = "test"; } diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp index 89eaa84..f2679a0 100644 --- a/include/FileUtil.hpp +++ b/include/FileUtil.hpp @@ -30,6 +30,7 @@ namespace sibs FileString utf8To16(const std::string &utf8Str); FileString toFileString(const std::string &utf8Str); FileString getLastErrorAsString(); + void replaceChar(FileString &input, wchar_t charToReplace, wchar_t charToReplaceWith); #endif using FileWalkCallbackFunc = std::function; diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp index 2f4b938..b098543 100644 --- a/include/GlobalLib.hpp +++ b/include/GlobalLib.hpp @@ -18,7 +18,7 @@ namespace sibs }; static Result validatePackageExists(const FileString &globalLibRootDir, const std::string &name); - static Result getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc); + static Result getLibsLinkerFlags(const SibsConfig &parentConfig, const FileString &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback); static Result downloadDependency(const Dependency &dependency); }; } diff --git a/include/Linker.hpp b/include/Linker.hpp index 7ea7b48..90bebe2 100644 --- a/include/Linker.hpp +++ b/include/Linker.hpp @@ -6,6 +6,7 @@ namespace sibs { using LinkerFlagCallbackFunc = std::function; + using GlobalIncludeDirCallbackFunc = std::function; } #endif //SIBS_LINKER_HPP diff --git a/include/env.hpp b/include/env.hpp index 51ee2bd..1ea55ca 100644 --- a/include/env.hpp +++ b/include/env.hpp @@ -9,9 +9,9 @@ #if defined(_WIN32) || defined(_WIN64) #if defined(_WIN64) - #define CISB_ENV_64BIT + #define SIBS_ENV_64BIT #else - #define CISB_ENV_32BIT + #define SIBS_ENV_32BIT #endif #define OS_FAMILY OS_FAMILY_WINDOWS #define OS_TYPE OS_TYPE_WINDOWS @@ -41,13 +41,13 @@ #if defined(__GNUC__) #if defined(__x86_64__) || defined(__pc64__) - #define CISB_ENV_64BIT + #define SIBS_ENV_64BIT #else - #define CISB_ENV_32BIT + #define SIBS_ENV_32BIT #endif #endif -#if !defined(CISB_ENV_32BIT) && !defined(CISB_ENV_64BIT) +#if !defined(SIBS_ENV_32BIT) && !defined(SIBS_ENV_64BIT) #error "System is not detected as either 32-bit or 64-bit" #endif -- cgit v1.2.3