diff options
author | Charlie Root <root@dec05eba.my.domain> | 2018-09-30 23:44:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | 0b09e97d0d6163b5a898f5642505ee12dd5ef30e (patch) | |
tree | 6464ce5279090cf99aa957aaca1faf68c50db095 | |
parent | 147188af8356d21fb9720308ef4912e1f3a22a15 (diff) |
Add OpenBSD support
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | backend/ninja/Ninja.cpp | 12 | ||||
-rwxr-xr-x | cmake/install.sh | 8 | ||||
-rw-r--r-- | include/Conf.hpp | 31 | ||||
-rw-r--r-- | include/env.hpp | 16 | ||||
-rwxr-xr-x | install.sh | 5 | ||||
-rw-r--r-- | project.conf | 2 | ||||
-rw-r--r-- | src/Conf.cpp | 10 | ||||
-rw-r--r-- | src/Exec.cpp | 4 | ||||
-rw-r--r-- | src/FileUtil.cpp | 5 |
10 files changed, 85 insertions, 21 deletions
@@ -6,7 +6,8 @@ Zig support has not been tested properly yet and currently always links to c lib You can run zig tests with `sibs test --file filepath` or `sibs test --all-files`. Currently zig tests are cached because ninja build system is used, which means if source files do not change between runs. Currently zig files generate header files and include exported functions into sibs-build/generated-headers/zig and the generated headers -are usable from c/c++ by using including: `#include <zig/INSERT_ZIG_HEADER_FILE_NAME_HERE>` +are usable from c/c++ by using including: `#include <zig/INSERT_ZIG_HEADER_FILE_NAME_HERE>`. +If your project contains zig files then it will currently only run on Linux, Windows and MacOS as zig doesn't support more platforms at the moment. The CMakeLists.txt should only be used during development or when installing sibs for the first time. To compile under windows you can use vcpkg to install dependencies and then generate visual studio project using cmake. @@ -14,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 |... | -|-----|-------|-----------|-----------| -|✓ |✓ |✓ |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. @@ -45,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"] +platforms = ["linux32", "linux64", "win32", "win64", "macos32", "macos64", "openbsd32", "openbsd64"] authors = ["DEC05EBA <0xdec05eba@gmail.com>"] [dependencies] @@ -100,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". +Required. A list of platforms the package supports. Can contain the following values: "any", "linux32", "linux64", "win32", "win64", "macos32", "macos64", "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/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 3d71574..0c9cf0e 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -1150,10 +1150,16 @@ namespace backend } // TODO: Add flag to disable -ldl and -lm (dlopen, dlclose, floor, max, ...) +#if OS_TYPE == OS_TYPE_OPENBSD + buildExeArgs.insert(buildExeArgs.end(), { + ninja::NinjaArg::createRaw("-lm") + }); +#else buildExeArgs.insert(buildExeArgs.end(), { ninja::NinjaArg::createRaw("-ldl"), ninja::NinjaArg::createRaw("-lm") }); +#endif break; } case Compiler::MSVC: @@ -1338,10 +1344,16 @@ namespace backend } // TODO: Add flag to disable -ldl and -lm (dlopen, dlclose, floor, max, ...) +#if OS_TYPE == OS_TYPE_OPENBSD + buildDynamicArgs.insert(buildDynamicArgs.end(), { + ninja::NinjaArg::createRaw("-lm") + }); +#else buildDynamicArgs.insert(buildDynamicArgs.end(), { ninja::NinjaArg::createRaw("-ldl"), ninja::NinjaArg::createRaw("-lm") }); +#endif break; } case Compiler::MSVC: diff --git a/cmake/install.sh b/cmake/install.sh index 595fd26..03eae77 100755 --- a/cmake/install.sh +++ b/cmake/install.sh @@ -5,7 +5,8 @@ set -e case "$(uname -s)" in Linux*) machine="Linux" ;; Darwin*) machine="Mac" ;; - *) echo "The install file can only be run on linux and mac" && exit 1 ;; + OpenBSD*) machine="OpenBSD" ;; + *) echo "The install file can only be run on linux, mac and openbsd" && exit 1 ;; esac scriptpath="$(dirname "$0")" @@ -15,8 +16,9 @@ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../../../ ninja case $machine in - Linux) bin_dir="/usr/bin" ;; - Mac) bin_dir="/usr/local/bin" ;; + Linux) bin_dir="/usr/bin" ;; + Mac) bin_dir="/usr/local/bin" ;; + OpenBSD) bin_dir="/usr/local/bin" ;; esac sudo cp sibs "$bin_dir" diff --git a/include/Conf.hpp b/include/Conf.hpp index 7e5bf69..8fa3475 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -120,7 +120,10 @@ namespace sibs PLATFORM_WIN64, PLATFORM_MACOS32, - PLATFORM_MACOS64 + PLATFORM_MACOS64, + + PLATFORM_OPENBSD32, + PLATFORM_OPENBSD64 }; enum class CVersion @@ -174,7 +177,15 @@ namespace sibs "config.macos64", "config.macos64.static.debug", - "config.macos64.static.release" + "config.macos64.static.release", + + "config.openbsd32", + "config.openbsd32.static.debug", + "config.openbsd32.static.release", + + "config.openbsd64", + "config.openbsd64.static.debug", + "config.openbsd64.static.release" }; const int NUM_CONFIGS = 12; @@ -226,6 +237,22 @@ namespace sibs #endif #define CONFIG_STATIC_LIB_FILE_EXTENSION "a" #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "dylib" + #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 + #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 + #endif + #define CONFIG_STATIC_LIB_FILE_EXTENSION "a" + #define CONFIG_DYNAMIC_LIB_FILE_EXTENSION "so" #endif bool containsPlatform(const std::vector<Platform> &platforms, Platform platform); diff --git a/include/env.hpp b/include/env.hpp index fa9c860..33e8068 100644 --- a/include/env.hpp +++ b/include/env.hpp @@ -7,6 +7,7 @@ #define OS_TYPE_WINDOWS 0 #define OS_TYPE_LINUX 1 #define OS_TYPE_APPLE 2 +#define OS_TYPE_OPENBSD 2 #if defined(_WIN32) || defined(_WIN64) #if defined(_WIN64) @@ -32,18 +33,21 @@ #include <Windows.h> #endif -#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(_POSIX_VERSION) - #define OS_FAMILY OS_FAMILY_POSIX -#endif - #ifdef __linux__ + #define OS_FAMILY OS_FAMILY_POSIX #define OS_TYPE OS_TYPE_LINUX #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__MACOSX__) + #define OS_FAMILY OS_FAMILY_POSIX #define OS_TYPE OS_TYPE_APPLE #endif +#ifdef __OpenBSD__ + #define OS_FAMILY OS_FAMILY_POSIX + #define OS_TYPE OS_TYPE_OPENBSD +#endif + #if defined(__GNUC__) #if defined(__x86_64__) || defined(__pc64__) #define SIBS_ENV_64BIT @@ -61,7 +65,7 @@ #endif #if !defined(OS_TYPE) - #error "System not supported. Only Windows and linux systems supported right now" + #error "System not supported. Only Windows, linux, macos and openbsd systems supported right now" #endif #if !defined(DEBUG) && !defined(NDEBUG) @@ -10,8 +10,11 @@ case "$(uname -s)" in bin_dir="/usr/local/bin" export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig/" ;; + OpenBSD*) + bin_dir="/usr/local/bin" + ;; *) - echo "The install file can only be run on linux and mac" && exit 1 + echo "The install file can only be run on linux, mac and openbsd" && exit 1 ;; esac diff --git a/project.conf b/project.conf index 73eed20..bcfc4d1 100644 --- a/project.conf +++ b/project.conf @@ -3,7 +3,7 @@ name = "sibs" type = "executable" version = "0.1.5" authors = ["DEC05EBA <0xdec05eba@gmail.com>"] -platforms = ["linux32", "linux64", "win64", "macos32", "macos64"] +platforms = ["any"] [config] ignore_dirs = ["cmake", "cmake-build-debug", "build", "distribute", "examples", "msvc", "cmake_msvc"] diff --git a/src/Conf.cpp b/src/Conf.cpp index 6645913..2fdef25 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -811,11 +811,19 @@ namespace sibs { platforms.push_back(PLATFORM_MACOS64); } + else if (platform.equals("openbsd32")) + { + platforms.push_back(PLATFORM_OPENBSD32); + } + else if (platform.equals("openbsd64")) + { + platforms.push_back(PLATFORM_OPENBSD64); + } 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 or macos64"; + errMsg += "\". Expected platform to be one of: any, linux32, linux64, win32, win64, macos32, macos64, openbsd32 or openbsd64"; throw ParserException(errMsg); } } diff --git a/src/Exec.cpp b/src/Exec.cpp index a183ed2..cfeb19d 100644 --- a/src/Exec.cpp +++ b/src/Exec.cpp @@ -1,6 +1,10 @@ #include "../include/Exec.hpp" #include "../include/env.hpp" +#if OS_FAMILY == OS_FAMILY_POSIX +#include <sys/wait.h> +#endif + using namespace std; const int BUFSIZE = 1024; diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index e3d4c3c..f52dd1f 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -16,13 +16,16 @@ using namespace std; +#if OS_TYPE == OS_TYPE_OPENBSD +#define stat64 stat +#endif + #if OS_FAMILY == OS_FAMILY_POSIX static int makedir(const _tinydir_char_t *dir) { return mkdir(dir, S_IRWXU); } #elif OS_FAMILY == OS_FAMILY_WINDOWS - static int makedir(const _tinydir_char_t *dir) { return _wmkdir(dir); |