-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnimedscript.nimble
More file actions
33 lines (26 loc) · 1.16 KB
/
nimedscript.nimble
File metadata and controls
33 lines (26 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Package
version = "0.1.0"
author = "hlaaftana"
description = "FL Studio EdisonScript JS wrapper "
license = "MIT"
srcDir = "src"
skipDirs = @["tests"]
# Dependencies
requires "nim >= 0.18.0"
task docs, "Build documentation":
exec "nim doc -o:docs/nimedscript.html src/nimedscript.nim"
import ospaths, strformat, strutils
proc transform(text: string): string =
# i would have done all of this better with regex or pegs or whatever but this'll have to do unless we hit a barrier
result = text
result = result.replace("if (typeof ", "//") # edscript doesn't like typeof undefined checking
result = result.replace("base:", "\"base\":") # it also doesn't like "base" as an identifier
result = result.replace("break ", "break; ") # it also doesn't like labeled break/continue
task buildTests, "Compiles tests to javascript":
for test in listFiles("tests"):
let split = splitFile(test)
if split.ext == ".nim":
let path = "bin/" & split.name & ".edscript"
exec "nim js --gc:none -d:release -o:" & path & " " & test
writeFile(path, &"""script "{split.name}" language "javascript";
{transform(readFile(path))}""")