build/tools

Procs

proc configure(path, check: string; flags = "") {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadDirEffect,
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect].}

Run the GNU configure command to generate all Makefiles or other build scripts in the specified path

If a configure script is not present and an autogen.sh script is present, it will be run before attempting configure.

Next, if configure.ac or configure.in exist, autoreconf will be executed.

check is a file that will be generated by the configure command. This is required to prevent configure from running on every build. It is relative to the path and should not be an absolute path.

flags are any flags that should be passed to the configure command.

proc getCmakeIncludePath(paths: openArray[string]): string {...}{.raises: [], tags: [].}

Create a cmake flag to specify custom include paths

Result can be included in the flag parameter for cmake() or the cmakeFlags parameter for getHeader().

proc setCmakeProperty(outdir, name, property, value: string) {...}{.
    raises: [IOError, ValueError],
    tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect].}

Set a cmake property in outdir / CMakeLists.txt - usable in the xxxPreBuild hook for getHeader()

set_target_properties(name PROPERTIES property "value")

proc setCmakeLibName(outdir, name, prefix = ""; oname = ""; suffix = "") {...}{.
    raises: [ValueError, IOError],
    tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect].}

Set a cmake property in outdir / CMakeLists.txt to specify a custom library output name - usable in the xxxPreBuild hook for getHeader()

prefix is typically lib oname is the library name suffix is typically .a

Sometimes, cmake generates non-standard library names - e.g. zlib compiles to libzlibstatic.a on Windows. This proc can help rename it to libzlib.a so that getHeader() can find it after the library is compiled.

set_target_properties(name PROPERTIES PREFIX "prefix")
set_target_properties(name PROPERTIES OUTPUT_NAME "oname")
set_target_properties(name PROPERTIES SUFFIX "suffix")

proc setCmakePositionIndependentCode(outdir: string) {...}{.raises: [IOError],
    tags: [ReadDirEffect, ReadIOEffect, WriteIOEffect].}
Set a cmake directive to create libraries with -fPIC enabled
proc cmake(path, check, flags: string) {...}{.raises: [ValueError, OSError, Exception,
    IOError, KeyError], tags: [ReadDirEffect, ExecIOEffect, ReadIOEffect, RootEffect,
                            WriteIOEffect, ReadEnvEffect].}

Run the cmake command to generate all Makefiles or other build scripts in the specified path

path will be created since typically cmake is run in an empty directory.

check is a file that will be generated by the cmake command. This is required to prevent cmake from running on every build. It is relative to the path and should not be an absolute path.

flags are any flags that should be passed to the cmake command. Unlike configure, it is required since typically it will be the path to the repository, typically .. when path is a subdir.

proc make(path, check: string; flags = ""; regex = false) {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ExecIOEffect,
    ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect, ReadDirEffect].}

Run the make command to build all binaries in the specified path

check is a file that will be generated by the make command. This is required to prevent make from running on every build. It is relative to the path and should not be an absolute path.

flags are any flags that should be passed to the make command.

regex can be set to true if check is a regular expression.

If make.exe is missing and mingw32-make.exe is available, it will be copied over to make.exe in the same location.

proc buildWithCmake(outdir, flags: string): BuildStatus {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadDirEffect,
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect].}
proc buildWithAutoConf(outdir, flags: string): BuildStatus {...}{.
    raises: [ValueError, OSError, Exception, IOError, KeyError], tags: [ReadDirEffect,
    ExecIOEffect, ReadIOEffect, RootEffect, WriteIOEffect, ReadEnvEffect].}
proc flagBuild(base: string; flags: openArray[string]): string {...}{.raises: [ValueError],
    tags: [].}

Simple helper proc to generate flags for configure, cmake, etc.

Every entry in flags is replaced into the base string and concatenated to the result.

E.g.
base = "--disable-$#" flags = @["one", "two"]

flagBuild(base, flags) => " --disable-one --disable-two"