From 551e195f66db419be45f9b69571faa116b8629d2 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 08:26:46 -0500 Subject: [PATCH 1/9] Updated README.md to fix https://github.com/olab-io/ofSketch/issues/54 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 039c63b..3329f65 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,11 @@ For ofSketch to work properly, the "Projects" folder __must__ be located in the ### Running Examples -Double-click ofSketch to open the editor. From there you can create, load, save, and run ofSketch projects. The projects folder comes with a few example projects to get a feel for the editor. Click the open folder icon to select a project. Press the play button to run a project. +Double-click ofSketch to open the editor. + +_Note: If OSX does not allow you to open the program due to security restrictions, right click on the ofSketch.app bundle and click "open". See [this link](http://support.apple.com/kb/ht5290) for more information about Apple's security system._ + +From there you can create, load, save, and run ofSketch projects. The projects folder comes with a few example projects to get a feel for the editor. Click the open folder icon to select a project. Press the play button to run a project. ### Coding From 343e72acb292f510050892456a3aacf9fee0324a Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 08:34:09 -0500 Subject: [PATCH 2/9] Use all processors to build by default. --- ofSketchApp/src/MakeTask.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ofSketchApp/src/MakeTask.cpp b/ofSketchApp/src/MakeTask.cpp index 79a30cc..2672ecb 100644 --- a/ofSketchApp/src/MakeTask.cpp +++ b/ofSketchApp/src/MakeTask.cpp @@ -25,6 +25,7 @@ #include "MakeTask.h" #include "Poco/TaskNotification.h" +#include "Poco/Environment.h" namespace of { @@ -33,8 +34,8 @@ namespace Sketch { MakeTask::Settings::Settings(): ofRoot(ofToDataPath("openFrameworks")), - numProcessors(1), - isSilent(false), + numProcessors(Poco::Environment::processorCount()), + isSilent(true), useDistccServer(false), cxx(""), cc("") From 9618138dd66480dfb7b8457b13c1e56df8a7c32c Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 10:56:35 -0500 Subject: [PATCH 3/9] Now sending addons to client. --- ofSketchApp/src/Addon.cpp | 24 +++++++++ ofSketchApp/src/Addon.h | 15 +++--- ofSketchApp/src/AddonManager.cpp | 93 ++++++++++++++++++++++---------- ofSketchApp/src/AddonManager.h | 15 ++---- ofSketchApp/src/App.cpp | 29 +++++++++- 5 files changed, 130 insertions(+), 46 deletions(-) diff --git a/ofSketchApp/src/Addon.cpp b/ofSketchApp/src/Addon.cpp index b3ebf98..672179a 100644 --- a/ofSketchApp/src/Addon.cpp +++ b/ofSketchApp/src/Addon.cpp @@ -30,4 +30,28 @@ namespace of { namespace Sketch { +Addon::Addon(const std::string& name, const std::string& path): + _name(name), + _path(path) +{ +} + + +Addon::~Addon() +{ +} + + +const std::string& Addon::getName() const +{ + return _name; +} + + +const std::string& Addon::getPath() const +{ + return _path; +} + + } } // namespace of::Sketch diff --git a/ofSketchApp/src/Addon.h b/ofSketchApp/src/Addon.h index 5631495..9f1cdb8 100644 --- a/ofSketchApp/src/Addon.h +++ b/ofSketchApp/src/Addon.h @@ -38,13 +38,16 @@ class Addon public: typedef std::shared_ptr SharedPtr; - Addon() - { - } + Addon(const std::string& name, const std::string& path); - virtual ~Addon() - { - } + virtual ~Addon(); + + const std::string& getName() const; + const std::string& getPath() const; + +private: + std::string _name; + std::string _path; }; diff --git a/ofSketchApp/src/AddonManager.cpp b/ofSketchApp/src/AddonManager.cpp index c6e80a3..ab9bc9b 100644 --- a/ofSketchApp/src/AddonManager.cpp +++ b/ofSketchApp/src/AddonManager.cpp @@ -36,76 +36,115 @@ const std::string AddonManager::DEFAULT_ADDON_PATH = "addons/"; AddonManager::AddonManager(const std::string& path): _path(path) { - _addonWatcher.addPath(ofToDataPath(_path)); + Poco::Path fullPath(ofToDataPath(_path, true)); - std::vector files; + Poco::File file(fullPath); - ofx::IO::DirectoryFilter filter; + if(!file.exists()) + { + Poco::FileNotFoundException exc(fullPath.toString()); + throw exc; + } - ofx::IO::DirectoryUtils::list(ofToDataPath(_path), - files, - true, - &filter); + std::vector files; - std::vector::iterator iter = files.begin(); + ofx::IO::DirectoryUtils::list(file, files, true, &_directoryFilter); -// while(iter != files.end()) -// { -// cout << *iter << endl; -// ++iter; -// } - -} + std::vector::iterator iter = files.begin(); + while(iter != files.end()) + { + std::string addonPath = (*iter).path(); + std::string addonName = Poco::Path(addonPath).getBaseName(); -AddonManager::~AddonManager() -{ -} + _addons[addonName] = Addon::SharedPtr(new Addon(addonName, addonPath)); + ++iter; + } -void AddonManager::setup() -{ + _addonWatcher.registerAllEvents(this); + _addonWatcher.addPath(fullPath.toString(), + false, + true, + &_directoryFilter); } -void AddonManager::updateAddon(const Poco::URI& uri) +AddonManager::~AddonManager() { + _addonWatcher.unregisterAllEvents(this); } void AddonManager::onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt) { -// ofSendMessage("Added: " + evt.item.path()); + ofLogNotice("AddonManager::onDirectoryWatcherItemAdded") << evt.event << " " << evt.item.path(); + + std::string path = evt.item.path(); + std::string name = Poco::Path(path).getBaseName(); + + _addons[name] = Addon::SharedPtr(new Addon(name, path)); + } void AddonManager::onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt) { -// ofSendMessage("Removed: " + evt.item.path()); + ofLogNotice("AddonManager::onDirectoryWatcherItemRemoved") << evt.event << " " << evt.item.path(); + + std::string path = evt.item.path(); + std::string name = Poco::Path(path).getBaseName(); + + std::map::iterator iter = _addons.find(name); + + if (iter != _addons.end()) + { + _addons.erase(iter); + } + else + { + ofLogError("AddonManager::onDirectoryWatcherItemRemoved") << "Unable to find " << path; + } } void AddonManager::onDirectoryWatcherItemModified(const Poco::DirectoryWatcher::DirectoryEvent& evt) { -// ofSendMessage("Modified: " + evt.item.path()); + ofLogNotice("AddonManager::onDirectoryWatcherItemModified") << evt.event << " " << evt.item.path(); } void AddonManager::onDirectoryWatcherItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& evt) { -// ofLogNotice("ofApp::onDirectoryWatcherItemMovedFrom") << "Moved From: " << evt.item.path(); + ofLogNotice("AddonManager::onDirectoryWatcherItemMovedFrom") << evt.event << " " << evt.item.path(); } void AddonManager::onDirectoryWatcherItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& evt) { -// ofLogNotice("ofApp::onDirectoryWatcherItemMovedTo") << "Moved To: " << evt.item.path(); + ofLogNotice("AddonManager::onDirectoryWatcherItemMovedTo") << evt.event << " " << evt.item.path(); } void AddonManager::onDirectoryWatcherError(const Poco::Exception& exc) { -// ofLogError("ofApp::onDirectoryWatcherError") << "Error: " << exc.displayText(); + ofLogError("AddonManager::onDirectoryWatcherError") << exc.displayText(); +} + + +std::vector AddonManager::getAddons() const +{ + std::vector addons; + + std::map::const_iterator iter = _addons.begin(); + + if (iter != _addons.end()) + { + addons.push_back(iter->second); + ++iter; + } + + return addons; } diff --git a/ofSketchApp/src/AddonManager.h b/ofSketchApp/src/AddonManager.h index 551bc5f..98e6b24 100644 --- a/ofSketchApp/src/AddonManager.h +++ b/ofSketchApp/src/AddonManager.h @@ -44,15 +44,9 @@ namespace Sketch { class AddonManager { public: - typedef std::shared_ptr SharedPtr; - AddonManager(const std::string& addonsPath); virtual ~AddonManager(); - void setup(); - - void updateAddon(const Poco::URI& uri); - void onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt); void onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt); void onDirectoryWatcherItemModified(const Poco::DirectoryWatcher::DirectoryEvent& evt); @@ -60,18 +54,17 @@ class AddonManager void onDirectoryWatcherItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& evt); void onDirectoryWatcherError(const Poco::Exception& exc); - static SharedPtr makeShared(const std::string& addonsPath) - { - return SharedPtr(new AddonManager(addonsPath)); - } + std::vector getAddons() const; static const std::string DEFAULT_ADDON_PATH; private: std::string _path; - std::set _addons; + std::map _addons; ofx::IO::DirectoryWatcherManager _addonWatcher; + ofx::IO::DirectoryFilter _directoryFilter; + }; diff --git a/ofSketchApp/src/App.cpp b/ofSketchApp/src/App.cpp index d8f7560..e7a76bc 100644 --- a/ofSketchApp/src/App.cpp +++ b/ofSketchApp/src/App.cpp @@ -372,8 +372,8 @@ bool App::onWebSocketOpenEvent(HTTP::WebSocketOpenEventArgs& args) // Send the update to the client that just connected. args.getConnectionRef().sendFrame(frame); - // Send version info. + params.clear(); params["version"] = getVersion(); params["major"] = getVersionMajor(); params["minor"] = getVersionMinor(); @@ -385,7 +385,32 @@ bool App::onWebSocketOpenEvent(HTTP::WebSocketOpenEventArgs& args) frame = ofx::HTTP::WebSocketFrame(App::toJSONString(json)); args.getConnectionRef().sendFrame(frame); - + + params.clear(); + + Json::Value addonsJSON; + + std::vector addons = _addonManager.getAddons(); + + std::vector::const_iterator iter = addons.begin(); + + while (iter != addons.end()) + { + Json::Value addon; + addon["name"] = (*iter)->getName(); + addon["path"] = (*iter)->getPath(); + addonsJSON.append(addon); + ++iter; + } + + params["addons"] = addonsJSON; + + json = App::toJSONMethod("Server", "addons", params); + frame = ofx::HTTP::WebSocketFrame(App::toJSONString(json)); + + args.getConnectionRef().sendFrame(frame); + + // Send editor ettings // params.clear(); // From f84bd7de5d6e28ce9b916f812cd7cfad6b8f703c Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:03:24 -0500 Subject: [PATCH 4/9] Oops. --- ofSketchApp/src/AddonManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofSketchApp/src/AddonManager.cpp b/ofSketchApp/src/AddonManager.cpp index ab9bc9b..84d78f4 100644 --- a/ofSketchApp/src/AddonManager.cpp +++ b/ofSketchApp/src/AddonManager.cpp @@ -138,7 +138,7 @@ std::vector AddonManager::getAddons() const std::map::const_iterator iter = _addons.begin(); - if (iter != _addons.end()) + while (iter != _addons.end()) { addons.push_back(iter->second); ++iter; From 737b1b9bd9181434d7c0630ca96ff40c3dd31f99 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:03:42 -0500 Subject: [PATCH 5/9] Print results in client. --- ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js b/ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js index ee59966..2e3e479 100644 --- a/ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js +++ b/ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js @@ -108,6 +108,10 @@ $(document).ready( function() checkVersion(); } + else if (evt.method == "addons") + { + console.log(evt.params); + } else if (evt.method == "updateEditorSettings") { From c20ccf13ff657df2444ae97049f3eae746f2ce72 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:05:52 -0500 Subject: [PATCH 6/9] Version bump 0.1.5. --- CHANGELOG.md | 4 ++++ ofSketchApp/src/App.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad1b26..db1ca50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +- 0.1.5 (06-16-2014) + + Server now sends available addons to client. + + Rewrote build scripts. Now works on all osx / linux. + - 0.1.4 (06-13-2014) + Added linux64 build. + Updated build script for linux64. diff --git a/ofSketchApp/src/App.h b/ofSketchApp/src/App.h index f36ea13..b5c4562 100644 --- a/ofSketchApp/src/App.h +++ b/ofSketchApp/src/App.h @@ -125,7 +125,7 @@ class App: public ofBaseApp { VERSION_MAJOR = 0, VERSION_MINOR = 1, - VERSION_PATCH = 4 + VERSION_PATCH = 5 }; static const std::string VERSION_PRE_RELEASE; From cd352cdd79f9955b0f0ead4bd42f5c87c6136a52 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:08:27 -0500 Subject: [PATCH 7/9] Additional changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db1ca50..1772d36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ - 0.1.5 (06-16-2014) + Server now sends available addons to client. + + Updated default number of processors to match target machine cores on a make build. + Rewrote build scripts. Now works on all osx / linux. - 0.1.4 (06-13-2014) From b3424bf71d4a939b53265c22f4d4196130221af1 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:14:10 -0500 Subject: [PATCH 8/9] Clean up build script. --- scripts/build_release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build_release.sh b/scripts/build_release.sh index 03602e3..981b983 100755 --- a/scripts/build_release.sh +++ b/scripts/build_release.sh @@ -82,13 +82,15 @@ cd data/Projects echo `pwd` +# remove any built project apps rm -rf $(find . -name *.app) -rm -rf $(find . -name obj) +rm -rf $(find . -name *App) cd ../.. echo `pwd` +rm -rf $(find . -name obj) rm -rf $(find . -name .git*) rm -rf $(find . -name .DS_Store) From 3e321a794665cf06c6bf322c32ef59fbe79ec764 Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Mon, 16 Jun 2014 11:16:04 -0500 Subject: [PATCH 9/9] Build script cleanup. --- scripts/build_release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build_release.sh b/scripts/build_release.sh index 981b983..15ce9a5 100755 --- a/scripts/build_release.sh +++ b/scripts/build_release.sh @@ -85,6 +85,7 @@ echo `pwd` # remove any built project apps rm -rf $(find . -name *.app) rm -rf $(find . -name *App) +rm -rf $(find . -name libs) cd ../..