bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
790 stars 38 forks source link

Add platform checks for macOS #73

Closed malob closed 2 years ago

malob commented 2 years ago

Currently platform checks in the code only check for whether the system is Linux or Windows. This causes compilation failures on macOS in main.h since, e.g., GETCHAR and PUTCHAR don't get defined when compiling on macOS systems.

This PR replaces defined(__linux__) with (defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))) throughout the code base, since all the Linux specific code is either required on macOS (main.h), or is applicable to macOS as well.

I've tested compilation of the executable for both Intel and Apple Silicon chips on macOS.

(See https://github.com/NixOS/nixpkgs/pull/185963)

bepaald commented 2 years ago

Ok thanks for this. I don't have any Apple hardware, but I should have seen this one coming. This project does not accept any pull requests currently (sorry, I'll make a mention of that), but I'll fix this tomorrow at the latest.

The fix might look like your patch, but I'm also tempted to only check defined(_WIN32) and leave all linux/mac/whatever code in the else. Without any explicit defines, maybe this will make sure everything (like GETCHAR) is always defined, even if neither __linux__ and __APPLE__ exist (possibly BSD, or some future system?). Any thoughts on that?

Also, what is the other patch? It includes .ccls-cache/ (~I think?~ edit: no it excludes it?), but there is no such directory in the git tree as far as I know. Besides, the * at the top of the file should already exclude everything not explicitly included?

bepaald commented 2 years ago

I went ahead and made some changes. Let me know if this fixes compmilation on macOS.

malob commented 2 years ago

Cool, thanks! Testing it out now.

Also, what is the other patch? It includes .ccls-cache/ (I think? edit: no it excludes it?), but there is no such directory in the git tree as far as I know. Besides, the * at the top of the file should already exclude everything not explicitly included?

ccls is a language server that I use for C/C++. It creates that cache directory. I added it to the .gitignore since Git was seeing it. ¯_(ツ)_/¯

malob commented 2 years ago

Everything is building fine for me on macOS with your changes :)

Without any explicit defines, maybe this will make sure everything (like GETCHAR) is always defined, even if neither linux and APPLE exist (possibly BSD, or some future system?). Any thoughts on that?

Unfortunately I don't know enough to have an informed opinion here.