finally make niminst smart about which files are important

This commit is contained in:
Andreas Rumpf 2016-06-07 13:47:02 +02:00
commit e0f57ee1a1
3 changed files with 42 additions and 179 deletions

View file

@ -202,23 +202,41 @@ proc parseCmdLine(c: var ConfigData) =
if c.infile.len == 0: quit(Usage)
if c.mainfile.len == 0: c.mainfile = changeFileExt(c.infile, "nim")
proc walkDirRecursively(s: var seq[string], root: string) =
proc ignoreFile(f, root: string, preventHtml: bool): bool =
let (_, name, ext) = splitFile(f)
let html = if preventHtml: ".html" else: ""
let explicit = splitPath(root).tail
result = (ext in ["", ".exe", ".idx"] or
ext == html or name[0] == '.') and f != explicit
proc walkDirRecursively(s: var seq[string], root: string,
preventHtml: bool) =
let tail = splitPath(root).tail
if tail == "nimcache" or tail[0] == '.':
return
let preventHtml = preventHtml or tail != "doc"
for k, f in walkDir(root):
case k
of pcFile, pcLinkToFile: add(s, unixToNativePath(f))
of pcDir: walkDirRecursively(s, f)
of pcLinkToDir: discard
if f[0] == '.' and root[0] != '.':
discard "skip .git directories etc"
else:
case k
of pcFile, pcLinkToFile:
if not ignoreFile(f, root, preventHtml):
add(s, unixToNativePath(f))
of pcDir:
walkDirRecursively(s, f, preventHtml)
of pcLinkToDir: discard
proc addFiles(s: var seq[string], patterns: seq[string]) =
for p in items(patterns):
if existsDir(p):
walkDirRecursively(s, p)
walkDirRecursively(s, p, true)
else:
var i = 0
for f in walkFiles(p):
if existsDir(f):
walkDirRecursively(s, f)
else:
walkDirRecursively(s, f, false)
elif not ignoreFile(f, p, false):
add(s, unixToNativePath(f))
inc(i)
if i == 0: echo("[Warning] No file found that matches: " & p)
@ -613,13 +631,14 @@ proc xzDist(c: var ConfigData) =
let nimbleFile = c.nimblePkgName & ".nimble"
processFile(z, proj / nimbleFile, nimbleFile)
let oldDir = getCurrentDir()
setCurrentDir(tmpDir)
try:
if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
echo("External program failed")
finally:
setCurrentDir(oldDir)
when true:
let oldDir = getCurrentDir()
setCurrentDir(tmpDir)
try:
if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
echo("External program failed")
finally:
setCurrentDir(oldDir)
# -- prepare build files for .deb creation