added tools and web dirs

This commit is contained in:
Andreas Rumpf 2009-09-15 23:22:22 +02:00
commit 66a7e3d37c
489 changed files with 4593 additions and 9878 deletions

97
tools/build.tmpl Executable file
View file

@ -0,0 +1,97 @@
#subsChar ?
#proc GenerateBuildScript(c: TConfigData): string =
# result = "#! /bin/sh\n# Generated by niminst\n"
CC="gcc"
LINKER="gcc"
COMP_FLAGS="-w -O3 -fno-strict-aliasing"
LINK_FLAGS=""
# add(result, "# platform detection\n")
ucpu=`uname -m`
uos=`uname`
# add(result, "# convert to lower case:\n")
upcu=`echo $ucpu | tr "[:upper:]" "[:lower:]"`
uos=`echo $uos | tr "[:upper:]" "[:lower:]"`
case $uos in
*linux* )
myos="linux"
LINK_FLAGS="$LINK_FLAGS -ldl -lm"
;;
*freebsd* )
myos="freebsd"
LINK_FLAGS="$LINK_FLAGS -lm"
;;
*openbsd* )
myos="openbsd"
LINK_FLAGS="$LINK_FLAGS -lm"
;;
*netbsd* )
myos="netbsd"
LINK_FLAGS="$LINK_FLAGS -lm"
;;
*darwin* )
myos="macosx"
LINK_FLAGS="$LINK_FLAGS -ldl -lm"
;;
*aix* )
myos="aix"
LINK_FLAGS="$LINK_FLAGS -ldl -lm"
;;
*solaris* | *sun* )
myos="solaris"
LINK_FLAGS="$LINK_FLAGS -ldl -lm"
;;
*)
echo "Error: unknown operating system: $uos"
exit 1
;;
esac
case $ucpu in
*i386* | *i486* | *i586* | *i686* )
mycpu="i386" ;;
*amd*64* | *x86-64* | *x86_64* )
mycpu="amd64" ;;
*sparc*|*sun* )
mycpu="sparc" ;;
*power* )
mycpu="powerpc" ;;
*mips* )
mycpu="mips" ;;
*)
echo "Error: unknown processor: $ucpu"
exit 1
;;
esac
# add(result, "# write ``build/platdef.c`` file\n")
cat >build/platdef.c <<EOF
char* nimOS(void) { return "$myos"; }
char* nimCPU(void) { return "$mycpu"; }
EOF
# add(result, "# call the compiler:\n")
case $myos in
# for osA in 1..c.oses.len:
?{c.oses[osA-1]})
case $mycpu in
# for cpuA in 1..c.cpus.len:
?{c.cpus[cpuA-1]})
# var linkCmd = "build/platdef.o"
# for f in items(c.cfiles[osA][cpuA]):
echo "$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}"
$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")} || exit 1
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
# end for
$CC $COMP_FLAGS -Ibuild -c build/platdef.c -o build/platdef.o || exit 1
echo "$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd"
$LINKER $LINK_FLAGS -o ?{c.binPaths[0]}/?{toLower(c.name)} ?linkCmd || exit 1
;;
# end for
esac
;;
# end for
esac
echo "SUCCESS"

62
tools/deinstall.tmpl Executable file
View file

@ -0,0 +1,62 @@
#subsChar ?
#proc GenerateDeinstallScript(c: TConfigData): string =
# result = "#! /bin/sh\n# Generated by niminst\n"
# var proj = c.name.toLower
if [ $# -eq 1 ] ; then
case $1 in
"--help"|"-h"|"help"|"h")
echo "?c.name deinstallation script"
echo "Usage: [sudo] sh deinstall.sh DIR"
echo "Where DIR may be:"
echo " /usr/bin"
echo " /usr/local/bin"
echo " /opt"
echo " <some other dir> (treated like '/opt')"
exit 1
;;
"/usr/bin")
bindir=/usr/bin
configdir=/etc
libdir=/usr/lib/?proj
docdir=/usr/share/?proj/doc
datadir=/usr/share/?proj/data
;;
"/usr/local/bin")
bindir=/usr/local/bin
configdir=/etc
libdir=/usr/local/lib/?proj
docdir=/usr/local/share/?proj/doc
datadir=/usr/local/share/?proj/data
;;
*)
bindir="$1/?proj/bin"
configdir="$1/?proj/config"
libdir="$1/?proj/lib"
docdir="$1/?proj/doc"
datadir="$1/?proj/data"
;;
esac
echo "removing files..."
#for f in items(c.cat[fcUnixBin]):
rm -f $bindir/?f.skipRoot
#end for
#for f in items(c.cat[fcConfig]):
rm -f $configdir/?f.skipRoot
#end for
rm -rf $docdir
rm -rf $datadir
rm -rf $libdir
echo "deinstallation successful"
else
echo "?c.name deinstallation script"
echo "Usage: [sudo] sh deinstall.sh DIR"
echo "Where DIR may be:"
echo " /usr/bin"
echo " /usr/local/bin"
echo " /opt"
echo " <some other dir> (treated like '/opt')"
exit 1
fi

