mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 04:57:49 +00:00
the installer can generate tar.gz
This commit is contained in:
21
koch.nim
21
koch.nim
@@ -106,6 +106,12 @@ proc zip(args: string) =
|
||||
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
|
||||
["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) =
|
||||
exec("$# cc $# $#" % [findNim(), args, toolname])
|
||||
copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe)
|
||||
@@ -118,7 +124,7 @@ proc nsis(args: string) =
|
||||
exec "nim c compiler" / "nim.nim"
|
||||
copyExe("compiler/nim".exe, "bin/nim_debug".exe)
|
||||
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) =
|
||||
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/nimgrep", " -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
|
||||
|
||||
# -------------- tests --------------------------------------------------------
|
||||
@@ -357,6 +365,7 @@ of cmdArgument:
|
||||
of "pdf": pdf()
|
||||
of "csource", "csources": csource(op.cmdLineRest)
|
||||
of "zip": zip(op.cmdLineRest)
|
||||
of "targz": targz(op.cmdLineRest)
|
||||
of "nsis": nsis(op.cmdLineRest)
|
||||
of "install": install(op.cmdLineRest)
|
||||
of "test", "tests": tests(op.cmdLineRest)
|
||||
|
||||
@@ -35,6 +35,7 @@ type
|
||||
actionNsis, # action: create NSIS installer
|
||||
actionScripts # action: create install and deinstall scripts
|
||||
actionZip, # action: create zip file
|
||||
actionTargz, # action: create targz file
|
||||
actionDeb # action: prepare deb package
|
||||
|
||||
FileCategory = enum
|
||||
@@ -171,6 +172,7 @@ proc parseCmdLine(c: var ConfigData) =
|
||||
of "csource": incl(c.actions, actionCSource)
|
||||
of "scripts": incl(c.actions, actionScripts)
|
||||
of "zip": incl(c.actions, actionZip)
|
||||
of "targz": incl(c.actions, actionTargz)
|
||||
of "inno": incl(c.actions, actionInno)
|
||||
of "nsis": incl(c.actions, actionNsis)
|
||||
of "deb": incl(c.actions, actionDeb)
|
||||
@@ -181,10 +183,10 @@ proc parseCmdLine(c: var ConfigData) =
|
||||
break
|
||||
of cmdLongoption, cmdShortOption:
|
||||
case normalize(key.string)
|
||||
of "help", "h":
|
||||
of "help", "h":
|
||||
stdout.write(Usage)
|
||||
quit(0)
|
||||
of "version", "v":
|
||||
of "version", "v":
|
||||
stdout.write(Version & "\n")
|
||||
quit(0)
|
||||
of "o", "output": c.outdir = val
|
||||
@@ -240,7 +242,7 @@ proc incl(s: var seq[string], x: string): int =
|
||||
for i in 0.. <s.len:
|
||||
if cmpIgnoreStyle(s[i], x) == 0: return i
|
||||
s.add(x)
|
||||
result = s.len-1
|
||||
result = s.len-1
|
||||
|
||||
proc platforms(c: var ConfigData, v: string) =
|
||||
for line in splitLines(v):
|
||||
@@ -277,17 +279,17 @@ proc parseIniFile(c: var ConfigData) =
|
||||
of "name": c.name = v
|
||||
of "displayname": c.displayName = v
|
||||
of "version": c.version = v
|
||||
of "os":
|
||||
of "os":
|
||||
c.oses = split(v, {';'})
|
||||
hasCpuOs = true
|
||||
if c.explicitPlatforms:
|
||||
quit(errorStr(p, "you cannot have both 'platforms' and 'os'"))
|
||||
of "cpu":
|
||||
of "cpu":
|
||||
c.cpus = split(v, {';'})
|
||||
hasCpuOs = true
|
||||
if c.explicitPlatforms:
|
||||
quit(errorStr(p, "you cannot have both 'platforms' and 'cpu'"))
|
||||
of "platforms":
|
||||
of "platforms":
|
||||
platforms(c, v)
|
||||
c.explicitPlatforms = true
|
||||
if hasCpuOs:
|
||||
@@ -389,7 +391,7 @@ proc readCFiles(c: var ConfigData, osA, cpuA: int) =
|
||||
of cfgKeyValuePair:
|
||||
case section
|
||||
of "ccompiler": pathFlags(p, k.key, k.value, c.ccompiler)
|
||||
of "linker":
|
||||
of "linker":
|
||||
pathFlags(p, k.key, k.value, c.linker)
|
||||
# HACK: we conditionally add ``-lm -ldl``, so remove them from the
|
||||
# linker flags:
|
||||
@@ -558,28 +560,67 @@ when haveZipLib:
|
||||
else:
|
||||
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
|
||||
|
||||
proc debDist(c: var ConfigData) =
|
||||
if not existsFile(getOutputDir(c) / "build.sh"): quit("No build.sh found.")
|
||||
if not existsFile(getOutputDir(c) / "install.sh"): quit("No install.sh found.")
|
||||
|
||||
|
||||
if c.debOpts.shortDesc == "": quit("shortDesc must be set in the .ini file.")
|
||||
if c.debOpts.licenses.len == 0:
|
||||
echo("[Warning] No licenses specified for .deb creation.")
|
||||
|
||||
|
||||
# -- Copy files into /tmp/..
|
||||
echo("Copying source to tmp/niminst/deb/")
|
||||
var currentSource = getCurrentDir()
|
||||
var workingDir = getTempDir() / "niminst" / "deb"
|
||||
var upstreamSource = (c.name.toLower() & "-" & c.version)
|
||||
|
||||
|
||||
createDir(workingDir / upstreamSource)
|
||||
|
||||
|
||||
template copyNimDist(f, dest: string): stmt =
|
||||
createDir((workingDir / upstreamSource / dest).splitFile.dir)
|
||||
copyFile(currentSource / f, workingDir / upstreamSource / dest)
|
||||
|
||||
|
||||
# Don't copy all files, only the ones specified in the config:
|
||||
copyNimDist(buildShFile, buildShFile)
|
||||
copyNimDist(makeFile, makeFile)
|
||||
@@ -624,5 +665,7 @@ if actionZip in c.actions:
|
||||
zipDist(c)
|
||||
else:
|
||||
quit("libzip is not installed")
|
||||
if actionTargz in c.actions:
|
||||
targzDist(c)
|
||||
if actionDeb in c.actions:
|
||||
debDist(c)
|
||||
|
||||
Reference in New Issue
Block a user