diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Platform.cpp | 29 | ||||
-rw-r--r-- | src/main.cpp | 13 |
2 files changed, 39 insertions, 3 deletions
diff --git a/src/Platform.cpp b/src/Platform.cpp index b011d93..f92e1ea 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -1,5 +1,6 @@ #include "../include/Platform.hpp" #include <cassert> +#include <algorithm> namespace sibs { @@ -63,6 +64,34 @@ namespace sibs return PLATFORM_INVALID; } + static std::string join(const std::vector<std::string> &strings) + { + std::string result; + ssize size = strings.size(); + ssize i = 0; + for(const std::string &str: strings) + { + result += str; + if(i == size - 2) + result += " and "; + else if(i < size - 2) + result += ", "; + ++i; + } + return result; + } + + std::string getPlatformListFormatted() + { + std::vector<std::string> platformsSorted; + for(auto &it: PLATFORM_BY_NAME) + { + platformsSorted.push_back({ it.first.data, it.first.size }); + } + std::sort(platformsSorted.begin(), platformsSorted.end()); + return join(platformsSorted); + } + bool isSamePlatformFamily(Platform a, Platform b) { return a & b; diff --git a/src/main.cpp b/src/main.cpp index c954634..bf97450 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,6 +127,7 @@ static void usage() printf(" test\t\tBuild and run tests for a sibs project\n"); printf(" package\t\tCreate a redistributable package from a sibs project. Note: Redistributable packages can't use system packages to build\n"); printf(" platform\t\tPrint name of platform (to stdout) and exit\n"); + printf(" platforms\t\tPrint list of supported platforms (to stdout) and exit\n"); exit(1); } @@ -138,7 +139,7 @@ static void usageBuild() printf(" project_path\t\tThe directory containing a project.conf file - Optional (default: current directory)\n"); printf(" --debug|--release\t\tOptimization level to build project and dependencies with (if not a system package) - Optional (default: --debug)\n"); printf(" --sanitize\t\tAdd runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: disabled)\n"); - printf(" --platform\t\tThe platform to build for - Optional (default: the running platform). Platform can be either linux32, linux64, win32 or win64\n"); + printf(" --platform\t\tThe platform to build for - Optional (default: the running platform)\n"); printf("Examples:\n"); printf(" sibs build\n"); printf(" sibs build dirA/dirB\n"); @@ -522,13 +523,14 @@ static int buildProject(int argc, const _tinydir_char_t **argv) if(platform == PLATFORM_INVALID) { ferr << "Invalid platform " << platformName << endl; + ferr << "Expected one of: " << getPlatformListFormatted() << std::endl; usageBuild(); } - bool crossCompileLinux64ToWin64 = (SYSTEM_PLATFORM == PLATFORM_LINUX64 && platform == PLATFORM_WIN64); + bool crossCompileLinux64ToWin64 = (SYSTEM_PLATFORM == PLATFORM_LINUX_X86_64 && platform == PLATFORM_WIN64); if(platform != SYSTEM_PLATFORM && !crossCompileLinux64ToWin64) { - ferr << "Cross compilation is currently only supported from linux64 to win64" << endl; + ferr << "Cross compilation is currently only supported from linux_X86_64 to win64" << endl; exit(33); } @@ -1434,6 +1436,11 @@ int wmain(int argc, const _tinydir_char_t **argv) printf("%s\n", asString(SYSTEM_PLATFORM)); return 0; } + else if(_tinydir_strcmp(arg, TINYDIR_STRING("platforms")) == 0) + { + printf("%s\n", getPlatformListFormatted().c_str()); + return 0; + } else { ferr << "Expected command to be either 'build', 'new' or 'test', was: " << arg << endl << endl; |