Clean out niminst (#15451)
This commit is contained in:
parent
b4fe0c8862
commit
d1eb76184b
1 changed files with 31 additions and 74 deletions
|
|
@ -7,12 +7,6 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
const
|
|
||||||
haveZipLib = false # zip not in stdlib anymore
|
|
||||||
|
|
||||||
when haveZipLib:
|
|
||||||
import zipfiles
|
|
||||||
|
|
||||||
import
|
import
|
||||||
os, strutils, parseopt, parsecfg, strtabs, streams, debcreation,
|
os, strutils, parseopt, parsecfg, strtabs, streams, debcreation,
|
||||||
std / sha1
|
std / sha1
|
||||||
|
|
@ -36,7 +30,6 @@ type
|
||||||
actionInno, # action: create Inno Setup installer
|
actionInno, # action: create Inno Setup installer
|
||||||
actionNsis, # action: create NSIS installer
|
actionNsis, # action: create NSIS installer
|
||||||
actionScripts # action: create install and deinstall scripts
|
actionScripts # action: create install and deinstall scripts
|
||||||
actionZip, # action: create zip file
|
|
||||||
actionXz, # action: create xz file
|
actionXz, # action: create xz file
|
||||||
actionDeb # action: prepare deb package
|
actionDeb # action: prepare deb package
|
||||||
|
|
||||||
|
|
@ -75,7 +68,7 @@ const
|
||||||
"$configdir", "$datadir", "$docdir", "$libdir"
|
"$configdir", "$datadir", "$docdir", "$libdir"
|
||||||
]
|
]
|
||||||
|
|
||||||
proc iniConfigData(c: var ConfigData) =
|
func iniConfigData(c: var ConfigData) =
|
||||||
c.actions = {}
|
c.actions = {}
|
||||||
for i in low(FileCategory)..high(FileCategory): c.cat[i] = @[]
|
for i in low(FileCategory)..high(FileCategory): c.cat[i] = @[]
|
||||||
c.binPaths = @[]
|
c.binPaths = @[]
|
||||||
|
|
@ -107,17 +100,17 @@ proc iniConfigData(c: var ConfigData) =
|
||||||
c.debOpts.shortDesc = ""
|
c.debOpts.shortDesc = ""
|
||||||
c.debOpts.licenses = @[]
|
c.debOpts.licenses = @[]
|
||||||
|
|
||||||
proc firstBinPath(c: ConfigData): string =
|
func firstBinPath(c: ConfigData): string =
|
||||||
if c.binPaths.len > 0: result = c.binPaths[0]
|
if c.binPaths.len > 0: result = c.binPaths[0]
|
||||||
else: result = ""
|
else: result = ""
|
||||||
|
|
||||||
proc `\`(a, b: string): string =
|
func `\`(a, b: string): string =
|
||||||
result = if a.len == 0: b else: a & '\\' & b
|
result = if a.len == 0: b else: a & '\\' & b
|
||||||
|
|
||||||
template toUnix(s: string): string = s.replace('\\', '/')
|
template toUnix(s: string): string = s.replace('\\', '/')
|
||||||
template toWin(s: string): string = s.replace('/', '\\')
|
template toWin(s: string): string = s.replace('/', '\\')
|
||||||
|
|
||||||
proc skipRoot(f: string): string =
|
func skipRoot(f: string): string =
|
||||||
# "abc/def/xyz" --> "def/xyz"
|
# "abc/def/xyz" --> "def/xyz"
|
||||||
var i = 0
|
var i = 0
|
||||||
result = ""
|
result = ""
|
||||||
|
|
@ -146,7 +139,6 @@ Usage:
|
||||||
Command:
|
Command:
|
||||||
csource build C source code for source based installations
|
csource build C source code for source based installations
|
||||||
scripts build install and deinstall scripts
|
scripts build install and deinstall scripts
|
||||||
zip build the ZIP file
|
|
||||||
inno build the Inno Setup installer
|
inno build the Inno Setup installer
|
||||||
nsis build the NSIS Setup installer
|
nsis build the NSIS Setup installer
|
||||||
deb create files for debhelper
|
deb create files for debhelper
|
||||||
|
|
@ -175,7 +167,6 @@ proc parseCmdLine(c: var ConfigData) =
|
||||||
case a
|
case a
|
||||||
of "csource": incl(c.actions, actionCSource)
|
of "csource": incl(c.actions, actionCSource)
|
||||||
of "scripts": incl(c.actions, actionScripts)
|
of "scripts": incl(c.actions, actionScripts)
|
||||||
of "zip": incl(c.actions, actionZip)
|
|
||||||
of "xz": incl(c.actions, actionXz)
|
of "xz": incl(c.actions, actionXz)
|
||||||
of "inno": incl(c.actions, actionInno)
|
of "inno": incl(c.actions, actionInno)
|
||||||
of "nsis": incl(c.actions, actionNsis)
|
of "nsis": incl(c.actions, actionNsis)
|
||||||
|
|
@ -221,11 +212,11 @@ proc eqT(a, b: string; t: proc (a: char): char{.nimcall.}): bool =
|
||||||
inc j
|
inc j
|
||||||
result = i >= a.len and j >= b.len
|
result = i >= a.len and j >= b.len
|
||||||
|
|
||||||
proc tPath(c: char): char =
|
func tPath(c: char): char =
|
||||||
if c == '\\': '/'
|
if c == '\\': '/'
|
||||||
else: c
|
else: c
|
||||||
|
|
||||||
proc ignoreFile(f, explicit: string, allowHtml: bool): bool =
|
func ignoreFile(f, explicit: string, allowHtml: bool): bool =
|
||||||
let (_, name, ext) = splitFile(f)
|
let (_, name, ext) = splitFile(f)
|
||||||
let html = if not allowHtml: ".html" else: ""
|
let html = if not allowHtml: ".html" else: ""
|
||||||
result = (ext in ["", ".exe", ".idx", ".o", ".obj", ".dylib"] or
|
result = (ext in ["", ".exe", ".idx", ".o", ".obj", ".dylib"] or
|
||||||
|
|
@ -283,13 +274,13 @@ proc yesno(p: var CfgParser, v: string): bool =
|
||||||
result = false
|
result = false
|
||||||
else: quit(errorStr(p, "unknown value; use: yes|no"))
|
else: quit(errorStr(p, "unknown value; use: yes|no"))
|
||||||
|
|
||||||
proc incl(s: var seq[string], x: string): int =
|
func incl(s: var seq[string], x: string): int =
|
||||||
for i in 0 ..< s.len:
|
for i in 0 ..< s.len:
|
||||||
if cmpIgnoreStyle(s[i], x) == 0: return i
|
if cmpIgnoreStyle(s[i], x) == 0: return i
|
||||||
s.add(x)
|
s.add(x)
|
||||||
result = s.len-1
|
result = s.len-1
|
||||||
|
|
||||||
proc platforms(c: var ConfigData, v: string) =
|
func platforms(c: var ConfigData, v: string) =
|
||||||
for line in splitLines(v):
|
for line in splitLines(v):
|
||||||
let p = line.find(": ")
|
let p = line.find(": ")
|
||||||
if p <= 1: continue
|
if p <= 1: continue
|
||||||
|
|
@ -462,10 +453,10 @@ proc readCFiles(c: var ConfigData, osA, cpuA: int) =
|
||||||
else:
|
else:
|
||||||
quit("Cannot open: " & f)
|
quit("Cannot open: " & f)
|
||||||
|
|
||||||
proc buildDir(os, cpu: int): string =
|
func buildDir(os, cpu: int): string =
|
||||||
return "c_code" / ($os & "_" & $cpu)
|
"c_code" / ($os & "_" & $cpu)
|
||||||
|
|
||||||
proc getOutputDir(c: var ConfigData): string =
|
func getOutputDir(c: var ConfigData): string =
|
||||||
if c.outdir.len > 0: c.outdir else: "build"
|
if c.outdir.len > 0: c.outdir else: "build"
|
||||||
|
|
||||||
proc writeFile(filename, content, newline: string) =
|
proc writeFile(filename, content, newline: string) =
|
||||||
|
|
@ -596,42 +587,6 @@ proc setupDist2(c: var ConfigData) =
|
||||||
else:
|
else:
|
||||||
quit("External program failed")
|
quit("External program failed")
|
||||||
|
|
||||||
# ------------------ generate ZIP file ---------------------------------------
|
|
||||||
when haveZipLib:
|
|
||||||
proc zipDist(c: var ConfigData) =
|
|
||||||
var proj = toLowerAscii(c.name) & "-" & c.version
|
|
||||||
var n = "$#.zip" % proj
|
|
||||||
if c.outdir.len == 0: n = "build" / n
|
|
||||||
else: n = c.outdir / n
|
|
||||||
var z: ZipArchive
|
|
||||||
if open(z, n, fmWrite):
|
|
||||||
addFile(z, proj / buildBatFile, "build" / buildBatFile)
|
|
||||||
addFile(z, proj / buildBatFile32, "build" / buildBatFile32)
|
|
||||||
addFile(z, proj / buildBatFile64, "build" / buildBatFile64)
|
|
||||||
addFile(z, proj / buildShFile, "build" / buildShFile)
|
|
||||||
addFile(z, proj / makeFile, "build" / makeFile)
|
|
||||||
addFile(z, proj / installShFile, installShFile)
|
|
||||||
addFile(z, proj / deinstallShFile, deinstallShFile)
|
|
||||||
|
|
||||||
template addFileAux(src, dst) = addFile(z, dst, src)
|
|
||||||
gatherFiles(addFileAux, c.libpath, proj / "c_code")
|
|
||||||
for osA in 1..c.oses.len:
|
|
||||||
for cpuA in 1..c.cpus.len:
|
|
||||||
var dir = buildDir(osA, cpuA)
|
|
||||||
for k, f in walkDir("build" / dir):
|
|
||||||
if k == pcFile: addFile(z, proj / dir / extractFilename(f), f)
|
|
||||||
|
|
||||||
for cat in items({fcConfig..fcOther, fcUnix, fcNimble}):
|
|
||||||
for f in items(c.cat[cat]): addFile(z, proj / f, f)
|
|
||||||
|
|
||||||
# Copy the .nimble file over
|
|
||||||
let nimbleFile = c.nimblePkgName & ".nimble"
|
|
||||||
processFile(z, proj / nimbleFile, nimbleFile)
|
|
||||||
|
|
||||||
close(z)
|
|
||||||
else:
|
|
||||||
quit("Cannot open for writing: " & n)
|
|
||||||
|
|
||||||
proc xzDist(c: var ConfigData; windowsZip=false) =
|
proc xzDist(c: var ConfigData; windowsZip=false) =
|
||||||
let proj = toLowerAscii(c.name) & "-" & c.version
|
let proj = toLowerAscii(c.name) & "-" & c.version
|
||||||
let tmpDir = if c.outdir.len == 0: "build" else: c.outdir
|
let tmpDir = if c.outdir.len == 0: "build" else: c.outdir
|
||||||
|
|
@ -753,21 +708,23 @@ proc debDist(c: var ConfigData) =
|
||||||
|
|
||||||
# ------------------- main ----------------------------------------------------
|
# ------------------- main ----------------------------------------------------
|
||||||
|
|
||||||
var c: ConfigData
|
proc main() =
|
||||||
iniConfigData(c)
|
var c: ConfigData
|
||||||
parseCmdLine(c)
|
iniConfigData(c)
|
||||||
parseIniFile(c)
|
parseCmdLine(c)
|
||||||
if actionInno in c.actions:
|
parseIniFile(c)
|
||||||
setupDist(c)
|
if actionInno in c.actions:
|
||||||
if actionNsis in c.actions:
|
setupDist(c)
|
||||||
setupDist2(c)
|
if actionNsis in c.actions:
|
||||||
if actionCSource in c.actions:
|
setupDist2(c)
|
||||||
srcdist(c)
|
if actionCSource in c.actions:
|
||||||
if actionScripts in c.actions:
|
srcdist(c)
|
||||||
writeInstallScripts(c)
|
if actionScripts in c.actions:
|
||||||
if actionZip in c.actions:
|
writeInstallScripts(c)
|
||||||
xzDist(c, true)
|
if actionXz in c.actions:
|
||||||
if actionXz in c.actions:
|
xzDist(c)
|
||||||
xzDist(c)
|
if actionDeb in c.actions:
|
||||||
if actionDeb in c.actions:
|
debDist(c)
|
||||||
debDist(c)
|
|
||||||
|
when isMainModule:
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue