Fix paths, git for Windows build
This commit is contained in:
parent
2049787f43
commit
9f196e3f77
8 changed files with 87 additions and 76 deletions
42
appveyor.yml
42
appveyor.yml
|
|
@ -1,8 +1,8 @@
|
||||||
version: '{build}'
|
version: '{build}'
|
||||||
|
|
||||||
image:
|
image:
|
||||||
|
- Visual Studio 2015
|
||||||
- Ubuntu
|
- Ubuntu
|
||||||
- Visual Studio 2017
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
@ -16,13 +16,12 @@ for:
|
||||||
-
|
-
|
||||||
matrix:
|
matrix:
|
||||||
only:
|
only:
|
||||||
- image: Visual Studio 2017
|
- image: Visual Studio 2015
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
ARCH: 32
|
ARCH: 64
|
||||||
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf
|
GIT_URL: https://github.com/git-for-windows/git/releases/download/v2.23.0.windows.1/
|
||||||
MINGW_ARCHIVE: i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z
|
GIT_ARCHIVE: PortableGit-2.23.0-64-bit.7z.exe
|
||||||
SFNET_URL: https://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- CD c:\
|
- CD c:\
|
||||||
|
|
@ -30,20 +29,23 @@ for:
|
||||||
echo %NIM_VERSION% &&
|
echo %NIM_VERSION% &&
|
||||||
MKDIR binaries &&
|
MKDIR binaries &&
|
||||||
CD binaries &&
|
CD binaries &&
|
||||||
appveyor DownloadFile "%MINGW_URL%/%MINGW_ARCHIVE%/download" -FileName "%MINGW_ARCHIVE%" &&
|
MKDIR git &&
|
||||||
7z x -y "%MINGW_ARCHIVE%"> nul &&
|
CD git &&
|
||||||
del "%MINGW_ARCHIVE%" &&
|
appveyor DownloadFile "%GIT_URL%/%GIT_ARCHIVE%" -FileName "%GIT_ARCHIVE%" &&
|
||||||
|
7z x -y -bd "%GIT_ARCHIVE%"> nul &&
|
||||||
|
del "%GIT_ARCHIVE%" &&
|
||||||
|
CD .. &&
|
||||||
appveyor DownloadFile "https://nim-lang.org/download/nim-%NIM_VERSION%_x%ARCH%.zip" -FileName "nim-%NIM_VERSION%_x%ARCH%.zip" &&
|
appveyor DownloadFile "https://nim-lang.org/download/nim-%NIM_VERSION%_x%ARCH%.zip" -FileName "nim-%NIM_VERSION%_x%ARCH%.zip" &&
|
||||||
7z x -y "nim-%NIM_VERSION%_x%ARCH%.zip"> nul &&
|
7z x -y "nim-%NIM_VERSION%_x%ARCH%.zip"> nul &&
|
||||||
del "nim-%NIM_VERSION%_x%ARCH%.zip")
|
del "nim-%NIM_VERSION%_x%ARCH%.zip")
|
||||||
- SET PATH=c:\binaries\mingw%ARCH%\bin;c:\binaries\nim-%NIM_VERSION%\bin;%USERPROFILE%\.nimble\bin;%PATH%
|
- SET PATH=c:\binaries\git\bin;C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;c:\binaries\nim-%NIM_VERSION%\bin;%USERPROFILE%\.nimble\bin;%PATH%
|
||||||
- CD %APPVEYOR_BUILD_FOLDER%
|
- CD %APPVEYOR_BUILD_FOLDER%
|
||||||
|
|
||||||
on_finish:
|
# on_finish:
|
||||||
- 7z a -r buildlogs-win-pkgs.zip %USERPROFILE%\.nimble\pkgs
|
# - 7z a -r buildlogs-win-pkgs.zip %USERPROFILE%\.nimble\pkgs
|
||||||
- appveyor PushArtifact buildlogs-win-pkgs.zip
|
# - appveyor PushArtifact buildlogs-win-pkgs.zip
|
||||||
- 7z a -r buildlogs-win-projects.zip c:\projects\*
|
# - 7z a -r buildlogs-win-projects.zip c:\projects\*
|
||||||
- appveyor PushArtifact buildlogs-win-projects.zip
|
# - appveyor PushArtifact buildlogs-win-projects.zip
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
- c:\binaries
|
- c:\binaries
|
||||||
|
|
@ -71,11 +73,11 @@ for:
|
||||||
- export PATH=/home/appveyor/binaries/nim-$NIM_VERSION/bin:~/.nimble/bin:$PATH
|
- export PATH=/home/appveyor/binaries/nim-$NIM_VERSION/bin:~/.nimble/bin:$PATH
|
||||||
- cd $APPVEYOR_BUILD_FOLDER
|
- cd $APPVEYOR_BUILD_FOLDER
|
||||||
|
|
||||||
on_finish:
|
# on_finish:
|
||||||
- zip -r -q buildlogs-lin-pkgs.zip ~/.nimble/pkgs
|
# - zip -r -q buildlogs-lin-pkgs.zip ~/.nimble/pkgs
|
||||||
- appveyor PushArtifact buildlogs-lin-pkgs.zip
|
# - appveyor PushArtifact buildlogs-lin-pkgs.zip
|
||||||
- zip -r -q buildlogs-lin-projects.zip /home/appveyor/projects
|
# - zip -r -q buildlogs-lin-projects.zip /home/appveyor/projects
|
||||||
- appveyor PushArtifact buildlogs-lin-projects.zip
|
# - appveyor PushArtifact buildlogs-lin-projects.zip
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
- /home/appveyor/binaries
|
- /home/appveyor/binaries
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ import os except findExe
|
||||||
|
|
||||||
import "."/[compat]
|
import "."/[compat]
|
||||||
|
|
||||||
|
proc sanitizePath*(path: string, noQuote = false): string =
|
||||||
|
result = path.multiReplace([("\\\\", $DirSep), ("\\", $DirSep), ("/", $DirSep)])
|
||||||
|
if not noQuote:
|
||||||
|
result = result.quoteShell
|
||||||
|
|
||||||
proc execAction*(cmd: string, nostderr=false): string =
|
proc execAction*(cmd: string, nostderr=false): string =
|
||||||
## Execute an external command - supported at compile time
|
## Execute an external command - supported at compile time
|
||||||
##
|
##
|
||||||
|
|
@ -39,7 +44,7 @@ proc findExe*(exe: string): string =
|
||||||
(oup, code) = gorgeEx(cmd)
|
(oup, code) = gorgeEx(cmd)
|
||||||
|
|
||||||
if code == 0:
|
if code == 0:
|
||||||
return oup.strip()
|
return oup.splitLines()[0].strip()
|
||||||
|
|
||||||
proc mkDir*(dir: string) =
|
proc mkDir*(dir: string) =
|
||||||
## Create a directory at cmopile time
|
## Create a directory at cmopile time
|
||||||
|
|
@ -49,7 +54,7 @@ proc mkDir*(dir: string) =
|
||||||
if not dirExists(dir):
|
if not dirExists(dir):
|
||||||
let
|
let
|
||||||
flag = when not defined(Windows): "-p" else: ""
|
flag = when not defined(Windows): "-p" else: ""
|
||||||
discard execAction(&"mkdir {flag} {dir.quoteShell}")
|
discard execAction(&"mkdir {flag} {dir.sanitizePath}")
|
||||||
|
|
||||||
proc cpFile*(source, dest: string, move=false) =
|
proc cpFile*(source, dest: string, move=false) =
|
||||||
## Copy a file from source to destination at compile time
|
## Copy a file from source to destination at compile time
|
||||||
|
|
@ -68,7 +73,7 @@ proc cpFile*(source, dest: string, move=false) =
|
||||||
else:
|
else:
|
||||||
"cp -f"
|
"cp -f"
|
||||||
|
|
||||||
discard execAction(&"{cmd} {source.quoteShell} {dest.quoteShell}")
|
discard execAction(&"{cmd} {source.sanitizePath} {dest.sanitizePath}")
|
||||||
|
|
||||||
proc mvFile*(source, dest: string) =
|
proc mvFile*(source, dest: string) =
|
||||||
## Move a file from source to destination at compile time
|
## Move a file from source to destination at compile time
|
||||||
|
|
@ -87,7 +92,7 @@ proc rmFile*(source: string, dir = false) =
|
||||||
else:
|
else:
|
||||||
"rm -rf"
|
"rm -rf"
|
||||||
|
|
||||||
discard execAction(&"{cmd} {source.quoteShell}")
|
discard execAction(&"{cmd} {source.sanitizePath}")
|
||||||
|
|
||||||
proc rmDir*(source: string) =
|
proc rmDir*(source: string) =
|
||||||
## Remove a directory or pattern at compile time
|
## Remove a directory or pattern at compile time
|
||||||
|
|
@ -103,7 +108,7 @@ proc extractZip*(zipfile, outdir: string) =
|
||||||
"[IO.Compression.ZipFile]::ExtractToDirectory('$#', '.'); }\""
|
"[IO.Compression.ZipFile]::ExtractToDirectory('$#', '.'); }\""
|
||||||
|
|
||||||
echo "# Extracting " & zipfile
|
echo "# Extracting " & zipfile
|
||||||
discard execAction(&"cd {outdir.quoteShell} && {cmd % zipfile}")
|
discard execAction(&"cd {outdir.sanitizePath} && {cmd % zipfile}")
|
||||||
|
|
||||||
proc extractTar*(tarfile, outdir: string) =
|
proc extractTar*(tarfile, outdir: string) =
|
||||||
## Extract a tar file using tar, 7z or 7za to the specified output directory
|
## Extract a tar file using tar, 7z or 7za to the specified output directory
|
||||||
|
|
@ -121,20 +126,22 @@ proc extractTar*(tarfile, outdir: string) =
|
||||||
of ".bz2": "j"
|
of ".bz2": "j"
|
||||||
else: ""
|
else: ""
|
||||||
|
|
||||||
cmd = "tar xvf" & typ & " " & tarfile.quoteShell
|
cmd = "tar xvf" & typ & " " & tarfile.sanitizePath
|
||||||
else:
|
else:
|
||||||
for i in ["7z", "7za"]:
|
for i in ["7z", "7za"]:
|
||||||
if findExe(i).len != 0:
|
if findExe(i).len != 0:
|
||||||
cmd = i & " x $#" % tarfile.quoteShell
|
cmd = i & " x $#" % tarfile.sanitizePath
|
||||||
|
|
||||||
name = tarfile.splitFile().name
|
name = tarfile.splitFile().name
|
||||||
if ".tar" in name.toLowerAscii():
|
if ".tar" in name.toLowerAscii():
|
||||||
cmd &= " && " & i & " x $#" % name.quoteShell
|
cmd &= " && " & i & " x $#" % name.sanitizePath
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
doAssert cmd.len != 0, "No extraction tool - tar, 7z, 7za - available for " & tarfile.sanitizePath
|
||||||
|
|
||||||
echo "# Extracting " & tarfile
|
echo "# Extracting " & tarfile
|
||||||
discard execAction(&"cd {outdir.quoteShell} && {cmd}")
|
discard execAction(&"cd {outdir.sanitizePath} && {cmd}")
|
||||||
if name.len != 0:
|
if name.len != 0:
|
||||||
rmFile(outdir / name)
|
rmFile(outdir / name)
|
||||||
|
|
||||||
|
|
@ -152,7 +159,7 @@ proc downloadUrl*(url, outdir: string) =
|
||||||
mkDir(outdir)
|
mkDir(outdir)
|
||||||
var cmd = findExe("curl")
|
var cmd = findExe("curl")
|
||||||
if cmd.len != 0:
|
if cmd.len != 0:
|
||||||
cmd &= " -L $# -o $#"
|
cmd &= " -Lk $# -o $#"
|
||||||
else:
|
else:
|
||||||
cmd = findExe("wget")
|
cmd = findExe("wget")
|
||||||
if cmd.len != 0:
|
if cmd.len != 0:
|
||||||
|
|
@ -161,7 +168,7 @@ proc downloadUrl*(url, outdir: string) =
|
||||||
cmd = "powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; wget $# -OutFile $#"
|
cmd = "powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; wget $# -OutFile $#"
|
||||||
else:
|
else:
|
||||||
doAssert false, "No download tool available - curl, wget"
|
doAssert false, "No download tool available - curl, wget"
|
||||||
discard execAction(cmd % [url, (outdir/file).quoteShell])
|
discard execAction(cmd % [url, (outdir/file).sanitizePath])
|
||||||
|
|
||||||
if ext == ".zip":
|
if ext == ".zip":
|
||||||
extractZip(file, outdir)
|
extractZip(file, outdir)
|
||||||
|
|
@ -172,7 +179,7 @@ proc gitReset*(outdir: string) =
|
||||||
## Hard reset the git repository at the specified directory
|
## Hard reset the git repository at the specified directory
|
||||||
echo "# Resetting " & outdir
|
echo "# Resetting " & outdir
|
||||||
|
|
||||||
let cmd = &"cd {outdir.quoteShell} && git reset --hard"
|
let cmd = &"cd {outdir.sanitizePath} && git reset --hard"
|
||||||
while execAction(cmd).contains("Permission denied"):
|
while execAction(cmd).contains("Permission denied"):
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
echo "# Retrying ..."
|
echo "# Retrying ..."
|
||||||
|
|
@ -185,7 +192,7 @@ proc gitCheckout*(file, outdir: string) =
|
||||||
## successful wrapping with `cImport()` or `c2nImport()`.
|
## successful wrapping with `cImport()` or `c2nImport()`.
|
||||||
echo "# Resetting " & file
|
echo "# Resetting " & file
|
||||||
let file2 = file.relativePath outdir
|
let file2 = file.relativePath outdir
|
||||||
let cmd = &"cd {outdir.quoteShell} && git checkout {file2.quoteShell}"
|
let cmd = &"cd {outdir.sanitizePath} && git checkout {file2.sanitizePath}"
|
||||||
while execAction(cmd).contains("Permission denied"):
|
while execAction(cmd).contains("Permission denied"):
|
||||||
sleep(500)
|
sleep(500)
|
||||||
echo "# Retrying ..."
|
echo "# Retrying ..."
|
||||||
|
|
@ -206,7 +213,7 @@ proc gitPull*(url: string, outdir = "", plist = "", checkout = "") =
|
||||||
return
|
return
|
||||||
|
|
||||||
let
|
let
|
||||||
outdirQ = outdir.quoteShell
|
outdirQ = outdir.sanitizePath
|
||||||
|
|
||||||
mkDir(outdir)
|
mkDir(outdir)
|
||||||
|
|
||||||
|
|
@ -279,7 +286,7 @@ proc configure*(path, check: string, flags = "") =
|
||||||
if fileExists(path / i):
|
if fileExists(path / i):
|
||||||
echo "# Running autogen.sh"
|
echo "# Running autogen.sh"
|
||||||
|
|
||||||
echo execAction(&"cd {(path / i).parentDir().quoteShell} && bash autogen.sh")
|
echo execAction(&"cd {(path / i).parentDir().sanitizePath} && bash autogen.sh")
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -288,7 +295,7 @@ proc configure*(path, check: string, flags = "") =
|
||||||
if fileExists(path / i):
|
if fileExists(path / i):
|
||||||
echo "# Running autoreconf"
|
echo "# Running autoreconf"
|
||||||
|
|
||||||
echo execAction(&"cd {path.quoteShell} && autoreconf -fi")
|
echo execAction(&"cd {path.sanitizePath} && autoreconf -fi")
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -296,7 +303,7 @@ proc configure*(path, check: string, flags = "") =
|
||||||
echo "# Running configure " & flags
|
echo "# Running configure " & flags
|
||||||
|
|
||||||
var
|
var
|
||||||
cmd = &"cd {path.quoteShell} && bash configure"
|
cmd = &"cd {path.sanitizePath} && bash configure"
|
||||||
if flags.len != 0:
|
if flags.len != 0:
|
||||||
cmd &= &" {flags}"
|
cmd &= &" {flags}"
|
||||||
|
|
||||||
|
|
@ -327,7 +334,7 @@ proc cmake*(path, check, flags: string) =
|
||||||
mkDir(path)
|
mkDir(path)
|
||||||
|
|
||||||
var
|
var
|
||||||
cmd = &"cd {path.quoteShell} && cmake {flags}"
|
cmd = &"cd {path.sanitizePath} && cmake {flags}"
|
||||||
|
|
||||||
echo execAction(cmd)
|
echo execAction(cmd)
|
||||||
|
|
||||||
|
|
@ -359,7 +366,7 @@ proc make*(path, check: string|Regex, flags = "") =
|
||||||
cpFile(cmd, cmd.replace("mingw32-make", "make"))
|
cpFile(cmd, cmd.replace("mingw32-make", "make"))
|
||||||
doAssert cmd.len != 0, "Make not found"
|
doAssert cmd.len != 0, "Make not found"
|
||||||
|
|
||||||
cmd = &"cd {path.quoteShell} && make"
|
cmd = &"cd {path.sanitizePath} && make"
|
||||||
if flags.len != 0:
|
if flags.len != 0:
|
||||||
cmd &= &" {flags}"
|
cmd &= &" {flags}"
|
||||||
|
|
||||||
|
|
@ -383,8 +390,7 @@ proc getGccPaths*(mode = "c"): seq[string] =
|
||||||
break
|
break
|
||||||
if inc:
|
if inc:
|
||||||
var
|
var
|
||||||
path = line.strip()
|
path = line.strip().myNormalizedPath()
|
||||||
path.normalizePath()
|
|
||||||
if path notin result:
|
if path notin result:
|
||||||
result.add path
|
result.add path
|
||||||
|
|
||||||
|
|
@ -400,15 +406,13 @@ proc getGccLibPaths*(mode = "c"): seq[string] =
|
||||||
if "LIBRARY_PATH=" in line:
|
if "LIBRARY_PATH=" in line:
|
||||||
for path in line[13 .. ^1].split(PathSep):
|
for path in line[13 .. ^1].split(PathSep):
|
||||||
var
|
var
|
||||||
path = path.strip()
|
path = path.strip().myNormalizedPath()
|
||||||
path.normalizePath()
|
|
||||||
if path notin result:
|
if path notin result:
|
||||||
result.add path
|
result.add path
|
||||||
break
|
break
|
||||||
elif '\t' in line:
|
elif '\t' in line:
|
||||||
var
|
var
|
||||||
path = line.strip()
|
path = line.strip().myNormalizedPath()
|
||||||
path.normalizePath()
|
|
||||||
if path notin result:
|
if path notin result:
|
||||||
result.add path
|
result.add path
|
||||||
|
|
||||||
|
|
@ -504,7 +508,7 @@ proc buildLibrary(lname, outdir, conFlags, cmakeFlags, makeFlags: string): strin
|
||||||
gen = "MinGW Makefiles"
|
gen = "MinGW Makefiles"
|
||||||
else:
|
else:
|
||||||
gen = "Unix Makefiles"
|
gen = "Unix Makefiles"
|
||||||
cmake(outdir / "build", "Makefile", &".. -G {gen.quoteShell} {cmakeFlags}")
|
cmake(outdir / "build", "Makefile", &".. -G {gen.sanitizePath} {cmakeFlags}")
|
||||||
cmakeDeps = true
|
cmakeDeps = true
|
||||||
makePath = outdir / "build"
|
makePath = outdir / "build"
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,11 @@ proc getFileDate(fullpath: string): string =
|
||||||
ret = 0
|
ret = 0
|
||||||
cmd =
|
cmd =
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
&"cmd /c for %a in ({fullpath.quoteShell}) do echo %~ta"
|
&"cmd /c for %a in ({fullpath.sanitizePath}) do echo %~ta"
|
||||||
elif defined(Linux):
|
elif defined(Linux):
|
||||||
&"stat -c %y {fullpath.quoteShell}"
|
&"stat -c %y {fullpath.sanitizePath}"
|
||||||
elif defined(OSX):
|
elif defined(OSX):
|
||||||
&"stat -f %m {fullpath.quoteShell}"
|
&"stat -f %m {fullpath.sanitizePath}"
|
||||||
|
|
||||||
(result, ret) = gorgeEx(cmd)
|
(result, ret) = gorgeEx(cmd)
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ proc getNimCheckError(output: string): tuple[tmpFile, errors: string] =
|
||||||
getCurrentCompilerExe()
|
getCurrentCompilerExe()
|
||||||
else:
|
else:
|
||||||
"nim"
|
"nim"
|
||||||
(check, _) = gorgeEx(&"{nim} check {result.tmpFile.quoteShell}")
|
(check, _) = gorgeEx(&"{nim} check {result.tmpFile.sanitizePath}")
|
||||||
|
|
||||||
result.errors = "\n\n" & check
|
result.errors = "\n\n" & check
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ proc getToast(fullpath: string, recurse: bool = false, dynlib: string = "",
|
||||||
cmd = when defined(Windows): "cmd /c " else: ""
|
cmd = when defined(Windows): "cmd /c " else: ""
|
||||||
|
|
||||||
let toastExe = toastExePath()
|
let toastExe = toastExePath()
|
||||||
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.quoteShell &
|
doAssert fileExists(toastExe), "toast not compiled: " & toastExe.sanitizePath &
|
||||||
" make sure 'nimble build' or 'nimble install' built it"
|
" make sure 'nimble build' or 'nimble install' built it"
|
||||||
cmd &= &"{toastExe} --preprocess"
|
cmd &= &"{toastExe} --preprocess"
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ proc getToast(fullpath: string, recurse: bool = false, dynlib: string = "",
|
||||||
cmd.add &" --defines+={i.quoteShell}"
|
cmd.add &" --defines+={i.quoteShell}"
|
||||||
|
|
||||||
for i in gStateCT.includeDirs:
|
for i in gStateCT.includeDirs:
|
||||||
cmd.add &" --includeDirs+={i.quoteShell}"
|
cmd.add &" --includeDirs+={i.sanitizePath}"
|
||||||
|
|
||||||
if not noNimout:
|
if not noNimout:
|
||||||
cmd.add &" --pnim"
|
cmd.add &" --pnim"
|
||||||
|
|
@ -157,12 +157,12 @@ proc getToast(fullpath: string, recurse: bool = false, dynlib: string = "",
|
||||||
cmd.add &" --symOverride={gStateCT.symOverride.join(\",\")}"
|
cmd.add &" --symOverride={gStateCT.symOverride.join(\",\")}"
|
||||||
|
|
||||||
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 9):
|
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 9):
|
||||||
cmd.add &" --nim:{getCurrentCompilerExe().quoteShell}"
|
cmd.add &" --nim:{getCurrentCompilerExe().sanitizePath}"
|
||||||
|
|
||||||
if gStateCT.pluginSourcePath.nBl:
|
if gStateCT.pluginSourcePath.nBl:
|
||||||
cmd.add &" --pluginSourcePath={gStateCT.pluginSourcePath.quoteShell}"
|
cmd.add &" --pluginSourcePath={gStateCT.pluginSourcePath.sanitizePath}"
|
||||||
|
|
||||||
cmd.add &" {fullpath.quoteShell}"
|
cmd.add &" {fullpath.sanitizePath}"
|
||||||
|
|
||||||
# see https://github.com/nimterop/nimterop/issues/69
|
# see https://github.com/nimterop/nimterop/issues/69
|
||||||
(result, ret) = gorgeEx(cmd, cache=getCacheValue(fullpath))
|
(result, ret) = gorgeEx(cmd, cache=getCacheValue(fullpath))
|
||||||
|
|
@ -527,7 +527,7 @@ macro cImport*(filename: static string, recurse: static bool = false, dynlib: st
|
||||||
let
|
let
|
||||||
fullpath = findPath(filename)
|
fullpath = findPath(filename)
|
||||||
|
|
||||||
echo "# Importing " & fullpath
|
echo "# Importing " & fullpath.sanitizePath
|
||||||
|
|
||||||
let
|
let
|
||||||
output = getToast(fullpath, recurse, dynlib, mode, flags)
|
output = getToast(fullpath, recurse, dynlib, mode, flags)
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,18 @@ put everything that requires `when (NimMajor, NimMinor, NimPatch)` here
|
||||||
import os
|
import os
|
||||||
|
|
||||||
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 9):
|
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 9):
|
||||||
|
proc myNormalizedPath*(path: string): string = path.normalizedPath()
|
||||||
|
|
||||||
export relativePath
|
export relativePath
|
||||||
|
|
||||||
else:
|
else:
|
||||||
import std/[ospaths,strutils]
|
import std/[ospaths,strutils]
|
||||||
|
|
||||||
|
proc myNormalizedPath*(path: string): string =
|
||||||
|
result = path.normalizedPath()
|
||||||
|
when defined(windows):
|
||||||
|
result = result.strip(trailing = false, chars = {'\\'})
|
||||||
|
|
||||||
proc relativePath*(file, base: string): string =
|
proc relativePath*(file, base: string): string =
|
||||||
## naive version of `os.relativePath` ; remove after nim >= 0.19.9
|
## naive version of `os.relativePath` ; remove after nim >= 0.19.9
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
|
|
@ -17,8 +25,8 @@ else:
|
||||||
check:
|
check:
|
||||||
"/foo/bar/baz/log.txt".unixToNativePath.relativePath("/foo/bar".unixToNativePath) == "baz/log.txt".unixToNativePath
|
"/foo/bar/baz/log.txt".unixToNativePath.relativePath("/foo/bar".unixToNativePath) == "baz/log.txt".unixToNativePath
|
||||||
"foo/bar/baz/log.txt".unixToNativePath.relativePath("foo/bar".unixToNativePath) == "baz/log.txt".unixToNativePath
|
"foo/bar/baz/log.txt".unixToNativePath.relativePath("foo/bar".unixToNativePath) == "baz/log.txt".unixToNativePath
|
||||||
var base = base.normalizedPath
|
var base = base.myNormalizedPath
|
||||||
var file = file.normalizedPath
|
var file = file.myNormalizedPath
|
||||||
if not base.endsWith DirSep: base.add DirSep
|
if not base.endsWith DirSep: base.add DirSep
|
||||||
doAssert file.startsWith base
|
doAssert file.startsWith base
|
||||||
result = file[base.len .. ^1]
|
result = file[base.len .. ^1]
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,6 @@ const gTypeMap = {
|
||||||
"long double": "clongdouble"
|
"long double": "clongdouble"
|
||||||
}.toTable()
|
}.toTable()
|
||||||
|
|
||||||
proc sanitizePath*(path: string): string =
|
|
||||||
path.multiReplace([("\\\\", $DirSep), ("\\", $DirSep), ("/", $DirSep)])
|
|
||||||
|
|
||||||
proc getType*(str: string): string =
|
proc getType*(str: string): string =
|
||||||
if str == "void":
|
if str == "void":
|
||||||
return "object"
|
return "object"
|
||||||
|
|
@ -205,15 +202,15 @@ proc getPreprocessor*(gState: State, fullpath: string, mode = "cpp"): string =
|
||||||
|
|
||||||
rdata: seq[string] = @[]
|
rdata: seq[string] = @[]
|
||||||
start = false
|
start = false
|
||||||
sfile = fullpath.sanitizePath
|
sfile = fullpath.sanitizePath(noQuote = true)
|
||||||
|
|
||||||
for inc in gState.includeDirs:
|
for inc in gState.includeDirs:
|
||||||
cmd &= &"-I{inc.quoteShell} "
|
cmd &= &"-I{inc.sanitizePath} "
|
||||||
|
|
||||||
for def in gState.defines:
|
for def in gState.defines:
|
||||||
cmd &= &"-D{def} "
|
cmd &= &"-D{def} "
|
||||||
|
|
||||||
cmd &= &"{fullpath.quoteShell}"
|
cmd &= &"{fullpath.sanitizePath}"
|
||||||
|
|
||||||
# Include content only from file
|
# Include content only from file
|
||||||
for line in execAction(cmd).splitLines():
|
for line in execAction(cmd).splitLines():
|
||||||
|
|
@ -221,19 +218,19 @@ proc getPreprocessor*(gState: State, fullpath: string, mode = "cpp"): string =
|
||||||
if line.len > 1 and line[0 .. 1] == "# ":
|
if line.len > 1 and line[0 .. 1] == "# ":
|
||||||
start = false
|
start = false
|
||||||
let
|
let
|
||||||
saniLine = line.sanitizePath
|
saniLine = line.sanitizePath(noQuote = true)
|
||||||
if sfile in saniLine:
|
if sfile in saniLine:
|
||||||
start = true
|
start = true
|
||||||
elif not ("\\" in line) and not ("/" in line) and extractFilename(sfile) in line:
|
elif not ("\\" in line) and not ("/" in line) and extractFilename(sfile) in line:
|
||||||
start = true
|
start = true
|
||||||
elif gState.recurse:
|
elif gState.recurse:
|
||||||
let
|
let
|
||||||
pDir = sfile.expandFilename().parentDir().sanitizePath()
|
pDir = sfile.expandFilename().parentDir().sanitizePath(noQuote = true)
|
||||||
if pDir.len == 0 or pDir in saniLine:
|
if pDir.len == 0 or pDir in saniLine:
|
||||||
start = true
|
start = true
|
||||||
else:
|
else:
|
||||||
for inc in gState.includeDirs:
|
for inc in gState.includeDirs:
|
||||||
if inc.absolutePath().sanitizePath in saniLine:
|
if inc.absolutePath().sanitizePath(noQuote = true) in saniLine:
|
||||||
start = true
|
start = true
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
@ -395,7 +392,7 @@ proc loadPlugin*(gState: State, sourcePath: string) =
|
||||||
pdll = sourcePath.dll
|
pdll = sourcePath.dll
|
||||||
if not fileExists(pdll) or
|
if not fileExists(pdll) or
|
||||||
sourcePath.getLastModificationTime() > pdll.getLastModificationTime():
|
sourcePath.getLastModificationTime() > pdll.getLastModificationTime():
|
||||||
discard execAction(&"{gState.nim.quoteShell} c --app:lib {sourcePath.quoteShell}")
|
discard execAction(&"{gState.nim.sanitizePath} c --app:lib {sourcePath.sanitizePath}")
|
||||||
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
||||||
|
|
||||||
let lib = loadLib(pdll)
|
let lib = loadLib(pdll)
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,17 @@ import ".."/[setup, paths, types]
|
||||||
static:
|
static:
|
||||||
treesitterSetup()
|
treesitterSetup()
|
||||||
|
|
||||||
const sourcePath = incDir() / "treesitter/lib"
|
const sourcePath = incDir() / "treesitter" / "lib"
|
||||||
|
|
||||||
when defined(Linux):
|
when defined(Linux):
|
||||||
{.passC: "-std=c11".}
|
{.passC: "-std=c11".}
|
||||||
|
|
||||||
{.passC: "-DUTF8PROC_STATIC".}
|
{.passC: "-DUTF8PROC_STATIC".}
|
||||||
{.passC: "-I$1/include" % sourcePath.}
|
{.passC: "-I$1" % (sourcePath / "include").}
|
||||||
{.passC: "-I$1/src" % sourcePath.}
|
{.passC: "-I$1" % (sourcePath / "src").}
|
||||||
{.passC: "-I$1/../../utf8proc" % sourcePath.}
|
{.passC: "-I$1" % (sourcePath / ".." / ".." / "utf8proc").}
|
||||||
|
|
||||||
{.compile: sourcePath / "src/lib.c".}
|
{.compile: sourcePath / "src" / "lib.c".}
|
||||||
|
|
||||||
### Generated below
|
### Generated below
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ defineEnum(TSInputEncoding)
|
||||||
defineEnum(TSSymbolType)
|
defineEnum(TSSymbolType)
|
||||||
defineEnum(TSLogType)
|
defineEnum(TSLogType)
|
||||||
const
|
const
|
||||||
headerapi {.used.} = sourcePath / "include/tree_sitter/api.h"
|
headerapi {.used.} = sourcePath / "include" / "tree_sitter" / "api.h"
|
||||||
TREE_SITTER_LANGUAGE_VERSION* = 9
|
TREE_SITTER_LANGUAGE_VERSION* = 9
|
||||||
TSInputEncodingUTF8* = 0.TSInputEncoding
|
TSInputEncodingUTF8* = 0.TSInputEncoding
|
||||||
TSInputEncodingUTF16* = 1.TSInputEncoding
|
TSInputEncodingUTF16* = 1.TSInputEncoding
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import ".."/[setup, paths]
|
||||||
static:
|
static:
|
||||||
treesitterCSetup()
|
treesitterCSetup()
|
||||||
|
|
||||||
const srcDir = incDir() / "treesitter_c/src"
|
const srcDir = incDir() / "treesitter_c" / "src"
|
||||||
|
|
||||||
import "."/api
|
import "."/api
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import ".."/[setup, paths]
|
||||||
static:
|
static:
|
||||||
treesitterCppSetup()
|
treesitterCppSetup()
|
||||||
|
|
||||||
const srcDir = incDir() / "treesitter_cpp/src"
|
const srcDir = incDir() / "treesitter_cpp" / "src"
|
||||||
|
|
||||||
{.passC: "-I$1" % srcDir.}
|
{.passC: "-I$1" % srcDir.}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue