Fixes compilation without windows module (0.11.3). Ref #150.
This commit is contained in:
parent
f12ed36b07
commit
43f7e4c310
1 changed files with 22 additions and 5 deletions
|
|
@ -12,7 +12,20 @@ import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
|
||||||
when not defined(windows):
|
when not defined(windows):
|
||||||
from posix import getpid
|
from posix import getpid
|
||||||
else:
|
else:
|
||||||
from windows import GetVersionExA, OSVERSIONINFO, WINBOOL, DWORD
|
# This is just for Win XP support.
|
||||||
|
# TODO: Drop XP support?
|
||||||
|
from winlean import WINBOOL, DWORD
|
||||||
|
type
|
||||||
|
OSVERSIONINFO* {.final, pure.} = object
|
||||||
|
dwOSVersionInfoSize*: DWORD
|
||||||
|
dwMajorVersion*: DWORD
|
||||||
|
dwMinorVersion*: DWORD
|
||||||
|
dwBuildNumber*: DWORD
|
||||||
|
dwPlatformId*: DWORD
|
||||||
|
szCSDVersion*: array[0..127, char]
|
||||||
|
|
||||||
|
proc GetVersionExA*(VersionInformation: var OSVERSIONINFO): WINBOOL{.stdcall,
|
||||||
|
dynlib: "kernel32", importc: "GetVersionExA".}
|
||||||
|
|
||||||
type
|
type
|
||||||
Options = object
|
Options = object
|
||||||
|
|
@ -577,15 +590,19 @@ proc installFromDir(dir: string, latest: bool, options: Options,
|
||||||
# http://stackoverflow.com/questions/2182568/batch-script-is-not-executed-if-chcp-was-called
|
# http://stackoverflow.com/questions/2182568/batch-script-is-not-executed-if-chcp-was-called
|
||||||
# But this workaround brokes code page on newer systems, so we need to detect OS version
|
# But this workaround brokes code page on newer systems, so we need to detect OS version
|
||||||
var osver = OSVERSIONINFO()
|
var osver = OSVERSIONINFO()
|
||||||
osver.dwOSVersionInfoSize= cast[DWORD](sizeof(OSVERSIONINFO))
|
osver.dwOSVersionInfoSize = cast[DWORD](sizeof(OSVERSIONINFO))
|
||||||
if GetVersionExA(addr osver) == WINBOOL(0):
|
if GetVersionExA(osver) == WINBOOL(0):
|
||||||
quit "Can't detect OS version: GetVersionExA call failed"
|
raise newException(NimbleError,
|
||||||
|
"Can't detect OS version: GetVersionExA call failed")
|
||||||
let fixChcp = osver.dwMajorVersion <= 5
|
let fixChcp = osver.dwMajorVersion <= 5
|
||||||
|
|
||||||
let dest = binDir / cleanBin.changeFileExt("cmd")
|
let dest = binDir / cleanBin.changeFileExt("cmd")
|
||||||
echo("Creating stub: ", pkgDestDir / bin, " -> ", dest)
|
echo("Creating stub: ", pkgDestDir / bin, " -> ", dest)
|
||||||
var contents = "@"
|
var contents = "@"
|
||||||
if options.config.chcp:
|
if options.config.chcp:
|
||||||
if fixChcp: contents.add "chcp 65001 > nul && " else: contents.add "chcp 65001 > nul\n@"
|
if fixChcp:
|
||||||
|
contents.add "chcp 65001 > nul && "
|
||||||
|
else: contents.add "chcp 65001 > nul\n@"
|
||||||
contents.add "\"" & pkgDestDir / bin & "\" %*\n"
|
contents.add "\"" & pkgDestDir / bin & "\" %*\n"
|
||||||
writeFile(dest, contents)
|
writeFile(dest, contents)
|
||||||
# For bash on Windows (Cygwin/Git bash).
|
# For bash on Windows (Cygwin/Git bash).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue