Merge branch 'master' of https://github.com/minciue/nimble into minciue-master

Conflicts:
	developers.markdown
	src/nimble.nim
This commit is contained in:
Dominik Picheta 2015-06-04 17:53:48 +01:00
commit ca9a09f07b
4 changed files with 31 additions and 9 deletions

View file

@ -457,16 +457,18 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
addRevDep(options, i, pkginfo)
saveNimbleData(options)
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string]) =
proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
## Builds a package as specified by ``pkgInfo``.
let realDir = pkgInfo.getRealDir()
let releaseOpt = if forRelease: "-d:release" else: ""
var args = ""
for path in paths: args.add("--path:\"" & path & "\" ")
for bin in pkgInfo.bin:
let outputOpt = pkgInfo.getOutputOption(bin)
echo("Building ", pkginfo.name, "/", bin, " using ", pkgInfo.backend,
" backend...")
doCmd(getNimBin() & " $# -d:release --noBabelPath $# \"$#\"" %
[pkgInfo.backend, args, realDir / bin.changeFileExt("nim")])
doCmd(getNimBin() & " $# $# --noBabelPath $# $# \"$#\"" %
[pkgInfo.backend, releaseOpt, args, outputOpt, realDir / bin.changeFileExt("nim")])
proc saveNimbleMeta(pkgDestDir, url: string, filesInstalled: HashSet[string]) =
var nimblemeta = %{"url": %url}
@ -517,7 +519,7 @@ proc installFromDir(dir: string, latest: bool, options: Options,
# Build before removing an existing package (if one exists). This way
# if the build fails then the old package will still be installed.
if pkgInfo.bin.len > 0: buildFromDir(pkgInfo, result.paths)
if pkgInfo.bin.len > 0: buildFromDir(pkgInfo, result.paths, true)
let versionStr = (if latest: "" else: '-' & pkgInfo.version)
let pkgDestDir = pkgsDir / (pkgInfo.name & versionStr)
@ -661,7 +663,7 @@ proc install(packages: seq[PkgTuple],
proc build(options: Options) =
var pkgInfo = getPkgInfo(getCurrentDir())
let paths = processDeps(pkginfo, options)
buildFromDir(pkgInfo, paths)
buildFromDir(pkgInfo, paths, false)
proc compile(options: Options) =
var pkgInfo = getPkgInfo(getCurrentDir())

View file

@ -21,6 +21,7 @@ type
installExt*: seq[string]
requires*: seq[PkgTuple]
bin*: seq[string]
buildDir*: string
srcDir*: string
backend*: string
@ -56,6 +57,7 @@ proc initPackageInfo(): PackageInfo =
result.requires = @[]
result.bin = @[]
result.srcDir = ""
result.buildDir = ""
result.backend = "c"
proc validatePackageInfo(pkgInfo: PackageInfo, path: string) =
@ -141,6 +143,7 @@ proc readPackageInfo*(path: string): PackageInfo =
of "description": result.description = ev.value
of "license": result.license = ev.value
of "srcdir": result.srcDir = ev.value
of "builddir": result.buildDir = ev.value
of "skipdirs":
result.skipDirs.add(ev.value.multiSplit)
of "skipfiles":
@ -326,6 +329,14 @@ proc getRealDir*(pkgInfo: PackageInfo): string =
else:
result = pkgInfo.mypath.splitFile.dir
proc getOutputOption*(pkgInfo: TPackageInfo, bin: string): string =
## Returns an output option for the nim compiler if a build directory
## has been set.
if pkgInfo.buildDir != "":
result = " -o:\"" & pkgInfo.mypath.splitFile.dir / pkgInfo.buildDir / bin & "\""
else:
result = " -o:\"" & pkgInfo.mypath.splitFile.dir / bin & "\""
proc getNameVersion*(pkgpath: string): tuple[name, version: string] =
## Splits ``pkgpath`` in the format ``/home/user/.nimble/pkgs/package-0.1``
## into ``(packagea, 0.1)``