MangoHud icon indicating copy to clipboard operation
MangoHud copied to clipboard

FreeBSD support (part one: preparation)

Open danfe opened this issue 2 years ago • 3 comments

MangoHud works fine on FreeBSD, but currently requires some patching in order to do so. I'd like to upstream some of them, starting with more generic ones. Consider the following patch: Rationale:

  • FreeBSD is definitely Unixy :-)
  • popen(3) is POSIX call, limiting it to GNU/Linux is wrong
  • Same applies to standard header files
--- meson.build.orig
+++ meson.build
@@ -31,7 +31,7 @@
 
 # TODO: this is very incomplete
 is_unixy = false
-if ['linux', 'cygwin', 'gnu'].contains(host_machine.system())
+if ['linux', 'cygwin', 'gnu', 'freebsd'].contains(host_machine.system())
   pre_args += '-D_GNU_SOURCE'
   pre_args += '-DHAVE_PTHREAD'
   is_unixy = true
--- src/logging.cpp.orig
+++ src/logging.cpp
@@ -16,7 +16,7 @@
 string exec(string command) {
    char buffer[128];
    string result = "";
-#ifdef __gnu_linux__
+#ifndef _WIN32
 
    // Open pipe to file
    FILE* pipe = popen(command.c_str(), "r");
--- src/vulkan.cpp.orig
+++ src/vulkan.cpp
@@ -33,7 +33,7 @@
 #include <vector>
 #include <list>
 #include <array>
-#ifdef __gnu_linux__
+#ifndef _WIN32
 #include <libgen.h>
 #include <unistd.h>
 #endif

danfe avatar Dec 14 '21 07:12 danfe

This might be better rather than just accepting everything that isn't windows?

#if defined(__gnu_linux__) || defined(__FreeBSD__)

flightlessmango avatar Dec 14 '21 08:12 flightlessmango

Also fine, I guess. Personally I prefer to avoid enumerating systems where something is supported, because e.g. tomorrow OpenBSD or Haiku hacker comes, and then you have to extend that list again. On the contrary, chances for native popen(3) to appear on Win32 are much lower. But as I say, it's ultimately your code and your call.

danfe avatar Dec 14 '21 08:12 danfe

I agree, it's better to use WIN32

flightlessmango avatar Jan 02 '22 06:01 flightlessmango