diff options
author | Araq <rumpf_a@web.de> | 2014-10-20 08:44:00 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-10-20 08:44:00 +0200 |
commit | 53a9d6f5cd199382957188cd8a1a7f0aa5035033 (patch) | |
tree | 9873032461904538e21cbff3417882d1b54ef881 | |
parent | c7570dcd3e4202bd339a2ebbc09952a546c62269 (diff) | |
parent | b0179f9af5c5ed3cc63c5cd3b9d1055b742a3b79 (diff) | |
download | Nim-53a9d6f5cd199382957188cd8a1a7f0aa5035033.tar.gz |
Merge branch 'devel' into bigbreak
Conflicts: compiler/nim.ini doc/manual.txt doc/tut2.txt koch.nim lib/system/channels.nim readme.txt tools/niminst/niminst.nim tools/nimweb.nim web/download.txt web/news.txt
-rw-r--r-- | compiler/commands.nim | 4 | ||||
-rw-r--r-- | compiler/docgen.nim | 2 | ||||
-rw-r--r-- | compiler/importer.nim | 6 | ||||
-rw-r--r-- | compiler/nim.ini | 36 | ||||
-rw-r--r-- | config/nimdoc.cfg | 6 | ||||
-rw-r--r-- | config/nimrod.cfg | 5 | ||||
-rw-r--r-- | copying.txt | 8 | ||||
-rw-r--r-- | doc/manual.txt | 1 | ||||
-rw-r--r-- | doc/tut2.txt | 12 | ||||
-rw-r--r-- | install.txt | 2 | ||||
-rw-r--r-- | koch.nim | 35 | ||||
-rw-r--r-- | lib/system/channels.nim | 19 | ||||
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | readme.txt | 60 | ||||
-rw-r--r-- | tests/modules/tselfimport.nim | 8 | ||||
-rw-r--r-- | tools/niminst/EnvVarUpdate.nsh | 346 | ||||
-rw-r--r-- | tools/niminst/inno.tmpl | 6 | ||||
-rw-r--r-- | tools/niminst/niminst.nim | 49 | ||||
-rw-r--r-- | tools/niminst/nsis.tmpl | 255 | ||||
-rw-r--r-- | tools/nimweb.nim | 18 | ||||
-rw-r--r-- | web/download.txt | 123 | ||||
-rw-r--r-- | web/news.txt | 77 | ||||
-rw-r--r-- | web/nim.ini | 7 | ||||
-rw-r--r-- | web/ticker.txt | 5 |
24 files changed, 814 insertions, 278 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index 616e50507..f26d1d6c7 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -395,7 +395,9 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = of "linedir": processOnOffSwitch({optLineDir}, arg, pass, info) of "assertions", "a": processOnOffSwitch({optAssert}, arg, pass, info) of "deadcodeelim": processOnOffSwitchG({optDeadCodeElim}, arg, pass, info) - of "threads": processOnOffSwitchG({optThreads}, arg, pass, info) + of "threads": + processOnOffSwitchG({optThreads}, arg, pass, info) + if optThreads in gGlobalOptions: incl(gNotes, warnGcUnsafe) of "tlsemulation": processOnOffSwitchG({optTlsEmulation}, arg, pass, info) of "taintmode": processOnOffSwitchG({optTaintMode}, arg, pass, info) of "implicitstatic": diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 273fcb7f3..8bd0bb490 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -383,6 +383,8 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = var seeSrcRope: PRope = nil let docItemSeeSrc = getConfigVar("doc.item.seesrc") if docItemSeeSrc.len > 0 and options.docSeeSrcUrl.len > 0: + # XXX toFilename doesn't really work. We need to ensure that this keeps + # returning a relative path. let urlRope = ropeFormatNamedVars(options.docSeeSrcUrl, ["path", "line"], [n.info.toFilename.toRope, toRope($n.info.line)]) dispA(seeSrcRope, "$1", "", [ropeFormatNamedVars(docItemSeeSrc, diff --git a/compiler/importer.nim b/compiler/importer.nim index 159dfa6a5..b9fd552bf 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -92,7 +92,7 @@ proc rawImportSymbol(c: PContext, s: PSym) = if s.kind == skConverter: addConverter(c, s) if hasPattern(s): addPattern(c, s) -proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = +proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = let ident = lookups.considerQuotedIdent(n) let s = strTableGet(fromMod.tab, ident) if s == nil: @@ -155,10 +155,12 @@ proc importModuleAs(n: PNode, realModule: PSym): PSym = # some misguided guy will write 'import abc.foo as foo' ... result = createModuleAlias(realModule, n.sons[1].ident, n.sons[1].info) -proc myImportModule(c: PContext, n: PNode): PSym = +proc myImportModule(c: PContext, n: PNode): PSym = var f = checkModuleName(n) if f != InvalidFileIDX: result = importModuleAs(n, gImportModule(c.module, f)) + if result.info.fileIndex == n.info.fileIndex: + localError(n.info, errGenerated, "A module cannot import itself") if sfDeprecated in result.flags: message(n.info, warnDeprecated, result.name.s) diff --git a/compiler/nim.ini b/compiler/nim.ini index 6f3f663d9..d9e0dc037 100644 --- a/compiler/nim.ini +++ b/compiler/nim.ini @@ -1,3 +1,6 @@ +; This config file holds configuration information about the Nim compiler +; and project. + [Project] Name: "Nim" Version: "$version" @@ -34,11 +37,11 @@ Files: "config/nimdoc.cfg" Files: "config/nimdoc.tex.cfg" [Documentation] -Files: "doc/*.txt" -Files: "doc/*.html" -Files: "doc/*.cfg" -Files: "doc/*.pdf" -Files: "doc/*.ini" +; Files: "doc/*.html" +; Files: "doc/*.cfg" +; Files: "doc/*.pdf" +; Files: "doc/*.ini" +Files: "doc/overview.html" Start: "doc/overview.html" @@ -61,13 +64,9 @@ Files: "compiler/readme.txt" Files: "compiler/nim.ini" Files: "compiler/nim.nimrod.cfg" Files: "compiler/*.nim" -Files: "compiler/c2nim/*.nim" -Files: "compiler/c2nim/*.cfg" -Files: "compiler/pas2nim/*.nim" -Files: "compiler/pas2nim/*.cfg" - -Files: "build/empty.txt" -Files: "bin/empty.txt" +Files: "doc/*.txt" +Files: "compiler/nimfix/*.nim" +Files: "compiler/nimfix/*.cfg" [Lib] @@ -115,17 +114,21 @@ Files: "examples/*.tmpl" [Windows] Files: "bin/nim.exe" +Files: "bin/nim_debug.exe" Files: "bin/c2nim.exe" -Files: "bin/niminst.exe" Files: "bin/nimgrep.exe" Files: "dist/*.dll" Files: "koch.exe" -Files: "dist/mingw" +; Files: "dist/mingw" Files: "start.bat" BinPath: r"bin;dist\mingw\bin;dist" -InnoSetup: "Yes" +; Section | dir | zipFile | size hint (in KB) | url | exe start menu entry +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" +Download: r"Aporia IDE|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.1.3.zip|aporia\bin\aporia.exe" +; for now only NSIS supports optional downloads [UnixBin] Files: "bin/nim" @@ -140,6 +143,9 @@ UninstallScript: "yes" path = r"c:\Program Files (x86)\Inno Setup 5\iscc.exe" flags = "/Q" +[NSIS] +path = r"c:\Program Files (x86)\NSIS\makensis.exe" +flags = "/V0" [C_Compiler] path = r"" diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index dc241db50..975c7c06a 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -41,7 +41,6 @@ doc.item = """ <dt id="$itemSym"><a name="$itemSymOrID"></a><pre>$header</pre></dt> <dd> $desc -$seeSrc </dd> """ @@ -93,6 +92,11 @@ doc.file = """<?xml version="1.0" encoding="utf-8" ?> <title>$title</title> <style type="text/css"> +body { + color: black; + background: white; +} + span.DecNumber {color: blue} span.BinNumber {color: blue} span.HexNumber {color: blue} diff --git a/config/nimrod.cfg b/config/nimrod.cfg index 6d56bba2c..b7210b329 100644 --- a/config/nimrod.cfg +++ b/config/nimrod.cfg @@ -132,10 +132,5 @@ vcc.options.always = "/nologo" vcc.options.speed = "/Ox /arch:SSE2" vcc.options.size = "/O1" -# Configuration for the Digital Mars C/C++ compiler: -@if windows: - dmc.path = r"$nimrod\dist\dm\bin" -@end - # Configuration for the Tiny C Compiler: tcc.options.always = "-w" diff --git a/copying.txt b/copying.txt index 4041ca027..254b91c77 100644 --- a/copying.txt +++ b/copying.txt @@ -1,7 +1,7 @@ -=============================================================================== -Nimrod -- a Compiler for Nimrod. http://nimrod-code.org/ - -Copyright (C) 2004-2014 Andreas Rumpf. All rights reserved. +===================================================== +Nimrod -- a Compiler for Nimrod. http://nimrod-lang.org/ + +Copyright (C) 2006-2014 Andreas Rumpf. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/manual.txt b/doc/manual.txt index 5c6f64344..2dbbf0447 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -12,6 +12,7 @@ Nim Manual user to one/some of the other players, but the total amount seems to remain pretty much constant for a given task. -- Ran + .. include:: manual/about.txt .. include:: manual/definitions.txt .. include:: manual/lexing.txt diff --git a/doc/tut2.txt b/doc/tut2.txt index 651c38838..34f59b1cb 100644 --- a/doc/tut2.txt +++ b/doc/tut2.txt @@ -438,18 +438,6 @@ module. Example: echo "Got exception ", repr(e), " with message ", msg -Exception hierarchy -------------------- - -If you want to create your own exceptions you can inherit from ``system.Exception``, -but you can also inherit from one of the existing exceptions if they fit your -purpose. The exception tree is: - -.. include:: exception_hierarchy_fragment.txt - -See the `system <system.html>`_ module for a description of each exception. - - Annotating procs with raised exceptions --------------------------------------- diff --git a/install.txt b/install.txt index 2883c8495..4543e4ece 100644 --- a/install.txt +++ b/install.txt @@ -58,8 +58,6 @@ Currently, the following C compilers are supported under Windows: | http://www.mingw.org/download.shtml - | LLVM with Clang or GNU C/C++ frontend | http://llvm.org/releases/download.html -- | Digital Mars C++ - | http://www.digitalmars.com/download/freecompiler.html However, most testing is done with GCC. diff --git a/koch.nim b/koch.nim index 3ea3475b9..f24d9bfbb 100644 --- a/koch.nim +++ b/koch.nim @@ -43,7 +43,7 @@ Possible Commands: web [options] generates the website csource [options] builds the C sources for installation zip builds the installation ZIP package - inno [options] builds the Inno Setup installer (for Windows) + nsis [options] builds the NSIS Setup installer (for Windows) tests [options] run the testsuite update updates nim to the latest version from github (compile koch with -d:withUpdate to enable) @@ -78,6 +78,14 @@ proc tryExec(cmd: string): bool = echo(cmd) result = execShellCmd(cmd) == 0 +proc safeRemove(filename: string) = + if existsFile(filename): removeFile(filename) + +proc copyExe(source, dest: string) = + safeRemove(dest) + copyFile(dest=dest, source=source) + inclFilePermissions(dest, {fpUserExec}) + const compileNimInst = "-d:useLibzipSrc tools/niminst/niminst" @@ -86,24 +94,27 @@ proc csource(args: string) = [args, NimVersion, compileNimInst, findNim()]) proc zip(args: string) = - exec("$3 cc -r $2 --var:version=$1 scripts compiler/nim.ini" % + exec("$3 cc -r $2 --var:version=$1 --var:mingw=mingw32 scripts compiler/nim.ini" % [NimVersion, compileNimInst, findNim()]) - exec("$# --var:version=$# zip compiler/nim.ini" % + exec("$# --var:version=$# --var:mingw=mingw32 zip compiler/nim.ini" % ["tools/niminst/niminst".exe, NimVersion]) proc buildTool(toolname, args: string) = exec("$# cc $# $#" % [findNim(), args, toolname]) copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe) -proc inno(args: string) = +proc nsis(args: string) = # make sure we have generated the niminst executables: buildTool("tools/niminst/niminst", args) buildTool("tools/nimgrep", args) - exec("tools" / "niminst" / "niminst --var:version=$# inno compiler/nim" % - NimVersion) + # produce 'nimrod_debug.exe': + exec "nim c compiler" / "nim.nim" + copyExe("compiler/nim".exe, "bin/nim_debug".exe) + exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw32" & + " nsis compiler/nim") % NimVersion) proc install(args: string) = - exec("$# cc -r $# --var:version=$# scripts compiler/nim.ini" % + exec("$# cc -r $# --var:version=$# --var:mingw=mingw32 scripts compiler/nim.ini" % [findNim(), compileNimInst, NimVersion]) exec("sh ./install.sh $#" % args) @@ -148,16 +159,8 @@ proc findStartNim: string = echo("Found no nim compiler and every attempt to build one failed!") quit("FAILURE") -proc safeRemove(filename: string) = - if existsFile(filename): removeFile(filename) - proc thVersion(i: int): string = result = ("compiler" / "nim" & $i).exe - -proc copyExe(source, dest: string) = - safeRemove(dest) - copyFile(dest=dest, source=source) - inclFilePermissions(dest, {fpUserExec}) proc boot(args: string) = var output = "compiler" / "nim".exe @@ -342,7 +345,7 @@ of cmdArgument: of "web": web(op.cmdLineRest) of "csource", "csources": csource(op.cmdLineRest) of "zip": zip(op.cmdLineRest) - of "inno": inno(op.cmdLineRest) + of "nsis": nsis(op.cmdLineRest) of "install": install(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest) of "update": diff --git a/lib/system/channels.nim b/lib/system/channels.nim index d7ec2c4af..4796ebb82 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -225,16 +225,17 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg = acquireSys(q.lock) llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) releaseSys(q.lock) - -proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvaliable: bool, - msg: TMsg] = - ## try to receives a message from the channel `c` if available. Otherwise - ## it returns ``(false, default(msg))``. + +proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, + msg: TMsg] = + ## try to receives a message from the channel `c` if available. Otherwise + ## it returns ``(false, default(msg))``. var q = cast[PRawChannel](addr(c)) - if q.mask != ChannelDeadMask: - lockChannel(q): - llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) - result.dataAvaliable = true + if q.mask != ChannelDeadMask: + if tryAcquireSys(q.lock): + llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) + result.dataAvailable = true + releaseSys(q.lock) proc peek*[TMsg](c: var TChannel[TMsg]): int = ## returns the current number of messages in the channel `c`. Returns -1 diff --git a/readme.md b/readme.md index 7c6fc8e45..a2f83b4b0 100644 --- a/readme.md +++ b/readme.md @@ -62,5 +62,5 @@ allowing you to create commercial applications. Read copying.txt for more details. -Copyright (c) 2004-2014 Andreas Rumpf. +Copyright (c) 2006-2014 Andreas Rumpf. All rights reserved. diff --git a/readme.txt b/readme.txt index 7c6fc8e45..e3119f83d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,60 +1,12 @@ -# Nim Compiler -This repo contains the Nim compiler, Nim's stdlib, tools and +This package contains the Nim compiler, Nim's stdlib, tools and documentation. -## Compiling -Compiling the Nim compiler is quite straightforward. Because -the Nim compiler itself is written in the Nim programming language -the C source of an older version of the compiler are needed to bootstrap the -latest version. The C sources are available in a separate repo [here](http://github.com/nim-code/csources). +Nim is a compiled, garbage-collected systems programming language which has +an excellent productivity/performance ratio. Nim's design focuses on +efficiency, expressiveness, elegance (in the order of priority). -Pre-compiled snapshots of the compiler are also available on -[Nimbuild](http://build.nim-lang.org/). Your platform however may not -currently be built for. +Read install.txt for instructions of how to build and install it. -The compiler currently supports the following platform and architecture -combinations: - - * Windows (Windows XP or greater) - x86 and x86_64 - * Linux (most, if not all, distributions) - x86, x86_64, ppc64 and armv6l - * Mac OS X 10.04 or higher - x86, x86_64 and ppc64 - -In reality a lot more are supported, however they are not tested regularly. - -To build from source you will need: - - * gcc 3.x or later recommended. Other alternatives which may work - are: clang, Visual C++, Intel's C++ compiler - * git or wget - -If you are on a fairly modern *nix system, the following steps should work: - -``` -$ git clone git://github.com/Araq/Nimrod.git -$ cd Nimrod -$ git clone --depth 1 git://github.com/nimrod-code/csources -$ cd csources && sh build.sh -$ cd .. -$ bin/nim c koch -$ ./koch boot -d:release -``` - -``koch install [dir]`` may then be used to install Nim, or you can simply -add it to your PATH. More ``koch`` related options are documented in -[doc/koch.txt](doc/koch.txt). - -The above steps can be performed on Windows in a similar fashion, the -``build.bat`` and ``build64.bat`` (for x86_64 systems) are provided to be used -instead of ``build.sh``. - -## Getting help -A [forum](http://forum.nim-lang.org/) is available if you have any -questions, and you can also get help in the IRC channel on -[Freenode](irc://irc.freenode.net/nim) in #nim. If you ask questions on -[StackOverflow use the nim -tag](http://stackoverflow.com/questions/tagged/nim). - -## License The compiler and the standard library are licensed under the MIT license, except for some modules where the documentation suggests otherwise. This means that you can use any license for your own programs developed with Nim, @@ -62,5 +14,5 @@ allowing you to create commercial applications. Read copying.txt for more details. -Copyright (c) 2004-2014 Andreas Rumpf. +Copyright (c) 2006-2014 Andreas Rumpf. All rights reserved. diff --git a/tests/modules/tselfimport.nim b/tests/modules/tselfimport.nim new file mode 100644 index 000000000..f20a40407 --- /dev/null +++ b/tests/modules/tselfimport.nim @@ -0,0 +1,8 @@ +discard """ + file: "tselfimport.nim" + line: 6 + errormsg: "A module cannot import itself" +""" +import tselfimport #ERROR +echo("Hello World") + diff --git a/tools/niminst/EnvVarUpdate.nsh b/tools/niminst/EnvVarUpdate.nsh new file mode 100644 index 000000000..4340b8f3c --- /dev/null +++ b/tools/niminst/EnvVarUpdate.nsh @@ -0,0 +1,346 @@ +/** + * EnvVarUpdate.nsh + * : Environmental Variables: append, prepend, and remove entries + * + * WARNING: If you use StrFunc.nsh header then include it before this file + * with all required definitions. This is to avoid conflicts + * + * Usage: + * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" + * + * Credits: + * Version 1.0 + * * Cal Turney (turnec2) + * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this + * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, + * WriteEnvStr, and un.DeleteEnvStr + * * Diego Pedroso (deguix) for StrTok + * * Kevin English (kenglish_hi) for StrContains + * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry + * (dandaman32) for StrReplace + * + * Version 1.1 (compatibility with StrFunc.nsh) + * * techtonik + * + * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries + * + */ + + +!ifndef ENVVARUPDATE_FUNCTION +!define ENVVARUPDATE_FUNCTION +!verbose push +!verbose 3 +!include "LogicLib.nsh" +!include "WinMessages.NSH" +!include "StrFunc.nsh" + +; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- +!macro _IncludeStrFunction StrFuncName + !ifndef ${StrFuncName}_INCLUDED + ${${StrFuncName}} + !endif + !ifndef Un${StrFuncName}_INCLUDED + ${Un${StrFuncName}} + !endif + !define un.${StrFuncName} "${Un${StrFuncName}}" +!macroend + +!insertmacro _IncludeStrFunction StrTok +!insertmacro _IncludeStrFunction StrStr +!insertmacro _IncludeStrFunction StrRep + +; ---------------------------------- Macro Definitions ---------------------------------------- +!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString + Push "${EnvVarName}" + Push "${Action}" + Push "${RegLoc}" + Push "${PathString}" + Call EnvVarUpdate + Pop "${ResultVar}" +!macroend +!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' + +!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString + Push "${EnvVarName}" + Push "${Action}" + Push "${RegLoc}" + Push "${PathString}" + Call un.EnvVarUpdate + Pop "${ResultVar}" +!macroend +!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' +; ---------------------------------- Macro Definitions end------------------------------------- + +;----------------------------------- EnvVarUpdate start---------------------------------------- +!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' +!define hkcu_current_user 'HKCU "Environment"' + +!macro EnvVarUpdate UN + +Function ${UN}EnvVarUpdate + + Push $0 + Exch 4 + Exch $1 + Exch 3 + Exch $2 + Exch 2 + Exch $3 + Exch + Exch $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R0 + + /* After this point: + ------------------------- + $0 = ResultVar (returned) + $1 = EnvVarName (input) + $2 = Action (input) + $3 = RegLoc (input) + $4 = PathString (input) + $5 = Orig EnvVar (read from registry) + $6 = Len of $0 (temp) + $7 = tempstr1 (temp) + $8 = Entry counter (temp) + $9 = tempstr2 (temp) + $R0 = tempChar (temp) */ + + ; Step 1: Read contents of EnvVarName from RegLoc + ; + ; Check for empty EnvVarName + ${If} $1 == "" + SetErrors + DetailPrint "ERROR: EnvVarName is blank" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Check for valid Action + ${If} $2 != "A" + ${AndIf} $2 != "P" + ${AndIf} $2 != "R" + SetErrors + DetailPrint "ERROR: Invalid Action - must be A, P, or R" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ${If} $3 == HKLM + ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 + ${ElseIf} $3 == HKCU + ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5 + ${Else} + SetErrors + DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Check for empty PathString + ${If} $4 == "" + SetErrors + DetailPrint "ERROR: PathString is blank" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + Push $6 + Push $7 + Push $8 + StrLen $7 $4 + StrLen $6 $5 + IntOp $8 $6 + $7 + ${If} $5 == "" + ${OrIf} $8 >= ${NSIS_MAX_STRLEN} + SetErrors + DetailPrint "Current $1 length ($6) too long to modify in NSIS; set manually if needed" + Pop $8 + Pop $7 + Pop $6 + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + Pop $8 + Pop $7 + Pop $6 + + ; Make sure we've got some work to do + ${If} $5 == "" + ${AndIf} $2 == "R" + SetErrors + DetailPrint "$1 is empty - Nothing to remove" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Step 2: Scrub EnvVar + ; + StrCpy $0 $5 ; Copy the contents to $0 + ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or + ; after the last one are not removed here but instead in Step 3) + ${If} $0 != "" ; If EnvVar is not empty ... + ${Do} + ${${UN}StrStr} $7 $0 " ;" + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 " ;" ";" ; Remove '<space>;' + ${Loop} + ${Do} + ${${UN}StrStr} $7 $0 "; " + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';<space>' + ${Loop} + ${Do} + ${${UN}StrStr} $7 $0 ";;" + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 ";;" ";" + ${Loop} + + ; Remove a leading or trailing semicolon from EnvVar + StrCpy $7 $0 1 0 + ${If} $7 == ";" + StrCpy $0 $0 "" 1 ; Change ';<EnvVar>' to '<EnvVar>' + ${EndIf} + StrLen $6 $0 + IntOp $6 $6 - 1 + StrCpy $7 $0 1 $6 + ${If} $7 == ";" + StrCpy $0 $0 $6 ; Change ';<EnvVar>' to '<EnvVar>' + ${EndIf} + ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug + ${EndIf} + + /* Step 3. Remove all instances of the target path/string (even if "A" or "P") + $6 = bool flag (1 = found and removed PathString) + $7 = a string (e.g. path) delimited by semicolon(s) + $8 = entry counter starting at 0 + $9 = copy of $0 + $R0 = tempChar */ + + ${If} $5 != "" ; If EnvVar is not empty ... + StrCpy $9 $0 + StrCpy $0 "" + StrCpy $8 0 + StrCpy $6 0 + + ${Do} + ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter + + ${If} $7 == "" ; If we've run out of entries, + ${ExitDo} ; were done + ${EndIf} ; + + ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) + ${Do} + StrCpy $R0 $7 1 + ${If} $R0 != " " + ${ExitDo} + ${EndIf} + StrCpy $7 $7 "" 1 ; Remove leading space + ${Loop} + ${Do} + StrCpy $R0 $7 1 -1 + ${If} $R0 != " " + ${ExitDo} + ${EndIf} + StrCpy $7 $7 -1 ; Remove trailing space + ${Loop} + ${If} $7 == $4 ; If string matches, remove it by not appending it + StrCpy $6 1 ; Set 'found' flag + ${ElseIf} $7 != $4 ; If string does NOT match + ${AndIf} $0 == "" ; and the 1st string being added to $0, + StrCpy $0 $7 ; copy it to $0 without a prepended semicolon + ${ElseIf} $7 != $4 ; If string does NOT match + ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, + StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon + ${EndIf} ; + + IntOp $8 $8 + 1 ; Bump counter + ${Loop} ; Check for duplicates until we run out of paths + ${EndIf} + + ; Step 4: Perform the requested Action + ; + ${If} $2 != "R" ; If Append or Prepend + ${If} $6 == 1 ; And if we found the target + DetailPrint "Target is already present in $1. It will be removed and" + ${EndIf} + ${If} $0 == "" ; If EnvVar is (now) empty + StrCpy $0 $4 ; just copy PathString to EnvVar + ${If} $6 == 0 ; If found flag is either 0 + ${OrIf} $6 == "" ; or blank (if EnvVarName is empty) + DetailPrint "$1 was empty and has been updated with the target" + ${EndIf} + ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty), + StrCpy $0 $0;$4 ; append PathString + ${If} $6 == 1 + DetailPrint "appended to $1" + ${Else} + DetailPrint "Target was appended to $1" + ${EndIf} + ${Else} ; If Prepend (and EnvVar is not empty), + StrCpy $0 $4;$0 ; prepend PathString + ${If} $6 == 1 + DetailPrint "prepended to $1" + ${Else} + DetailPrint "Target was prepended to $1" + ${EndIf} + ${EndIf} + ${Else} ; If Action = Remove + ${If} $6 == 1 ; and we found the target + DetailPrint "Target was found and removed from $1" + ${Else} + DetailPrint "Target was NOT found in $1 (nothing to remove)" + ${EndIf} + ${If} $0 == "" + DetailPrint "$1 is now empty" + ${EndIf} + ${EndIf} + + ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change + ; + ClearErrors + ${If} $3 == HKLM + WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section + ${ElseIf} $3 == HKCU + WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section + ${EndIf} + + IfErrors 0 +4 + MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" + DetailPrint "Could not write updated $1 to $3" + Goto EnvVarUpdate_Restore_Vars + + ; "Export" our change + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + EnvVarUpdate_Restore_Vars: + ; + ; Restore the user's variables and return ResultVar + Pop $R0 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Push $0 ; Push my $0 (ResultVar) + Exch + Pop $0 ; Restore his $0 + +FunctionEnd + +!macroend ; EnvVarUpdate UN +!insertmacro EnvVarUpdate "" +!insertmacro EnvVarUpdate "un." +;----------------------------------- EnvVarUpdate end---------------------------------------- + +!verbose pop +!endif diff --git a/tools/niminst/inno.tmpl b/tools/niminst/inno.tmpl index b9d04755e..3460c22a2 100644 --- a/tools/niminst/inno.tmpl +++ b/tools/niminst/inno.tmpl @@ -44,9 +44,9 @@ Name: modifypath; Description: &Add $c.displayName to your system path (if not i [Code] function GiveMeAPath(const DefaultPathName: string): string; begin - if IsAdminLoggedOn then Result := ExpandConstant('{pf}') - else Result := ExpandConstant('{userdocs}'); - Result := Result + '\' + DefaultPathName; + if IsAdminLoggedOn then result := ExpandConstant('{pf}') + else result := ExpandConstant('{userdocs}'); + result := result + '\' + DefaultPathName; end; #if c.binPaths.len > 0: diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim index 614009c24..022b14209 100644 --- a/tools/niminst/niminst.nim +++ b/tools/niminst/niminst.nim @@ -31,6 +31,7 @@ type actionNone, # action not yet known actionCSource # action: create C sources actionInno, # action: create Inno Setup installer + actionNsis, # action: create NSIS installer actionScripts # action: create install and deinstall scripts actionZip, # action: create zip file actionDeb # action: prepare deb package @@ -50,10 +51,10 @@ type TConfigData = object of TObject actions: set[TAction] 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]]] 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 libpath: string innoSetupFlag, installScript, uninstallScript: bool @@ -75,9 +76,11 @@ proc initConfigData(c: var TConfigData) = c.authors = @[] c.oses = @[] c.cpus = @[] + c.downloads = @[] c.ccompiler = ("", "") c.linker = ("", "") c.innosetup = ("", "") + c.nsisSetup = ("", "") c.name = "" c.displayName = "" c.version = "" @@ -117,6 +120,7 @@ proc skipRoot(f: string): string = if result.len == 0: result = f include "inno.tmpl" +include "nsis.tmpl" include "buildsh.tmpl" include "buildbat.tmpl" include "install.tmpl" @@ -125,10 +129,10 @@ include "deinstall.tmpl" # ------------------------- configuration file ------------------------------- const - Version = "0.9" + Version = "1.0" Usage = "niminst - Nim Installation Generator Version " & Version & """ - (c) 2013 Andreas Rumpf + (c) 2014 Andreas Rumpf Usage: niminst [options] command[;command2...] ini-file[.ini] [compile_options] Command: @@ -136,6 +140,7 @@ Command: scripts build install and deinstall scripts zip build the ZIP file inno build the Inno Setup installer + nsis build the NSIS Setup installer deb create files for debhelper Options: -o, --output:dir set the output directory @@ -162,6 +167,7 @@ proc parseCmdLine(c: var TConfigData) = of "scripts": incl(c.actions, actionScripts) of "zip": incl(c.actions, actionZip) of "inno": incl(c.actions, actionInno) + of "nsis": incl(c.actions, actionNsis) of "deb": incl(c.actions, actionDeb) else: quit(Usage) else: @@ -190,7 +196,7 @@ proc walkDirRecursively(s: var seq[string], root: string) = case k of pcFile, pcLinkToFile: add(s, unixToNativePath(f)) of pcDir: walkDirRecursively(s, f) - of pcLinkToDir: nil + of pcLinkToDir: discard proc addFiles(s: var seq[string], patterns: seq[string]) = for p in items(patterns): @@ -288,7 +294,7 @@ proc parseIniFile(c: var TConfigData) = else: quit(errorStr(p, "expected: console or gui")) of "license": c.license = unixToNativePath(k.value) 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 "config": filesOnly(p, k.key, v, c.cat[fcConfig]) 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 "binpath": c.binPaths = split(v, {';'}) of "innosetup": c.innoSetupFlag = yesno(p, v) + of "download": c.downloads.add(v) else: quit(errorStr(p, "unknown variable: " & k.key)) of "unix": case normalize(k.key) @@ -313,6 +320,7 @@ proc parseIniFile(c: var TConfigData) = else: quit(errorStr(p, "unknown variable: " & k.key)) of "unixbin": filesOnly(p, k.key, v, c.cat[fcUnixBin]) 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 "linker": pathFlags(p, k.key, v, c.linker) of "deb": @@ -479,14 +487,14 @@ proc srcdist(c: var TConfigData) = # --------------------- generate inno setup ----------------------------------- proc setupDist(c: var TConfigData) = - var scrpt = generateInnoSetup(c) - var n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version] + let scrpt = generateInnoSetup(c) + let n = "build" / "install_$#_$#.iss" % [toLower(c.name), c.version] 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$# $#" % [quoteShell(c.innosetup.path), + let outcmd = if c.outdir.len == 0: "build" else: c.outdir + let cmd = "$# $# /O$# $#" % [quoteShell(c.innosetup.path), c.innosetup.flags, outcmd, n] echo(cmd) if execShellCmd(cmd) == 0: @@ -494,6 +502,23 @@ proc setupDist(c: var TConfigData) = else: 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 --------------------------------------- when haveZipLib: proc zipDist(c: var TConfigData) = @@ -509,7 +534,7 @@ when haveZipLib: addFile(z, proj / installShFile, installShFile) addFile(z, proj / deinstallShFile, deinstallShFile) for f in walkFiles(c.libpath / "lib/*.h"): - addFile(z, proj / "build" / extractFilename(f), f) + addFile(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) @@ -576,6 +601,8 @@ parseCmdLine(c) parseIniFile(c) if actionInno in c.actions: setupDist(c) +if actionNsis in c.actions: + setupDist2(c) if actionCSource in c.actions: srcdist(c) if actionScripts in c.actions: diff --git a/tools/niminst/nsis.tmpl b/tools/niminst/nsis.tmpl new file mode 100644 index 000000000..c4270081e --- /dev/null +++ b/tools/niminst/nsis.tmpl @@ -0,0 +1,255 @@ +#! stdtmpl(subsChar='?') | standard +#proc generateNsisSetup(c: TConfigData): string = +# result = "; NSIS script generated by niminst\n" & +# "; To regenerate run ``niminst nsis`` or ``koch nsis``\n" + +;-------------------------------- +; Included headers + ; Modern User Interface 2.0 Header + !include "MUI2.nsh" + + ; File Functions Header, used to get the current drive root. + !include "FileFunc.nsh" + + ; *Patched* Environment Variable Manipulation Header, used to add + ; tools to the user's PATH environment variable. + !include "EnvVarUpdate.nsh" + +;-------------------------------- +; Global variables and defines + !define PRODUCT_NAME "?c.displayName" + !define PRODUCT_VERSION "?c.version" + !define PRODUCT_PUBLISHER "?c.authors" + !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\?{c.name}.exe" + !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" + !define PRODUCT_UNINST_ROOT_KEY "HKCU" + !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir" + + +;-------------------------------- +; General Setup Information + + ; Name and output file + Name "?{c.name} ?{c.version}" + OutFile "?{c.name}_?{c.version}.exe" + + ; Default installation folder + ; This is changed later (in .onInit) to the root directory, if possible. + InstallDir "$LOCALAPPDATA\?{c.name}" + + ; Get installation folder from registry if available + InstallDirRegKey HKCU "Software\c.name\c.version" "" + + ; Request user level application privileges. + RequestExecutionLevel user + + ; Allow installation to the root drive directory. + AllowRootDirInstall true + + ; Maximum compression! + SetCompressor /SOLID /FINAL lzma + + ; Installer and Uninstaller Icons + ; Icon "nimrod.ico" + ; UninstallIcon "nimrod.ico" + + ; Set installation details to be shown by default + ShowInstDetails show + ShowUnInstDetails show + +;-------------------------------- +; Interface Settings + + ; Warn the user if aborting during installation/uninstallation + !define MUI_ABORTWARNING + !define MUI_UNABORTWARNING + + ; Don't show a description for sections + !define MUI_COMPONENTSPAGE_NODESC + +;-------------------------------- +; Pages + + ; Setup the installer pages + !insertmacro MUI_PAGE_WELCOME + !insertmacro MUI_PAGE_LICENSE "?{expandFilename(c.license)}" + !insertmacro MUI_PAGE_COMPONENTS + !insertmacro MUI_PAGE_DIRECTORY + + ; Setup the start menu entry page + var ICONS_GROUP + !define MUI_STARTMENUPAGE_DEFAULTFOLDER "?{c.displayName}" + !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" + !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" + !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}" + !insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP + + !insertmacro MUI_PAGE_INSTFILES + !insertmacro MUI_PAGE_FINISH + + ; Setup the uninstaller pages + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Installer Sections + + ; The core section. This is comprised of a base Nim installation, + ; such as what would be retrieved via git, and an already bootstrapped + ; Nim binary. + Section "Core Files" CoreSection + ; This is a mandotory section + SectionIn RO + + ; Output files to the base installation directory + SetOutPath "$INSTDIR" + + ; Only overwrite newer files + SetOverwrite ifnewer + + ; Write all the files to the output directory. + #for i in low(TFileCategory)..fcWindows: + # for f in items(c.cat[i]): + SetOutPath "$INSTDIR\?{splitFile(f).dir.toWin}" + File "?{expandFilename(f).toWin}" + # end for + #end for + + ; Write out the uninstaller + WriteUninstaller "$INSTDIR\uninstaller.exe" + SectionEnd + + Section "-Add Registry Keys" RegistrySection + ; Write application registry keys + WriteRegStr HKCU "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\?{c.name}.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\?{c.name}.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" + ; Reset the output path + SetOutPath "$INSTDIR" + SectionEnd + + ; Section for adding the shortcuts related to files and applications + Section "-Setup Shortcuts" ShortcutsSection + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + CreateDirectory "$SMPROGRAMS\$ICONS_GROUP" + + #if c.app == appConsole: + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\start.bat" + CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\start.bat" + #else: + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe" + CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe" + #end if + + ; Add shortcuts for the documentation + #for f in items(c.cat[fcDocStart]): + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{splitFile(f).name}.lnk" "$INSTDIR\?{f.toWin}" + #end for + + ; Write the shortcut to the uninstaller + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninstaller.exe" + !insertmacro MUI_STARTMENU_WRITE_END + SectionEnd + + ; Section for adding tools to the PATH variable + Section "Setup Path Environment" PathSection + ${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\dist\mingw" + ${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\bin" + ${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\dist\babel" + SectionEnd + + ; The downloadable sections. These sections are automatically generated by + ; niminst and the template filters. + #var i = 0 + #for download in c.downloads: + # inc i + # let d = download.split('|') + # if d.len != 5 and d.len != 6: + # quit("download string needs 5..6 parts: " & download) + # end if + # let sectionName = d[0] + # let dir = d[1] + # let zipName = d[2] + # let size = d[3] + # let url = d[4] + Section /o "?sectionName" ?{i}Section + ; Add the section size to the total size. + AddSize ?size + + ; Download the file, and if successful, extract it to the given directory + ; otherwise, + retry: + NSISdl::download "?url" "$TEMP\?zipName" + Pop $0 + ${If} $0 == "success" + ZipDLL::extractall "$TEMP\?zipName" "$INSTDIR\?dir" + Delete "$TEMP\?zipName" + ${Else} + MessageBox MB_ICONSTOP|MB_ABORTRETRYIGNORE "Error: $0" IDRETRY retry IDIGNORE ignore + abort + ${EndIf} + + # if d.len >= 6: + # let startMenuEntry = d[5] + # let e = splitFile(startMenuEntry).name.capitalize + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{e}.lnk" "$INSTDIR\?dir\?{startMenuEntry.toWin}" + # end if + + ; Shortcuts + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + !insertmacro MUI_STARTMENU_WRITE_END + ignore: + SectionEnd + #end + +;-------------------------------- +; Section Descriptions + ; Series of strings describing each section + ; LangString DESC_CoreSection ${LANG_ENGLISH} "Core Nim files" + + ; The macros to actually insert the descriptions into the sections. + ; Each description above should have a corresponding MUI_DESCRIPTION_TEXT + ; macro linking the section to the description. + ; !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + ; !insertmacro MUI_DESCRIPTION_TEXT ${CoreSection} $(DESC_CoreSection) + ; !insertmacro MUI_FUNCTION_DESCRIPTION_END + + +;-------------------------------- +; Uninstaller Sections + + Section "Uninstall" + ; Remove previously created shortcuts + !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP + Delete "$DESKTOP\?{c.displayName}.lnk" + + ; Remove installed application files + RMDir /r "$SMPROGRAMS\$ICONS_GROUP" + RMDir /r "$INSTDIR" + + ; Remove the previously created registry key + DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" + DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}" + SetAutoClose true + + ; Remove entries from the PATH environment variable + ${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\dist\mingw" + ${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\bin" + ${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\dist\babel" + SectionEnd + +;-------------------------------- +; Function hooks + + Function .onInit + ${GetRoot} "$EXEDIR" $R0 + strCpy $INSTDIR "$R0\?{c.name}" + FunctionEnd \ No newline at end of file diff --git a/tools/nimweb.nim b/tools/nimweb.nim index 24ade58fc..6312dace4 100644 --- a/tools/nimweb.nim +++ b/tools/nimweb.nim @@ -45,9 +45,10 @@ proc initConfigData(c: var TConfigData) = c.gitCommit = "master" c.numProcessors = countProcessors() # Attempts to obtain the git current commit. - let (output, code) = execCmdEx("git log -n 1 --format=%H") - if code == 0 and output.strip.len == 40: - c.gitCommit = output.strip + when false: + let (output, code) = execCmdEx("git log -n 1 --format=%H") + if code == 0 and output.strip.len == 40: + c.gitCommit = output.strip c.quotations = initTable[string, tuple[quote, author: string]]() include "website.tmpl" @@ -285,8 +286,10 @@ proc buildPdfDoc(c: var TConfigData, destPath: string) = exec("pdflatex " & changeFileExt(d, "tex")) exec("pdflatex " & changeFileExt(d, "tex")) # delete all the crappy temporary files: - var pdf = splitFile(d).name & ".pdf" - moveFile(dest=destPath / pdf, source=pdf) + let pdf = splitFile(d).name & ".pdf" + let dest = destPath / pdf + removeFile(dest) + moveFile(dest=dest, source=pdf) removeFile(changeFileExt(pdf, "aux")) if existsFile(changeFileExt(pdf, "toc")): removeFile(changeFileExt(pdf, "toc")) @@ -428,4 +431,7 @@ var c: TConfigData initConfigData(c) parseCmdLine(c) parseIniFile(c) -main(c) +when false: + buildPdfDoc(c, "doc") +else: + main(c) diff --git a/web/download.txt b/web/download.txt index 6d860b332..2d3abe3db 100644 --- a/web/download.txt +++ b/web/download.txt @@ -1,125 +1,39 @@ -You can download the latest version of the Nimrod compiler here. You can -use the binaries provided or build from source. - -Binaries -======== - -All installers and archives contain the html documentation and tools -(nimgrep, c2nim and babel). +You can download the latest version of the Nimrod compiler here. **Note:** The Nimrod compiler requires a C compiler to compile software. On Windows we recommend that you use `Mingw-w64 <http://mingw-w64.sourceforge.net/>`_. GCC is recommended on Linux and clang on Mac OS X. -Installers ----------- - -The "full" version includes a full mingw distribution which includes a C -compiler. The "slim" version lacks this. - -* Full (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_full.exe>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: dca7c63d0c1861d2d7c51b2e7a29fa98371750a10ab282d5df9de22a07719c24 - </p> - -* Slim (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_slim.exe>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: c0fcd1201bd20fad1e14b9d2cc2529494057068de1dd01f871cf129f088a8242 - </p> - -* Full (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_full.exe>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: af9d478c2f3361e0f238fcb07fa8e7ae5821938c0f9063c6670e925c9ae9d16e - </p> - -* Slim (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_slim.exe>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 90c380721a46be2b9b8d5437187f701940aefc2e1fb9722dbc543f5c5a3bb85e - </p> -Archives --------- - -Windows -~~~~~~~ - -The "full" version includes a full mingw distribution which includes a C -compiler. The "slim" version lacks this. - -* Full (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_full.zip>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 8ee18faaa3a3d5df482c7abd6aa7ea87a350d7328b80ce1e2d486b59a7a93956 - </p> - -* Slim (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_slim.zip>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 7024fb8ad8f98c0bd4949ae36ed11b52b4e401754bbd62a11199d6dc8628d857 - </p> - -* Full (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_full.zip>`_ - - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: cb33cacc1a84fec771323d24cb6d9795f4803882466a9f417b424990aa49e18a - </p> - -* Slim (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_slim.zip>`_ +Binaries +======== - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: fcf877e4bd1ebfa214749af6e4811cd8539af19f1d7b23017e4bd7f6cbfb3eba - </p> +Unfortunately for now we only provide builds for Windows. -Linux -~~~~~ +* 32 bit: `nimrod_0.9.6.exe <download/nimrod_0.9.6.exe>`_ +* 64 bit: `nimrod_0.9.6_x64.exe <download/nimrod_0.9.6_x64.exe>`_ -* Linux (i386, 32bit): `<download/nimrod_0.9.4_linux_i386.tar.gz>`_ - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 79DD337A77AC4313A75F2C5EED8252F00BBBDEB1E0C3504660D4A52EA63DBA92 - </p> -* Linux (amd64, 64bit): `<download/nimrod_0.9.4_linux_amd64.tar.gz>`_ +Installation based on generated C code +====================================== - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 6F6CB3C727BA8059B7605C02942AE7910C20C2A3DC6A8A600D90D50FE61F0D8C - </p> -* Linux (ppc64, 64bit): `<download/nimrod_0.9.4_linux_ppc64.tar.gz>`_ +This installation method is the preferred way for Linux, Mac OS X, and other Unix +like systems. Binary packages may be provided later. - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: 5DAC2D9F7F545929E04540E6E2594C68FC3126A3B2F7B1FA7DBA5E295B4A7D31 - </p> -Mac OS X -~~~~~~~~ +Download `nimrod_0.9.6.zip <download/nimrod_0.9.6.zip>`_, extract it and follow +these instructions: -* Mac OS X (amd64, 64bit): `<download/nimrod_0.9.4_macosx_amd64.zip>`_ +* sh build.sh +* Add ``$your_install_dir/bin`` to your PATH. - .. raw:: html - <p style="font-size: 8pt; margin-top: 0;"> - SHA256: E6F3A8E434DF3E89686F043954C6DFC09ABEBC0FC09D3B9A6B35C2B3102F7C3C - </p> +There are other ways to install Nimrod (like using the ``install.sh`` script), +but these tend to cause more problems. -If a binary for your platform is not available then you must build from source. -Bleeding edge binaries are available from the `Nimrod build farm <http://build.nimrod-lang.org/>`_. -Source -====== +Installation from github +======================== Use the following commands to build the compiler from source. Change the branch to suit your needs:: @@ -135,4 +49,3 @@ Change the branch to suit your needs:: The ``master`` branch always contains the latest stable version of the compiler. If you want bleeding edge then switch to the ``devel`` branch and follow the same instructions outlined above. - diff --git a/web/news.txt b/web/news.txt index d57b3f83a..6efb064ac 100644 --- a/web/news.txt +++ b/web/news.txt @@ -3,36 +3,12 @@ News ==== .. - 2014-10-11 Version 0.10.0 released + 2014-10-21 Version 0.10.0 released ================================== Changes affecting backwards compatibility ----------------------------------------- - - ``spawn`` now uses an elaborate self-adapting thread pool and as such - has been moved into its own module. So to use it, you now have to import - ``threadpool``. - - The symbol binding rules in generics changed: ``bar`` in ``foo.bar`` is - now considered for implicit early binding. - - ``c2nim`` moved into its own - `repository <https://github.com/nimrod-code/c2nim>`_ - and is now a Nimble package. - - ``pas2nim`` moved into its own - `repository <https://github.com/nimrod-code/pas2nim>`_ - and is now a Nimble package. - - ``system.$`` for floating point types now produces a human friendly string - representation. - - ``uri.TUrl`` as well as the ``parseurl`` module are now deprecated in favour - of the new ``TUri`` type in the ``uri`` module. - - The ``destructor`` pragma has been deprecated. Use the ``override`` pragma - instead. The destructor's name has to be ``destroy`` now. - - ``lambda`` is not a keyword anymore. - - **system.defined has been split into system.defined and system.declared**. - You have to use ``--symbol`` to declare new conditional symbols that can be - set via ``--define``. - - ``--threadanalysis:on`` is now the default. To make your program compile - you can disable it but this is only a temporary solution as this option - will disappear soon! - ``system.fileHandle`` has been renamed to ``system.getFileHandle`` to prevent name conflicts with the new type ``FileHandle``. - Comments are now not part of the AST, as such you cannot use them in place @@ -49,12 +25,20 @@ News be used instead. - Large parts of the stdlib got rid of the T/P type prefixes. Instead most types now simply start with an uppercased letter. The - so called "partial case sensitivity" is now active allowing code - like ``var foo: Foo``. - - String case (or any non-ordinal case) statements + so called "partial case sensitivity" is now active allowing for code + like ``var foo: Foo`` in more contexts. + - String case (or any non-ordinal case) statements without 'else' are deprecated. - Recursive tuple types are not allowed anymore. Use ``object`` instead. + Language Additions + ------------------ + + - The new concurrency model has been implemented including ``locks`` sections, + lock levels and object field ``guards``. + - The ``parallel`` statement has been implemented. + - ``deepCopy`` has been added to the language. + Compiler Additions ------------------ @@ -76,11 +60,48 @@ News system.writeFile +2014-10-19 Nimrod version 0.9.6 released +======================================== + +**Note: 0.9.6 is the last release of Nimrod. The language has been renamed to +Nim. Nim slightly breaks compatibility.** + +This is a maintenance release. The upcoming 0.10.0 release has +the new features and exciting developments. + + +Changes affecting backwards compatibility +----------------------------------------- + +- ``spawn`` now uses an elaborate self-adapting thread pool and as such + has been moved into its own module. So to use it, you now have to import + ``threadpool``. +- The symbol binding rules in generics changed: ``bar`` in ``foo.bar`` is + now considered for implicit early binding. +- ``c2nim`` moved into its own repository and is now a Babel package. +- ``pas2nim`` moved into its own repository and is now a Babel package. +- ``system.$`` for floating point types now produces a human friendly string + representation. +- ``uri.TUrl`` as well as the ``parseurl`` module are now deprecated in favour + of the new ``TUri`` type in the ``uri`` module. +- The ``destructor`` pragma has been deprecated. Use the ``override`` pragma + instead. The destructor's name has to be ``destroy`` now. +- ``lambda`` is not a keyword anymore. +- **system.defined has been split into system.defined and system.declared**. + You have to use ``--symbol`` to declare new conditional symbols that can be + set via ``--define``. +- ``--threadanalysis:on`` is now the default. To make your program compile + you can disable it but this is only a temporary solution as this option + will disappear soon! + + Language Additions ------------------ - This version introduces the new ``deprecated`` pragma statement that is used to handle the upcoming massive amount of symbol renames. +- ``spawn`` can now wrap proc that has a return value. It then returns a flow + variable of the wrapped return type. Library Additions diff --git a/web/nim.ini b/web/nim.ini index d0867ca4e..e982d6ec3 100644 --- a/web/nim.ini +++ b/web/nim.ini @@ -26,9 +26,10 @@ file: ticker.txt [Quotations] # Page: quote - Person # Bad things will happen if you use multiple dashes here. -index: """The most important thing in the programming language is the name. -A language will not succeed without a good name. I have recently invented a -very good name and now I am looking for a suitable language. - D. E. Knuth""" +index: """Is it so bad, then, to be misunderstood? Pythagoras was misunderstood, +and Socrates, and Jesus, and Luther, and Copernicus, and Galileo, and Newton, +and every pure and wise spirit that ever took flesh. To be great is to be +misunderstood. - Ralph Waldo Emerson""" documentation: """Incorrect documentation is often worse than no documentation. - Bertrand Meyer""" download: """There are two major products that come out of Berkeley: LSD and diff --git a/web/ticker.txt b/web/ticker.txt index f06b00572..98ad25905 100644 --- a/web/ticker.txt +++ b/web/ticker.txt @@ -1,3 +1,8 @@ +<a class="news" href="news.html#Z2014-10-19-version-0-9-6-released"> + <h3>Oct 19, 2014</h3> + <p>Nimrod version 0.9.6 has been released!</p> +</a> + <a class="news" href="news.html#Z2014-04-21-version-0-9-4-released"> <h3>Apr 21, 2014</h3> <p>Nimrod version 0.9.4 has been released!</p> |