From 45e00fd7c7695adb9d69e8621ab76fdfa085900b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 5 Oct 2018 07:15:55 +0200 Subject: Fix for windows & mingw --- src/Conf.cpp | 6 +++--- src/FileUtil.cpp | 29 +---------------------------- src/PkgConfig.cpp | 2 +- src/main.cpp | 29 +++++++++++++++++++++++------ 4 files changed, 28 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/Conf.cpp b/src/Conf.cpp index aabb957..38774e0 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -486,12 +486,12 @@ namespace sibs return Result::Err(errMsg); } - if (!containsPlatform(config.getPlatforms(), SYSTEM_PLATFORM)) + if (!containsPlatform(config.getPlatforms(), config.platform)) { string errMsg = "The project "; errMsg += config.getPackageName(); - errMsg += " does not support your platform ("; - errMsg += asString(SYSTEM_PLATFORM); + errMsg += " does not support your target platform ("; + errMsg += asString(config.platform); errMsg += ")"; return Result::Err(errMsg); } diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index e317304..ae24996 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -1,6 +1,5 @@ #include "../include/FileUtil.hpp" #include -#include #if OS_FAMILY == OS_FAMILY_POSIX #include @@ -8,7 +7,7 @@ #include #include #else -#include +#include // Copied from linux libc sys/stat.h: #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) @@ -498,30 +497,4 @@ namespace sibs return pathIndex == path.size() && otherPathIndex == otherPath.size(); } - - Result copyFile(const FileString &src, const FileString &dst) - { - ifstream srcFile(src.c_str(), ios::binary); - if(!srcFile) - { - string errMsg = "Failed to open file "; - errMsg += toUtf8(src); - errMsg += ", reason: "; - errMsg += strerror(errno); - return Result::Err(errMsg); - } - - ofstream dstFile(dst.c_str(), ios::binary); - if(!dstFile) - { - string errMsg = "Failed to create/overwrite file "; - errMsg += toUtf8(dst); - errMsg += ", reason: "; - errMsg += strerror(errno); - return Result::Err(errMsg); - } - - dstFile << srcFile.rdbuf(); - return Result::Ok(true); - } } diff --git a/src/PkgConfig.cpp b/src/PkgConfig.cpp index 9efc238..e8f742c 100644 --- a/src/PkgConfig.cpp +++ b/src/PkgConfig.cpp @@ -4,7 +4,7 @@ using namespace std; -static sibs::FileString pkgConfigPath = "pkg-config"; +static sibs::FileString pkgConfigPath = TINYDIR_STRING("pkg-config"); // TODO: Do not use pkg-config program. The same functionality can easily be achieved // by reading files in /usr/share/pkgconfig diff --git a/src/main.cpp b/src/main.cpp index 3ffb264..29f6ba3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1144,22 +1144,31 @@ static int packageProject(int argc, const _tinydir_char_t **argv) case PackagingType::BUNDLE: case PackagingType::BUNDLE_INSTALL: { - const char *bundleType = nullptr; + const _tinydir_char_t *bundleType = nullptr; switch(packagingType) { case PackagingType::BUNDLE: - bundleType = "--bundle"; + bundleType = TINYDIR_STRING("--bundle"); break; case PackagingType::BUNDLE_INSTALL: - bundleType = "--bundle-install"; + bundleType = TINYDIR_STRING("--bundle-install"); break; } - string packagePath = toUtf8(projectPath + TINYDIR_STRING("/sibs-build/package")); - string executablePath = toUtf8(projectPath + TINYDIR_STRING("/sibs-build/release/") + sibsConfig.getPackageName()); + FileString packagePath = projectPath + TINYDIR_STRING("/sibs-build/package"); + FileString executablePath = projectPath + TINYDIR_STRING("/sibs-build/release/") + toFileString(sibsConfig.getPackageName()); printf("Creating a package from project and dependencies...\n"); // args: executable_path program_version destination_path <--bundle|--bundle-install> - FileString cmd = "python3 \"" + packageScriptPath + "\" \"" + executablePath + "\" \"" + sibsConfig.version + "\" \"" + packagePath + "\" " + bundleType; + FileString cmd = TINYDIR_STRING("python3 \"") + + packageScriptPath + + TINYDIR_STRING("\" \"") + + executablePath + + TINYDIR_STRING("\" \"") + + toFileString(sibsConfig.version) + + TINYDIR_STRING("\" \"") + + packagePath + + TINYDIR_STRING("\" ") + + bundleType; Result bundleResult = exec(cmd.c_str(), true); if(!bundleResult) { @@ -1413,3 +1422,11 @@ int wmain(int argc, const _tinydir_char_t **argv) usage(); return 0; } + +// Mingw needs this +#if OS_FAMILY == OS_FAMILY_WINDOWS +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + return wmain(__argc, (const _tinydir_char_t**)__wargv); +} +#endif \ No newline at end of file -- cgit v1.2.3