From 7c0941777f6ea1889c6ba78c558cf7296cdf230b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 1 May 2024 03:33:20 -0400 Subject: [PATCH] Define ARCH_* macros in arch.hpp instead of on the command line. --- compile.mk | 5 ----- include/arch.hpp | 20 ++++++++++++++++++++ include/common.hpp | 2 ++ include/simd/Vector.hpp | 1 + include/simd/functions.hpp | 1 - src/asset.cpp | 2 ++ src/plugin.cpp | 4 +++- src/string.cpp | 2 ++ src/system.cpp | 4 +++- src/window/Window.cpp | 2 ++ 10 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 include/arch.hpp diff --git a/compile.mk b/compile.mk index bbda7652..c26cd4f2 100644 --- a/compile.mk +++ b/compile.mk @@ -28,20 +28,16 @@ endif # Architecture-independent flags ifdef ARCH_X64 - FLAGS += -DARCH_X64 FLAGS += -march=nehalem endif ifdef ARCH_ARM64 - FLAGS += -DARCH_ARM64 FLAGS += -march=armv8-a+fp+simd endif ifdef ARCH_LIN - FLAGS += -DARCH_LIN CXXFLAGS += -Wsuggest-override endif ifdef ARCH_MAC - FLAGS += -DARCH_MAC CXXFLAGS += -stdlib=libc++ LDFLAGS += -stdlib=libc++ MAC_SDK_FLAGS := -mmacosx-version-min=10.9 @@ -49,7 +45,6 @@ ifdef ARCH_MAC LDFLAGS += $(MAC_SDK_FLAGS) endif ifdef ARCH_WIN - FLAGS += -DARCH_WIN FLAGS += -D_USE_MATH_DEFINES FLAGS += -municode CXXFLAGS += -Wsuggest-override diff --git a/include/arch.hpp b/include/arch.hpp new file mode 100644 index 00000000..99cd27b0 --- /dev/null +++ b/include/arch.hpp @@ -0,0 +1,20 @@ +#pragma once + +// Check CPU +#if defined __x86_64__ + #define ARCH_X64 1 +#endif +#if defined __aarch64__ + #define ARCH_ARM64 1 +#endif + +// Check OS +#if defined _WIN32 + #define ARCH_WIN 1 +#endif +#if defined __APPLE__ + #define ARCH_MAC 1 +#endif +#if defined __linux__ + #define ARCH_LIN 1 +#endif diff --git a/include/common.hpp b/include/common.hpp index 588a325b..4f320267 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -15,6 +15,8 @@ #include #include +#include + /** Attribute for deprecated functions and symbols. E.g. diff --git a/include/simd/Vector.hpp b/include/simd/Vector.hpp index 4c497b9a..df040ea3 100644 --- a/include/simd/Vector.hpp +++ b/include/simd/Vector.hpp @@ -1,6 +1,7 @@ #pragma once #include #include "common.hpp" +#include namespace rack { diff --git a/include/simd/functions.hpp b/include/simd/functions.hpp index 890f4265..3208d452 100644 --- a/include/simd/functions.hpp +++ b/include/simd/functions.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include diff --git a/src/asset.cpp b/src/asset.cpp index 6611239c..8c3a5123 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -1,3 +1,5 @@ +#include + #if defined ARCH_MAC #include #include diff --git a/src/plugin.cpp b/src/plugin.cpp index f039dd07..7f607880 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -99,7 +101,7 @@ static InitCallback loadPluginCallback(Plugin* plugin) { libraryExt = "so"; #elif defined ARCH_WIN libraryExt = "dll"; -#elif ARCH_MAC +#elif defined ARCH_MAC libraryExt = "dylib"; #endif diff --git a/src/string.cpp b/src/string.cpp index c64052d3..128892de 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -1,3 +1,5 @@ +#include + #include #include // for tolower and toupper #include // for transform and equal diff --git a/src/system.cpp b/src/system.cpp index 32fdfdd7..d4130b18 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -701,7 +703,7 @@ std::string getStackTrace() { // If regex fails, just use the raw line s += line; } -#elif ARCH_MAC +#elif defined ARCH_MAC // Parse line, e.g. // 1 Rack 0x0000000002ddc3eb _mangled_symbol + 27 std::regex r(R"((\d+)\s+(.+?)\s+(.+?) (.*?) \+ (.+?))"); diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 19d3cd8c..b3eab079 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include