the installer can generate tar.gz

This commit is contained in:
Araq 2015-04-29 19:59:06 +02:00
commit 813a4f1d83
2 changed files with 70 additions and 18 deletions

View file

@ -106,6 +106,12 @@ proc zip(args: string) =
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
["tools/niminst/niminst".exe, VersionAsString]) ["tools/niminst/niminst".exe, VersionAsString])
proc targz(args: string) =
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst, findNim()])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim targz compiler/installer.ini" %
["tools" / "niminst" / "niminst".exe, VersionAsString])
proc buildTool(toolname, args: string) = proc buildTool(toolname, args: string) =
exec("$# cc $# $#" % [findNim(), args, toolname]) exec("$# cc $# $#" % [findNim(), args, toolname])
copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe) copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe)
@ -118,7 +124,7 @@ proc nsis(args: string) =
exec "nim c compiler" / "nim.nim" exec "nim c compiler" / "nim.nim"
copyExe("compiler/nim".exe, "bin/nim_debug".exe) copyExe("compiler/nim".exe, "bin/nim_debug".exe)
exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" & exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" &
" nsis compiler/nim") % [VersionAsString, $(sizeof(pointer)*8)]) " nsis compiler/installer.ini") % [VersionAsString, $(sizeof(pointer)*8)])
proc install(args: string) = proc install(args: string) =
exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
@ -308,12 +314,14 @@ proc winRelease() =
#buildTool("tools/niminst/niminst", " -d:release") #buildTool("tools/niminst/niminst", " -d:release")
buildTool("tools/nimgrep", " -d:release") buildTool("tools/nimgrep", " -d:release")
buildTool("compiler/nimfix/nimfix", " -d:release") buildTool("compiler/nimfix/nimfix", " -d:release")
buildTool("compiler/nimsuggest/nimsuggest", " -d:release")
#run7z("win32", "bin/nim.exe", "bin/c2nim.exe", "bin/nimgrep.exe",
# "bin/nimfix.exe",
# "bin/nimble.exe", "bin/*.dll",
# "config", "dist/*.dll", "examples", "lib",
# "readme.txt", "contributors.txt", "copying.txt")
run7z("win32", "bin/nim.exe", "bin/c2nim.exe", "bin/nimgrep.exe",
"bin/nimfix.exe",
"bin/nimble.exe", "bin/*.dll",
"config", "dist/*.dll", "examples", "lib",
"readme.txt", "contributors.txt", "copying.txt")
# second step: XXX build 64 bit version # second step: XXX build 64 bit version
# -------------- tests -------------------------------------------------------- # -------------- tests --------------------------------------------------------
@ -357,6 +365,7 @@ of cmdArgument:
of "pdf": pdf() of "pdf": pdf()
of "csource", "csources": csource(op.cmdLineRest) of "csource", "csources": csource(op.cmdLineRest)
of "zip": zip(op.cmdLineRest) of "zip": zip(op.cmdLineRest)
of "targz": targz(op.cmdLineRest)
of "nsis": nsis(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest)
of "install": install(op.cmdLineRest) of "install": install(op.cmdLineRest)
of "test", "tests": tests(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest)

View file

@ -35,6 +35,7 @@ type
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 actionZip, # action: create zip file
actionTargz, # action: create targz file
actionDeb # action: prepare deb package actionDeb # action: prepare deb package
FileCategory = enum FileCategory = enum
@ -171,6 +172,7 @@ proc parseCmdLine(c: var ConfigData) =
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 "zip": incl(c.actions, actionZip)
of "targz": incl(c.actions, actionTargz)
of "inno": incl(c.actions, actionInno) of "inno": incl(c.actions, actionInno)
of "nsis": incl(c.actions, actionNsis) of "nsis": incl(c.actions, actionNsis)
of "deb": incl(c.actions, actionDeb) of "deb": incl(c.actions, actionDeb)
@ -558,6 +560,45 @@ when haveZipLib:
else: else:
quit("Cannot open for writing: " & n) quit("Cannot open for writing: " & n)
proc targzDist(c: var ConfigData) =
let proj = toLower(c.name) & "-" & c.version
var n = "$#.tar.gz" % proj
let tmpDir = if c.outdir.len == 0: "build" else: c.outdir
template processFile(z, dest, src) =
let s = src
let d = dest
echo "Copying ", s, " to ", tmpDir / d
let destdir = tmpdir / d.splitFile.dir
if not dirExists(destdir): createDir(destdir)
copyFile(s, tmpDir / d)
processFile(z, proj / buildBatFile32, "build" / buildBatFile32)
processFile(z, proj / buildBatFile64, "build" / buildBatFile64)
processFile(z, proj / buildShFile, "build" / buildShFile)
processFile(z, proj / makeFile, "build" / makeFile)
processFile(z, proj / installShFile, installShFile)
processFile(z, proj / deinstallShFile, deinstallShFile)
for f in walkFiles(c.libpath / "lib/*.h"):
processFile(z, proj / "c_code" / extractFilename(f), f)
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: processFile(z, proj / dir / extractFilename(f), f)
for cat in items({fcConfig..fcOther, fcUnix}):
for f in items(c.cat[cat]): processFile(z, proj / f, f)
let oldDir = getCurrentDir()
setCurrentDir(tmpDir)
try:
if execShellCmd("7z a -ttar $1.tar $1" % proj) != 0 or
execShellCmd("7z a -tgzip $1.tar.gz $1.tar" % proj) != 0:
echo("External program failed")
finally:
setCurrentDir(oldDir)
# -- prepare build files for .deb creation # -- prepare build files for .deb creation
proc debDist(c: var ConfigData) = proc debDist(c: var ConfigData) =
@ -624,5 +665,7 @@ if actionZip in c.actions:
zipDist(c) zipDist(c)
else: else:
quit("libzip is not installed") quit("libzip is not installed")
if actionTargz in c.actions:
targzDist(c)
if actionDeb in c.actions: if actionDeb in c.actions:
debDist(c) debDist(c)