diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Conf.cpp | 6 | ||||
-rw-r--r-- | src/FileUtil.cpp | 29 | ||||
-rw-r--r-- | src/PkgConfig.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 29 |
4 files changed, 28 insertions, 38 deletions
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<bool>::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<bool>::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 <cstdio> -#include <fstream> #if OS_FAMILY == OS_FAMILY_POSIX #include <unistd.h> @@ -8,7 +7,7 @@ #include <pwd.h> #include <fcntl.h> #else -#include <UserEnv.h> +#include <userenv.h> // 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<bool> 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<bool>::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<bool>::Err(errMsg); - } - - dstFile << srcFile.rdbuf(); - return Result<bool>::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<ExecResult> 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 |