niminst supports NSIS
This commit is contained in:
parent
b7befd69ba
commit
55d8e71ab1
3 changed files with 53 additions and 20 deletions
|
|
@ -34,11 +34,11 @@ Files: "config/nimdoc.cfg"
|
||||||
Files: "config/nimdoc.tex.cfg"
|
Files: "config/nimdoc.tex.cfg"
|
||||||
|
|
||||||
[Documentation]
|
[Documentation]
|
||||||
Files: "doc/*.txt"
|
; Files: "doc/*.txt"
|
||||||
Files: "doc/*.html"
|
; Files: "doc/*.html"
|
||||||
Files: "doc/*.cfg"
|
; Files: "doc/*.cfg"
|
||||||
Files: "doc/*.pdf"
|
; Files: "doc/*.pdf"
|
||||||
Files: "doc/*.ini"
|
; Files: "doc/*.ini"
|
||||||
Start: "doc/overview.html"
|
Start: "doc/overview.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,11 +121,14 @@ Files: "bin/nimgrep.exe"
|
||||||
|
|
||||||
Files: "dist/*.dll"
|
Files: "dist/*.dll"
|
||||||
Files: "koch.exe"
|
Files: "koch.exe"
|
||||||
Files: "dist/mingw"
|
; Files: "dist/mingw"
|
||||||
Files: "start.bat"
|
Files: "start.bat"
|
||||||
BinPath: r"bin;dist\mingw\bin;dist"
|
BinPath: r"bin;dist\mingw\bin;dist"
|
||||||
InnoSetup: "Yes"
|
|
||||||
|
|
||||||
|
; Section | dir | zipFile | size hint (in KB) | url
|
||||||
|
Download: r"Documentation|doc|docs.zip|13824|http://nim-lang.org/download/docs-${version}.zip"
|
||||||
|
Download: r"C compiler (mingw)|dist|mingw.zip|82944|http://nim-lang.org/download/${mingw}.zip"
|
||||||
|
; for now only NSIS supports optional downloads
|
||||||
|
|
||||||
[UnixBin]
|
[UnixBin]
|
||||||
Files: "bin/nimrod"
|
Files: "bin/nimrod"
|
||||||
|
|
@ -140,6 +143,9 @@ UninstallScript: "yes"
|
||||||
path = r"c:\Program Files (x86)\Inno Setup 5\iscc.exe"
|
path = r"c:\Program Files (x86)\Inno Setup 5\iscc.exe"
|
||||||
flags = "/Q"
|
flags = "/Q"
|
||||||
|
|
||||||
|
[NSIS]
|
||||||
|
path = r"c:\Program Files (x86)\NSIS\makensis.exe"
|
||||||
|
flags = ""
|
||||||
|
|
||||||
[C_Compiler]
|
[C_Compiler]
|
||||||
path = r""
|
path = r""
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ Name: modifypath; Description: &Add $c.displayName to your system path (if not i
|
||||||
[Code]
|
[Code]
|
||||||
function GiveMeAPath(const DefaultPathName: string): string;
|
function GiveMeAPath(const DefaultPathName: string): string;
|
||||||
begin
|
begin
|
||||||
if IsAdminLoggedOn then Result := ExpandConstant('{pf}')
|
if IsAdminLoggedOn then result := ExpandConstant('{pf}')
|
||||||
else Result := ExpandConstant('{userdocs}');
|
else result := ExpandConstant('{userdocs}');
|
||||||
Result := Result + '\' + DefaultPathName;
|
result := result + '\' + DefaultPathName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
#if c.binPaths.len > 0:
|
#if c.binPaths.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ type
|
||||||
actionNone, # action not yet known
|
actionNone, # action not yet known
|
||||||
actionCSource # action: create C sources
|
actionCSource # action: create C sources
|
||||||
actionInno, # action: create Inno Setup installer
|
actionInno, # action: create Inno Setup 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
|
||||||
actionDeb # action: prepare deb package
|
actionDeb # action: prepare deb package
|
||||||
|
|
@ -50,10 +51,10 @@ type
|
||||||
TConfigData = object of TObject
|
TConfigData = object of TObject
|
||||||
actions: set[TAction]
|
actions: set[TAction]
|
||||||
cat: array[TFileCategory, seq[string]]
|
cat: array[TFileCategory, seq[string]]
|
||||||
binPaths, authors, oses, cpus: seq[string]
|
binPaths, authors, oses, cpus, downloads: seq[string]
|
||||||
cfiles: array[1..maxOS, array[1..maxCPU, seq[string]]]
|
cfiles: array[1..maxOS, array[1..maxCPU, seq[string]]]
|
||||||
platforms: array[1..maxOS, array[1..maxCPU, bool]]
|
platforms: array[1..maxOS, array[1..maxCPU, bool]]
|
||||||
ccompiler, linker, innosetup: tuple[path, flags: string]
|
ccompiler, linker, innosetup, nsisSetup: tuple[path, flags: string]
|
||||||
name, displayName, version, description, license, infile, outdir: string
|
name, displayName, version, description, license, infile, outdir: string
|
||||||
libpath: string
|
libpath: string
|
||||||
innoSetupFlag, installScript, uninstallScript: bool
|
innoSetupFlag, installScript, uninstallScript: bool
|
||||||
|
|
@ -75,9 +76,11 @@ proc initConfigData(c: var TConfigData) =
|
||||||
c.authors = @[]
|
c.authors = @[]
|
||||||
c.oses = @[]
|
c.oses = @[]
|
||||||
c.cpus = @[]
|
c.cpus = @[]
|
||||||
|
c.downloads = @[]
|
||||||
c.ccompiler = ("", "")
|
c.ccompiler = ("", "")
|
||||||
c.linker = ("", "")
|
c.linker = ("", "")
|
||||||
c.innosetup = ("", "")
|
c.innosetup = ("", "")
|
||||||
|
c.nsisSetup = ("", "")
|
||||||
c.name = ""
|
c.name = ""
|
||||||
c.displayName = ""
|
c.displayName = ""
|
||||||
c.version = ""
|
c.version = ""
|
||||||
|
|
@ -117,6 +120,7 @@ proc skipRoot(f: string): string =
|
||||||
if result.len == 0: result = f
|
if result.len == 0: result = f
|
||||||
|
|
||||||
include "inno.tmpl"
|
include "inno.tmpl"
|
||||||
|
include "nsis.tmpl"
|
||||||
include "buildsh.tmpl"
|
include "buildsh.tmpl"
|
||||||
include "buildbat.tmpl"
|
include "buildbat.tmpl"
|
||||||
include "install.tmpl"
|
include "install.tmpl"
|
||||||
|
|
@ -125,10 +129,10 @@ include "deinstall.tmpl"
|
||||||
# ------------------------- configuration file -------------------------------
|
# ------------------------- configuration file -------------------------------
|
||||||
|
|
||||||
const
|
const
|
||||||
Version = "0.9"
|
Version = "1.0"
|
||||||
Usage = "niminst - Nimrod Installation Generator Version " & Version & """
|
Usage = "niminst - Nimrod Installation Generator Version " & Version & """
|
||||||
|
|
||||||
(c) 2013 Andreas Rumpf
|
(c) 2014 Andreas Rumpf
|
||||||
Usage:
|
Usage:
|
||||||
niminst [options] command[;command2...] ini-file[.ini] [compile_options]
|
niminst [options] command[;command2...] ini-file[.ini] [compile_options]
|
||||||
Command:
|
Command:
|
||||||
|
|
@ -136,6 +140,7 @@ Command:
|
||||||
scripts build install and deinstall scripts
|
scripts build install and deinstall scripts
|
||||||
zip build the ZIP file
|
zip build the ZIP file
|
||||||
inno build the Inno Setup installer
|
inno build the Inno Setup installer
|
||||||
|
nsis build the NSIS Setup installer
|
||||||
deb create files for debhelper
|
deb create files for debhelper
|
||||||
Options:
|
Options:
|
||||||
-o, --output:dir set the output directory
|
-o, --output:dir set the output directory
|
||||||
|
|
@ -162,6 +167,7 @@ proc parseCmdLine(c: var TConfigData) =
|
||||||
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 "inno": incl(c.actions, actionInno)
|
of "inno": incl(c.actions, actionInno)
|
||||||
|
of "nsis": incl(c.actions, actionNsis)
|
||||||
of "deb": incl(c.actions, actionDeb)
|
of "deb": incl(c.actions, actionDeb)
|
||||||
else: quit(Usage)
|
else: quit(Usage)
|
||||||
else:
|
else:
|
||||||
|
|
@ -190,7 +196,7 @@ proc walkDirRecursively(s: var seq[string], root: string) =
|
||||||
case k
|
case k
|
||||||
of pcFile, pcLinkToFile: add(s, unixToNativePath(f))
|
of pcFile, pcLinkToFile: add(s, unixToNativePath(f))
|
||||||
of pcDir: walkDirRecursively(s, f)
|
of pcDir: walkDirRecursively(s, f)
|
||||||
of pcLinkToDir: nil
|
of pcLinkToDir: discard
|
||||||
|
|
||||||
proc addFiles(s: var seq[string], patterns: seq[string]) =
|
proc addFiles(s: var seq[string], patterns: seq[string]) =
|
||||||
for p in items(patterns):
|
for p in items(patterns):
|
||||||
|
|
@ -288,7 +294,7 @@ proc parseIniFile(c: var TConfigData) =
|
||||||
else: quit(errorStr(p, "expected: console or gui"))
|
else: quit(errorStr(p, "expected: console or gui"))
|
||||||
of "license": c.license = unixToNativePath(k.value)
|
of "license": c.license = unixToNativePath(k.value)
|
||||||
else: quit(errorStr(p, "unknown variable: " & k.key))
|
else: quit(errorStr(p, "unknown variable: " & k.key))
|
||||||
of "var": nil
|
of "var": discard
|
||||||
of "winbin": filesOnly(p, k.key, v, c.cat[fcWinBin])
|
of "winbin": filesOnly(p, k.key, v, c.cat[fcWinBin])
|
||||||
of "config": filesOnly(p, k.key, v, c.cat[fcConfig])
|
of "config": filesOnly(p, k.key, v, c.cat[fcConfig])
|
||||||
of "data": filesOnly(p, k.key, v, c.cat[fcData])
|
of "data": filesOnly(p, k.key, v, c.cat[fcData])
|
||||||
|
|
@ -304,6 +310,7 @@ proc parseIniFile(c: var TConfigData) =
|
||||||
of "files": addFiles(c.cat[fcWindows], split(v, {';'}))
|
of "files": addFiles(c.cat[fcWindows], split(v, {';'}))
|
||||||
of "binpath": c.binPaths = split(v, {';'})
|
of "binpath": c.binPaths = split(v, {';'})
|
||||||
of "innosetup": c.innoSetupFlag = yesno(p, v)
|
of "innosetup": c.innoSetupFlag = yesno(p, v)
|
||||||
|
of "download": c.downloads.add(v)
|
||||||
else: quit(errorStr(p, "unknown variable: " & k.key))
|
else: quit(errorStr(p, "unknown variable: " & k.key))
|
||||||
of "unix":
|
of "unix":
|
||||||
case normalize(k.key)
|
case normalize(k.key)
|
||||||
|
|
@ -313,6 +320,7 @@ proc parseIniFile(c: var TConfigData) =
|
||||||
else: quit(errorStr(p, "unknown variable: " & k.key))
|
else: quit(errorStr(p, "unknown variable: " & k.key))
|
||||||
of "unixbin": filesOnly(p, k.key, v, c.cat[fcUnixBin])
|
of "unixbin": filesOnly(p, k.key, v, c.cat[fcUnixBin])
|
||||||
of "innosetup": pathFlags(p, k.key, v, c.innosetup)
|
of "innosetup": pathFlags(p, k.key, v, c.innosetup)
|
||||||
|
of "nsis": pathFlags(p, k.key, v, c.nsisSetup)
|
||||||
of "ccompiler": pathFlags(p, k.key, v, c.ccompiler)
|
of "ccompiler": pathFlags(p, k.key, v, c.ccompiler)
|
||||||
of "linker": pathFlags(p, k.key, v, c.linker)
|
of "linker": pathFlags(p, k.key, v, c.linker)
|
||||||
of "deb":
|
of "deb":
|
||||||
|
|
@ -479,14 +487,14 @@ proc srcdist(c: var TConfigData) =
|
||||||
|
|
||||||
# --------------------- generate inno setup -----------------------------------
|
# --------------------- generate inno setup -----------------------------------
|
||||||
proc setupDist(c: var TConfigData) =
|
proc setupDist(c: var TConfigData) =
|
||||||
var scrpt = generateInnoSetup(c)
|
let scrpt = generateInnoSetup(c)
|
||||||
var n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version]
|
let n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version]
|
||||||
writeFile(n, scrpt, "\13\10")
|
writeFile(n, scrpt, "\13\10")
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
if c.innosetup.path.len == 0:
|
if c.innosetup.path.len == 0:
|
||||||
c.innosetup.path = "iscc.exe"
|
c.innosetup.path = "iscc.exe"
|
||||||
var outcmd = if c.outdir.len == 0: "build" else: c.outdir
|
let outcmd = if c.outdir.len == 0: "build" else: c.outdir
|
||||||
var cmd = "$# $# /O$# $#" % [quoteShell(c.innosetup.path),
|
let cmd = "$# $# /O$# $#" % [quoteShell(c.innosetup.path),
|
||||||
c.innosetup.flags, outcmd, n]
|
c.innosetup.flags, outcmd, n]
|
||||||
echo(cmd)
|
echo(cmd)
|
||||||
if execShellCmd(cmd) == 0:
|
if execShellCmd(cmd) == 0:
|
||||||
|
|
@ -494,6 +502,23 @@ proc setupDist(c: var TConfigData) =
|
||||||
else:
|
else:
|
||||||
quit("External program failed")
|
quit("External program failed")
|
||||||
|
|
||||||
|
# --------------------- generate NSIS setup -----------------------------------
|
||||||
|
proc setupDist2(c: var TConfigData) =
|
||||||
|
let scrpt = generateNsisSetup(c)
|
||||||
|
let n = "build" / "install_$#_$#.nsi" % [toLower(c.name), c.version]
|
||||||
|
writeFile(n, scrpt, "\13\10")
|
||||||
|
when defined(windows):
|
||||||
|
if c.nsisSetup.path.len == 0:
|
||||||
|
c.nsisSetup.path = "makensis.exe"
|
||||||
|
let outcmd = if c.outdir.len == 0: "build" else: c.outdir
|
||||||
|
let cmd = "$# $# /O$# $#" % [quoteShell(c.nsisSetup.path),
|
||||||
|
c.nsisSetup.flags, outcmd, n]
|
||||||
|
echo(cmd)
|
||||||
|
if execShellCmd(cmd) == 0:
|
||||||
|
removeFile(n)
|
||||||
|
else:
|
||||||
|
quit("External program failed")
|
||||||
|
|
||||||
# ------------------ generate ZIP file ---------------------------------------
|
# ------------------ generate ZIP file ---------------------------------------
|
||||||
when haveZipLib:
|
when haveZipLib:
|
||||||
proc zipDist(c: var TConfigData) =
|
proc zipDist(c: var TConfigData) =
|
||||||
|
|
@ -576,6 +601,8 @@ parseCmdLine(c)
|
||||||
parseIniFile(c)
|
parseIniFile(c)
|
||||||
if actionInno in c.actions:
|
if actionInno in c.actions:
|
||||||
setupDist(c)
|
setupDist(c)
|
||||||
|
if actionNsis in c.actions:
|
||||||
|
setupDist2(c)
|
||||||
if actionCSource in c.actions:
|
if actionCSource in c.actions:
|
||||||
srcdist(c)
|
srcdist(c)
|
||||||
if actionScripts in c.actions:
|
if actionScripts in c.actions:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue