From ae151f8f0ebf1706206ebb2d4dd221a405b375a5 Mon Sep 17 00:00:00 2001
From: Christopher Stawarz <cstawarz@mit.edu>
Date: Thu, 13 Oct 2016 09:45:07 -0400
Subject: [PATCH] Ensure that plugin entry points are always exported on macOS
 and Linux (otherwise, plugins won't load in macOS release builds)

---
 .gitignore                                                    | 2 ++
 PluginGenerator/JuceLibraryCode/BinaryData.cpp                | 4 ++--
 PluginGenerator/JuceLibraryCode/BinaryData.h                  | 2 +-
 Source/Plugins/ArduinoOutput/OpenEphysLib.cpp                 | 2 +-
 Source/Plugins/BasicSpikeDisplay/OpenEphysLib.cpp             | 2 +-
 Source/Plugins/BinaryWriter/OpenEphysLib.cpp                  | 2 +-
 Source/Plugins/CAR/OpenEphysLib.cpp                           | 2 +-
 Source/Plugins/ChannelMappingNode/OpenEphysLib.cpp            | 2 +-
 Source/Plugins/EcubeSource/OpenEphysLib.cpp                   | 2 +-
 Source/Plugins/EventBroadcaster/OpenEphysLib.cpp              | 2 +-
 Source/Plugins/FilterNode/OpenEphysLib.cpp                    | 2 +-
 Source/Plugins/JuliaProcessor/OpenEphysLib.cpp                | 2 +-
 Source/Plugins/KWIKFormat/OpenEphysLib.cpp                    | 2 +-
 Source/Plugins/LfpDisplayNode/OpenEphysLib.cpp                | 2 +-
 Source/Plugins/LfpDisplayNodeBeta/OpenEphysLib.cpp            | 2 +-
 Source/Plugins/NetworkEvents/OpenEphysLib.cpp                 | 2 +-
 Source/Plugins/PCIeRhythm/OpenEphysLib.cpp                    | 2 +-
 Source/Plugins/PhaseDetector/OpenEphysLib.cpp                 | 2 +-
 Source/Plugins/PulsePalOutput/OpenEphysLib.cpp                | 2 +-
 Source/Plugins/RecordControl/OpenEphysLib.cpp                 | 2 +-
 Source/Plugins/Rectifier/OpenEphysLib.cpp                     | 2 +-
 Source/Plugins/SerialInput/OpenEphysLib.cpp                   | 2 +-
 Source/Plugins/SpikeRaster/OpenEphysLib.cpp                   | 2 +-
 Source/Plugins/SpikeSorter/OpenEphysLib.cpp                   | 2 +-
 .../Templates/openEphys_OpenEphysLibTemplate.cpp              | 2 +-
 Source/Processors/RecordNode/OriginalRecording.cpp            | 3 ++-
 26 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/.gitignore b/.gitignore
index 65e463fd0..df9d14471 100644
--- a/.gitignore
+++ b/.gitignore
@@ -116,6 +116,8 @@ Introjucer/Builds/MacOSX/The Introjucer.xcodeproj/*.pbxuser
 Introjucer/Builds/MacOSX/The Introjucer.xcodeproj/xcuserdata
 Introjucer/Builds/MacOSX/The Introjucer.xcodeproj/project.xcworkspace
 Introjucer/Builds/MacOSX/build
+Projucer/Builds/MacOSX/Projucer.xcodeproj/xcuserdata
+Projucer/Builds/MacOSX/Projucer.xcodeproj/project.xcworkspace
 
 # 9. Plugin build dirs
 build/
diff --git a/PluginGenerator/JuceLibraryCode/BinaryData.cpp b/PluginGenerator/JuceLibraryCode/BinaryData.cpp
index c91014dbe..ff01c2aa8 100644
--- a/PluginGenerator/JuceLibraryCode/BinaryData.cpp
+++ b/PluginGenerator/JuceLibraryCode/BinaryData.cpp
@@ -610,7 +610,7 @@ static const unsigned char temp_binary_data_6[] =
 "    #include <Windows.h>\n"
 "    #define EXPORT __declspec(dllexport)\n"
 "#else\n"
-"    #define EXPORT\n"
+"    #define EXPORT __attribute__((visibility(\"default\")))\n"
 "#endif\n"
 "\n"
 "using namespace Plugin;\n"
@@ -6076,7 +6076,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
         case 0x9a9516bc:  numBytes = 1817; return openEphys_DataThreadPluginTemplate_h;
         case 0xd768da9a:  numBytes = 1487; return openEphys_FileSourcePluginTemplate_cpp;
         case 0xdc872b1f:  numBytes = 1450; return openEphys_FileSourcePluginTemplate_h;
-        case 0x354e9a48:  numBytes = 4216; return openEphys_OpenEphysLibTemplate_cpp;
+        case 0x354e9a48:  numBytes = 4255; return openEphys_OpenEphysLibTemplate_cpp;
         case 0xbf9557ba:  numBytes = 923; return openEphys_PluginMakefile_example;
         case 0x0d98caa2:  numBytes = 2993; return openEphys_ProcessorContentComponentTemplate_cpp;
         case 0x20837d27:  numBytes = 2348; return openEphys_ProcessorContentComponentTemplate_h;
diff --git a/PluginGenerator/JuceLibraryCode/BinaryData.h b/PluginGenerator/JuceLibraryCode/BinaryData.h
index 98fd2224f..bb16afc99 100644
--- a/PluginGenerator/JuceLibraryCode/BinaryData.h
+++ b/PluginGenerator/JuceLibraryCode/BinaryData.h
@@ -28,7 +28,7 @@ namespace BinaryData
     const int            openEphys_FileSourcePluginTemplate_hSize = 1450;
 
     extern const char*   openEphys_OpenEphysLibTemplate_cpp;
-    const int            openEphys_OpenEphysLibTemplate_cppSize = 4216;
+    const int            openEphys_OpenEphysLibTemplate_cppSize = 4255;
 
     extern const char*   openEphys_PluginMakefile_example;
     const int            openEphys_PluginMakefile_exampleSize = 923;
diff --git a/Source/Plugins/ArduinoOutput/OpenEphysLib.cpp b/Source/Plugins/ArduinoOutput/OpenEphysLib.cpp
index d564b4def..b77ef5022 100644
--- a/Source/Plugins/ArduinoOutput/OpenEphysLib.cpp
+++ b/Source/Plugins/ArduinoOutput/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/BasicSpikeDisplay/OpenEphysLib.cpp b/Source/Plugins/BasicSpikeDisplay/OpenEphysLib.cpp
index fc63bf6cf..1260bd62a 100644
--- a/Source/Plugins/BasicSpikeDisplay/OpenEphysLib.cpp
+++ b/Source/Plugins/BasicSpikeDisplay/OpenEphysLib.cpp
@@ -29,7 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/BinaryWriter/OpenEphysLib.cpp b/Source/Plugins/BinaryWriter/OpenEphysLib.cpp
index 0c8f7e3de..4f5679530 100644
--- a/Source/Plugins/BinaryWriter/OpenEphysLib.cpp
+++ b/Source/Plugins/BinaryWriter/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 
diff --git a/Source/Plugins/CAR/OpenEphysLib.cpp b/Source/Plugins/CAR/OpenEphysLib.cpp
index f589163f9..e4d9b3efc 100644
--- a/Source/Plugins/CAR/OpenEphysLib.cpp
+++ b/Source/Plugins/CAR/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/ChannelMappingNode/OpenEphysLib.cpp b/Source/Plugins/ChannelMappingNode/OpenEphysLib.cpp
index 3ad2a98fe..0345874ef 100644
--- a/Source/Plugins/ChannelMappingNode/OpenEphysLib.cpp
+++ b/Source/Plugins/ChannelMappingNode/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/EcubeSource/OpenEphysLib.cpp b/Source/Plugins/EcubeSource/OpenEphysLib.cpp
index e446f3c25..d4872f700 100644
--- a/Source/Plugins/EcubeSource/OpenEphysLib.cpp
+++ b/Source/Plugins/EcubeSource/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/EventBroadcaster/OpenEphysLib.cpp b/Source/Plugins/EventBroadcaster/OpenEphysLib.cpp
index 302b5da63..7c4975352 100644
--- a/Source/Plugins/EventBroadcaster/OpenEphysLib.cpp
+++ b/Source/Plugins/EventBroadcaster/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/FilterNode/OpenEphysLib.cpp b/Source/Plugins/FilterNode/OpenEphysLib.cpp
index 0a012841b..a945d2969 100644
--- a/Source/Plugins/FilterNode/OpenEphysLib.cpp
+++ b/Source/Plugins/FilterNode/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/JuliaProcessor/OpenEphysLib.cpp b/Source/Plugins/JuliaProcessor/OpenEphysLib.cpp
index 56e0f5019..189d524e9 100644
--- a/Source/Plugins/JuliaProcessor/OpenEphysLib.cpp
+++ b/Source/Plugins/JuliaProcessor/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/KWIKFormat/OpenEphysLib.cpp b/Source/Plugins/KWIKFormat/OpenEphysLib.cpp
index 07420b133..ed107bdc4 100644
--- a/Source/Plugins/KWIKFormat/OpenEphysLib.cpp
+++ b/Source/Plugins/KWIKFormat/OpenEphysLib.cpp
@@ -29,7 +29,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 
diff --git a/Source/Plugins/LfpDisplayNode/OpenEphysLib.cpp b/Source/Plugins/LfpDisplayNode/OpenEphysLib.cpp
index d2826342f..e036db1f9 100644
--- a/Source/Plugins/LfpDisplayNode/OpenEphysLib.cpp
+++ b/Source/Plugins/LfpDisplayNode/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/LfpDisplayNodeBeta/OpenEphysLib.cpp b/Source/Plugins/LfpDisplayNodeBeta/OpenEphysLib.cpp
index e24876c0f..ab7605a4c 100644
--- a/Source/Plugins/LfpDisplayNodeBeta/OpenEphysLib.cpp
+++ b/Source/Plugins/LfpDisplayNodeBeta/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/NetworkEvents/OpenEphysLib.cpp b/Source/Plugins/NetworkEvents/OpenEphysLib.cpp
index f3f9e804d..c56aabb9f 100644
--- a/Source/Plugins/NetworkEvents/OpenEphysLib.cpp
+++ b/Source/Plugins/NetworkEvents/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/PCIeRhythm/OpenEphysLib.cpp b/Source/Plugins/PCIeRhythm/OpenEphysLib.cpp
index 390227fc9..8e932252c 100644
--- a/Source/Plugins/PCIeRhythm/OpenEphysLib.cpp
+++ b/Source/Plugins/PCIeRhythm/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/PhaseDetector/OpenEphysLib.cpp b/Source/Plugins/PhaseDetector/OpenEphysLib.cpp
index 698b59a7e..efc48b412 100644
--- a/Source/Plugins/PhaseDetector/OpenEphysLib.cpp
+++ b/Source/Plugins/PhaseDetector/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/PulsePalOutput/OpenEphysLib.cpp b/Source/Plugins/PulsePalOutput/OpenEphysLib.cpp
index a9d0e4b46..19f1a8767 100644
--- a/Source/Plugins/PulsePalOutput/OpenEphysLib.cpp
+++ b/Source/Plugins/PulsePalOutput/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/RecordControl/OpenEphysLib.cpp b/Source/Plugins/RecordControl/OpenEphysLib.cpp
index 8f99f8631..f895f4dd8 100644
--- a/Source/Plugins/RecordControl/OpenEphysLib.cpp
+++ b/Source/Plugins/RecordControl/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/Rectifier/OpenEphysLib.cpp b/Source/Plugins/Rectifier/OpenEphysLib.cpp
index 16d2bae31..673281f79 100644
--- a/Source/Plugins/Rectifier/OpenEphysLib.cpp
+++ b/Source/Plugins/Rectifier/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/SerialInput/OpenEphysLib.cpp b/Source/Plugins/SerialInput/OpenEphysLib.cpp
index c51ea7237..25dd39c47 100644
--- a/Source/Plugins/SerialInput/OpenEphysLib.cpp
+++ b/Source/Plugins/SerialInput/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/SpikeRaster/OpenEphysLib.cpp b/Source/Plugins/SpikeRaster/OpenEphysLib.cpp
index f6784bcb2..abc7fd079 100644
--- a/Source/Plugins/SpikeRaster/OpenEphysLib.cpp
+++ b/Source/Plugins/SpikeRaster/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Plugins/SpikeSorter/OpenEphysLib.cpp b/Source/Plugins/SpikeSorter/OpenEphysLib.cpp
index 2a458487a..5f6c6a285 100644
--- a/Source/Plugins/SpikeSorter/OpenEphysLib.cpp
+++ b/Source/Plugins/SpikeSorter/OpenEphysLib.cpp
@@ -28,7 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <Windows.h>
 #define EXPORT __declspec(dllexport)
 #else
-#define EXPORT
+#define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Processors/PluginManager/Templates/openEphys_OpenEphysLibTemplate.cpp b/Source/Processors/PluginManager/Templates/openEphys_OpenEphysLibTemplate.cpp
index 30f12a199..69071a0ef 100644
--- a/Source/Processors/PluginManager/Templates/openEphys_OpenEphysLibTemplate.cpp
+++ b/Source/Processors/PluginManager/Templates/openEphys_OpenEphysLibTemplate.cpp
@@ -28,7 +28,7 @@
     #include <Windows.h>
     #define EXPORT __declspec(dllexport)
 #else
-    #define EXPORT
+    #define EXPORT __attribute__((visibility("default")))
 #endif
 
 using namespace Plugin;
diff --git a/Source/Processors/RecordNode/OriginalRecording.cpp b/Source/Processors/RecordNode/OriginalRecording.cpp
index b442142c5..9f8d0ae11 100644
--- a/Source/Processors/RecordNode/OriginalRecording.cpp
+++ b/Source/Processors/RecordNode/OriginalRecording.cpp
@@ -527,6 +527,7 @@ void OriginalRecording::writeContinuousBuffer(const float* data, int nSamples, i
     //std::cout << channel << " : " << nSamples << " : " << count << std::endl;
 
     jassert(count == nSamples); // make sure all the data was written
+    (void)count;  // Suppress unused variable warning in release builds
 
     diskWriteLock.exit();
 
@@ -719,4 +720,4 @@ RecordEngineManager* OriginalRecording::getEngineManager()
     param = new EngineParameter(EngineParameter::STR, 2, "Renamed files prefix", "CH");
     man->addParameter(param);
     return man;
-}
\ No newline at end of file
+}
-- 
GitLab