0
tools/inno.tmpl Normal file → Executable file
View file

0
tools/install.tmpl Normal file → Executable file
View file

39
tools/niminst.nim Normal file → Executable file
View file

@ -96,7 +96,7 @@ include "deinstall.tmpl"
# ------------------------- configuration file -------------------------------
const
Version = "0.6"
Version = "0.7"
Usage = "niminst - Nimrod Installation Generator Version " & version & """
(c) 2009 Andreas Rumpf
@ -175,7 +175,7 @@ proc pathFlags(p: var TCfgParser, k, v: string,
proc filesOnly(p: var TCfgParser, k, v: string, dest: var seq[string]) =
case normalize(k)
of "files": addFiles(dest, splitSeq(v, {';'}))
of "files": addFiles(dest, split(v, {';'}))
else: quit(errorStr(p, "unknown variable: " & k))
proc yesno(p: var TCfgParser, v: string): bool =
@ -208,9 +208,9 @@ proc parseIniFile(c: var TConfigData) =
case normalize(k.key)
of "name": c.name = v
of "version": c.version = v
of "os": c.oses = splitSeq(v, {';'})
of "cpu": c.cpus = splitSeq(v, {';'})
of "authors": c.authors = splitSeq(v, {';'})
of "os": c.oses = split(v, {';'})
of "cpu": c.cpus = split(v, {';'})
of "authors": c.authors = split(v, {';'})
of "description": c.description = v
of "app":
case normalize(v)
@ -228,13 +228,13 @@ proc parseIniFile(c: var TConfigData) =
of "other": filesOnly(p, k.key, v, c.cat[fcOther])
of "windows":
case normalize(k.key)
of "files": addFiles(c.cat[fcWindows], splitSeq(v, {';'}))
of "binpath": c.binPaths = splitSeq(v, {';'})
of "files": addFiles(c.cat[fcWindows], split(v, {';'}))
of "binpath": c.binPaths = split(v, {';'})
of "innosetup": c.innoSetupFlag = yesno(p, v)
else: quit(errorStr(p, "unknown variable: " & k.key))
of "unix":
case normalize(k.key)
of "files": addFiles(c.cat[fcUnix], splitSeq(v, {';'}))
of "files": addFiles(c.cat[fcUnix], split(v, {';'}))
of "installscript": c.installScript = yesno(p, v)
of "uninstallscript": c.uninstallScript = yesno(p, v)
else: quit(errorStr(p, "unknown variable: " & k.key))
@ -279,10 +279,12 @@ proc readCFiles(c: var TConfigData, osA, cpuA: int) =
proc buildDir(os, cpu: int): string =
return "build" / ($os & "_" & $cpu)
proc writeFile(filename, content: string) =
proc writeFile(filename, content, newline: string) =
var f: TFile
if open(f, filename, fmWrite):
writeln(f, content)
for x in splitLines(content):
write(f, x)
write(f, newline)
close(f)
else:
quit("Cannot open for writing: " & filename)
@ -299,7 +301,7 @@ proc srcdist(c: var TConfigData) =
" --os:$# --cpu:$# $# $#") %
[c.oses[osA-1], c.cpus[cpuA-1], c.nimrodArgs,
changeFileExt(c.infile, "nim")]
echo("Executing: " & cmd)
echo(cmd)
if executeShellCommand(cmd) != 0:
quit("Error: call to nimrod compiler failed")
readCFiles(c, osA, cpuA)
@ -322,19 +324,23 @@ proc srcdist(c: var TConfigData) =
# file is identical, so delete duplicate:
RemoveFile(dup)
c.cfiles[osA][cpuA][i] = orig
writeFile(buildShFile, GenerateBuildScript(c))
writeFile(buildShFile, GenerateBuildScript(c), "\10")
if c.installScript:
writeFile(installShFile, GenerateInstallScript(c), "\10")
if c.uninstallScript:
writeFile(deinstallShFile, GenerateDeinstallScript(c), "\10")
# --------------------- generate inno setup -----------------------------------
proc setupDist(c: var TConfigData) =
var scrpt = GenerateInnoSetup(c)
var n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version]
writeFile(n, scrpt)
writeFile(n, scrpt, "\13\10")
when defined(windows):
if c.innoSetup.path.len == 0:
c.innoSetup.path = "iscc.exe"
var outcmd = if c.outdir.len == 0: "build" else: c.outdir
var cmd = "$# $# /O$# $#" % [c.innoSetup.path, c.innoSetup.flags, outcmd, n]
Echo("Executing: " & cmd)
Echo(cmd)
if executeShellCommand(cmd) == 0:
removeFile(n)
else:
@ -343,11 +349,6 @@ proc setupDist(c: var TConfigData) =
# ------------------ generate ZIP file ---------------------------------------
when haveZipLib:
proc zipDist(c: var TConfigData) =
if c.installScript:
writeFile(installShFile, GenerateInstallScript(c))
if c.uninstallScript:
writeFile(deinstallShFile, GenerateDeinstallScript(c))
var proj = toLower(c.name)
var n = "$#_$#.zip" % [proj, c.version]
if c.outdir.len == 0: n = "build" / n

9
tools/nimweb.nim Normal file → Executable file
View file

@ -1,6 +1,6 @@
#
#
# The Nimrod Website Generator
# Nimrod Website Generator
# (c) Copyright 2009 Andreas Rumpf
#
# See the file "copying.txt", included in this
@ -131,9 +131,9 @@ proc parseIniFile(c: var TConfigData) =
of "ticker": c.ticker = v
of "documentation":
case normalize(k.key)
of "doc": addFiles(c.doc, "doc", ".txt", splitSeq(v, {';'}))
of "srcdoc": addFiles(c.srcdoc, "lib", ".nim", splitSeq(v, {';'}))
of "webdoc": addFiles(c.webdoc, "lib", ".nim", splitSeq(v, {';'}))
of "doc": addFiles(c.doc, "doc", ".txt", split(v, {';'}))
of "srcdoc": addFiles(c.srcdoc, "lib", ".nim", split(v, {';'}))
of "webdoc": addFiles(c.webdoc, "lib", ".nim", split(v, {';'}))
else: quit(errorStr(p, "unknown variable: " & k.key))
else: nil
@ -159,6 +159,7 @@ proc buildDoc(c: var TConfigData, destPath: string) =
Exec("nimrod rst2html $# -o:$# --index=$#/theindex $#" %
[c.nimrodArgs, destPath / changeFileExt(extractFileTrunk(d), "html"),
destpath, d])
Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])
for d in items(c.srcdoc):
Exec("nimrod doc $# -o:$# --index=$#/theindex $#" %
[c.nimrodArgs, destPath / changeFileExt(extractFileTrunk(d), "html"),

0
tools/sunset.tmpl Normal file → Executable file
View file

28
tools/trimcc.nim Executable file
View file

@ -0,0 +1,28 @@
# Trim C compiler installation to a minimum
import strutils, os
proc newName(f: string): string =
return extractDir(f) / "trim_" & extractFilename(f)
proc walker(dir: string) =
for kind, path in walkDir(dir):
case kind
of pcFile:
moveFile(newName(path), path)
# test if installation still works:
if executeShellCommand(r"nimrod c --force_build tests\tlastmod") == 0:
echo "Optional: ", path
removeFile(newName(path))
else:
echo "Required: ", path
# copy back:
moveFile(path, newName(path))
of pcDirectory:
walker(path)
else: nil
if paramCount() == 1:
walker(paramStr(1))
else:
echo "Usage: trimcc c_compiler_directory"