-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 95bbc39
Showing
7 changed files
with
1,245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
cmake_minimum_required(VERSION 3.0) | ||
|
||
# boost handler (https://tinyurl.com/olotkwr, https://tinyurl.com/gmxfspp, assumes $BOOST_ROOT) | ||
set(BOOST_ROOT "/Users/dirkleas/Downloads/boost_1_63_0") | ||
set(Boost_USE_STATIC_LIBS ON) | ||
set(Boost_USE_MULTITHREADED ON) | ||
set(Boost_USE_STATIC_RUNTIME ON) | ||
set(Boost_LIBRARIES "/Users/dirkleas/Downloads/boost_1_63_0/stage/lib") | ||
find_package(Boost 1.63.0 COMPONENTS filesystem) | ||
if(Boost_FOUND) | ||
#include_directories(${Boost_INCLUDE_DIRS}) | ||
#add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp) | ||
#target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) | ||
|
||
# from max-devkit boilerplate | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-api/script/max-pretarget.cmake) | ||
include_directories("${C74_INCLUDES}" "${Boost_INCLUDE_DIRS}") | ||
add_library(${PROJECT_NAME} MODULE ${PROJECT_NAME}.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-api/script/max-posttarget.cmake) | ||
endif() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# msdpfs | ||
|
||
Max/MSP external for [Music_SDP](http://musicsdp.com/) w/ basic file services | ||
(e.g. exists, cp, mkdir, and rm). The Quickstart section provides detailed | ||
walkthroughs for both MacOS and Windows for compiling and linking this repo with the | ||
[Cycling74 max-devkit](https://github.com/Cycling74/max-devkit) for C++ (this is | ||
replacement legacy [Max SDK](https://github.com/Cycling74/max-api) for C), | ||
[Boost](http://www.boost.org/) C++ libraries, and this repo's Max/MSP external | ||
**msdpfs** code for your specific platform. Recent binaries are available in | ||
the **externals** folder for your convenience. | ||
|
||
Low level file I/O is provided by **Boost** via it's **filesystem** library. | ||
**Quickstart** only builds dependent **Boost** libaries to minimize build time. | ||
|
||
|
||
## Quickstart: | ||
|
||
Complete the following steps for your preferred platform. | ||
|
||
|
||
## MacOS: | ||
|
||
Build **Boost** static libraries as **MacOS** universal binary format. This isn't | ||
documented by either **Cycling74** or the **Boost** guides. Changes from their | ||
provided documentation incudes 1) BASH scripting for compiling universal binaries, | ||
and 2) an enhanced [CMake](https://cmake.org/download/) script integrating the two | ||
SDKs. | ||
|
||
* download and install [CMake](https://cmake.org/download/) binaries for your MacOS | ||
* download **BOOST** and untar | ||
* change directory to resulting directory | ||
* invoke the [following](https://tinyurl.com/mzhsghp) (thanks bruth) to generate | ||
the universal binaries for static linking with resulting binaries under | ||
**stage/lib** | ||
|
||
rm -rf i386 x86_64 universal && ./bootstrap.sh --with-toolset=clang --with-libraries=filesystem && ./b2 toolset=darwin -j8 address-model=32 architecture=x86 -a && mkdir -p i386 && cp stage/lib/*.dylib i386 && ./b2 toolset=clang -j8 cxxflags="-arch i386 -arch x86_64" -a && mkdir x86_64 && cp stage/lib/*.dylib x86_64 && mkdir universal && for dylib in i386/*; do lipo -create -arch i386 $dylib -arch x86_64 x86_64/$(basename $dylib) -output universal/$(basename $dylib); done | ||
|
||
* download [Cycling74 max-devkit](https://github.com/Cycling74/max-devkit) and untar | ||
* change directory to resulting directory | ||
* create build directory: **mkdir build; cd build** | ||
* add this repo to the demos projects directory: **cd ../source/projects; clone https://github.com/dirkleas/msdpfs.git** | ||
* return to the build direoctory and build the external binary: **cd ../../build; cmake ..; cmake --build .** | ||
* add **max-devkit** folder to your Max/MSP path via Options, File Preferences... menu | ||
* test the external with the included **msdpfs** help patcher **msdpfs.maxhelp** | ||
|
||
|
||
## Windows: | ||
|
||
Build **Boost** static libraries as 64-bit **Windows** binary format. | ||
[CMake](https://cmake.org/download/) is used for compiling/linking the external. | ||
|
||
* download and install [CMake](https://cmake.org/download/) binaries for your MacOS | ||
* download **BOOST** and untar | ||
* change directory to resulting directory | ||
* **BOOST** complile/link details are TBD <== *** WARNING *** | ||
* download [Cycling74 max-devkit](https://github.com/Cycling74/max-devkit) and untar | ||
* change directory to resulting directory | ||
* create build directory: **mkdir build; cd build** | ||
* add this repo to the demos projects directory: **cd ../source/projects; clone https://github.com/dirkleas/msdpfs.git** | ||
* return to the build direoctory and build the external binary: **cd ../../build; cmake ..; cmake --build .** | ||
* add **max-devkit** folder to your Max/MSP path via Options, File Preferences... menu | ||
* test the external with the included **msdpfs** help patcher **msdpfs.maxhelp** | ||
|
||
|
||
## ToDo: | ||
|
||
Unprioritized toDo items: | ||
|
||
* complete Windows walkthrough (e.g. compile/link details) | ||
* remove hard-coded references in CMake make spec | ||
* add additional type checking, clarify special cases, and adjust statusing to | ||
external .cpp code for reliability | ||
* security/vulnerability/reliability peer review | ||
* verify file I/O behaviors | ||
* implement cross-platform CI | ||
* enhance Max/MSP help file and consider reference, refactor other UX aspects | ||
based on feedback | ||
* automate builds for both platforms | ||
|
||
-- | ||
|
||
Feel free to submit pull requests, or submit feedback/suggestions | ||
[here](http://musicsdp.com/contact-the-team/). Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>msdpfs</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.cycling74.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
|
||
<key>CFBundlePackageType</key> | ||
<string>iLaX</string> | ||
<key>CFBundleSignature</key> | ||
<string>max2</string> | ||
|
||
<key>CFBundleVersion</key> | ||
<string>0.2.1</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>0.2.1</string> | ||
<key>CFBundleLongVersionString</key> | ||
<string>msdpfs 0.2.1 - Copyright (c) 2016 Cycling '74</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright (c) 2016 Cycling '74</string> | ||
|
||
<key>CSResourcesFileMapped</key> | ||
<true/> | ||
<key>LSRequiresCarbon</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/** | ||
msdpfs.cpp, by Dirk Leas | ||
Copyright (C) 2017 Dirk Leas | ||
This programme is free software; you may redistribute and/or modify | ||
it under the terms of the GNU General Public Licence as published by | ||
the Free Software Foundation, either version 3 of said Licence, or | ||
(at your option) any later version. | ||
-- | ||
msdpfs - filesystem exists, rm, mkdir, cp (w/ boost c++) | ||
max-devkit api: quasi (https://tinyurl.com/khygtdf) | ||
macos (boost universal https://tinyurl.com/mzhsghp): | ||
cmake .. | ||
cmake --build . | ||
windows: | ||
TBD | ||
*/ | ||
|
||
#include "c74_max.h" | ||
#include <boost/filesystem.hpp> | ||
using namespace c74::max; | ||
using namespace boost::filesystem; | ||
|
||
struct t_msdpfs { | ||
t_object ob; | ||
void *status; | ||
}; | ||
|
||
static t_class* this_class = nullptr; | ||
|
||
void* msdpfs_new(t_symbol* name, long argc, t_atom* argv) { | ||
t_msdpfs* self = (t_msdpfs*) object_alloc(this_class); | ||
self->status = outlet_new(self, "cmd status, 1=success, 0=failure"); | ||
return self; | ||
} | ||
|
||
void msdpfs_free(t_msdpfs* self) {} | ||
|
||
void msdpfs_docp(t_msdpfs* self, t_symbol* s, long argc, t_atom* argv) { | ||
if (argc != 2) { | ||
object_error((t_object*)self, "source and destination required, but missing%s", ""); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
try { | ||
copy(atom_getsym(&argv[0])->s_name, atom_getsym(&argv[1])->s_name); | ||
outlet_int(self->status, 1); | ||
return; | ||
} catch (const std::exception& e) { | ||
object_error((t_object*)self, "can't copy from %s to %s", | ||
atom_getsym(&argv[0])->s_name, atom_getsym(&argv[1])->s_name); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
} | ||
|
||
void msdpfs_doexists(t_msdpfs* self, t_symbol* s, long argc, t_atom* argv) { | ||
if (exists(s->s_name)) outlet_int(self->status, 1); | ||
else { | ||
object_error((t_object*)self, "no such file or directory %s", s->s_name); | ||
outlet_int(self->status, 0); | ||
} | ||
} | ||
|
||
void msdpfs_domkdir(t_msdpfs* self, t_symbol* s, long argc, t_atom* argv) { | ||
if (exists(s->s_name)) { | ||
object_error((t_object*)self, "directory %s already exists", s->s_name); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
try { | ||
create_directory(s->s_name); | ||
outlet_int(self->status, 1); | ||
return; | ||
} | ||
catch (const std::exception& e) { | ||
object_error((t_object*)self, "can't make directory %s", s->s_name); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
} | ||
|
||
void msdpfs_dorm(t_msdpfs* self, t_symbol* s, long argc, t_atom* argv) { | ||
if (! exists(s->s_name)) { | ||
object_error((t_object*)self, "no such directory %s", s->s_name); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
try { | ||
remove(s->s_name); | ||
outlet_int(self->status, 1); | ||
return; | ||
} | ||
catch (const std::exception& e) { | ||
object_error((t_object*)self, "can't remove directory %s", s->s_name); | ||
outlet_int(self->status, 0); | ||
return; | ||
} | ||
} | ||
|
||
void msdpfs_cp(t_object* self, t_symbol* s, long argc, t_atom* argv) { | ||
defer(self, (method)msdpfs_docp, s, argc, argv); | ||
} | ||
void msdpfs_exists(t_object* self, t_symbol* s) { defer(self, (method)msdpfs_doexists, s, 0, NULL); } | ||
void msdpfs_mkdir(t_object* self, t_symbol* s) { defer(self, (method)msdpfs_domkdir, s, 0, NULL); } | ||
void msdpfs_rm(t_object* self, t_symbol* s) { defer(self, (method)msdpfs_dorm, s, 0, NULL); } | ||
|
||
void msdpfs_assist(t_msdpfs* self, void* unused, t_assist_function io, long index, char* string_dest) { | ||
if (io == ASSIST_INLET) { | ||
switch (index) { | ||
case 0: | ||
strncpy(string_dest,"[ cp | exists | mkdir | rm ] FILE | DIR [ FILE ]", ASSIST_STRING_MAXSIZE); | ||
break; | ||
} | ||
} | ||
else if (io == ASSIST_OUTLET) { | ||
switch (index) { | ||
case 0: | ||
strncpy(string_dest,"status, 1=success, 0=fail", ASSIST_STRING_MAXSIZE); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void ext_main(void* r) { | ||
this_class = class_new("msdpfs", (method)msdpfs_new, (method)msdpfs_free, sizeof(t_msdpfs), 0L, A_GIMME, 0); | ||
class_addmethod(this_class, (method)msdpfs_cp, "cp", A_GIMME, 0); | ||
class_addmethod(this_class, (method)msdpfs_exists, "exists", A_DEFSYM, 0); | ||
class_addmethod(this_class, (method)msdpfs_mkdir, "mkdir", A_DEFSYM, 0); | ||
class_addmethod(this_class, (method)msdpfs_rm, "rm", A_DEFSYM, 0); | ||
class_register(CLASS_BOX, this_class); | ||
} |
Oops, something went wrong.