From cc0f3bf97a5138e8c4f2e121f304eda7beac56a9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 29 Oct 2018 00:02:22 +0100 Subject: Add cygwin support --- README.md | 7 ++++--- backend/ninja/Ninja.cpp | 2 +- include/env.hpp | 7 ++++++- install.sh | 6 ++++++ src/FileUtil.cpp | 2 +- src/main.cpp | 4 ++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2a3efde..111d2dd 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,12 @@ 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 |Haiku|... | +|Linux|Windows(1)|MacOS |OpenBSD |Haiku|... | |-----|-------|-----------|-----------|-----|-----------| -|✓ |✓ |✓ |✓ |✓ |TBD* | +|✓ |✓ |✓ |✓ |✓ |TBD(2) | -\* 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. +(1). Msvc, mingw-w64 and cygwin are supported. Cygwin is defined as a linux platform while mingw-w64 is defined as a windows system. +(2). 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. Linux is the primary platform, the platform which master branch is guaranteed to compile on. diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 4162c58..9a8dc25 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -1023,7 +1023,7 @@ namespace backend ninja::NinjaArg::createRaw("-fdiagnostics-color=always"), ninja::NinjaArg::createRaw("-pipe"), ninja::NinjaArg::createRaw("-D_FILE_OFFSET_BITS=64"), - ninja::NinjaArg::createRaw("-Winvalid-pch"), + ninja::NinjaArg::createRaw("-Winvalid-pch -D_GNU_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE"), }); if(config.getCompiler() != Compiler::MINGW_W64) diff --git a/include/env.hpp b/include/env.hpp index 9cdaf9d..72b7828 100644 --- a/include/env.hpp +++ b/include/env.hpp @@ -7,7 +7,7 @@ #define OS_TYPE_WINDOWS 0 #define OS_TYPE_LINUX 1 #define OS_TYPE_APPLE 2 -#define OS_TYPE_OPENBSD 2 +#define OS_TYPE_OPENBSD 3 #define OS_TYPE_HAIKU 10 #if defined(_WIN32) || defined(_WIN64) @@ -54,6 +54,11 @@ #define OS_TYPE OS_TYPE_HAIKU #endif +#ifdef __CYGWIN__ + #define OS_FAMILY OS_FAMILY_POSIX + #define OS_TYPE OS_TYPE_LINUX +#endif + #if defined(__GNUC__) #if defined(__x86_64__) || defined(__pc64__) #define SIBS_ENV_64BIT diff --git a/install.sh b/install.sh index 530a7bc..44cb648 100755 --- a/install.sh +++ b/install.sh @@ -13,6 +13,12 @@ case "$(uname -s)" in OpenBSD*) bin_dir="/usr/local/bin" ;; + CYGWIN*) + bin_dir="/usr/bin" + sudo() { + "$@" + } + ;; *) echo "The install file can only be run on linux, mac and openbsd" && exit 1 ;; diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index d07a074..2a0b290 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -16,7 +16,7 @@ using namespace std; -#if OS_TYPE != OS_TYPE_LINUX && OS_TYPE != OS_TYPE_APPLE && OS_TYPE != OS_TYPE_WINDOWS +#if (OS_TYPE != OS_TYPE_LINUX && OS_TYPE != OS_TYPE_APPLE && OS_TYPE != OS_TYPE_WINDOWS) || defined(__CYGWIN__) #define stat64 stat #endif diff --git a/src/main.cpp b/src/main.cpp index 1265d3d..ab8cd59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,6 +101,10 @@ using namespace std::chrono; // TODO: If dependencies are using a version that is not within our dependency version range then ask the user if they still want to use the dependency (the closest matching dependency). // Currently if dependency version does not match, build will always fail with no option to ignore version mismatch. +// TODO: Move global lib dependencies into different directories depending on the target platform, because one system can be used +// to build packages for the host platfrom and another platform by cross compilation. If cross compilation is used and a dependency is installed that is not compatible with the target platform then the dependency that fits the target platform wont be downloaded +// since the dependency already exists locally (but for a different platform). + #if OS_FAMILY == OS_FAMILY_POSIX #define fout std::cout #define ferr std::cerr -- cgit v1.2.3