Unique nims filename to enable parallelism

This commit is contained in:
Ganesh Viswanathan 2019-05-31 22:36:53 -05:00 committed by Dominik Picheta
commit be83dcdca9
2 changed files with 11 additions and 9 deletions

View file

@ -24,8 +24,7 @@ const
proc execNimscript(nimsFile, projectDir, actionName: string, options: Options,
live = true): tuple[output: string, exitCode: int] =
let
shash = $projectDir.hash().abs()
nimsFileCopied = projectDir / nimsFile.splitFile().name & "_" & shash & ".nims"
nimsFileCopied = projectDir / nimsFile.splitFile().name & "_" & getProcessId() & ".nims"
outFile = getNimbleTempDir() & ".out"
let

View file

@ -148,6 +148,15 @@ proc contains*(j: JsonNode, elem: tuple[key: string, val: JsonNode]): bool =
when not defined(windows):
from posix import getpid
proc getProcessId*(): string =
when defined(windows):
proc GetCurrentProcessId(): int32 {.stdcall, dynlib: "kernel32",
importc: "GetCurrentProcessId".}
result = $GetCurrentProcessId()
else:
result = $getpid()
proc getNimbleTempDir*(): string =
## Returns a path to a temporary directory.
##
@ -155,13 +164,7 @@ proc getNimbleTempDir*(): string =
## different for different runs of it. You have to make sure to create it
## first. In release builds the directory will be removed when nimble finishes
## its work.
result = getTempDir() / "nimble_"
when defined(windows):
proc GetCurrentProcessId(): int32 {.stdcall, dynlib: "kernel32",
importc: "GetCurrentProcessId".}
result.add($GetCurrentProcessId())
else:
result.add($getpid())
result = getTempDir() / "nimble_" & getProcessId()
proc getNimbleUserTempDir*(): string =
## Returns a path to a temporary directory.