aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-13 00:09:22 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit5e79e361c97e88b4a5912990eda0f1fb0d4a6dbd (patch)
treeb4ea98e404aec68a8eae7f9d64fa24bb4b29effa
parent7c24c5d0de4d3584d6d2f9f3c26b4d757b0a0df2 (diff)
Add posix as a platform, remove zig from compile_commands.json
-rw-r--r--README.md2
-rw-r--r--backend/ninja/Ninja.cpp4
-rw-r--r--include/Platform.hpp41
-rw-r--r--project.conf4
-rw-r--r--src/Platform.cpp50
-rw-r--r--src/main.cpp7
6 files changed, 56 insertions, 52 deletions
diff --git a/README.md b/README.md
index 8fefd74..d2159b9 100644
--- a/README.md
+++ b/README.md
@@ -120,7 +120,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", "linux", "linux32", "linux64", "win", "win32", "win64", "macos32", "macos64", "bsd", "openbsd", "openbsd32", "openbsd64", "haiku", "haiku32", "haiku64".
+Required. A list of platforms the package supports. Can contain the following values: "any", "posix", "posix32", "posix64", linux", "linux32", "linux64", "win", "win32", "win64", "macos32", "macos64", "bsd", "openbsd", "openbsd32", "openbsd64", "haiku", "haiku32", "haiku64".
If platforms contains "any" then 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 3a2fa0f..f236210 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -1845,9 +1845,9 @@ namespace backend
bool isCompdbAvailable = (compdbAvailableResult && compdbAvailableResult.unwrap().exitCode == 0);
FileString command = TINYDIR_STRING("ninja -C \"");
- command += (isCompdbAvailable ? buildFilePath : saveDir);
- command += TINYDIR_STRING("\" -t compdb compile_c compile_cpp compile_zig > \"");
command += buildFilePath;
+ command += TINYDIR_STRING("\" -t compdb compile_c compile_cpp > \"");
+ command += (isCompdbAvailable ? buildFilePath : saveDir);
command += TINYDIR_STRING("/compile_commands.json\"");
Result<ExecResult> execResult = exec(command.c_str(), false);
if(execResult)
diff --git a/include/Platform.hpp b/include/Platform.hpp
index 3ae3d24..955df57 100644
--- a/include/Platform.hpp
+++ b/include/Platform.hpp
@@ -6,36 +6,43 @@
namespace sibs
{
- enum Platform : u32
+ enum Platform : u64
{
PLATFORM_INVALID = 0x00000000,
PLATFORM_ANY = 0xFFFFFFFF,
- PLATFORM_LINUX = 1 << 1,
- PLATFORM_LINUX32 = 1 << 2 | PLATFORM_LINUX,
- PLATFORM_LINUX64 = 1 << 3 | PLATFORM_LINUX,
+ PLATFORM_POSIX = 1 << 1,
+ PLATFORM_POSIX32 = 1 << 2 | PLATFORM_POSIX,
+ PLATFORM_POSIX64 = 1 << 3 | PLATFORM_POSIX,
- PLATFORM_WIN = 1 << 4,
- PLATFORM_WIN32 = 1 << 5 | PLATFORM_WIN,
- PLATFORM_WIN64 = 1 << 6 | PLATFORM_WIN,
+ PLATFORM_LINUX = 1 << 4 | PLATFORM_POSIX,
+ PLATFORM_LINUX32 = 1 << 5 | PLATFORM_LINUX | PLATFORM_POSIX32,
+ PLATFORM_LINUX64 = 1 << 6 | PLATFORM_LINUX | PLATFORM_POSIX64,
- PLATFORM_MACOS = 1 << 7,
- PLATFORM_MACOS32 = 1 << 8 | PLATFORM_MACOS,
- PLATFORM_MACOS64 = 1 << 9 | PLATFORM_MACOS,
+ PLATFORM_WIN = 1 << 7,
+ PLATFORM_WIN32 = 1 << 8 | PLATFORM_WIN,
+ PLATFORM_WIN64 = 1 << 9 | PLATFORM_WIN,
- PLATFORM_BSD = 1 << 10,
- PLATFORM_OPENBSD = 1 << 11 | PLATFORM_BSD,
- PLATFORM_OPENBSD32 = 1 << 12 | PLATFORM_OPENBSD,
- PLATFORM_OPENBSD64 = 1 << 13 | PLATFORM_OPENBSD,
+ PLATFORM_MACOS = 1 << 10 | PLATFORM_POSIX,
+ PLATFORM_MACOS32 = 1 << 11 | PLATFORM_MACOS | PLATFORM_POSIX32,
+ PLATFORM_MACOS64 = 1 << 12 | PLATFORM_MACOS | PLATFORM_POSIX64,
- PLATFORM_HAIKU = 1 << 20,
- PLATFORM_HAIKU32 = 1 << 21 | PLATFORM_HAIKU,
- PLATFORM_HAIKU64 = 1 << 22 | PLATFORM_HAIKU
+ PLATFORM_BSD = 1 << 13 | PLATFORM_POSIX,
+ PLATFORM_OPENBSD = 1 << 14 | PLATFORM_BSD,
+ PLATFORM_OPENBSD32 = 1 << 15 | PLATFORM_OPENBSD | PLATFORM_POSIX32,
+ PLATFORM_OPENBSD64 = 1 << 16 | PLATFORM_OPENBSD | PLATFORM_POSIX64,
+
+ PLATFORM_HAIKU = 1 << 24 | PLATFORM_POSIX,
+ PLATFORM_HAIKU32 = 1 << 25 | PLATFORM_HAIKU | PLATFORM_POSIX32,
+ PLATFORM_HAIKU64 = 1 << 26 | PLATFORM_HAIKU | PLATFORM_POSIX64
};
const StringViewMap<Platform> PLATFORM_BY_NAME = {
{ "any", PLATFORM_ANY },
+ { "posix", PLATFORM_POSIX },
+ { "posix32", PLATFORM_POSIX32 },
+ { "posix64", PLATFORM_POSIX64 },
{ "linux", PLATFORM_LINUX },
{ "linux32", PLATFORM_LINUX32 },
{ "linux64", PLATFORM_LINUX64 },
diff --git a/project.conf b/project.conf
index bcfc4d1..f042daf 100644
--- a/project.conf
+++ b/project.conf
@@ -10,5 +10,5 @@ ignore_dirs = ["cmake", "cmake-build-debug", "build", "distribute", "examples",
[dependencies]
libcurl = "7"
-libarchive = "3.3.0"
-libgit2 = "0.26.0"
+libarchive = "3"
+libgit2 = "0.24.0" \ No newline at end of file
diff --git a/src/Platform.cpp b/src/Platform.cpp
index dd81667..b011d93 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -3,27 +3,29 @@
namespace sibs
{
- static int countSetBits(u32 value)
+ static std::unordered_map<Platform, const char*> platformNames;
+ static bool platformNamesSet = false;
+ static int countSetBits(u64 value)
{
int count = 0;
while(value)
{
- count += (value & 1U);
- value >>= 1U;
+ count += (value & 1ULL);
+ value >>= 1ULL;
}
return count;
}
// Returns -1 if no bit is set
- static int getLeastSignificantBitSetPosition(u32 value)
+ static u64 getLeastSignificantBitSetPosition(u64 value)
{
- for(u32 i = 0; i < sizeof(u32); ++i)
+ for(u64 i = 0; i < sizeof(u64); ++i)
{
- if(value & 1U)
+ if(value & 1ULL)
return i;
- value >>= 1U;
+ value >>= 1ULL;
}
- return -1;
+ return -1ULL;
}
bool containsPlatform(const std::vector<Platform> &platforms, Platform platform)
@@ -38,27 +40,19 @@ namespace sibs
const char* asString(Platform platform)
{
- switch (platform)
+ if(!platformNamesSet)
{
- case PLATFORM_ANY: return "any";
- case PLATFORM_LINUX: return "linux";
- case PLATFORM_LINUX32: return "linux32";
- case PLATFORM_LINUX64: return "linux64";
- case PLATFORM_WIN: return "win";
- case PLATFORM_WIN32: return "win32";
- case PLATFORM_WIN64: return "win64";
- case PLATFORM_MACOS: return "macos";
- case PLATFORM_MACOS32: return "macos32";
- case PLATFORM_MACOS64: return "macos64";
- case PLATFORM_BSD: return "bsd";
- case PLATFORM_OPENBSD: return "openbsd";
- case PLATFORM_OPENBSD32: return "openbsd32";
- case PLATFORM_OPENBSD64: return "openbsd64";
- case PLATFORM_HAIKU: return "haiku";
- case PLATFORM_HAIKU32: return "haiku32";
- case PLATFORM_HAIKU64: return "haiku64";
- default: assert(false); return nullptr;
+ platformNamesSet = true;
+ for(auto &it : PLATFORM_BY_NAME)
+ {
+ platformNames[it.second] = it.first.data;
+ }
}
+
+ auto it = platformNames.find(platform);
+ if(it != platformNames.end())
+ return it->second;
+ return nullptr;
}
Platform getPlatformByName(StringView name)
@@ -83,6 +77,6 @@ namespace sibs
{
if(platform == PLATFORM_INVALID || platform == PLATFORM_ANY)
return PLATFORM_INVALID;
- return (Platform)(1U << (u32)getLeastSignificantBitSetPosition(platform));
+ return (Platform)(1ULL << (u64)getLeastSignificantBitSetPosition(platform));
}
}
diff --git a/src/main.cpp b/src/main.cpp
index b3a8f40..952497a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -93,6 +93,9 @@ using namespace std::chrono;
// Also compile_commands.json shouldn't update if no files have changed. This is easier to do when ninja is replaced so we can track changes
// in source/header files.
+// TODO: Create a script that downloads every library in the package list (packages.json) and build each project for every new release of sibs
+// to verify we don't break anything.
+
#if OS_FAMILY == OS_FAMILY_POSIX
#define fout std::cout
#define ferr std::cerr
@@ -968,7 +971,7 @@ static int initProject(int argc, const _tinydir_char_t **argv)
else if(_tinydir_strcmp(lang, TINYDIR_STRING("zig")) == 0 && projectTypeConf == "executable")
{
auto mainFilePath = projectPath + TINYDIR_STRING("/src/main.zig");
- Result<bool> fileOverwriteResult = fileWrite(mainFilePath.c_str(), "const warn = @import(\"std\").debug.warn;\n\npub fn main() void\n{\n warn(\"Hello, world!\\n\");\n}\n");
+ Result<bool> fileOverwriteResult = fileWrite(mainFilePath.c_str(), "const warn = @import(\"std\").debug.warn;\n\npub fn main() void {\n warn(\"Hello, world!\\n\");\n}\n");
if(!fileOverwriteResult)
fout << "Warning: Failed to create project file: " << toFileString(fileOverwriteResult.getErrMsg()) << endl;
}
@@ -1366,7 +1369,7 @@ static int newProject(int argc, const _tinydir_char_t **argv)
else if(_tinydir_strcmp(lang, TINYDIR_STRING("zig")) == 0 && projectTypeConf == "executable")
{
auto mainFilePath = projectPath + TINYDIR_STRING("/src/main.zig");
- Result<bool> fileOverwriteResult = fileWrite(mainFilePath.c_str(), "const warn = @import(\"std\").debug.warn;\n\npub fn main() void\n{\n warn(\"Hello, world!\\n\");\n}\n");
+ Result<bool> fileOverwriteResult = fileWrite(mainFilePath.c_str(), "const warn = @import(\"std\").debug.warn;\n\npub fn main() void {\n warn(\"Hello, world!\\n\");\n}\n");
if(!fileOverwriteResult)
{
ferr << " Failed to create project file: " << toFileString(fileOverwriteResult.getErrMsg()) << endl;