Compare commits
5 Commits
de6512b420
...
f76ec9a1ef
Author | SHA1 | Date |
---|---|---|
Christopher Arndt | f76ec9a1ef | |
Christopher Arndt | 308da25bbc | |
Christopher Arndt | 5aebe31715 | |
Christopher Arndt | 30047ff0ca | |
Christopher Arndt | 6c57a8b249 |
|
@ -32,8 +32,11 @@ Install the `amp.lv2` example plugin:
|
||||||
them as you like (also rename `amp.lv2/amp.ttl`). I'll use `myplugin` as the
|
them as you like (also rename `amp.lv2/amp.ttl`). I'll use `myplugin` as the
|
||||||
base name in the examples below.
|
base name in the examples below.
|
||||||
|
|
||||||
* Edit `myplugin.lv2/manifest.ttl` and change the plugin URI and change the
|
* Edit `myplugin.lv2/manifest.ttl`:
|
||||||
plugin's shared library name defined with `lv2:binary` to `libmyplugin.so`.
|
* Change the plugin URI.
|
||||||
|
* Change the plugin's shared library name defined via `lv2:binary` to
|
||||||
|
`libmyplugin.so`.
|
||||||
|
* Change file name referenced via `rdfs:seeAlso` to `myplugin.ttl`.
|
||||||
|
|
||||||
* Edit `myplugin.lv2/myplugin.ttl`:
|
* Edit `myplugin.lv2/myplugin.ttl`:
|
||||||
* Change the plugin URI.
|
* Change the plugin URI.
|
||||||
|
|
121
nymph.nimble
121
nymph.nimble
|
@ -1,3 +1,4 @@
|
||||||
|
import std/os except commandLineParams
|
||||||
import std/strformat
|
import std/strformat
|
||||||
|
|
||||||
# Package definition
|
# Package definition
|
||||||
|
@ -14,6 +15,14 @@ requires "nim >= 2.0"
|
||||||
|
|
||||||
# Custom tasks
|
# Custom tasks
|
||||||
|
|
||||||
|
type Example = tuple
|
||||||
|
name: string
|
||||||
|
uri: string
|
||||||
|
source: string
|
||||||
|
bundle: string
|
||||||
|
dll: string
|
||||||
|
|
||||||
|
|
||||||
const examples = to_table({
|
const examples = to_table({
|
||||||
"amp": "urn:nymph:examples:amp"
|
"amp": "urn:nymph:examples:amp"
|
||||||
})
|
})
|
||||||
|
@ -28,100 +37,78 @@ proc parseArgs(): tuple[options: seq[string], args: seq[string]] =
|
||||||
result.args.add(arg)
|
result.args.add(arg)
|
||||||
|
|
||||||
|
|
||||||
proc showArgs() =
|
proc getExample(task_name: string): Example =
|
||||||
## Show task environment (for debugging when writing nimble tasks)
|
let (_, args) = parseArgs()
|
||||||
echo "Command: ", getCommand()
|
|
||||||
echo "ProjectName: ", projectName()
|
|
||||||
echo "ProjectDir: ", projectDir()
|
|
||||||
echo "ProjectPath: ", projectPath()
|
|
||||||
echo "Task args: ", commandLineParams
|
|
||||||
|
|
||||||
for i in 0..paramCount():
|
if args.len == 0:
|
||||||
echo &"Arg {i}: ", paramStr(i)
|
quit(&"Usage: nimble {task_name} <example name>")
|
||||||
|
|
||||||
|
result.name = changeFileExt(args[^1], "")
|
||||||
|
|
||||||
|
let examplesDir = thisDir() / "examples"
|
||||||
|
result.source = examplesDir / changeFileExt(result.name, "nim")
|
||||||
|
|
||||||
|
if not fileExists(result.source):
|
||||||
|
quit(&"Example '{result.name}' not found.")
|
||||||
|
|
||||||
|
result.uri = examples.getOrDefault(result.name)
|
||||||
|
|
||||||
|
if result.uri == "":
|
||||||
|
quit(&"Plugin URI for example '{result.name}' not set.")
|
||||||
|
|
||||||
|
result.bundle = examplesDir / changeFileExt(result.name, "lv2")
|
||||||
|
result.dll = result.bundle / toDll(result.name)
|
||||||
|
|
||||||
|
|
||||||
task build_ex, "Build given example plugin":
|
task build_ex, "Build given example plugin":
|
||||||
#showArgs()
|
let ex = getExample("build_ex")
|
||||||
let (_, args) = parseArgs()
|
|
||||||
|
|
||||||
if args.len == 0:
|
switch("app", "lib")
|
||||||
echo "Usage: nimble build_ex <example name>"
|
switch("noMain", "on")
|
||||||
return
|
switch("mm", "arc")
|
||||||
|
switch("out", ex.dll)
|
||||||
|
|
||||||
let example = args[^1]
|
when not defined(release) and not defined(debug):
|
||||||
let source = thisDir() & "/examples/" & example & ".nim"
|
echo &"Compiling plugin {ex.name} in release mode."
|
||||||
let bundle = thisDir() & "/examples/" & example & ".lv2"
|
|
||||||
let dll = bundle & "/" & toDll(example)
|
|
||||||
|
|
||||||
if fileExists(source):
|
|
||||||
switch("app", "lib")
|
|
||||||
switch("noMain", "on")
|
|
||||||
switch("mm", "arc")
|
|
||||||
switch("opt", "speed")
|
|
||||||
switch("define", "release")
|
switch("define", "release")
|
||||||
switch("out", dll)
|
switch("opt", "speed")
|
||||||
setCommand("compile", source)
|
switch("define", "lto")
|
||||||
else:
|
switch("define", "strip")
|
||||||
echo &"Example '{example}' not found."
|
|
||||||
|
setCommand("compile", ex.source)
|
||||||
|
|
||||||
|
|
||||||
task lv2lint, "Run lv2lint check on given example plugin":
|
task lv2lint, "Run lv2lint check on given example plugin":
|
||||||
let (_, args) = parseArgs()
|
let ex = getExample("lv2lint")
|
||||||
|
|
||||||
if args.len == 0:
|
if fileExists(ex.dll):
|
||||||
echo "Usage: nimble lv2lint <example name>"
|
exec(&"lv2lint -s NimMain -I \"{ex.bundle}\" \"{ex.uri}\"")
|
||||||
return
|
|
||||||
|
|
||||||
let example = args[^1]
|
|
||||||
let uri = examples.getOrDefault(example)
|
|
||||||
|
|
||||||
if uri == "":
|
|
||||||
echo &"Plugin URI for example '{example}' not set."
|
|
||||||
return
|
|
||||||
|
|
||||||
let examplesDir = thisDir() & "/examples"
|
|
||||||
let bundle = examplesDir & "/" & example & ".lv2"
|
|
||||||
let dll = bundle & "/" & toDll(example)
|
|
||||||
|
|
||||||
if fileExists(dll):
|
|
||||||
exec(&"lv2lint -s NimMain -I {bundle} \"{uri}\"")
|
|
||||||
else:
|
else:
|
||||||
echo &"Example '{example}' shared library not found. Use task 'build_ex' to build it."
|
echo &"Example '{ex.name}' shared library not found. Use task 'build_ex' to build it."
|
||||||
|
|
||||||
|
|
||||||
task lv2bm, "Run lv2bm benchmark on given example plugin":
|
task lv2bm, "Run lv2bm benchmark on given example plugin":
|
||||||
let (_, args) = parseArgs()
|
let ex = getExample("lv2bm")
|
||||||
|
|
||||||
if args.len == 0:
|
if ex.uri == "":
|
||||||
echo "Usage: nimble lv2bm <example name>"
|
echo &"Plugin URI for example '{ex.name}' not set."
|
||||||
return
|
return
|
||||||
|
|
||||||
let example = args[^1]
|
if fileExists(ex.dll):
|
||||||
let uri = examples.getOrDefault(example)
|
|
||||||
|
|
||||||
if uri == "":
|
|
||||||
echo &"Plugin URI for example '{example}' not set."
|
|
||||||
return
|
|
||||||
|
|
||||||
let examplesDir = thisDir() & "/examples"
|
|
||||||
let bundle = examplesDir & "/" & example & ".lv2"
|
|
||||||
let dll = bundle & "/" & toDll(example)
|
|
||||||
|
|
||||||
if fileExists(dll):
|
|
||||||
let lv2_path = getEnv("LV2_PATH")
|
let lv2_path = getEnv("LV2_PATH")
|
||||||
let tempLv2Dir = thisDir() & "/.lv2"
|
let tempLv2Dir = thisDir() / ".lv2"
|
||||||
let bundleLink = tempLv2Dir & "/" & example & ".lv2"
|
let bundleLink = tempLv2Dir / changeFileExt(ex.name, "lv2")
|
||||||
|
|
||||||
mkDir(tempLv2Dir)
|
mkDir(tempLv2Dir)
|
||||||
rmFile(bundleLink)
|
rmFile(bundleLink)
|
||||||
exec(&"ln -s \"{bundle}\" \"{bundleLink}\"")
|
exec(&"ln -s \"{ex.bundle}\" \"{bundleLink}\"")
|
||||||
|
|
||||||
if lv2_path == "":
|
if lv2_path == "":
|
||||||
putEnv("LV2_PATH", tempLv2Dir)
|
putEnv("LV2_PATH", tempLv2Dir)
|
||||||
else:
|
else:
|
||||||
putEnv("LV2_PATH", tempLv2Dir & ":" & lv2_path)
|
putEnv("LV2_PATH", tempLv2Dir & ":" & lv2_path)
|
||||||
|
|
||||||
exec(&"lv2bm --full-test -i white \"{uri}\"")
|
exec(&"lv2bm --full-test -i white \"{ex.uri}\"")
|
||||||
else:
|
else:
|
||||||
echo &"Example '{example}' shared library not found. Use task 'build_ex' to build it."
|
echo &"Example '{ex.name}' shared library not found. Use task 'build_ex' to build it."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue