build: Switch to GCC on MacOS (#552)

* build: Experimentally switch to gcc on macOS

* build: Corrected gcc paths

* build: Enable objective c support on macOS

* build: Enable ObjC and ObjC++ on macOS

* build: Add ObjC and ObjC++ flags

* build: Try compiling objc with clang

* build: Remove invalid flags again

* fix: Let's not include objc headers in C++ code

* sys: Move macos utils code to its own file

* fix: Missing unistd include on mac

* sys: Removed loader script stuff since it's currently unused and broken

* fix: Missing include

* fix: Another missing include

* fix: CFURLCreateWithBytes wants a pointer to mutable data

* fix: Try disabling name mangling of ObjC functions

* sys: Move macos utils declarations to its own header file

* fix: C Linkage

* fix: Move objc function prototypes to C++ headers

* fix: More missing includes

* fix: Warning error

* sys: Call ObjC with C ABI instead of trying to use C++

* build: Update libraries

* sys: Fixed build errors

* sys: No const correctness I guess

* sys: Fixed prototypes

* sys: This is C now

* sys: More nullptr -> NULL

* sys: Fix crash on exit

* sys: Try using proper std concepts instead of custom ones

* sys: Replaced another hex::is_signed

* build: Upgrade to gcc 12 and MacOS Monterey

* build: Fixed MacOS runner name

* build: Cache correct ccache folder on macOS
This commit is contained in:
WerWolv
2022-06-25 12:19:59 +02:00
committed by GitHub
parent 546d0a4922
commit 3471b314dd
28 changed files with 201 additions and 579 deletions

View File

@@ -156,7 +156,7 @@ namespace hex {
}
template<hex::derived_from<View> T, typename... Args>
template<std::derived_from<View> T, typename... Args>
void add(Args &&...args) {
return impl::add(new T(std::forward<Args>(args)...));
}
@@ -234,7 +234,7 @@ namespace hex {
}
template<hex::derived_from<dp::Node> T, typename... Args>
template<std::derived_from<dp::Node> T, typename... Args>
void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, Args &&...args) {
add(impl::Entry { unlocalizedCategory.c_str(), unlocalizedName.c_str(), [=] {
auto node = new T(std::forward<Args>(args)...);
@@ -326,7 +326,7 @@ namespace hex {
}
template<hex::derived_from<hex::prv::Provider> T>
template<std::derived_from<hex::prv::Provider> T>
void add(const std::string &unlocalizedName, bool addToList = true) {
(void)EventManager::subscribe<RequestCreateProvider>([expectedName = unlocalizedName](const std::string &name, hex::prv::Provider **provider) {
if (name != expectedName) return;
@@ -415,7 +415,7 @@ namespace hex {
}
template<hex::derived_from<DataVisualizer> T, typename... Args>
template<std::derived_from<DataVisualizer> T, typename... Args>
void addDataVisualizer(const std::string &unlocalizedName, Args &&...args) {
return impl::addDataVisualizer(unlocalizedName, new T(std::forward<Args>(args)...));
}

View File

@@ -127,7 +127,7 @@ namespace hex {
void add(prv::Provider *provider);
template<hex::derived_from<prv::Provider> T>
template<std::derived_from<prv::Provider> T>
void add(auto &&...args) {
add(new T(std::forward<decltype(args)>(args)...));
}

View File

@@ -5,151 +5,7 @@
#include <type_traits>
#include <memory>
namespace hex {
template<typename>
struct is_integral_helper : public std::false_type { };
template<>
struct is_integral_helper<u8> : public std::true_type { };
template<>
struct is_integral_helper<i8> : public std::true_type { };
template<>
struct is_integral_helper<u16> : public std::true_type { };
template<>
struct is_integral_helper<i16> : public std::true_type { };
template<>
struct is_integral_helper<u32> : public std::true_type { };
template<>
struct is_integral_helper<i32> : public std::true_type { };
template<>
struct is_integral_helper<u64> : public std::true_type { };
template<>
struct is_integral_helper<i64> : public std::true_type { };
template<>
struct is_integral_helper<u128> : public std::true_type { };
template<>
struct is_integral_helper<i128> : public std::true_type { };
template<>
struct is_integral_helper<bool> : public std::true_type { };
template<>
struct is_integral_helper<char> : public std::true_type { };
template<>
struct is_integral_helper<char8_t> : public std::true_type { };
template<>
struct is_integral_helper<char16_t> : public std::true_type { };
template<>
struct is_integral_helper<char32_t> : public std::true_type { };
template<>
struct is_integral_helper<wchar_t> : public std::true_type { };
template<typename T>
struct is_integral : public is_integral_helper<std::remove_cvref_t<T>>::type { };
template<typename>
struct is_signed_helper : public std::false_type { };
template<>
struct is_signed_helper<i8> : public std::true_type { };
template<>
struct is_signed_helper<i16> : public std::true_type { };
template<>
struct is_signed_helper<i32> : public std::true_type { };
template<>
struct is_signed_helper<i64> : public std::true_type { };
template<>
struct is_signed_helper<i128> : public std::true_type { };
template<>
struct is_signed_helper<char> : public std::true_type { };
template<>
struct is_signed_helper<float> : public std::true_type { };
template<>
struct is_signed_helper<double> : public std::true_type { };
template<>
struct is_signed_helper<long double> : public std::true_type { };
template<typename T>
struct is_signed : public is_signed_helper<std::remove_cvref_t<T>>::type { };
template<typename>
struct is_floating_point_helper : public std::false_type { };
template<>
struct is_floating_point_helper<float> : public std::true_type { };
template<>
struct is_floating_point_helper<double> : public std::true_type { };
template<>
struct is_floating_point_helper<long double> : public std::true_type { };
template<typename T>
struct is_floating_point : public is_floating_point_helper<std::remove_cvref_t<T>>::type { };
}
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 12000
#if __has_include(<concepts>)
// Make sure we break when derived_from is implemented in libc++. Then we can fix a compatibility version above
#include <concepts>
#endif
// libcxx 12 still doesn't have many default concepts implemented, as a result we need to define it ourself using clang built-ins.
// [concept.derived] (patch from https://reviews.llvm.org/D74292)
namespace hex {
template<class _Dp, class _Bp>
concept derived_from =
__is_base_of(_Bp, _Dp) && __is_convertible_to(const volatile _Dp *, const volatile _Bp *);
}
#else
// Assume supported
#include <concepts>
namespace hex {
using std::derived_from;
}
#endif
// [concepts.arithmetic]
namespace hex {
template<class T>
concept integral = hex::is_integral<T>::value;
template<class T>
concept signed_integral = integral<T> && hex::is_signed<T>::value;
template<class T>
concept unsigned_integral = integral<T> && !signed_integral<T>;
template<class T>
concept floating_point = std::is_floating_point<T>::value;
}
#include <concepts>
namespace hex {
@@ -159,11 +15,6 @@ namespace hex {
template<typename T, size_t Size>
concept has_size = sizeof(T) == Size;
}
namespace hex {
template<typename T>
class Cloneable {
public:

View File

@@ -1,10 +0,0 @@
#pragma once
#if defined(OS_MACOS)
#include <hex/helpers/fs.hpp>
namespace hex {
std::string getMacExecutableDirectoryPath();
std::string getMacApplicationSupportDirectoryPath();
}
#endif

View File

@@ -0,0 +1,12 @@
#pragma once
#if defined(OS_MACOS)
#include <hex/helpers/fs.hpp>
extern "C" char * getMacExecutableDirectoryPath();
extern "C" char * getMacApplicationSupportDirectoryPath();
extern "C" void macFree(void *ptr);
#endif

View File

@@ -1,38 +0,0 @@
#pragma once
#include <string>
#include <string_view>
#include <hex/helpers/fs.hpp>
struct _object;
typedef struct _object PyObject;
namespace hex {
namespace prv {
class Provider;
}
class LoaderScript {
public:
LoaderScript() = delete;
static bool processFile(const std::fs::path &scriptPath);
static void setFilePath(const std::fs::path &filePath) { LoaderScript::s_filePath = filePath; }
static void setDataProvider(prv::Provider *provider) { LoaderScript::s_dataProvider = provider; }
private:
static inline std::fs::path s_filePath;
static inline prv::Provider *s_dataProvider;
static PyObject *Py_getFilePath(PyObject *self, PyObject *args);
static PyObject *Py_addPatch(PyObject *self, PyObject *args);
static PyObject *Py_addBookmark(PyObject *self, PyObject *args);
static PyObject *Py_addStruct(PyObject *self, PyObject *args);
static PyObject *Py_addUnion(PyObject *self, PyObject *args);
};
}

View File

@@ -43,7 +43,7 @@ namespace hex {
std::string encodeByteString(const std::vector<u8> &bytes);
std::vector<u8> decodeByteString(const std::string &string);
[[nodiscard]] constexpr inline u64 extract(u8 from, u8 to, const hex::unsigned_integral auto &value) {
[[nodiscard]] constexpr inline u64 extract(u8 from, u8 to, const std::unsigned_integral auto &value) {
if (from < to) std::swap(from, to);
using ValueType = std::remove_cvref_t<decltype(value)>;
@@ -72,7 +72,7 @@ namespace hex {
return (value ^ mask) - mask;
}
template<hex::integral T>
template<std::integral T>
constexpr inline T swapBitOrder(size_t numBits, T value) {
T result = 0x00;
@@ -200,7 +200,7 @@ namespace hex {
return T(1) << bit_width(T(x - 1));
}
template<hex::integral T, hex::integral U>
template<std::integral T, std::integral U>
auto powi(T base, U exp) {
using ResultType = decltype(T{} * U{});
@@ -264,7 +264,7 @@ namespace hex {
return result;
}
inline std::string toBinaryString(hex::unsigned_integral auto number) {
inline std::string toBinaryString(std::unsigned_integral auto number) {
if (number == 0) return "0";
std::string result;
@@ -317,7 +317,7 @@ namespace hex {
return *value;
}
template<hex::integral T>
template<std::integral T>
T alignTo(T value, T alignment) {
T remainder = value % alignment;

View File

@@ -0,0 +1,9 @@
#pragma once
#if defined(OS_MACOS)
#include <string>
extern "C" void openWebpageMacos(const char *url);
#endif