Skip to content

Commit

Permalink
platformUtils: cp/rm DLLs (win) and deQuarantine (macos)
Browse files Browse the repository at this point in the history
  • Loading branch information
elgiano committed May 22, 2024
1 parent 00329a1 commit a773f0f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(NNUGens_sc_files
plugins/NNModel/sc/NN_nrt.sc
plugins/NNModel/sc/NNModel.sc
plugins/NNModel/sc/NNUGens.sc
plugins/NNModel/sc/platformUtils.sc
)
set(NNUGens_schelp_files
plugins/NNModel/schelp/NNModel.schelp
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Failing to do so can produce errors like:
2. Find the folder where you have `scsynth.exe`, it's usually something like: `C:\Program Files\SuperCollider3.x.x\` (where 3.x.x is the version you have installed).
3. Paste all the .dll files you got in step 1 to the folder where `scsynth.exe` is.

Alternatively, you can use `NN.copyDLLs`, but you might have to run SuperCollider as Administrator:
```
s.quit; // server needs to be off for this to work
NN.copyDLLs
```

## Usage

### Pre-trained models
Expand Down
47 changes: 47 additions & 0 deletions plugins/NNModel/sc/platformUtils.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
+NN {
*copyDLLs {
Platform.case { \windows } {
(NN.filenameSymbol.asString.dirname +/+ "../ignore/*.dll").pathMatch.do { |dll|
try {
File.copy(dll, Platform.resourceDir);
"*** % copied".format(dll.basename).postln;
} { |err|
err.errorString.postln;
}
}
} {
warn("You don't need to copy DLLs unless you're on Windows");
};
}

*deleteDLLs {
Platform.case { \windows } {

(NN.filenameSymbol.asString.dirname +/+ "../ignore/*.dll").pathMatch.do { |dll|
var file = Platform.resourceDir +/+ dll.basename;
try {
if(File.delete(file)) {
"*** % deleted".format(file).postln;
} {

"couldn't delete %".format(file).warn;
}
} { |err|
err.errorString.postln;
}
}
} {
warn("You don't need to delete DLLs unless you're on Windows");
}
}

*deQuarantine {
Platform.case { \osx } {
var path = PathName(NN.filenameSymbol.asString.dirname).parentPath;
runInTerminal("xattr -d -r com.apple.quarantine" + shellQuote(path))
} {
warn("You don't need to delete DLLs unless you're on macOS");
}
}
}

17 changes: 17 additions & 0 deletions plugins/NNModel/schelp/NN.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ code::nil:: which disables writing to a file (useful for NRT servers since they
can't write to files) and prints to console instead.


section::Windows utility methods
These method are useful for Windows installations only.

method::copyDLLs
Copies all .dll files from NN's teletype::ignore:: folder to
link::Classes/Platform#*resourceDir::

method::deleteDLLs
Removes all .dll files listed in NN's teletype::ignore:: folder from
link::Classes/Platform#*resourceDir::

section::macOS utility methods

method::deQuarantine
Opens a terminal and runs teletype::xattr -d -r com.apple.quarantine:: for NN Extension path


examples::

code::
Expand Down

0 comments on commit a773f0f

Please sign in to comment.