fix macOS build (following Projucer changes made in Windows, which removed /Applications/JUCE/modules from its headers). move JUCE headers under source control, so that Windows and macOS can both build against same version of JUCE. remove AUv3 target (I think it's an iOS thing, so it will never work with this macOS fluidsynth dylib).

This commit is contained in:
Alex Birch
2018-06-17 13:34:53 +01:00
parent a2be47c887
commit dff4d13a1d
1563 changed files with 601601 additions and 3466 deletions

View File

@ -0,0 +1,130 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
/*
This file provides flags for compiler features that aren't supported on all platforms.
*/
//==============================================================================
// GCC
#if JUCE_GCC
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
#error "JUCE requires GCC 4.7 or later"
#endif
#if ! (__cplusplus >= 201103L || defined (__GXX_EXPERIMENTAL_CXX0X__))
#error "JUCE requires that GCC has C++11 compatibility enabled"
#endif
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500
#define JUCE_HAS_CONSTEXPR 1
#endif
#ifndef JUCE_EXCEPTIONS_DISABLED
#if ! __EXCEPTIONS
#define JUCE_EXCEPTIONS_DISABLED 1
#endif
#endif
#define JUCE_CXX14_IS_AVAILABLE (__cplusplus >= 201402L)
#define JUCE_CXX17_IS_AVAILABLE (__cplusplus >= 201703L)
#endif
//==============================================================================
// Clang
#if JUCE_CLANG
#if (__clang_major__ < 3) || (__clang_major__ == 3 && __clang_minor__ < 3)
#error "JUCE requires Clang 3.3 or later"
#endif
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#define JUCE_HAS_CONSTEXPR 1
#ifndef JUCE_COMPILER_SUPPORTS_ARC
#define JUCE_COMPILER_SUPPORTS_ARC 1
#endif
#ifndef JUCE_EXCEPTIONS_DISABLED
#if ! __has_feature (cxx_exceptions)
#define JUCE_EXCEPTIONS_DISABLED 1
#endif
#endif
#define JUCE_CXX14_IS_AVAILABLE (__cplusplus >= 201402L)
#define JUCE_CXX17_IS_AVAILABLE (__cplusplus >= 201703L)
#endif
//==============================================================================
// MSVC
#if JUCE_MSVC
#if _MSC_VER < 1800 // VS2013
#error "JUCE requires Visual Studio 2013 or later"
#endif
#if _MSC_VER >= 1900 // VS2015
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#define JUCE_HAS_CONSTEXPR 1
#else
#define _ALLOW_KEYWORD_MACROS 1 // prevent a warning
#undef noexcept
#define noexcept throw()
#endif
#ifndef JUCE_EXCEPTIONS_DISABLED
#if ! _CPPUNWIND
#define JUCE_EXCEPTIONS_DISABLED 1
#endif
#endif
#define JUCE_CXX14_IS_AVAILABLE (_MSVC_LANG >= 201402L)
#define JUCE_CXX17_IS_AVAILABLE (_MSVC_LANG >= 201703L)
#endif
//==============================================================================
// C++ library
#if (defined (__GLIBCXX__) && __GLIBCXX__ < 20130322) || (defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 3700))
#error "JUCE requires a C++ library containing std::atomic"
#endif
//==============================================================================
#if JUCE_HAS_CONSTEXPR
#define JUCE_CONSTEXPR constexpr
#else
#define JUCE_CONSTEXPR
#endif
#if ! DOXYGEN
// These are old flags that are now supported on all compatible build targets
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1
#define JUCE_DELETED_FUNCTION = delete
#endif

View File

@ -0,0 +1,323 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
/* This file defines miscellaneous macros for debugging, assertions, etc.
*/
//==============================================================================
#ifdef JUCE_FORCE_DEBUG
#undef JUCE_DEBUG
#if JUCE_FORCE_DEBUG
#define JUCE_DEBUG 1
#endif
#endif
/** This macro defines the C calling convention used as the standard for JUCE calls. */
#if JUCE_MSVC
#define JUCE_CALLTYPE __stdcall
#define JUCE_CDECL __cdecl
#else
#define JUCE_CALLTYPE
#define JUCE_CDECL
#endif
//==============================================================================
// Debugging and assertion macros
#if JUCE_LOG_ASSERTIONS || JUCE_DEBUG
#define JUCE_LOG_CURRENT_ASSERTION juce::logAssertion (__FILE__, __LINE__);
#else
#define JUCE_LOG_CURRENT_ASSERTION
#endif
//==============================================================================
#if JUCE_IOS || JUCE_LINUX
/** This will try to break into the debugger if the app is currently being debugged.
If called by an app that's not being debugged, the behaviour isn't defined - it may
crash or not, depending on the platform.
@see jassert()
*/
#define JUCE_BREAK_IN_DEBUGGER { ::kill (0, SIGTRAP); }
#elif JUCE_MSVC
#ifndef __INTEL_COMPILER
#pragma intrinsic (__debugbreak)
#endif
#define JUCE_BREAK_IN_DEBUGGER { __debugbreak(); }
#elif JUCE_GCC || JUCE_MAC
#if JUCE_NO_INLINE_ASM
#define JUCE_BREAK_IN_DEBUGGER { }
#else
#define JUCE_BREAK_IN_DEBUGGER { asm ("int $3"); }
#endif
#elif JUCE_ANDROID
#define JUCE_BREAK_IN_DEBUGGER { __builtin_trap(); }
#else
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
#endif
#if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN)
#if __has_feature (attribute_analyzer_noreturn)
inline void __attribute__((analyzer_noreturn)) juce_assert_noreturn() {}
#define JUCE_ANALYZER_NORETURN juce::juce_assert_noreturn();
#endif
#endif
#ifndef JUCE_ANALYZER_NORETURN
#define JUCE_ANALYZER_NORETURN
#endif
//==============================================================================
#if JUCE_MSVC && ! DOXYGEN
#define JUCE_BLOCK_WITH_FORCED_SEMICOLON(x) \
__pragma(warning(push)) \
__pragma(warning(disable:4127)) \
do { x } while (false) \
__pragma(warning(pop))
#else
/** This is the good old C++ trick for creating a macro that forces the user to put
a semicolon after it when they use it.
*/
#define JUCE_BLOCK_WITH_FORCED_SEMICOLON(x) do { x } while (false)
#endif
//==============================================================================
#if (JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS) || DOXYGEN
/** Writes a string to the standard error stream.
Note that as well as a single string, you can use this to write multiple items
as a stream, e.g.
@code
DBG ("foo = " << foo << "bar = " << bar);
@endcode
The macro is only enabled in a debug build, so be careful not to use it with expressions
that have important side-effects!
@see Logger::outputDebugString
*/
#define DBG(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::String tempDbgBuf; tempDbgBuf << textToWrite; juce::Logger::outputDebugString (tempDbgBuf);)
//==============================================================================
/** This will always cause an assertion failure.
It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled for your build).
@see jassert
*/
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION; if (juce::juce_isRunningUnderDebugger()) JUCE_BREAK_IN_DEBUGGER; JUCE_ANALYZER_NORETURN)
//==============================================================================
/** Platform-independent assertion macro.
This macro gets turned into a no-op when you're building with debugging turned off, so be
careful that the expression you pass to it doesn't perform any actions that are vital for the
correct behaviour of your program!
@see jassertfalse
*/
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#else
//==============================================================================
// If debugging is disabled, these dummy debug and assertion macros are used..
#define DBG(textToWrite)
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION)
#if JUCE_LOG_ASSERTIONS
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#else
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON ( ; )
#endif
#endif
//==============================================================================
#if ! DOXYGEN
#define JUCE_JOIN_MACRO_HELPER(a, b) a ## b
#define JUCE_STRINGIFY_MACRO_HELPER(a) #a
#endif
/** A good old-fashioned C macro concatenation helper.
This combines two items (which may themselves be macros) into a single string,
avoiding the pitfalls of the ## macro operator.
*/
#define JUCE_JOIN_MACRO(item1, item2) JUCE_JOIN_MACRO_HELPER (item1, item2)
/** A handy C macro for stringifying any symbol, rather than just a macro parameter. */
#define JUCE_STRINGIFY(item) JUCE_STRINGIFY_MACRO_HELPER (item)
//==============================================================================
/** This is a shorthand macro for declaring stubs for a class's copy constructor and operator=.
For example, instead of
@code
class MyClass
{
etc..
private:
MyClass (const MyClass&);
MyClass& operator= (const MyClass&);
};@endcode
..you can just write:
@code
class MyClass
{
etc..
private:
JUCE_DECLARE_NON_COPYABLE (MyClass)
};@endcode
*/
#define JUCE_DECLARE_NON_COPYABLE(className) \
className (const className&) = delete;\
className& operator= (const className&) = delete;
/** This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and
JUCE_LEAK_DETECTOR macro for a class.
*/
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className) \
JUCE_DECLARE_NON_COPYABLE(className) \
JUCE_LEAK_DETECTOR(className)
/** This macro can be added to class definitions to disable the use of new/delete to
allocate the object on the heap, forcing it to only be used as a stack or member variable.
*/
#define JUCE_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new (size_t) = delete; \
static void operator delete (void*) = delete;
//==============================================================================
#if JUCE_MSVC && ! defined (DOXYGEN)
#define JUCE_WARNING_HELPER(file, line, mess) message(file "(" JUCE_STRINGIFY (line) ") : Warning: " #mess)
#define JUCE_COMPILER_WARNING(message) __pragma(JUCE_WARNING_HELPER (__FILE__, __LINE__, message))
#else
#ifndef DOXYGEN
#define JUCE_WARNING_HELPER(mess) message(#mess)
#endif
/** This macro allows you to emit a custom compiler warning message.
Very handy for marking bits of code as "to-do" items, or for shaming
code written by your co-workers in a way that's hard to ignore.
GCC and Clang provide the \#warning directive, but MSVC doesn't, so this macro
is a cross-compiler way to get the same functionality as \#warning.
*/
#define JUCE_COMPILER_WARNING(message) _Pragma(JUCE_STRINGIFY (JUCE_WARNING_HELPER (message)))
#endif
//==============================================================================
#if JUCE_DEBUG || DOXYGEN
/** A platform-independent way of forcing an inline function.
Use the syntax: @code
forcedinline void myfunction (int x)
@endcode
*/
#define forcedinline inline
#else
#if JUCE_MSVC
#define forcedinline __forceinline
#else
#define forcedinline inline __attribute__((always_inline))
#endif
#endif
#if JUCE_MSVC || DOXYGEN
/** This can be placed before a stack or member variable declaration to tell the compiler
to align it to the specified number of bytes. */
#define JUCE_ALIGN(bytes) __declspec (align (bytes))
#else
#define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes)))
#endif
//==============================================================================
// Cross-compiler deprecation macros..
#ifdef DOXYGEN
/** This macro can be used to wrap a function which has been deprecated. */
#define JUCE_DEPRECATED(functionDef)
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body)
#elif JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS
#define JUCE_DEPRECATED_ATTRIBUTE __declspec(deprecated)
#define JUCE_DEPRECATED(functionDef) JUCE_DEPRECATED_ATTRIBUTE functionDef
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body) JUCE_DEPRECATED_ATTRIBUTE functionDef body
#elif (JUCE_GCC || JUCE_CLANG) && ! JUCE_NO_DEPRECATION_WARNINGS
#define JUCE_DEPRECATED_ATTRIBUTE __attribute__ ((deprecated))
#define JUCE_DEPRECATED(functionDef) functionDef JUCE_DEPRECATED_ATTRIBUTE
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body) functionDef JUCE_DEPRECATED_ATTRIBUTE body
#else
#define JUCE_DEPRECATED_ATTRIBUTE
#define JUCE_DEPRECATED(functionDef) functionDef
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body) functionDef body
#endif
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
#if ! (defined (DOXYGEN) || defined (JUCE_GCC) || (JUCE_MSVC && _MSC_VER <= 1900))
#define JUCE_DEPRECATED_STATIC(valueDef) JUCE_DEPRECATED_ATTRIBUTE valueDef
#if JUCE_MSVC
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) \
__pragma(warning(push)) \
__pragma(warning(disable:4996)) \
valueDef \
__pragma(warning(pop))
#else
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef
#endif
#else
#define JUCE_DEPRECATED_STATIC(valueDef) valueDef
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef
#endif
#else
#define JUCE_DEPRECATED_STATIC(valueDef)
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef)
#endif
//==============================================================================
#if JUCE_ANDROID && ! DOXYGEN
#define JUCE_MODAL_LOOPS_PERMITTED 0
#elif ! defined (JUCE_MODAL_LOOPS_PERMITTED)
/** Some operating environments don't provide a modal loop mechanism, so this flag can be
used to disable any functions that try to run a modal loop. */
#define JUCE_MODAL_LOOPS_PERMITTED 1
#endif
//==============================================================================
#if JUCE_GCC || JUCE_CLANG
#define JUCE_PACKED __attribute__((packed))
#elif ! DOXYGEN
#define JUCE_PACKED
#endif
//==============================================================================
#if JUCE_GCC || DOXYGEN
/** This can be appended to a function declaration to tell gcc to disable associative
math optimisations which break some floating point algorithms. */
#define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS __attribute__((__optimize__("no-associative-math")))
#else
#define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS
#endif
} // namespace juce

View File

@ -0,0 +1,157 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
//==============================================================================
/** Current JUCE version number.
See also SystemStats::getJUCEVersion() for a string version.
*/
#define JUCE_MAJOR_VERSION 5
#define JUCE_MINOR_VERSION 3
#define JUCE_BUILDNUMBER 2
/** Current JUCE version number.
Bits 16 to 32 = major version.
Bits 8 to 16 = minor version.
Bits 0 to 8 = point release.
See also SystemStats::getJUCEVersion() for a string version.
*/
#define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER)
//==============================================================================
#include <memory>
#include <cmath>
#include <vector>
#include <iostream>
#include <functional>
#include <algorithm>
#include <limits>
#include <atomic>
//==============================================================================
#include "juce_CompilerSupport.h"
#include "juce_PlatformDefs.h"
//==============================================================================
// Now we'll include some common OS headers..
#if JUCE_MSVC
#pragma warning (push)
#pragma warning (disable: 4514 4245 4100)
#include <intrin.h>
#endif
#if JUCE_MAC || JUCE_IOS
#include <libkern/OSAtomic.h>
#include <xlocale.h>
#endif
#if JUCE_LINUX
#include <cstring>
#include <signal.h>
#if __INTEL_COMPILER
#if __ia64__
#include <ia64intrin.h>
#else
#include <ia32intrin.h>
#endif
#endif
#endif
#if JUCE_MSVC && JUCE_DEBUG
#include <crtdbg.h>
#endif
#if JUCE_MSVC
#pragma warning (pop)
#endif
#if JUCE_MINGW
#include <cstring>
#include <sys/types.h>
#endif
#if JUCE_ANDROID
#include <cstring>
#include <atomic>
#include <byteswap.h>
#endif
// undef symbols that are sometimes set by misguided 3rd-party headers..
#undef TYPE_BOOL
#undef max
#undef min
#undef major
#undef minor
#undef KeyPress
// Include a replacement for std::function
#if JUCE_PROJUCER_LIVE_BUILD
#include "../misc/juce_StdFunctionCompat.h"
#endif
//==============================================================================
// DLL building settings on Windows
#if JUCE_MSVC
#ifdef JUCE_DLL_BUILD
#define JUCE_API __declspec (dllexport)
#pragma warning (disable: 4251)
#elif defined (JUCE_DLL)
#define JUCE_API __declspec (dllimport)
#pragma warning (disable: 4251)
#endif
#ifdef __INTEL_COMPILER
#pragma warning (disable: 1125) // (virtual override warning)
#endif
#elif defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)
#define JUCE_API __attribute__ ((visibility("default")))
#endif
//==============================================================================
#ifndef JUCE_API
#define JUCE_API /**< This macro is added to all JUCE public class declarations. */
#endif
#if JUCE_MSVC && JUCE_DLL_BUILD
#define JUCE_PUBLIC_IN_DLL_BUILD(declaration) public: declaration; private:
#else
#define JUCE_PUBLIC_IN_DLL_BUILD(declaration) declaration;
#endif
/** This macro is added to all JUCE public function declarations. */
#define JUCE_PUBLIC_FUNCTION JUCE_API JUCE_CALLTYPE
#if (! defined (JUCE_CATCH_DEPRECATED_CODE_MISUSE)) && JUCE_DEBUG && ! DOXYGEN
/** This turns on some non-essential bits of code that should prevent old code from compiling
in cases where method signatures have changed, etc.
*/
#define JUCE_CATCH_DEPRECATED_CODE_MISUSE 1
#endif
#ifndef DOXYGEN
#define JUCE_NAMESPACE juce // This old macro is deprecated: you should just use the juce namespace directly.
#endif

