Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
commit
06b3852143
8 changed files with 67 additions and 32 deletions
|
|
@ -1361,7 +1361,9 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
|
||||||
ids = newSeq[PNode]()
|
ids = newSeq[PNode]()
|
||||||
# this will store the generated param names
|
# this will store the generated param names
|
||||||
|
|
||||||
internalAssert doBlk.kind == nkDo
|
if doBlk.kind != nkDo:
|
||||||
|
LocalError(n.info, errXExpected, "block")
|
||||||
|
|
||||||
processQuotations(doBlk.sons[bodyPos], op, quotes, ids)
|
processQuotations(doBlk.sons[bodyPos], op, quotes, ids)
|
||||||
|
|
||||||
doBlk.sons[namePos] = newAnonSym(skTemplate, n.info).newSymNode
|
doBlk.sons[namePos] = newAnonSym(skTemplate, n.info).newSymNode
|
||||||
|
|
|
||||||
|
|
@ -448,8 +448,11 @@ proc track(tracked: PEffects, n: PNode) =
|
||||||
# p's effects are ours too:
|
# p's effects are ours too:
|
||||||
let a = n.sons[0]
|
let a = n.sons[0]
|
||||||
let op = a.typ
|
let op = a.typ
|
||||||
if op != nil and op.kind == tyProc:
|
# XXX: in rare situations, templates and macros will reach here after
|
||||||
InternalAssert op.n.sons[0].kind == nkEffectList
|
# calling getAst(templateOrMacro()). Currently, templates and macros
|
||||||
|
# are indistinguishable from normal procs (both have tyProc type) and
|
||||||
|
# we can detect them only by cheking for attached nkEffectList.
|
||||||
|
if op != nil and op.kind == tyProc and op.n.sons[0].kind == nkEffectList:
|
||||||
var effectList = op.n.sons[0]
|
var effectList = op.n.sons[0]
|
||||||
if a.kind == nkSym and a.sym.kind == skMethod:
|
if a.kind == nkSym and a.sym.kind == skMethod:
|
||||||
propagateEffects(tracked, n, a.sym)
|
propagateEffects(tracked, n, a.sym)
|
||||||
|
|
|
||||||
|
|
@ -1511,13 +1511,19 @@ proc send*(socket: TSocket, data: pointer, size: int): int {.
|
||||||
|
|
||||||
proc send*(socket: TSocket, data: string) {.tags: [FWriteIO].} =
|
proc send*(socket: TSocket, data: string) {.tags: [FWriteIO].} =
|
||||||
## sends data to a socket.
|
## sends data to a socket.
|
||||||
if send(socket, cstring(data), data.len) != data.len:
|
if socket.nonblocking:
|
||||||
|
raise newException(EInvalidValue, "This function cannot be used on non-blocking sockets.")
|
||||||
|
let sent = send(socket, cstring(data), data.len)
|
||||||
|
if sent < 0:
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
if socket.isSSL:
|
if socket.isSSL:
|
||||||
SSLError()
|
SSLError()
|
||||||
|
|
||||||
OSError(OSLastError())
|
OSError(OSLastError())
|
||||||
|
|
||||||
|
if sent != data.len:
|
||||||
|
raise newException(EOS, "Could not send all data.")
|
||||||
|
|
||||||
proc sendAsync*(socket: TSocket, data: string): int {.tags: [FWriteIO].} =
|
proc sendAsync*(socket: TSocket, data: string): int {.tags: [FWriteIO].} =
|
||||||
## sends data to a non-blocking socket.
|
## sends data to a non-blocking socket.
|
||||||
## Returns ``0`` if no data could be sent, if data has been sent
|
## Returns ``0`` if no data could be sent, if data has been sent
|
||||||
|
|
@ -1620,7 +1626,13 @@ proc setBlocking(s: TSocket, blocking: bool) =
|
||||||
if fcntl(s.fd, F_SETFL, mode) == -1:
|
if fcntl(s.fd, F_SETFL, mode) == -1:
|
||||||
OSError(OSLastError())
|
OSError(OSLastError())
|
||||||
s.nonblocking = not blocking
|
s.nonblocking = not blocking
|
||||||
|
|
||||||
|
discard """ proc setReuseAddr*(s: TSocket) =
|
||||||
|
var blah: int = 1
|
||||||
|
var mode = SO_REUSEADDR
|
||||||
|
if setsockopt(s.fd, SOL_SOCKET, mode, addr blah, TSOcklen(sizeof(int))) == -1:
|
||||||
|
OSError(OSLastError()) """
|
||||||
|
|
||||||
proc connect*(socket: TSocket, address: string, port = TPort(0), timeout: int,
|
proc connect*(socket: TSocket, address: string, port = TPort(0), timeout: int,
|
||||||
af: TDomain = AF_INET) {.tags: [FReadIO, FWriteIO].} =
|
af: TDomain = AF_INET) {.tags: [FReadIO, FWriteIO].} =
|
||||||
## Connects to server as specified by ``address`` on port specified by ``port``.
|
## Connects to server as specified by ``address`` on port specified by ``port``.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ To build from source you will need:
|
||||||
|
|
||||||
* gcc 3.x or later recommended. Other alternatives which may work
|
* gcc 3.x or later recommended. Other alternatives which may work
|
||||||
are: clang, Visual C++, Intel's C++ compiler
|
are: clang, Visual C++, Intel's C++ compiler
|
||||||
* unzip
|
|
||||||
* git or wget
|
* git or wget
|
||||||
|
|
||||||
If you are on a fairly modern *nix system, the following steps should work:
|
If you are on a fairly modern *nix system, the following steps should work:
|
||||||
|
|
@ -34,10 +33,9 @@ If you are on a fairly modern *nix system, the following steps should work:
|
||||||
```
|
```
|
||||||
$ git clone git://github.com/Araq/Nimrod.git
|
$ git clone git://github.com/Araq/Nimrod.git
|
||||||
$ cd Nimrod
|
$ cd Nimrod
|
||||||
$ cd build
|
$ git clone --depth 1 git://github.com/nimrod-code/csources
|
||||||
$ unzip csources.zip
|
$ cd csources && ./build.sh
|
||||||
$ cd ..
|
$ cd ..
|
||||||
$ ./build.sh
|
|
||||||
$ bin/nimrod c koch
|
$ bin/nimrod c koch
|
||||||
$ ./koch boot -d:release
|
$ ./koch boot -d:release
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ To build from source you will need:
|
||||||
|
|
||||||
* gcc 3.x or later recommended. Other alternatives which may work
|
* gcc 3.x or later recommended. Other alternatives which may work
|
||||||
are: clang, Visual C++, Intel's C++ compiler
|
are: clang, Visual C++, Intel's C++ compiler
|
||||||
* unzip
|
|
||||||
* git or wget
|
* git or wget
|
||||||
|
|
||||||
If you are on a fairly modern *nix system, the following steps should work:
|
If you are on a fairly modern *nix system, the following steps should work:
|
||||||
|
|
@ -34,10 +33,9 @@ If you are on a fairly modern *nix system, the following steps should work:
|
||||||
```
|
```
|
||||||
$ git clone git://github.com/Araq/Nimrod.git
|
$ git clone git://github.com/Araq/Nimrod.git
|
||||||
$ cd Nimrod
|
$ cd Nimrod
|
||||||
$ cd build
|
$ git clone --depth 1 git://github.com/nimrod-code/csources
|
||||||
$ unzip csources.zip
|
$ cd csources && ./build.sh
|
||||||
$ cd ..
|
$ cd ..
|
||||||
$ ./build.sh
|
|
||||||
$ bin/nimrod c koch
|
$ bin/nimrod c koch
|
||||||
$ ./koch boot -d:release
|
$ ./koch boot -d:release
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ SET CC=gcc
|
||||||
SET LINKER=gcc
|
SET LINKER=gcc
|
||||||
SET COMP_FLAGS=?{c.ccompiler.flags}
|
SET COMP_FLAGS=?{c.ccompiler.flags}
|
||||||
SET LINK_FLAGS=?{c.linker.flags}
|
SET LINK_FLAGS=?{c.linker.flags}
|
||||||
|
SET BIN_DIR=?{firstBinPath(c)}
|
||||||
|
|
||||||
|
if EXIST ..\koch.nim SET BIN_DIR=..\bin
|
||||||
|
|
||||||
|
if NOT EXIST %BIN_DIR%\nul mkdir %BIN_DIR%
|
||||||
|
|
||||||
REM call the compiler:
|
REM call the compiler:
|
||||||
|
|
||||||
|
|
@ -12,13 +17,13 @@ REM call the compiler:
|
||||||
# var linkCmd = ""
|
# var linkCmd = ""
|
||||||
# for ff in items(c.cfiles[1][ord(target)]):
|
# for ff in items(c.cfiles[1][ord(target)]):
|
||||||
# let f = ff.replace('/', '\\')
|
# let f = ff.replace('/', '\\')
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}
|
ECHO %CC% %COMP_FLAGS% -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}
|
%CC% %COMP_FLAGS% -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
|
||||||
# linkCmd.add(" " & changeFileExt(f, "o"))
|
# linkCmd.add(" " & changeFileExt(f, "o"))
|
||||||
# end for
|
# end for
|
||||||
|
|
||||||
ECHO %LINKER% -o ?{firstBinPath(c)\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
|
ECHO %LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
|
||||||
%LINKER% -o ?{firstBinPath(c)\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
|
%LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
|
||||||
|
|
||||||
# end block
|
# end block
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,16 @@ LINK_FLAGS="?{c.linker.flags}"
|
||||||
# add(result, "# platform detection\n")
|
# add(result, "# platform detection\n")
|
||||||
ucpu=`uname -m`
|
ucpu=`uname -m`
|
||||||
uos=`uname`
|
uos=`uname`
|
||||||
|
# add(result, "# bin dir detection\n")
|
||||||
|
binDir=?{firstBinPath(c)}
|
||||||
|
|
||||||
|
if [ -s ../koch.nim ]; then
|
||||||
|
binDir="../bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $binDir ]; then
|
||||||
|
mkdir $binDir
|
||||||
|
fi
|
||||||
|
|
||||||
# add(result, "# convert to lower case:\n")
|
# add(result, "# convert to lower case:\n")
|
||||||
ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"`
|
ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"`
|
||||||
|
|
@ -117,12 +127,12 @@ case $myos in
|
||||||
?{c.cpus[cpuA-1]})
|
?{c.cpus[cpuA-1]})
|
||||||
# var linkCmd = ""
|
# var linkCmd = ""
|
||||||
# for f in items(c.cfiles[osA][cpuA]):
|
# for f in items(c.cfiles[osA][cpuA]):
|
||||||
echo "$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}"
|
echo "$CC $COMP_FLAGS -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}"
|
||||||
$CC $COMP_FLAGS -Ibuild -c ?{f} -o ?{changeFileExt(f, "o")}
|
$CC $COMP_FLAGS -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
|
||||||
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
|
# add(linkCmd, " \\\n" & changeFileExt(f, "o"))
|
||||||
# end for
|
# end for
|
||||||
echo "$LINKER -o ?{firstBinPath(c)/toLower(c.name)} ?linkCmd $LINK_FLAGS"
|
echo "$LINKER -o ?{"$binDir"/toLower(c.name)} ?linkCmd $LINK_FLAGS"
|
||||||
$LINKER -o ?{firstBinPath(c)/toLower(c.name)} ?linkCmd $LINK_FLAGS
|
$LINKER -o ?{"$binDir"/toLower(c.name)} ?linkCmd $LINK_FLAGS
|
||||||
;;
|
;;
|
||||||
# end for
|
# end for
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,10 @@ proc readCFiles(c: var TConfigData, osA, cpuA: int) =
|
||||||
quit("Cannot open: " & f)
|
quit("Cannot open: " & f)
|
||||||
|
|
||||||
proc buildDir(os, cpu: int): string =
|
proc buildDir(os, cpu: int): string =
|
||||||
return "build" / ($os & "_" & $cpu)
|
return "src" / ($os & "_" & $cpu)
|
||||||
|
|
||||||
|
proc getOutputDir(c: var TConfigData): string =
|
||||||
|
if c.outdir.len > 0: c.outdir else: "build"
|
||||||
|
|
||||||
proc writeFile(filename, content, newline: string) =
|
proc writeFile(filename, content, newline: string) =
|
||||||
var f: TFile
|
var f: TFile
|
||||||
|
|
@ -392,11 +395,14 @@ proc writeInstallScripts(c: var TConfigData) =
|
||||||
writeFile(deinstallShFile, GenerateDeinstallScript(c), "\10")
|
writeFile(deinstallShFile, GenerateDeinstallScript(c), "\10")
|
||||||
|
|
||||||
proc srcdist(c: var TConfigData) =
|
proc srcdist(c: var TConfigData) =
|
||||||
|
if not existsDir(getOutputDir(c) / "src"):
|
||||||
|
createDir(getOutputDir(c) / "src")
|
||||||
for x in walkFiles(c.libpath / "lib/*.h"):
|
for x in walkFiles(c.libpath / "lib/*.h"):
|
||||||
CopyFile(dest="build" / extractFilename(x), source=x)
|
echo(getOutputDir(c) / "src" / extractFilename(x))
|
||||||
|
CopyFile(dest=getOutputDir(c) / "src" / extractFilename(x), source=x)
|
||||||
for osA in 1..c.oses.len:
|
for osA in 1..c.oses.len:
|
||||||
for cpuA in 1..c.cpus.len:
|
for cpuA in 1..c.cpus.len:
|
||||||
var dir = buildDir(osA, cpuA)
|
var dir = getOutputDir(c) / buildDir(osA, cpuA)
|
||||||
if existsDir(dir): removeDir(dir)
|
if existsDir(dir): removeDir(dir)
|
||||||
createDir(dir)
|
createDir(dir)
|
||||||
var cmd = ("nimrod compile -f --symbolfiles:off --compileonly " &
|
var cmd = ("nimrod compile -f --symbolfiles:off --compileonly " &
|
||||||
|
|
@ -409,14 +415,15 @@ proc srcdist(c: var TConfigData) =
|
||||||
quit("Error: call to nimrod compiler failed")
|
quit("Error: call to nimrod compiler failed")
|
||||||
readCFiles(c, osA, cpuA)
|
readCFiles(c, osA, cpuA)
|
||||||
for i in 0 .. c.cfiles[osA][cpuA].len-1:
|
for i in 0 .. c.cfiles[osA][cpuA].len-1:
|
||||||
var dest = dir / extractFilename(c.cfiles[osA][cpuA][i])
|
let dest = dir / extractFilename(c.cfiles[osA][cpuA][i])
|
||||||
|
let relDest = buildDir(osA, cpuA) / extractFilename(c.cfiles[osA][cpuA][i])
|
||||||
CopyFile(dest=dest, source=c.cfiles[osA][cpuA][i])
|
CopyFile(dest=dest, source=c.cfiles[osA][cpuA][i])
|
||||||
c.cfiles[osA][cpuA][i] = dest
|
c.cfiles[osA][cpuA][i] = relDest
|
||||||
# second pass: remove duplicate files
|
# second pass: remove duplicate files
|
||||||
removeDuplicateFiles(c)
|
removeDuplicateFiles(c)
|
||||||
writeFile(buildShFile, GenerateBuildShellScript(c), "\10")
|
writeFile(getOutputDir(c) / buildShFile, GenerateBuildShellScript(c), "\10")
|
||||||
writeFile(buildBatFile32, GenerateBuildBatchScript(c, tWin32), "\13\10")
|
writeFile(getOutputDir(c) / buildBatFile32, GenerateBuildBatchScript(c, tWin32), "\13\10")
|
||||||
writeFile(buildBatFile64, GenerateBuildBatchScript(c, tWin64), "\13\10")
|
writeFile(getOutputDir(c) / buildBatFile64, GenerateBuildBatchScript(c, tWin64), "\13\10")
|
||||||
writeInstallScripts(c)
|
writeInstallScripts(c)
|
||||||
|
|
||||||
# --------------------- generate inno setup -----------------------------------
|
# --------------------- generate inno setup -----------------------------------
|
||||||
|
|
@ -467,8 +474,8 @@ when haveZipLib:
|
||||||
# -- prepare build files for .deb creation
|
# -- prepare build files for .deb creation
|
||||||
|
|
||||||
proc debDist(c: var TConfigData) =
|
proc debDist(c: var TConfigData) =
|
||||||
if not existsFile("build.sh"): quit("No build.sh found.")
|
if not existsFile(getOutputDir(c) / "build.sh"): quit("No build.sh found.")
|
||||||
if not existsFile("install.sh"): quit("No install.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.shortDesc == "": quit("shortDesc must be set in the .ini file.")
|
||||||
if c.debOpts.licenses.len == 0:
|
if c.debOpts.licenses.len == 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue