diff options
Diffstat (limited to 'tests/manyloc/nake')
-rw-r--r-- | tests/manyloc/nake/nake.nim | 19 | ||||
-rw-r--r-- | tests/manyloc/nake/nakefile.nim | 32 |
2 files changed, 27 insertions, 24 deletions
diff --git a/tests/manyloc/nake/nake.nim b/tests/manyloc/nake/nake.nim index 1e88fa73b..5d3173a20 100644 --- a/tests/manyloc/nake/nake.nim +++ b/tests/manyloc/nake/nake.nim @@ -22,10 +22,10 @@ proc runTask*(name: string) {.inline.} proc shell*(cmd: varargs[string, `$`]): int {.discardable.} proc cd*(dir: string) {.inline.} -template nakeImports*(): stmt {.immediate.} = +template nakeImports*() = import tables, parseopt, strutils, os -template task*(name: string; description: string; body: stmt): stmt {.dirty, immediate.} = +template task*(name: string; description: string; body: untyped) {.dirty.} = block: var t = newTask(description, proc() {.closure.} = body) @@ -40,7 +40,7 @@ proc runTask*(name: string) = tasks[name].action() proc shell*(cmd: varargs[string, `$`]): int = result = execShellCmd(cmd.join(" ")) proc cd*(dir: string) = setCurrentDir(dir) -template withDir*(dir: string; body: stmt): stmt = +template withDir*(dir: string; body: untyped) = ## temporary cd ## withDir "foo": ## # inside foo @@ -50,8 +50,8 @@ template withDir*(dir: string; body: stmt): stmt = body cd(curDir) -when isMainModule: - if not existsFile("nakefile.nim"): +when true: + if not fileExists("nakefile.nim"): echo "No nakefile.nim found. Current working dir is ", getCurrentDir() quit 1 var args = "" @@ -60,14 +60,15 @@ when isMainModule: args.add " " quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: - addQuitProc(proc() {.noconv.} = + import std/exitprocs + addExitProc(proc() {.noconv.} = var task: string printTaskList: bool - for kind, key, val in getOpt(): + for kind, key, val in getopt(): case kind of cmdLongOption, cmdShortOption: - case key.tolower + case key.tolowerAscii of "tasks", "t": printTaskList = true else: @@ -75,7 +76,7 @@ else: of cmdArgument: task = key else: discard - if printTaskList or task.isNil or not(tasks.hasKey(task)): + if printTaskList or task.len == 0 or not(tasks.hasKey(task)): echo "Available tasks:" for name, task in pairs(tasks): echo name, " - ", task.desc diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim index 2055d7834..fc479a5c2 100644 --- a/tests/manyloc/nake/nakefile.nim +++ b/tests/manyloc/nake/nakefile.nim @@ -10,7 +10,7 @@ const ExeName = "keineschweine" ServerDefines = "-d:NoSFML -d:NoChipmunk" TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild" - ReleaseDefines = "-d:release --deadCodeElim:on" + ReleaseDefines = "-d:release" ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild" task "testprofile", "..": @@ -29,11 +29,12 @@ task "test2", "Build release test build test release build": if shell("nim", ReleaseDefines, ReleaseTestDefines, "compile", ExeName) == 0: shell "."/ExeName -discard """task "dirserver", "build the directory server": - withDir "server": - if shell("nim", ServerDefines, "compile", "dirserver") != 0: - echo "Failed to build the dirserver" - quit 1""" +when false: + task "dirserver", "build the directory server": + withDir "server": + if shell("nim", ServerDefines, "compile", "dirserver") != 0: + echo "Failed to build the dirserver" + quit 1 task "zoneserver", "build the zone server": withDir "enet_server": @@ -63,7 +64,7 @@ task "release", "release build": ## zip up all the files and such or something useful here task "testskel", "create skeleton test dir for testing": - let dirname = "test-"& $random(5000) + let dirname = "test-" & $rand(5000) removeDir dirName createDir dirName/"data/fnt" copyFile "data/fnt/LiberationMono-Regular", dirName/"data/fnt/LiberationMono-Regular.ttf" @@ -76,19 +77,20 @@ task "testskel", "create skeleton test dir for testing": task "clean", "cleanup generated files": var dirs = @["nimcache", "server"/"nimcache"] - dirs.map(proc(x: var string) = - if existsDir(x): removeDir(x)) + dirs.apply(proc(x: var string) = + if dirExists(x): removeDir(x)) task "download", "download game assets": var skipAssets = false path = expandFilename("data") + client = newHttpClient() path.add DirSep path.add(extractFilename(GameAssets)) - if existsFile(path): + if fileExists(path): echo "The file already exists\n", "[R]emove [M]ove [Q]uit [S]kip Source: ", GameAssets - case stdin.readLine.toLower + case stdin.readLine.toLowerAscii of "r": removeFile path of "m": @@ -101,7 +103,7 @@ task "download", "download game assets": echo "Downloading from ", GameAssets if not skipAssets: echo "Downloading to ", path - downloadFile GameAssets, path + client.downloadFile(GameAssets, path) echo "Download finished" let targetDir = parentDir(parentDir(path)) @@ -120,19 +122,19 @@ task "download", "download game assets": echo "Download binary libs? Only libs for linux are available currently, enjoy the irony.\n", "[Y]es [N]o Source: ", BinLibs - case stdin.readline.toLower + case stdin.readline.toLowerAscii of "y", "yes": discard ## o_O else: return path = extractFilename(BinLibs) - downloadFile BinLibs, path + client.downloadFile(BinLibs, path) echo "Downloaded dem libs ", path when true: echo "Unpack it yourself, sorry." else: ## this crashes, dunno why var z: TZipArchive - destDir = getCurrentDir()/("unzip"& $random(5000)) + destDir = getCurrentDir()/("unzip" & $rand(5000)) if not z.open(path, fmRead): echo "Could not open zip, bad download?" return |