Skip to content

Commit

Permalink
Merge pull request #49 from atsushieno/build-on-android
Browse files Browse the repository at this point in the history
Exclude FileSystemWatcher from Android build.
  • Loading branch information
FigBug committed Apr 14, 2024
2 parents 67d37fe + 317492c commit f965e8c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions modules/gin_gui/utilities/gin_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ static juce::String getComponentPath (juce::Component& parent, juce::Component&
Layout::Layout (juce::Component& p) : parent (p)
{
setupParser();
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
watcher.addListener (this);
#endif
}

Layout::~Layout()
{
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
watcher.removeListener (this);
#endif
}
Expand Down Expand Up @@ -202,7 +202,7 @@ void Layout::setLayout (const juce::String& filename, const juce::File& source)
if (auto rawLayout = source.loadFileAsString(); rawLayout.isNotEmpty() && parseLayout (rawLayout))
{
layoutFile = source;
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
watcher.addFolder (source.getParentDirectory());
#endif
break;
Expand Down Expand Up @@ -342,7 +342,7 @@ juce::Component* Layout::setBounds (const juce::String& currentPath, const juce:
return curComponent;
}

#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
void Layout::fileChanged (const juce::File& f, gin::FileSystemWatcher::FileSystemEvent)
{
if (f == layoutFile)
Expand Down
8 changes: 4 additions & 4 deletions modules/gin_gui/utilities/gin_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
/** Layout components with json, supports hot reloading
*/
class Layout
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
: public FileSystemWatcher::Listener
#endif
{
public:
Layout (juce::Component&);
#if JUCE_IOS
#if JUCE_IOS || JUCE_ANDROID
~Layout();
#else
~Layout() override;
Expand All @@ -27,13 +27,13 @@ class Layout
void doComponent (const juce::String& currentPath, const juce::var& components);
juce::Component* setBounds (const juce::String& currentPath, const juce::String& id, int idIdx, const juce::var& component);

#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
void fileChanged (const juce::File&, gin::FileSystemWatcher::FileSystemEvent) override;
#endif

std::map<juce::String, juce::Component*> findAllComponents() const;

#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
gin::FileSystemWatcher watcher;
#endif

Expand Down
4 changes: 2 additions & 2 deletions modules/gin_plugin/components/gin_plugineditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void UpdateChecker::timerCallback()

void UpdateChecker::run()
{
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
juce::URL versionsUrl = juce::URL (slProc.processorOptions.updatesURL).withParameter ("plugin", slProc.processorOptions.pluginName).withParameter ("version", slProc.processorOptions.pluginVersion);
juce::XmlDocument doc (versionsUrl.readEntireTextStream());
if (std::unique_ptr<juce::XmlElement> root = doc.getDocumentElement())
Expand Down Expand Up @@ -105,7 +105,7 @@ void NewsChecker::timerCallback()

void NewsChecker::run()
{
#if ! JUCE_IOS
#if ! JUCE_IOS && ! JUCE_ANDROID
juce::XmlDocument doc (juce::URL ("https://socalabs.com/feed/").readEntireTextStream());
if (std::unique_ptr<juce::XmlElement> root = doc.getDocumentElement())
{
Expand Down
4 changes: 4 additions & 0 deletions modules/gin_plugin/plugin/gin_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ void Processor::init()
state.getOrCreateChildWithName ("instance", nullptr);
loadAllPrograms();

#if ! JUCE_IOS && ! JUCE_ANDROID
watcher.addListener (this);
watcher.addFolder (getProgramDirectory());
#endif
}

juce::PropertiesFile* Processor::getSettings()
Expand Down Expand Up @@ -340,12 +342,14 @@ bool Processor::hasProgram (juce::String name)
return false;
}

#if ! JUCE_IOS && ! JUCE_ANDROID
void Processor::folderChanged (const juce::File&)
{
auto now = juce::Time::getCurrentTime();
if (now - lastProgramsUpdated > juce::RelativeTime::seconds (1.0))
startTimer (150);
}
#endif

void Processor::timerCallback()
{
Expand Down
6 changes: 6 additions & 0 deletions modules/gin_plugin/plugin/gin_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class ProcessorOptions
*/
class Processor : public ProcessorBaseClass,
public juce::ChangeBroadcaster,
#if ! JUCE_IOS && ! JUCE_ANDROID
private FileSystemWatcher::Listener,
#endif
private juce::Timer
{
public:
Expand Down Expand Up @@ -208,7 +210,9 @@ class Processor : public ProcessorBaseClass,
void extractProgram (const juce::String& name, const void* data, int sz);

private:
#if ! JUCE_IOS && ! JUCE_ANDROID
void folderChanged (const juce::File&) override;
#endif
void timerCallback() override;

std::unique_ptr<juce::PropertiesFile> settings;
Expand All @@ -222,7 +226,9 @@ class Processor : public ProcessorBaseClass,

void updateParams();

#if ! JUCE_IOS && ! JUCE_ANDROID
FileSystemWatcher watcher;
#endif

juce::String currentProgramName;
int maxPrograms = 0;
Expand Down

0 comments on commit f965e8c

Please sign in to comment.