-
Notifications
You must be signed in to change notification settings - Fork 0
/
nakefile.nim
53 lines (47 loc) · 1.5 KB
/
nakefile.nim
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 2017 Xored Software, Inc.
import nake
import os, ospaths, times
import godotapigen
proc genGodotApi() =
let godotBin = getEnv("GODOT_BIN")
if godotBin.len == 0:
echo "GODOT_BIN environment variable is not set"
quit(-1)
if not fileExists(godotBin):
echo "Invalid GODOT_BIN path: " & godotBin
quit(-1)
const targetDir = "src"/"godotapi"
createDir(targetDir)
const jsonFile = targetDir/"api.json"
if not fileExists(jsonFile) or
godotBin.getLastModificationTime() > jsonFile.getLastModificationTime():
direShell(godotBin, "--gdnative-generate-json-api", getCurrentDir()/jsonFile)
if not fileExists(jsonFile):
echo "Failed to generate api.json"
quit(-1)
genApi(targetDir, jsonFile)
task "build", "Builds the client for the current platform":
genGodotApi()
let bitsPostfix = when sizeof(int) == 8: "_64" else: "_32"
let libFile =
when defined(windows):
"nim" & bitsPostfix & ".dll"
elif defined(ios):
"nim_ios" & bitsPostfix & ".dylib"
elif defined(macosx):
"nim_mac.dylib"
elif defined(android):
"libnim_android.so"
elif defined(linux):
"nim_linux" & bitsPostfix & ".so"
else: nil
createDir("_dlls")
withDir "src":
direShell(["nimble", "c", ".."/"src"/"stub.nim", "-o:.."/"_dlls"/libFile])
task "clean", "Remove files produced by build":
removeDir(".nimcache")
removeDir("src"/".nimcache")
removeDir("src"/"godotapi")
removeDir("_dlls")
removeFile("nakefile")
removeFile("nakefile.exe")