View File

@ -0,0 +1,237 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
String SystemStats::getJUCEVersion()
{
// Some basic tests, to keep an eye on things and make sure these types work ok
// on all platforms. Let me know if any of these assertions fail on your system!
static_assert (sizeof (pointer_sized_int) == sizeof (void*), "Basic sanity test failed: please report!");
static_assert (sizeof (int8) == 1, "Basic sanity test failed: please report!");
static_assert (sizeof (uint8) == 1, "Basic sanity test failed: please report!");
static_assert (sizeof (int16) == 2, "Basic sanity test failed: please report!");
static_assert (sizeof (uint16) == 2, "Basic sanity test failed: please report!");
static_assert (sizeof (int32) == 4, "Basic sanity test failed: please report!");
static_assert (sizeof (uint32) == 4, "Basic sanity test failed: please report!");
static_assert (sizeof (int64) == 8, "Basic sanity test failed: please report!");
static_assert (sizeof (uint64) == 8, "Basic sanity test failed: please report!");
return "JUCE v" JUCE_STRINGIFY(JUCE_MAJOR_VERSION)
"." JUCE_STRINGIFY(JUCE_MINOR_VERSION)
"." JUCE_STRINGIFY(JUCE_BUILDNUMBER);
}
#if JUCE_ANDROID && ! defined (JUCE_DISABLE_JUCE_VERSION_PRINTING)
#define JUCE_DISABLE_JUCE_VERSION_PRINTING 1
#endif
#if JUCE_DEBUG && ! JUCE_DISABLE_JUCE_VERSION_PRINTING
struct JuceVersionPrinter
{
JuceVersionPrinter()
{
DBG (SystemStats::getJUCEVersion());
}
};
static JuceVersionPrinter juceVersionPrinter;
#endif
StringArray SystemStats::getDeviceIdentifiers()
{
StringArray ids;
#if JUCE_WINDOWS
File f (File::getSpecialLocation (File::windowsSystemDirectory));
#else
File f ("~");
#endif
if (auto num = f.getFileIdentifier())
{
ids.add (String::toHexString ((int64) num));
}
else
{
Array<MACAddress> addresses;
MACAddress::findAllAddresses (addresses);
for (auto& address : addresses)
ids.add (address.toString());
}
jassert (ids.size() > 0); // Failed to create any IDs!
return ids;
}
//==============================================================================
struct CPUInformation
{
CPUInformation() noexcept { initialise(); }
void initialise() noexcept;
int numLogicalCPUs = 0, numPhysicalCPUs = 0;
bool hasMMX = false, hasSSE = false, hasSSE2 = false, hasSSE3 = false,
has3DNow = false, hasSSSE3 = false, hasSSE41 = false,
hasSSE42 = false, hasAVX = false, hasAVX2 = false, hasNeon = false;
};
static const CPUInformation& getCPUInformation() noexcept
{
static CPUInformation info;
return info;
}
int SystemStats::getNumCpus() noexcept { return getCPUInformation().numLogicalCPUs; }
int SystemStats::getNumPhysicalCpus() noexcept { return getCPUInformation().numPhysicalCPUs; }
bool SystemStats::hasMMX() noexcept { return getCPUInformation().hasMMX; }
bool SystemStats::has3DNow() noexcept { return getCPUInformation().has3DNow; }
bool SystemStats::hasSSE() noexcept { return getCPUInformation().hasSSE; }
bool SystemStats::hasSSE2() noexcept { return getCPUInformation().hasSSE2; }
bool SystemStats::hasSSE3() noexcept { return getCPUInformation().hasSSE3; }
bool SystemStats::hasSSSE3() noexcept { return getCPUInformation().hasSSSE3; }
bool SystemStats::hasSSE41() noexcept { return getCPUInformation().hasSSE41; }
bool SystemStats::hasSSE42() noexcept { return getCPUInformation().hasSSE42; }
bool SystemStats::hasAVX() noexcept { return getCPUInformation().hasAVX; }
bool SystemStats::hasAVX2() noexcept { return getCPUInformation().hasAVX2; }
bool SystemStats::hasNeon() noexcept { return getCPUInformation().hasNeon; }
//==============================================================================
String SystemStats::getStackBacktrace()
{
String result;
#if JUCE_ANDROID || JUCE_MINGW
jassertfalse; // sorry, not implemented yet!
#elif JUCE_WINDOWS
HANDLE process = GetCurrentProcess();
SymInitialize (process, nullptr, TRUE);
void* stack[128];
int frames = (int) CaptureStackBackTrace (0, numElementsInArray (stack), stack, nullptr);
HeapBlock<SYMBOL_INFO> symbol;
symbol.calloc (sizeof (SYMBOL_INFO) + 256, 1);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
for (int i = 0; i < frames; ++i)
{
DWORD64 displacement = 0;
if (SymFromAddr (process, (DWORD64) stack[i], &displacement, symbol))
{
result << i << ": ";
IMAGEHLP_MODULE64 moduleInfo;
zerostruct (moduleInfo);
moduleInfo.SizeOfStruct = sizeof (moduleInfo);
if (::SymGetModuleInfo64 (process, symbol->ModBase, &moduleInfo))
result << moduleInfo.ModuleName << ": ";
result << symbol->Name << " + 0x" << String::toHexString ((int64) displacement) << newLine;
}
}
#else
void* stack[128];
int frames = backtrace (stack, numElementsInArray (stack));
char** frameStrings = backtrace_symbols (stack, frames);
for (int i = 0; i < frames; ++i)
result << frameStrings[i] << newLine;
::free (frameStrings);
#endif
return result;
}
//==============================================================================
static SystemStats::CrashHandlerFunction globalCrashHandler = nullptr;
#if JUCE_WINDOWS
static LONG WINAPI handleCrash (LPEXCEPTION_POINTERS ep)
{
globalCrashHandler (ep);
return EXCEPTION_EXECUTE_HANDLER;
}
#else
static void handleCrash (int signum)
{
globalCrashHandler ((void*) (pointer_sized_int) signum);
kill (getpid(), SIGKILL);
}
int juce_siginterrupt (int sig, int flag);
#endif
void SystemStats::setApplicationCrashHandler (CrashHandlerFunction handler)
{
jassert (handler != nullptr); // This must be a valid function.
globalCrashHandler = handler;
#if JUCE_WINDOWS
SetUnhandledExceptionFilter (handleCrash);
#else
const int signals[] = { SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGABRT, SIGSYS };
for (int i = 0; i < numElementsInArray (signals); ++i)
{
::signal (signals[i], handleCrash);
juce_siginterrupt (signals[i], 1);
}
#endif
}
bool SystemStats::isRunningInAppExtensionSandbox() noexcept
{
#if JUCE_MAC || JUCE_IOS
static bool firstQuery = true;
static bool isRunningInAppSandbox = false;
if (firstQuery)
{
firstQuery = false;
File bundle = File::getSpecialLocation (File::invokedExecutableFile).getParentDirectory();
#if JUCE_MAC
bundle = bundle.getParentDirectory().getParentDirectory();
#endif
if (bundle.isDirectory())
isRunningInAppSandbox = (bundle.getFileExtension() == ".appex");
}
return isRunningInAppSandbox;
#else
return false;
#endif
}
} // namespace juce

View File

@ -0,0 +1,228 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
/**
Contains methods for finding out about the current hardware and OS configuration.
@tags{Core}
*/
class JUCE_API SystemStats final
{
public:
//==============================================================================
/** Returns the current version of JUCE,
See also the JUCE_VERSION, JUCE_MAJOR_VERSION and JUCE_MINOR_VERSION macros.
*/
static String getJUCEVersion();
//==============================================================================
/** The set of possible results of the getOperatingSystemType() method. */
enum OperatingSystemType
{
UnknownOS = 0,
MacOSX = 0x0100, /**< To test whether any version of OSX is running,
you can use the expression ((getOperatingSystemType() & MacOSX) != 0). */
Windows = 0x0200, /**< To test whether any version of Windows is running,
you can use the expression ((getOperatingSystemType() & Windows) != 0). */
Linux = 0x0400,
Android = 0x0800,
iOS = 0x1000,
MacOSX_10_4 = MacOSX | 4,
MacOSX_10_5 = MacOSX | 5,
MacOSX_10_6 = MacOSX | 6,
MacOSX_10_7 = MacOSX | 7,
MacOSX_10_8 = MacOSX | 8,
MacOSX_10_9 = MacOSX | 9,
MacOSX_10_10 = MacOSX | 10,
MacOSX_10_11 = MacOSX | 11,
MacOSX_10_12 = MacOSX | 12,
Win2000 = Windows | 1,
WinXP = Windows | 2,
WinVista = Windows | 3,
Windows7 = Windows | 4,
Windows8_0 = Windows | 5,
Windows8_1 = Windows | 6,
Windows10 = Windows | 7
};
/** Returns the type of operating system we're running on.
@returns one of the values from the OperatingSystemType enum.
@see getOperatingSystemName
*/
static OperatingSystemType getOperatingSystemType();
/** Returns the name of the type of operating system we're running on.
@returns a string describing the OS type.
@see getOperatingSystemType
*/
static String getOperatingSystemName();
/** Returns true if the OS is 64-bit, or false for a 32-bit OS. */
static bool isOperatingSystem64Bit();
/** Returns an environment variable.
If the named value isn't set, this will return the defaultValue string instead.
*/
static String getEnvironmentVariable (const String& name, const String& defaultValue);
//==============================================================================
/** Returns the current user's name, if available.
@see getFullUserName()
*/
static String getLogonName();
/** Returns the current user's full name, if available.
On some OSes, this may just return the same value as getLogonName().
@see getLogonName()
*/
static String getFullUserName();
/** Returns the host-name of the computer. */
static String getComputerName();
/** Returns the language of the user's locale.
The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
*/
static String getUserLanguage();
/** Returns the region of the user's locale.
The return value is a 2 letter country code (ISO 3166-1 alpha-2).
*/
static String getUserRegion();
/** Returns the user's display language.
The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2).
Note that depending on the OS and region, this may also be followed by a dash
and a sub-region code, e.g "en-GB"
*/
static String getDisplayLanguage();
/** This will attempt to return some kind of string describing the device.
If no description is available, it'll just return an empty string. You may
want to use this for things like determining the type of phone/iPad, etc.
*/
static String getDeviceDescription();
/** This will attempt to return the manufacturer of the device.
If no description is available, it'll just return an empty string.
*/
static String getDeviceManufacturer();
/** This method calculates some IDs to uniquely identify the device.
The first choice for an ID is a filesystem ID for the user's home folder or
windows directory. If that fails then this function returns the MAC addresses.
*/
static StringArray getDeviceIdentifiers();
//==============================================================================
// CPU and memory information..
/** Returns the number of logical CPU cores. */
static int getNumCpus() noexcept;
/** Returns the number of physical CPU cores. */
static int getNumPhysicalCpus() noexcept;
/** Returns the approximate CPU speed.
@returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
what year you're reading this...)
*/
static int getCpuSpeedInMegaherz();
/** Returns a string to indicate the CPU vendor.
Might not be known on some systems.
*/
static String getCpuVendor();
/** Attempts to return a string describing the CPU model.
May not be available on some systems.
*/
static String getCpuModel();
static bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
static bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
static bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
static bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
static bool hasSSE3() noexcept; /**< Returns true if Intel SSE3 instructions are available. */
static bool hasSSSE3() noexcept; /**< Returns true if Intel SSSE3 instructions are available. */
static bool hasSSE41() noexcept; /**< Returns true if Intel SSE4.1 instructions are available. */
static bool hasSSE42() noexcept; /**< Returns true if Intel SSE4.2 instructions are available. */
static bool hasAVX() noexcept; /**< Returns true if Intel AVX instructions are available. */
static bool hasAVX2() noexcept; /**< Returns true if Intel AVX2 instructions are available. */
static bool hasNeon() noexcept; /**< Returns true if ARM NEON instructions are available. */
//==============================================================================
/** Finds out how much RAM is in the machine.
@returns the approximate number of megabytes of memory, or zero if
something goes wrong when finding out.
*/
static int getMemorySizeInMegabytes();
/** Returns the system page-size.
This is only used by programmers with beards.
*/
static int getPageSize();
//==============================================================================
/** Returns a backtrace of the current call-stack.
The usefulness of the result will depend on the level of debug symbols
that are available in the executable.
*/
static String getStackBacktrace();
/** A function type for use in setApplicationCrashHandler(). The parameter will contain
platform-specific data about the crash.
*/
typedef void (*CrashHandlerFunction) (void*);
/** Sets up a global callback function that will be called if the application
executes some kind of illegal instruction.
You may want to call getStackBacktrace() in your handler function, to find out
where the problem happened and log it, etc.
*/
static void setApplicationCrashHandler (CrashHandlerFunction);
/** Returns true if this code is running inside an app extension sandbox.
This function will always return false on windows, linux and android.
*/
static bool isRunningInAppExtensionSandbox() noexcept;
private:
//==============================================================================
SystemStats();
JUCE_DECLARE_NON_COPYABLE (SystemStats)
};
} // namespace juce

View File

@ -0,0 +1,196 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
//==============================================================================
/* This file figures out which platform is being built, and defines some macros
that the rest of the code can use for OS-specific compilation.
Macros that will be set here are:
- One of JUCE_WINDOWS, JUCE_MAC JUCE_LINUX, JUCE_IOS, JUCE_ANDROID, etc.
- Either JUCE_32BIT or JUCE_64BIT, depending on the architecture.
- Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN.
- Either JUCE_INTEL or JUCE_ARM
- Either JUCE_GCC or JUCE_CLANG or JUCE_MSVC
*/
//==============================================================================
#ifdef JUCE_APP_CONFIG_HEADER
#include JUCE_APP_CONFIG_HEADER
#elif ! defined (JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED)
/*
Most projects will contain a global header file containing various settings that
should be applied to all the code in your project. If you use the projucer, it'll
set up a global header file for you automatically, but if you're doing things manually,
you may want to set the JUCE_APP_CONFIG_HEADER macro with the name of a file to include,
or just include one before all the module cpp files, in which you set
JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 to silence this error.
(Or if you don't need a global header, then you can just define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED
globally to avoid this error).
Note for people who hit this error when trying to compile a JUCE project created by
a pre-v4.2 version of the Introjucer/Projucer, it's very easy to fix: just re-save
your project with the latest version of the Projucer, and it'll magically fix this!
*/
#error "No global header file was included!"
#endif
//==============================================================================
#if defined (_WIN32) || defined (_WIN64)
#define JUCE_WIN32 1
#define JUCE_WINDOWS 1
#elif defined (JUCE_ANDROID)
#undef JUCE_ANDROID
#define JUCE_ANDROID 1
#elif defined (__FreeBSD__) || (__OpenBSD__)
#define JUCE_BSD 1
#elif defined (LINUX) || defined (__linux__)
#define JUCE_LINUX 1
#elif defined (__APPLE_CPP__) || defined (__APPLE_CC__)
#include <CoreFoundation/CoreFoundation.h> // (needed to find out what platform we're using)
#include "../native/juce_mac_ClangBugWorkaround.h"
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define JUCE_IPHONE 1
#define JUCE_IOS 1
#else
#define JUCE_MAC 1
#endif
#else
#error "Unknown platform!"
#endif
//==============================================================================
#if JUCE_WINDOWS
#ifdef _MSC_VER
#ifdef _WIN64
#define JUCE_64BIT 1
#else
#define JUCE_32BIT 1
#endif
#endif
#ifdef _DEBUG
#define JUCE_DEBUG 1
#endif
#ifdef __MINGW32__
#define JUCE_MINGW 1
#ifdef __MINGW64__
#define JUCE_64BIT 1
#else
#define JUCE_32BIT 1
#endif
#endif
/** If defined, this indicates that the processor is little-endian. */
#define JUCE_LITTLE_ENDIAN 1
#define JUCE_INTEL 1
#endif
//==============================================================================
#if JUCE_MAC || JUCE_IOS
#if defined (DEBUG) || defined (_DEBUG) || ! (defined (NDEBUG) || defined (_NDEBUG))
#define JUCE_DEBUG 1
#endif
#if ! (defined (DEBUG) || defined (_DEBUG) || defined (NDEBUG) || defined (_NDEBUG))
#warning "Neither NDEBUG or DEBUG has been defined - you should set one of these to make it clear whether this is a release build,"
#endif
#ifdef __LITTLE_ENDIAN__
#define JUCE_LITTLE_ENDIAN 1
#else
#define JUCE_BIG_ENDIAN 1
#endif
#ifdef __LP64__
#define JUCE_64BIT 1
#else
#define JUCE_32BIT 1
#endif
#if defined (__ppc__) || defined (__ppc64__)
#error "PowerPC is no longer supported by JUCE!"
#elif defined (__arm__) || defined (__arm64__)
#define JUCE_ARM 1
#else
#define JUCE_INTEL 1
#endif
#if JUCE_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
#error "Building for OSX 10.4 is no longer supported!"
#endif
#if JUCE_MAC && ! defined (MAC_OS_X_VERSION_10_6)
#error "To build with 10.5 compatibility, use a later SDK and set the deployment target to 10.5"
#endif
#endif
//==============================================================================
#if JUCE_LINUX || JUCE_ANDROID
#ifdef _DEBUG
#define JUCE_DEBUG 1
#endif
// Allow override for big-endian Linux platforms
#if defined (__LITTLE_ENDIAN__) || ! defined (JUCE_BIG_ENDIAN)
#define JUCE_LITTLE_ENDIAN 1
#undef JUCE_BIG_ENDIAN
#else
#undef JUCE_LITTLE_ENDIAN
#define JUCE_BIG_ENDIAN 1
#endif
#if defined (__LP64__) || defined (_LP64) || defined (__arm64__)
#define JUCE_64BIT 1
#else
#define JUCE_32BIT 1
#endif
#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
#define JUCE_ARM 1
#elif __MMX__ || __SSE__ || __amd64__
#define JUCE_INTEL 1
#endif
#endif
//==============================================================================
// Compiler type macros.
#ifdef __clang__
#define JUCE_CLANG 1
#elif defined (__GNUC__)
#define JUCE_GCC 1
#elif defined (_MSC_VER)
#define JUCE_MSVC 1
#else
#error unknown compiler
#endif